Rename *ll* and *ul* to ll and ul in easy-subs
[maxima.git] / share / finance / rtest_finance.mac
blob8b09b94edcde91616ceb5d8a252780114f062d37
1 /*******************************************************************************
2  *
3  *          Examples for the finance
4  *
5  ******************************************************************************/
7 kill(all);
8 'done$
10 (load("finance.mac"),'done);
11 'done$
13 (fpprec: 16, 'done);
14 'done$
16 days360(2008,12,16,2007,3,25);
17 -621$
19 fv(0.12,1000, 3);
20 1404.928$
22 pv(0.12,1000,3);
23 711.7802478134108$
25 annuity_pv(0.12,5000,10);
26 884.9208207992201$
29 annuity_fv(0.12,65000,10);
30 3703.970670389863$
32 block([s: make_string_output_stream()],
33   with_stdout(s, amortization(0.05,56000,3)),
34   get_output_stream_string(s));
35 "           \"n\"    \"Balance\"     \"Interest\"   \"Amortization\"  \"Payment\"      
36           0.000     56000.000         0.000         0.000         0.000  
37           1.000     38236.320      2800.000     17763.680     20563.680  
38           2.000     19584.457      1911.816     18651.864     20563.680  
39           3.000         0.000       979.223     19584.457     20563.680  
40  "$
42 block([s: make_string_output_stream()],
43   with_stdout(s, arit_amortization(0.05,1000,56000,3)),
44   get_output_stream_string(s));
45 "           \"n\"    \"Balance\"     \"Interest\"   \"Amortization\"  \"Payment\"      
46           0.000     56000.000         0.000         0.000         0.000  
47           1.000     39203.807      2800.000     16796.193     19596.193  
48           2.000     20567.803      1960.190     18636.003     20596.193  
49           3.000         0.000      1028.390     20567.803     21596.193  
50  "$
52 block([s: make_string_output_stream()],
53   with_stdout(s, geo_amortization(0.05,0.03,56000,3)),
54   get_output_stream_string(s));
55 "           \"n\"    \"Balance\"     \"Interest\"   \"Amortization\"  \"Payment\"      
56           0.000     56000.000         0.000         0.000         0.000  
57           1.000     38821.880      2800.000     17178.120     19978.120  
58           2.000     20185.511      1941.094     18636.369     20577.463  
59           3.000         0.000      1009.276     20185.511     21194.787  
60  "$
62 geo_annuity_pv(0.14,0.05,5000,10);
63 802.6888176505123$
65 geo_annuity_fv(0.14,0.05,5000,10);
66 216.5203395312695$
68 block([l: [100,500,323,124,300],
69   r: 0.25, ref],
70   ref: block([s], (s: 0, for n thru length(l) do s: s + l[n]/(1+r)^(n-1), s)),
71   npv(r, l) - ref);
72 0.0$
74 (res:irr([-5000,0,800,1300,1500,2000],0), rhs(res[1][1]));
75 .03009250374237132$
77 benefit_cost(0.24,[0,300,500,150],[100,320,0,180]);
78 1.427249324905784$
80 (reset(fpprec), 'done);
81 'done$