Compound Interest Calculator Formula

Understand the math behind the compound interest calculator. Each variable explained with a worked example.

Formulas Used

Future Value

future_value = monthly_rate > 0 ? principal * pow(1 + monthly_rate, num_months) + monthly_contribution * (pow(1 + monthly_rate, num_months) - 1) / monthly_rate : principal + monthly_contribution * num_months

Total Contributions

total_contributions = principal + monthly_contribution * num_months

Total Interest Earned

total_interest_earned = future_value - total_contributions

Variables

VariableDescriptionDefault
principalInitial Investment(USD)10000
monthly_contributionMonthly Contribution(USD)200
annual_rateAnnual Interest Rate(%)7
yearsTime Period(years)20
monthly_rateDerived value= annual_rate / 12 / 100calculated
num_monthsDerived value= years * 12calculated

How It Works

How Compound Interest Works

Compound interest is interest calculated on both the initial principal and the accumulated interest from previous periods.

Formula

FV = P(1+r)^n + PMT * [(1+r)^n - 1] / r

Where:

  • FV = Future value
  • P = Initial investment (principal)
  • PMT = Monthly contribution
  • r = Monthly interest rate
  • n = Total number of months
  • Worked Example

    You invest $10,000 and add $200 per month at 7% annual return for 20 years.

    principal = 10000monthly_contribution = 200annual_rate = 7years = 20
    1. 01Monthly rate: 7% / 12 = 0.5833% (0.005833)
    2. 02Total months: 20 * 12 = 240
    3. 03Growth of initial investment: $10,000 * (1.005833)^240 = $40,387.39
    4. 04Growth of contributions: $200 * [(1.005833)^240 - 1] / 0.005833 = $104,185.06
    5. 05Future Value = $40,387.39 + $104,185.06 = $144,572.45
    6. 06Total contributions: $10,000 + ($200 * 240) = $58,000
    7. 07Total interest earned: $144,572.45 - $58,000 = $86,572.45

    Ready to run the numbers?

    Open Compound Interest Calculator