Build mathematical modelsLesson 39 of 48 · 9 min

Solve a decay equation

Solve a first-order ODE with an initial condition and verify it.

Maths refresher: Rate proportional to what remains

Exponential decay removes a constant fraction per unit time rather than a constant absolute amount.

dNdt=−kN,N(0)=N0⇒N(t)=N0e−kt\frac{dN}{dt}=-kN,\quad N(0)=N_0\quad\Rightarrow\quad N(t)=N_0e^{-kt}
Worked example

For k>0k>0, the half-life is log⁡(2)/k\log(2)/k. Doubling N0N_0 doubles the trajectory but leaves that half-life unchanged.

Maths prerequisite map ↗

An ordinary differential equation relates a function to its derivatives with respect to one independent variable. A decay law says the rate of change is proportional to the current amount, with a negative sign for loss.

See the mathematics
01234-0.050.250.550.851.15u = ktN / N₀
01234-0.050.250.550.851.15u = ktN / N₀
N(t)N0=e−u,u=kt\frac{N(t)}{N_0}=e^{-u},\quad u=kt
Starter reference. A normalised decay curve. After u = log 2, half the initial amount remains; k sets the physical time scale.

SymPy Function represents the unknown function, and dsolve seeks a symbolic solution. An initial condition such as N(0)=N0N(0)=N_0 selects a member of the general solution family. Positive k makes this example decay as time increases.

Use checkodesol to substitute the returned function and its derivatives into the original differential equation. Also inspect the initial value. These mathematical checks do not establish that a constant decay rate is a suitable description of an actual population, stock or concentration.

Will a positive decay rate k make the solution grow or shrink for positive time?

Write a prediction (optional)

Exact solution of an authored decay model

Select Run Python with the code unchanged.

Tools
About Python

Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗

Ctrl+Enter or ⌘+Enter runs Python.

Compare with the worked example

Executed from the published Python during the site build. Your own run appears above. Build environment ↗

ODE
ddtN(t)=−kN(t)\frac{d}{d t} N{\left(t \right)} = - k N{\left(t \right)}
Initial-value solution
N(t)=N0e−ktN{\left(t \right)} = N_{0} e^{- k t}
ODE check
(True, 0)\left( \text{True}, \ 0\right)
Initial value
N0N_{0}
Half-life
log⁡(2)k\frac{\log{\left(2 \right)}}{k}
Example half-life, seconds
10log⁡(2)10 \log{\left(2 \right)}
Example fraction at 5 seconds
e−12e^{- \frac{1}{2}}
Worked text output
ODE: Eq(Derivative(N(t), t), -k*N(t))
Initial-value solution: Eq(N(t), N0*exp(-k*t))
ODE check: (True, 0)
Initial value: N0
Half-life: log(2)/k
Example half-life, seconds: 10*log(2)
Example fraction at 5 seconds: exp(-1/2)

Read the starter result

The ODE check reports whether the solution satisfies the original equation. Initial value separately checks the condition at time zero. The example rows evaluate decay using an invented rate.

Edit and compare

Replace rate = sp.Rational(1,10) with rate = sp.Rational(1,5) to double the example decay rate. Select Run Python. Compare Example half-life, seconds and Example fraction at 5 seconds with the first run.

Return to the editor

Scope. A first-order constant-rate model omits changing rates, external inputs and measurement uncertainty.

Try a fresh case

A general ODE solution contains an arbitrary constant. What typically selects a particular trajectory here?

Choose an answer
Need a hint?
Hint 1

Many exponential curves satisfy the same proportional-rate law.

Hint 2

Identify which one passes through the specified starting point.

Your notesNotes save in this browser when storage is available.