{
  "schemaVersion": 1,
  "slug": "savings-calculator",
  "category": "finance",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "a9bb44b43fce867735614ad39eea21091a2de690cf0570087f19dbf6847e92db",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/savings-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 = P0(1 + r)^n + PMT((1 + r)^n - 1) ÷ r; r = i ÷ 1200, n = 12Y",
    "vars": [
      [
        "P0",
        "Initial deposit"
      ],
      [
        "PMT",
        "Monthly deposit"
      ],
      [
        "i",
        "Annual rate (%)"
      ],
      [
        "Y",
        "Years"
      ],
      [
        "FV",
        "Final balance"
      ]
    ],
    "note": "Monthly rate = annual nominal rate÷100÷12; fixed monthly deposits are made at month-end. Inflation, taxes, fees and rate changes 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. Fractional month counts are mathematical projections, not an actual payment schedule.",
    "implementationHash": "a9bb44b43fce867735614ad39eea21091a2de690cf0570087f19dbf6847e92db"
  },
  "contract": {
    "compute": "const r=rate/100/12, n=years*12; const grown = initialDeposit*Math.pow(1+r,n); const dep = r ? monthlyDeposit*((Math.pow(1+r,n)-1)/r) : monthlyDeposit*n; const totalDeposits = initialDeposit + monthlyDeposit*n; return { finalBalance: grown+dep, totalDeposits, interestEarned: grown+dep-totalDeposits };",
    "inputs": [
      {
        "name": "initialDeposit",
        "type": "number",
        "default": 1000,
        "min": 0,
        "max": 1000000000,
        "step": 100
      },
      {
        "name": "monthlyDeposit",
        "type": "number",
        "default": 200,
        "min": 0,
        "max": 10000000,
        "step": 25
      },
      {
        "name": "rate",
        "type": "number",
        "default": 4,
        "min": 0,
        "max": 100,
        "step": 0.05,
        "slider": true
      },
      {
        "name": "years",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "finalBalance",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "totalDeposits",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "interestEarned",
        "precision": 2,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
