Lesson 5 of 15
Exponential Decay
Exponential Decay
The simplest real-world ODE:
The rate of change is proportional to the current value. The exact solution is:
Applications
- Radioactive decay: atoms decay at a rate proportional to their count
- Drug clearance: concentration in blood decreases proportionally
- Capacitor discharge: voltage drops exponentially
- Population decline: a species dying off at a fixed rate
Half-Life
The half-life is the time for to reach half its initial value:
Numerical Solution
Using Euler's method with steps:
def exponential_decay(k, y0, t_end, n):
h = t_end / n
y = float(y0)
for _ in range(n):
y = y + h * (-k * y)
return y
Your Task
Implement exponential_decay(k, y0, t_end, n) that numerically solves and returns the final value .
Pyodide loading...
Loading...
Click "Run" to execute your code.