Thursday, January 05, 2012

Finding The Interest Rate


In a previous Unix blog post, I gave two awk scripts for calculating compound interest.
 
Now, let us look at the opposite problem.  If we have a starting amount and ending amount, after X number of time periods, what is the average interest rate per time period?  We can use awk.
 
For example, If we started with $4000, and had $5200 after 6 years, what interest rate did we average per year?
 
We can use:
 
nawk 'BEGIN {print (5200/4000)^(1/6)}'
 
to get an answer of 1.0447.  So, we made about 4.5% a year for 6 years.
 
In this case, we are using the math principle that raising something to 1/N is like taking the Nth root.
 
So, 4000* 1.0447^6 = 5200.
 
This is covered in my powers and roots post on my math and logic blog.

0 comments: