{
  "schemaVersion": 1,
  "slug": "carpooling-savings-calculator",
  "category": "automotive",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "6f0c214926dc0c800e40ef38afa58bfedc84f6a4fab86990e73b1184f2800cf3",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/carpooling-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": "S = C × (1 − 1 ÷ k),  C = 52 w (d t + p)",
    "vars": [
      [
        "S",
        "Annual saving"
      ],
      [
        "C",
        "Annual solo-driving cost"
      ],
      [
        "k",
        "Number of riders"
      ],
      [
        "w",
        "Commute days per week"
      ],
      [
        "d",
        "Round-trip miles per day"
      ],
      [
        "t",
        "Per-mile fuel and wear"
      ],
      [
        "p",
        "Daily parking cost"
      ]
    ],
    "note": "Annual miles = round-trip miles × commute days × 52. Annual modeled costs divide fuel, wear and daily parking/tolls equally among riders. CO₂ uses 8,887 g per US gallon and assumes every rider otherwise drove alone on the same route; it is a tailpipe estimate."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const empty={annualMiles:null,soloCost:null,carpoolCost:null,annualSaving:null,co2Saved:null};if(!Number.isInteger(riders)||riders<2||riders>8)return{...empty,__error:'inputError'};const annualMiles=roundTripMiles*daysPerWeek*52;const fuelCost=annualMiles/mpg*fuelPrice;const soloCost=fuelCost+annualMiles*wearPerMile+parkingPerDay*daysPerWeek*52;const carpoolCost=soloCost/riders;const co2Saved=annualMiles/mpg*(1-1/riders)*8887/453.59237;return{annualMiles,soloCost,carpoolCost,annualSaving:soloCost-carpoolCost,co2Saved};",
    "inputs": [
      {
        "name": "roundTripMiles",
        "type": "number",
        "default": 40,
        "min": 0,
        "max": 1000,
        "step": 1,
        "slider": true
      },
      {
        "name": "daysPerWeek",
        "type": "number",
        "default": 5,
        "min": 1,
        "max": 7,
        "step": 1
      },
      {
        "name": "mpg",
        "type": "number",
        "default": 28,
        "min": 1,
        "max": 200,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "fuelPrice",
        "type": "number",
        "default": 3.5,
        "min": 0,
        "max": 30,
        "step": 0.01,
        "slider": true
      },
      {
        "name": "riders",
        "type": "number",
        "default": 3,
        "min": 2,
        "max": 8,
        "step": 1
      },
      {
        "name": "wearPerMile",
        "type": "number",
        "default": 0.12,
        "min": 0,
        "max": 5,
        "step": 0.01,
        "slider": true
      },
      {
        "name": "parkingPerDay",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 200,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "annualSaving",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "annualMiles",
        "precision": 0,
        "unit": "mi"
      },
      {
        "name": "soloCost",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "carpoolCost",
        "precision": 0,
        "unit": "$"
      },
      {
        "name": "co2Saved",
        "precision": 0,
        "unit": "lb"
      }
    ],
    "interpret": null
  }
}
