[Jprogramming] Accumulation, interest, and simulation
Don Guinn
donguinn at gmail.com
Sat Jul 18 22:34:45 HKT 2009
Perhaps it would be easier to look at this problem in terms of present value
of investments. Ask yourself, "I will invest $500 three years from now. What
would I have to invest today to be worth $500 three years from now?"
Taking the liberty to add a year to the interest and investments:
m=:1000 0 0 500 0 0 NB. m for money
i=.0 0.05 0.04 0.06 0.05 0.05
]g=:*/\>:i NB. Calculate growth of an investment over the years
1 1.05 1.092 1.15752 1.2154 1.27617
m%g NB. Convert investments to present value
1000 0 0 431.958 0 0
NB. What would I have to invest today to be worth $500 in 3 years?
NB. $431.958
+/\m%g NB. Accumulate investments at present values
1000 1000 1000 1431.96 1431.96 1431.96
g*+/\m%g NB. Convert to future value
1000 1050 1092 1657.52 1740.4 1827.42
c=: 13 : 'g*+/\y%g=.*/\>:x' NB. Putting this together
i c m
1000 1050 1092 1657.52 1740.4 1827.42
5!:5<'c'
] (] * [: +/\ %) [: */\ [: >: [
There is probably a neater tacit expression, but to me looking at the
problem in terms of present value makes so much clearer the thought process.
Okay, so I cheated a little to get a tacit expression!
More information about the Programming
mailing list