Series · ODE Foundations · Chapter 1

ODE Chapter 1: Origins and Intuition

Why do differential equations exist? Starting from cooling coffee and swinging pendulums, build your first ODE intuition and solve one in Python.

Everything around you is changing. Coffee cools, populations grow, pendulums swing, viruses spread, stocks oscillate, planets orbit. None of these systems are described by what something equals — they are described by how fast something changes. That second mode of description is what differential equations are for, and learning to read them is, quite literally, learning to read the language physics and biology are written in.

This chapter rebuilds your intuition from scratch. We start with a single cup of coffee, derive the same equation that governs radioactive decay and capacitor discharge, then climb upward to direction fields, classification, and the existence-and-uniqueness theorem that tells you when an ODE has a sensible answer at all.

What you will learn

  • What a differential equation actually is — beyond the symbols
  • ODE vs. PDE, order, linearity — and why each distinction earns its keep
  • Three classic models (cooling, decay, oscillation) that you will meet again and again
  • Direction fields: how to “see” the solution before solving anything
  • The existence and uniqueness theorem (Picard–Lindelöf), with a concrete counter-example
  • Your first numerical solution in Python with scipy, and when to trust it

Prerequisites

  • Single-variable calculus: derivatives, integrals, the chain rule
  • Basic Python: NumPy arrays and Matplotlib plotting

1. What is a differential equation? Start with coffee

You brew coffee at $T_0 = 90^\circ\mathrm{C}$ and put it in a $T_\text{env} = 20^\circ\mathrm{C}$ room. A few minutes later it has cooled. Two questions feel natural:

  1. What temperature is it now? — an algebraic question.
  2. How fast is it cooling right now? — a calculus question.

The first question seems easier, but in physics the second one is almost always the one nature answers. Newton wrote down the answer in 1701: the rate of cooling is proportional to the gap between the object and its surroundings.

$$ \frac{dT}{dt} = -k\,\bigl(T - T_\text{env}\bigr). $$

That single line is a differential equation — an equation that relates a function $T(t)$ to its own derivative. The unknown is the function, not a number.

SymbolMeaning
$T(t)$Temperature at time $t$
$dT/dt$Instantaneous rate of change
$T_\text{env}$Ambient temperature ($20^\circ\mathrm{C}$)
$k > 0$Cooling constant — depends on the cup, the surface area, the air

The minus sign matters: when $T > T_\text{env}$ the right-hand side is negative, so $T$ decreases. When $T < T_\text{env}$ it is positive, so $T$ rises. The equation already knows the second law of thermodynamics.

Reading the model before solving it

We can extract physical predictions without writing a single integral:

  • The closer $T$ gets to $T_\text{env}$, the smaller the gap, the slower the cooling. Cooling decelerates.
  • $T = T_\text{env}$ makes the right-hand side zero — once the coffee reaches room temperature, nothing changes. This is an equilibrium.
  • A bigger $k$ (thin cup, drafty room) means faster decay; a smaller $k$ (thermos) means slower.

This is the first lesson of the whole subject: a good ODE tells you the qualitative behaviour before you solve it.

Solving it in Python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint

def coffee_cooling(T, t, k, T_env):
    """Newton's law of cooling: dT/dt = -k (T - T_env)."""
    return -k * (T - T_env)

T0, T_env, k = 90.0, 20.0, 0.1
t = np.linspace(0, 60, 500)
T_sol = odeint(coffee_cooling, T0, t, args=(k, T_env))

plt.figure(figsize=(10, 5))
plt.plot(t, T_sol, color="#2563eb", linewidth=2, label="Coffee temperature")
plt.axhline(T_env, color="#ef4444", linestyle="--", label=f"Room = {T_env} °C")
plt.xlabel("Time (minutes)"); plt.ylabel("Temperature (°C)")
plt.title("Newton's Law of Cooling"); plt.legend(); plt.tight_layout(); plt.show()

print(f"After 10 min: {T_sol[np.abs(t-10).argmin()][0]:.1f} °C")
print(f"After 30 min: {T_sol[np.abs(t-30).argmin()][0]:.1f} °C")

The closed-form answer

This particular equation is friendly enough to solve by hand. Substitute $u = T - T_\text{env}$, so $du/dt = -ku$, separate variables, and re-substitute:

$$ \boxed{\,T(t) = T_\text{env} + \bigl(T_0 - T_\text{env}\bigr)\,e^{-kt}.\,} $$

Three things are worth memorising:

  • The departure $T - T_\text{env}$ decays as a pure exponential.
  • The decay rate is set entirely by $k$. Halving $k$ doubles the cooling time.
  • $T \to T_\text{env}$ asymptotically — never exactly equal, but close enough that physics stops caring.

Solution family for Newton’s law of cooling: every initial temperature flows to the same room-temperature equilibrium.
Figure 1. Newton’s cooling law produces a family of solutions, one curve per initial temperature. They all converge to the dashed equilibrium line. Hot coffee, iced coffee, frozen yoghurt — same physics, same destination.


2. Direction fields: see the solution before you compute it

Here is a profound little trick that took mathematics 200 years to fully appreciate. For any first-order ODE

$$ \frac{dy}{dt} = f(t, y), $$

the function $f$ tells you the slope of the solution at every point in the $(t, y)$-plane without actually solving anything. Plot a tiny arrow with that slope at each grid point and you have a direction field (also called a slope field or vector field). Solution curves are the trajectories that flow tangent to the arrows.

Direction field for dy/dt = -y with several solution curves overlaid.
Figure 2. Direction field for the prototype decay equation $dy/dt = -y$. Arrows give the local slope; purple curves are actual solutions threading through the field; the red dashed line marks the equilibrium $y = 0$. Notice how every solution is funnelled toward zero — the equilibrium is a global attractor.

This visual lets you reason about systems whose closed-form solution is hopeless. Looking at the field, you can already answer:

  • Is there an equilibrium? (Where do arrows go horizontal?)
  • Is it attracting or repelling? (Do nearby arrows point toward it or away?)
  • Does the solution blow up, oscillate, or settle?

We will lean on direction fields throughout the series — they are the cheapest, most honest way to understand a nonlinear ODE.


3. Classification: ODE, PDE, order, linearity

A few labels save us a lot of breath later.

ODE vs. PDE

TypeIndependent variablesExample
Ordinary (ODE)One (usually $t$)$\dfrac{dy}{dt} = -ky$
Partial (PDE)Several ($x, y, t, \dots$)$\dfrac{\partial u}{\partial t} = k\,\dfrac{\partial^2 u}{\partial x^2}$

This series is about ODEs. PDEs (heat, wave, Schrödinger, Navier–Stokes) get their own treatment in Chapter 13.

Order = highest derivative present

  • First-order: $y' = f(t, y)$ — radioactive decay, RC circuits, single-species growth.
  • Second-order: $y'' + p(t)y' + q(t)y = g(t)$ — springs, pendulums, RLC circuits, planetary orbits.

Why does the order matter? Because to pin down a unique solution you need exactly that many initial conditions. A first-order ODE needs $y(0)$. A second-order one needs both $y(0)$ and $y'(0)$ — position and velocity. That is not a quirk; it is Newton’s $F = ma$ telling you that to predict a particle’s future you need its starting position and its starting kick.

First-order vs second-order solution families.
Figure 3. Left: $y' = -y$ produces a one-parameter family — choose a starting height and the curve is determined. Right: $x'' + x = 0$ produces a two-parameter family — you must specify both initial position and initial velocity. Order = how much initial information the universe demands.

Linear vs. nonlinear

A differential equation is linear if $y$ and its derivatives appear only to the first power and are not multiplied together. The general $n$-th order linear form is

$$ a_n(t)\,y^{(n)} + a_{n-1}(t)\,y^{(n-1)} + \dots + a_0(t)\,y = g(t). $$

If anything else shows up — $y^2$, $\sin y$, $y\,y'$, $\sqrt{y}$ — the equation is nonlinear.

Why obsess over the distinction? Because linearity is a superpower:

  • Solutions can be added (superposition principle).
  • A complete solution decomposes into homogeneous + particular parts.
  • The whole machinery of linear algebra (eigenvalues, transforms, Green’s functions) becomes available.

Nonlinear equations have none of this for free. They can do things linear equations cannot — limit cycles, chaos, finite-time blow-up — but each one tends to require its own custom assault.

Linear stability vs nonlinear blow-up.
Figure 4. Same panel size, completely different worlds. Left: every solution of the linear equation $y' = -y + \sin t$ is dragged onto the same red oscillatory attractor — the future forgets the initial condition. Right: tiny changes in $y(0)$ for the nonlinear $y' = y^2 - t$ lead to wildly different fates, and some solutions escape to $+\infty$ in finite time. Welcome to nonlinear life.


4. A brief history

Differential equations were not “discovered” so much as required by physics. The same century that invented calculus needed it.

YearWhoMilestone
1666NewtonCalculus + the laws of motion. $F = ma$ is itself a second-order ODE.
1690sBernoulli familyCatenary, brachistochrone — turning physical questions into ODEs.
1739EulerFirst systematic ODE theory; Euler’s method (still the seed of modern integrators).
1820sCauchyExistence proofs — when does a solution actually exist?
1890Picard, LindelöfThe uniqueness theorem in essentially modern form.
1880s+PoincaréQualitative theory: stop chasing formulas, study the shape of solution flows.
1963LorenzChaos, born from a three-equation weather toy model.

The arc is striking: we begin chasing formulas, give up, and learn instead to study the geometry of solutions. Modern ODE theory is much closer in spirit to Poincaré than to Newton.


5. Three classic models you will keep meeting

The reason ODEs feel ubiquitous is that a small number of equations show up over and over in different physical disguises. Here are three.

Three classic ODE applications: Newton cooling, radioactive decay, harmonic oscillator.
Figure 5. Three of the most reused equations in all of science. Each is one line long, yet between them they describe heat exchange, archaeological dating, and every spring–mass system in mechanical engineering.

5.1 Radioactive decay — the universe’s stopwatch

Each radioactive atom has the same probability of decaying per unit time, so the total decay rate is proportional to how many atoms remain:

$$ \frac{dN}{dt} = -\lambda N \qquad\Longrightarrow\qquad N(t) = N_0\,e^{-\lambda t}. $$

The half-life $t_{1/2} = (\ln 2)/\lambda$ is a single number that summarises the whole curve. Carbon-14 has $t_{1/2} = 5730\,\text{yr}$, which is exactly why archaeologists can date a piece of charcoal: measure the surviving $^{14}\mathrm{C}$ ratio, take the log, and read off the age. The same equation also describes capacitor discharge in an RC circuit and drug clearance from the bloodstream.

5.2 Malthusian population growth

If a population of size $P$ has a constant per-capita birth rate minus death rate $r$, then

$$ \frac{dP}{dt} = rP \qquad\Longrightarrow\qquad P(t) = P_0\,e^{rt}. $$

This is the exact same equation as decay, with $r$ replacing $-\lambda$. The mathematics doesn’t care whether something is dying or breeding; it cares about the sign of the rate constant.

It also predicts unbounded exponential growth, which any biologist will tell you is nonsense — eventually you run out of food, space, or hosts. The fix, the logistic equation, is so important we plot it next to its naive cousin.

Exponential vs logistic growth.
Figure 6. Left: Malthus’ exponential model rockets to infinity; the logistic model bends over and saturates at the carrying capacity $K$. Right: a “phase view” of the growth rate. The logistic curve has two equilibria (at $P = 0$ and $P = K$), with growth in between and decline above $K$. We will dissect this in Chapter 2.

5.3 Simple harmonic motion

A mass $m$ on a spring with stiffness $k$ obeys Hooke’s law $F = -kx$ combined with Newton’s $F = ma$:

$$ m\,\frac{d^2 x}{dt^2} = -kx \qquad\Longleftrightarrow\qquad x'' + \omega_0^2\,x = 0, \quad \omega_0 = \sqrt{k/m}. $$

The general solution is $x(t) = A\cos(\omega_0 t + \varphi)$ — a pure sinusoid with natural angular frequency $\omega_0$. You meet this equation in pendulums (small swings), LC circuits, vibrating molecules, and the eigenmodes of essentially every linear system in physics.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint

omega0 = 2 * np.pi  # natural frequency: 1 Hz
t = np.linspace(0, 3, 500)

def spring(state, t):
    x, v = state
    return [v, -omega0**2 * x]

sol = odeint(spring, [1.0, 0.0], t)  # x(0) = 1, v(0) = 0

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4))
ax1.plot(t, sol[:, 0], color="#10b981", linewidth=2)
ax1.set_xlabel("Time (s)"); ax1.set_ylabel("Displacement x")
ax1.set_title("Simple Harmonic Motion")

ax2.plot(sol[:, 0], sol[:, 1], color="#7c3aed", linewidth=2)
ax2.set_xlabel("x"); ax2.set_ylabel("v = dx/dt")
ax2.set_title("Phase portrait — energy conservation gives a closed ellipse")
ax2.set_aspect("equal")
plt.tight_layout(); plt.show()

The right panel is a phase portrait, our first glimpse of how second-order systems live naturally in a 2D space of $(x, v)$. Energy conservation forces the trajectory to be a closed ellipse; that geometric fact will become the centrepiece of Chapter 7.


6. Initial value problems and the question of existence

A bare ODE has infinitely many solutions — an entire one-parameter (or $n$-parameter) family. To pick out one, you supply an initial condition:

$$ \frac{dy}{dt} = f(t, y), \qquad y(t_0) = y_0. $$

Together they form an initial value problem (IVP). The natural follow-up question is one mathematicians took two centuries to take seriously:

Does the IVP actually have a solution? If so, is it unique?

The answer, in modern form, is the Picard–Lindelöf theorem.

Theorem (Picard–Lindelöf, 1890). If $f(t, y)$ is continuous in $t$ and Lipschitz in $y$ on a rectangle around $(t_0, y_0)$, then the IVP has a unique solution on some open interval containing $t_0$.

A function is Lipschitz in $y$ if there exists a constant $L$ with $|f(t, y_1) - f(t, y_2)| \le L\,|y_1 - y_2|$ — informally, the slope of $f$ in the $y$-direction is bounded. Most “well-behaved” right-hand sides (polynomials, smooth functions) automatically satisfy this.

Why care? Because without this guarantee, the model itself is ambiguous — and that does happen.

Existence and uniqueness: Lipschitz vs not Lipschitz.
Figure 7. Left: for $y' = -y$, $f$ is smooth everywhere; through every point passes exactly one solution. The red curve is the unique solution starting at $(0, 1)$. Right: for $y' = 3\,y^{2/3}$, $f$ is continuous but not Lipschitz at $y = 0$ (its slope blows up). Starting from the origin, infinitely many solutions are valid: $y(t) = 0$ is one, $y(t) = (t-c)^3$ for any $c \ge 0$ is another, and the equation cannot decide between them. Physically: the model is broken.

The takeaway is sharp: a “law of physics” written as an ODE is only a law if Picard–Lindelöf holds. Otherwise the future is not determined by the present, and the whole point of a deterministic model collapses.


7. Analytical vs. numerical solutions

AnalyticalNumerical
What you getA formula: $y(t) = C e^{-kt}$A table of $(t_n, y_n)$ values
Where it comes fromPencil, paper, and a closed-form integralA march in time: $y_{n+1} = y_n + h\,f(t_n, y_n) + \dots$
ProExact; reveals structure (what depends on what)Works for any ODE you can write down
ConMost ODEs have no closed formApproximate; needs careful step-size control

In a graduate physics course you might solve a dozen ODEs by hand. In professional engineering and science, the overwhelming majority of ODEs are solved numerically — there is no shame in this; in fact most modern modelling depends on it.

The simplest numerical method, Euler’s method, is just the discretised definition of the derivative:

$$ y_{n+1} = y_n + h\,f(t_n, y_n). $$
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import numpy as np
import matplotlib.pyplot as plt

def euler(f, y0, t):
    """Forward Euler for y' = f(y, t)."""
    y = np.zeros(len(t)); y[0] = y0
    for i in range(len(t) - 1):
        h = t[i+1] - t[i]
        y[i+1] = y[i] + h * f(y[i], t[i])
    return y

t = np.linspace(0, 5, 100)
y_exact = np.exp(-t)
y_euler = euler(lambda y, t: -y, 1.0, t)

plt.figure(figsize=(8, 5))
plt.plot(t, y_exact, color="#2563eb", linewidth=2, label=r"Exact: $y = e^{-t}$")
plt.plot(t, y_euler, color="#ef4444", linewidth=2, linestyle="--", label="Euler approximation")
plt.xlabel("t"); plt.ylabel("y(t)")
plt.title("Analytical vs. Numerical")
plt.legend(); plt.tight_layout(); plt.show()

Euler is the seed of every more sophisticated method (Runge–Kutta, Adams–Bashforth, the symplectic integrators used for orbit propagation). We will spend Chapter 11 unpacking how the modern solvers in scipy.integrate.solve_ivp actually work — but the logic is always the same: estimate the derivative, take a step, repeat, control the error.


Summary

ConceptKey takeaway
Differential equationAn equation relating an unknown function to its derivatives
ODE vs. PDEOne independent variable vs. several
OrderHow many derivatives appear — equals how many initial conditions you need
Linear vs. nonlinearLinear admits superposition and a complete theory; nonlinear can chaos
Direction fieldVisualise the flow before solving
IVP + Picard–LindelöfInitial condition + Lipschitz $f$ ⇒ unique solution
Analytical vs. numericalExact when possible; numerical when necessary (almost always)

The big idea of this chapter, in one sentence: physics writes its laws as differential equations because nature speaks the language of rates of change, and learning ODEs is learning to translate that language back into pictures, formulas, and predictions.


Exercises

Warm-up

  1. Verify that $y(t) = C e^{3t}$ solves $y' = 3y$ for any constant $C$.
  2. Coffee cools from $90^\circ\mathrm{C}$ to $60^\circ\mathrm{C}$ in 10 minutes in a $20^\circ\mathrm{C}$ room. Find the cooling constant $k$. Then predict the temperature at $t = 30$ min.
  3. A radioactive sample has half-life 10 yr. How much of an initial 100 g remains after 25 yr?

Conceptual

  1. Prove that every solution of $y' = -2y$ approaches 0 as $t \to \infty$, regardless of $y(0)$.
  2. Sketch the direction field of $y' = y(1 - y)$ by hand. Identify the equilibria; predict the long-term behaviour for $y(0) = 0.1$, $y(0) = 0.5$, and $y(0) = 1.5$. (This is the logistic equation.)
  3. Why is the Malthusian population model unrealistic? Propose at least two physical mechanisms that should modify it.
  4. Show that the IVP $y' = 3 y^{2/3}$, $y(0) = 0$ admits more than one solution, and identify which hypothesis of Picard–Lindelöf fails.

Programming

  1. Implement Euler’s method and solve $y' = -y$, $y(0) = 1$ on $[0, 5]$ with step sizes $h = 0.5,\,0.1,\,0.01$. Plot the global error against $h$ on a log–log scale. What slope do you get? Why?
  2. Plot the direction field and several solution curves for $y' = \sin t - y$. Conjecture the long-term behaviour and confirm numerically.
  3. Reproduce Figure 6 (logistic vs exponential): solve both ODEs with scipy.integrate.solve_ivp and overlay them. At what time does the logistic solution reach 99% of $K$?

References

  • Boyce, DiPrima & Meade, Elementary Differential Equations and Boundary Value Problems, Wiley (11th ed., 2017).
  • Strogatz, Nonlinear Dynamics and Chaos, CRC Press (2nd ed., 2015) — chapters 1–2 are the perfect companion to this one.
  • Tenenbaum & Pollard, Ordinary Differential Equations, Dover (1985) — the classic exhaustive reference.
  • Hirsch, Smale & Devaney, Differential Equations, Dynamical Systems, and an Introduction to Chaos, Academic Press (3rd ed., 2012).
  • MIT OCW 18.03SC — Differential Equations (free video lectures).

Series Navigation

Liked this piece?

Follow on GitHub for the next one — usually one a week.

GitHub