Free lesson · Differential equations
Ordinary differential equations: growth and mean reversion
Open interactive lessonPractice calculationsExplore labs
Start with the idea
- An ordinary differential equation specifies a relationship between a function and its derivatives in one independent variable.
- An initial condition selects a particular solution from a family.
- The equation supplies a rule for change; solving it supplies a path.
Symbols, units & horizon
- t: time
- y₀,x₀: initial values at t=0
- k: constant growth/decay rate in inverse time
- κ: positive adjustment speed in inverse time
- θ: fixed equilibrium in x-units
- y′ or dy/dt: rate of y with respect to t
- e: exponential base
- z=x−θ: deviation from equilibrium
When and why to use this
Use ODEs to translate a rate hypothesis into a trajectory and distinguish parameters from initial conditions. Verify solutions by substitution before coding a solver.
- The growth equation y′=ky says the rate is proportional to the current level.
- It describes idealised growth or decay depending on the sign of k.
- The mean-reversion equation x′=κ(θ−x) says change is proportional to distance from an equilibrium.
- These are deterministic equations: fixed parameters and an initial value determine the entire solution.
- They are useful baseline models in population dynamics, cooling and adjustment processes.
- Random disturbances require an additional stochastic model, not merely a different initial condition.
Ordinary differential equations: growth and mean reversion
- For nonzero y, separate dy/y=k dt and integrate: ln|y|=kt+C. The initial condition gives y(t)=y₀exp(kt). The zero initial value has the separate solution y=0, also captured by the final formula.
- For mean reversion, set z=x−θ with θ constant. Then z′=−κz. Apply the growth solution with rate −κ to obtain z(t)=(x₀−θ)exp(−κt).
- Add θ back. Differentiate the result to verify the ODE and substitute t=0 to verify the initial condition.
Starting at 20 with equilibrium 10 and κ=.5 per hour, x(2)=10+10exp(−1)≈13.6788. The deviation shrinks to half after ln(2)/.5≈1.3863 hours.
Architecture pseudocode
from math import exp,log
def exponential_growth(initial,rate,time):
return initial*exp(rate*time)
def deterministic_reversion(initial,equilibrium,speed,time):
if speed<=0 or time<0: raise ValueError("Positive speed and nonnegative time required")
return equilibrium+(initial-equilibrium)*exp(-speed*time)
def reversion_half_life(speed):
if speed<=0: raise ValueError("Positive speed required")
return log(2)/speed
print(deterministic_reversion(20,10,.5,2),reversion_half_life(.5))An analogy to remember
Newton’s cooling model makes temperature move quickly when far from room temperature and slowly when near it. The equilibrium is approached rather than reached at a fixed deadline.
How this becomes a building block
The deterministic growth solution underlies continuous compounding. The mean-reversion ODE is the drift component of an Ornstein–Uhlenbeck stochastic model and can describe an expected path under its assumptions. The same equation is a building block, while adding noise changes the path distribution.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
from math import exp,log
def exponential_growth(initial,rate,time):
return initial*exp(rate*time)
def deterministic_reversion(initial,equilibrium,speed,time):
if speed<=0 or time<0: raise ValueError("Positive speed and nonnegative time required")
return equilibrium+(initial-equilibrium)*exp(-speed*time)
def reversion_half_life(speed):
if speed<=0: raise ValueError("Positive speed required")
return log(2)/speed
print(deterministic_reversion(20,10,.5,2),reversion_half_life(.5))Continue learning
Differential Equations & Numerical Models — all lessons- Start with a rate rule and an initial value
- Ordinary differential equations: growth and mean reversion
- Euler stepping, convergence and stability
- Partial differential equations and the bridge to current research
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations