Inflation Calculator

← All samples

inflation-calculator.dply
1---
2version: 0.1.0
3precision: 2
4form_title: Inflation Calculator
5form_description: See how inflation affects your money. Enter amount, inflation rate and years to see future value and purchasing power loss.
6form_inputs: Amount|amount{€}, Inflation rate|inflation{%}, Years|years{years}
7form_outputs: Future value|future_value, Purchasing power|purchasing_power, Loss|lost, Annual loss|annual_loss
8---
9# draftply – Inflation Calculator
10# How much will inflation reduce the value of your money?
11
12# ── Parameters ──────────────────────────────────────────
13amount = 10000# current amount of money
14inflation = 2.5 % # expected annual inflation rate
15years = 10 years # time period
16
17# ── Calculations ──────────────────────────────────────
18# Future nominal value (same number, but worth less)
19future_value = amount
20
21# Future value adjusted for inflation
22# Real value = nominal / (1 + inflation)^years
23purchasing_power = amount / (1 + inflation)^years
24
25# Purchasing power loss
26lost = amount - purchasing_power
27lost_percent = (lost / amount) * 100
28
29# Annual average loss of purchasing power
30annual_loss = (1 - 1 / (1 + inflation)) * 100
31
32# What will X in the future cost in today's money?
33# If something costs 100 in the future, how much is that in today's euros?
34future_cost = 100
35todays_equivalent = future_cost / (1 + inflation)^years
36
37# Rule of 72 for inflation: years until prices double
38years_to_double_prices = 72 / (inflation * 100)
39
40# Equivalent: how much do you need in the future to have same purchasing power?
41equivalent_future = amount * (1 + inflation)^years
42
43# Monthly inflation rate
44monthly_inflation = inflation / 12
45
46# Purchasing power per year
47purchasing_power_year(n) = amount / (1 + inflation)^n
48
49# ── Results ─────────────────────────────────────────────
50"Current amount": amount
51"Inflation rate (%)": inflation * 100
52"Time period": years
53
54"Future nominal value": future_value
55"Future purchasing power": purchasing_power
56"Purchasing power lost": lost
57"Loss percentage": lost_percent
58
59"Annual average loss": annual_loss
60"Years until prices double": years_to_double_prices
61
62"To maintain purchasing power in {years}, you need": equivalent_future
63
64"Something costing 100€ in {years} equals": todays_equivalent "today"
65
66# Purchasing power over time
67plot(purchasing_power_year(x), 0..years, "Purchasing power", "Years", "€", "Real value of {amount} over time")
68