{
  "schemaVersion": 1,
  "slug": "retirement-calculator",
  "category": "finance",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "c4bde6139492c0b2c81c7febb95de9cb4e6ae431a71212fcc76c94330da01688",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/retirement-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "FV = P(1+r)^n + M×((1+r)^n−1)÷r; n = 12×(A₂−A₁)",
    "vars": [
      [
        "P",
        "Current savings"
      ],
      [
        "M",
        "Monthly contribution"
      ],
      [
        "r",
        "Monthly return rate"
      ],
      [
        "n",
        "Number of months"
      ],
      [
        "A₁",
        "Current age"
      ],
      [
        "A₂",
        "Retirement age"
      ],
      [
        "FV",
        "Future value"
      ]
    ],
    "note": "r = annual return÷100÷12; monthly compounding with fixed contributions made at each month-end. If r = 0, the deposits term is M×n. Growth = FV − (P+M×n); inflation, taxes, fees and changing returns are not modeled."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-04",
    "sources": [
      {
        "name": "OpenStax — Ordinary annuities",
        "url": "https://openstax.org/books/principles-finance/pages/8-2-annuities"
      }
    ],
    "basis": "End-of-month deposits use FV = D × ((1 + i)^n - 1) / i, with i = annual percent / 1200 and n = 12 × years; zero rate uses D × n. Existing savings also grow by (1 + i)^n.",
    "limitations": "Constant nominal rate and equal monthly deposits; excludes taxes, fees and inflation. It is a projection, not a guaranteed return. It estimates accumulation only, not withdrawal sustainability. Fractional month counts are mathematical projections, not an actual payment schedule.",
    "implementationHash": "c4bde6139492c0b2c81c7febb95de9cb4e6ae431a71212fcc76c94330da01688"
  },
  "contract": {
    "compute": "const years = Math.max(retireAge-currentAge, 0); const r=annualReturn/100/12, n=years*12; const grown = currentSavings*Math.pow(1+r,n); const deposits = r ? monthlyContribution*((Math.pow(1+r,n)-1)/r) : monthlyContribution*n; const totalContributions = currentSavings + monthlyContribution*n; return { projectedSavings: grown+deposits, totalContributions, growth: grown+deposits-totalContributions, years };",
    "inputs": [
      {
        "name": "currentAge",
        "type": "number",
        "default": 30,
        "min": 16,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "retireAge",
        "type": "number",
        "default": 65,
        "min": 17,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "currentSavings",
        "type": "number",
        "default": 50000,
        "min": 0,
        "max": 1000000000,
        "step": 1000
      },
      {
        "name": "monthlyContribution",
        "type": "number",
        "default": 500,
        "min": 0,
        "max": 1000000,
        "step": 50
      },
      {
        "name": "annualReturn",
        "type": "number",
        "default": 7,
        "min": -20,
        "max": 30,
        "step": 0.1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "projectedSavings",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "totalContributions",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "growth",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "years",
        "precision": 0,
        "unit": "years"
      }
    ],
    "interpret": null
  }
}
