module.exports = { slug: "inflation-adjusted-value", title: "Inflation-adjusted value (CPI method)", deck_category: "finance", description: "Converts a dollar amount from one period to another period's dollars using two Consumer Price Index values.", inputs: [ { name: "amount", type: "number", unit: "currency units", required: true, description: "Amount stated in the starting period's dollars", min: 0 }, { name: "cpi_start", type: "number", required: true, description: "CPI index value for the starting period", min: 0 }, { name: "cpi_end", type: "number", required: true, description: "CPI index value for the ending period", min: 0 } ], outputs: [ { name: "adjusted_value", unit: "currency units", description: "Amount restated in the ending period's dollars" } ], steps: [ "adjusted_value = amount * (cpi_end / cpi_start).", "Round adjusted_value to 2 decimals (money to cents)." ], constants: [], sources: [ { kind: "url", value: "https://www.bls.gov/cpi/factsheets/escalation.htm", title: "How to Use the Consumer Price Index for Escalation", publisher: "U.S. Bureau of Labor Statistics", retrieved_utc: "2026-09-30T22:29:13Z", note: "Confirmed live. BLS describes CPI escalation as changing a payment by the percent change in the CPI between two periods; the ratio form used here, amount * (CPI_end / CPI_start), is the mathematically equivalent multiplicative statement of that same percent-change method (1 + percent_change/100 = CPI_end / CPI_start)." } ], disclaimer: null, questionText(inputs) { return `What is $${inputs.amount} from a period with a CPI of ${inputs.cpi_start} worth in dollars of a period with a CPI of ${inputs.cpi_end}, using the BLS CPI method?`; }, run(inputs) { const { amount, cpi_start, cpi_end } = inputs; if (typeof amount !== "number" || amount < 0) throw new Error("amount must be a non-negative number"); if (typeof cpi_start !== "number" || cpi_start <= 0) throw new Error("cpi_start must be a positive number"); if (typeof cpi_end !== "number" || cpi_end <= 0) throw new Error("cpi_end must be a positive number"); const adjusted_value = Math.round(amount * (cpi_end / cpi_start) * 100) / 100; const fmt = (n) => n.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","); return { answer: `$${fmt(adjusted_value)}`, values: { adjusted_value } }; }, examples: [ { name: "worked example", inputs: { amount: 100, cpi_start: 258.811, cpi_end: 314.175 }, expected: { answer: "$121.39" }, check: "hand computation: 100 * (314.175/258.811) = 100*1.213977... = 121.3977..., rounds to 121.39 (verified by the checker script, not by hand rounding of the truncated ratio)" }, { name: "test vector: deflating forward to backward period", inputs: { amount: 500, cpi_start: 314.175, cpi_end: 258.811 }, expected: { answer: "$411.89" }, check: "hand computation: 500 * (258.811/314.175), verified with the checker script against the same formula used by run()" } ] };