Financial Algorithms Cookbook | Time Value of Money
Algorithm: Calculating the Present Value
Typical Uses
- todo
Ingredients
To calculate the number of compounding periods you will need the following:
- todo
def derivative(i, PV, FV, PMT, n, inAdv=False, continious=False):
nFractionPart,nIntegerPart = modf(n)
discount = pow(1.0+i, -nIntegerPart)
if inAdv:
PMT *=(1.0+i)
if continious:
pvs =pow((1.0+i),nFractionPart)
else:
pvs =(1.0+ i*nFractionPart)
return PV + ( PMT*((1-discount)/i) + FV*discount)/pvs
def interestRate(estimate, PV, FV, PMT, n, inAdv=False, continous=False):
stop = PV
return 100* newton_raphson(derivative, estimate, PV, FV, PMT, n)
Example
You want to save for your childs collage bills estimated to be 100,000. She will graduate form high school in 8 years time. What annual interest rate will you need to achieve this amount on an investment of 60,000 with quarterly compounding?
FV= 100000 PV=-60000 PMT=0 n=8*4 estimate = 1.2/n interestRate(estimate/100, PV, FV, n) >> 1.61
So the annual interest rate is 6.44
References
- Gallager, T; Andrew Jr., J., Financial Management: Principals and Practices, Upper Saddle River, NJ: Prentice Hall, 1996
- HP-12C Business Calculator Owner's Manual, Hewlett Packard, 1984
- HP-10B Business Calculator Owner's Manual, Hewlett Packard, 1994
