: ) wonderful world ( :

the metasyntactic variable

granting a loan; simplified

leave a comment »

Based on the net present value term, in case of regular $R incomes and rate as discount rate:

      years - 1
      ---------
      \
       \        R
NPV =   )       -------------
       /                    i
      /         /          \
      --------- | 1 + rate |
        i = 0   \          /

 

Due to identical cash flows this is the sum of a geometric series, so can be rewritten into a closed form:

                        years
            /          \
            | 1        |
        1 - | -------- |
            | 1 + rate |
            \          /
NPV = R ---------------------
            1
        1 - --------
            1 + rate

 

Or identically:

            1
        1 - --------
            1 + rate
R = NPV ---------------------
                        years
            /          \
            | 1        |
        1 - | -------- |
            | 1 + rate |
            \          /

 

In case duration of the loan tends to infinity then the required yearly income converges to:

    /              \
    |     1        |
NPV | 1 - -------- |
    |     1 + rate |
    \              /

 

which is

    rate
NPV --------
    1 + rate

 

and this means that there’s no loan of USD NPV regarding rate as discount rate, where the required yearly pay back is less then this number, e.g. (NPV = $1000000, rate = 0.03):

% ./lx86cl
Welcome to Clozure Common Lisp Version 1.4-r13119  (LinuxX8632)!
? (defun limit (npv rate) (* npv (/ rate (+ 1 rate))))
LIMIT
? (limit 1000000 0.03)
29126.213
? (defun r (npv rate years)
(* npv (/ (- 1 (/ 1 (+ 1 rate))) (- 1 (expt (/ 1 (+ 1 rate)) years)))))
R
? (loop as i from 1 upto 50 collect (r 1000000 0.03 i))
(1000000.0 507389.3 343233.47 261191.42 211994.77 179220.95 155831.47 138307.22 124693.086
113816.05 104929.58 97536.03 91290.83 85947.914 81326.79 77292.09 73740.32 70590.97 67780.47
65257.973 62982.297 60919.8 59042.617 57327.58 55755.207 54309.016 52974.95 51740.992 50596.758
49533.246 48542.637 47618.066 46753.5 45943.64 45183.758 44469.687 43797.676 43164.387 42566.824
42002.29 41468.336 40962.766 40483.58 40028.957 39597.234 39186.906 38796.586 38425.0 38070.984
37733.465)
? (with-open-file (s #P"r.dat" :direction :output :if-exists :supersede)
(loop as val in * do (format s "~A~%" val)))
NIL
? (quit)
% echo set term png \; plot \'r.dat\' with lines | gnuplot > r.png
r

r.png

Written by grault

November 8, 2009 - 1:36 pm at November 8, 2009 - 1:36 pm

Posted in lisp, math

Leave a Reply