Calculate compound interest in four ways: Forward starts from a given balance and goes forward in time. Backward computes the required initial deposit to reach a target goal in X years with no extra additions. Contribution determines how much you must contribute each week/month/year to meet a retirement goal. Achieved interest determines the retrospective interest rate you achieved in going from a starting to an ending amount over a certain amount of time (or calculates the rate you must achieve to do so).
Calculate the amount of money you need to start with in order to achieve a target goal.
Calculate the amount of money you must periodically add to achieve a target goal.
Given a starting and ending balance, with optional regular contributions, calculate the interest rate achieved or required to reach the ending balance.
Interest "compounds" each time you earn interest on your money and that interest is added to your account. For example, if you have $100 in the bank and earn 5% interest compounded yearly, then after one year, your bank will deposit an extra $5 in your account. You now have $105. After the end of the next year, you will have $105*1.05 = $110.25, having earned 5% of $105, or $5.25. Naturally, if the interest rates are equal, you'd prefer an account that compounds more frequently. When you take into account the compounding, you get what's referred to as the "APY", or "Annual Percentage Yield". An account that compounds yearly will have an APY equal to its interest rate, but one that compounds more frequently will have a higher APY.
The most basic way to calculate compound interest would be to simply do it by hand. If you have an initial amount:
Balance = $100and add 5%, you get:
Balance = $100 + (100 * 0.05)Generalizing that, applying the interest is simply Balance = Balance * (1 + interest_rate)
Which is the same as:
Balance = $100 * 1 + $100 * .05
= $100 * 1.05
Of course, the interest rate is expressed yearly, so if we want to apply it more frequently -- say, daily -- we have to divide it by the fraction of the year that has passed. The daily interest rate is just 1/365 of the yearly interest rate. So each day, we would do Balance = Balance * (1 + interest_rate / 365).
But doing that 365 times would be tedious. To simplify that, we note that we're just doing that multiplication 365 times per year. Which we could express as (1 + interest_rate / 365) raised to the power of 365. So one year of daily compound interest is thus:
Balance = Balance * (1 + interest_rate / 365)365.And that's it for basic compounding. Thus, a 5% interest rate, compounded daily, would result in a (1 + 0.05/365)365 = 5.127% APY.
Code and page Copyright ©2016 David G. Andersen. Please send bug or feedback reports to dga AT pobox DOT com.