{
  "schemaVersion": 1,
  "slug": "car-depreciation-calculator",
  "category": "automotive",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "4fb091dfad510b80a6cd806deacde041e90d731f2d63e66a1bf26b0e095480ba",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/car-depreciation-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": "V = { P(1 − f ÷ 100)(1 − l ÷ 100)^(y−1),  y > 1;  P(1 − f·y ÷ 100),  y ≤ 1 }",
    "vars": [
      [
        "V",
        "Current value"
      ],
      [
        "P",
        "Original price"
      ],
      [
        "f",
        "First-year depreciation, %"
      ],
      [
        "l",
        "Annual depreciation after year 1, %"
      ],
      [
        "y",
        "Years owned"
      ]
    ],
    "note": "Piecewise rule; year 1 is prorated linearly. Loss per mile = (P − V) ÷ (annual miles × y)."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const afterFirst = price*(1-firstYearRate/100); const valueNow = years <= 1 ? price*(1-firstYearRate/100*years) : afterFirst*Math.pow(1-laterRate/100, years-1); const totalLoss = price-valueNow; const miles = annualMiles*years; return { valueNow, totalLoss, perYear: years > 0 ? totalLoss/years : 0, perMile: miles > 0 ? totalLoss/miles : 0, percentLeft: price > 0 ? valueNow/price*100 : 0 };",
    "inputs": [
      {
        "name": "price",
        "type": "number",
        "default": 35000,
        "min": 0,
        "max": 5000000,
        "step": 100
      },
      {
        "name": "years",
        "type": "number",
        "default": 5,
        "min": 0.5,
        "max": 30,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "firstYearRate",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 60,
        "step": 1,
        "slider": true
      },
      {
        "name": "laterRate",
        "type": "number",
        "default": 15,
        "min": 0,
        "max": 60,
        "step": 1,
        "slider": true
      },
      {
        "name": "annualMiles",
        "type": "number",
        "default": 12000,
        "min": 0,
        "max": 100000,
        "step": 500,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "valueNow",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "totalLoss",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "perYear",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "perMile",
        "precision": 3,
        "unit": "$"
      },
      {
        "name": "percentLeft",
        "precision": 1,
        "unit": "%"
      }
    ],
    "interpret": null
  }
}
