AnyLearn
All lessons
Mathintermediate

What a Differential Equation Says: Rates, Solutions, and Slope Fields

A differential equation is a local rule for change, not a formula for the answer. Learn to read and classify one, solve the exponential and logistic cases, know when a unique solution exists, turn any order into a first-order system, and step forward numerically with Euler and Runge-Kutta.

Updated · AI-authored, review-gated · how lessons are made

Progress1 / 10

A law about change, not a formula for the answer

A differential equation states how a quantity changes in terms of what it currently is. It does not hand you the quantity. It hands you the rule, and the answer is whatever curve obeys that rule at every instant.

LawEquationState
Radioactive decayN˙=−kN\dot{N} = -kNnumber of nuclei NN
Newton's law of coolingT˙=−k(T−Troom)\dot{T} = -k(T - T_{\text{room}})temperature TT
Spring with frictionmx¨=−kx−cx˙m\ddot{x} = -kx - c\dot{x}position and velocity
Logistic populationP˙=rP(1−P/K)\dot{P} = rP(1 - P/K)population PP

The dot is a time derivative: x˙=dx/dt\dot{x} = dx/dt. Look at what every row shares. The right-hand side is local: it needs only the present state, not the history.

That is why the form is everywhere. Physics, chemistry and ecology usually know the local rule (forces, reaction rates, birth and death rates) far better than they know the long-run outcome, and a differential equation is the machine that turns one into the other.

Sign in free to save your progress and earn certificates.

Full lesson text

All 10 steps on one page, for reading, reference, and search.

Show

1. A law about change, not a formula for the answer

A differential equation states how a quantity changes in terms of what it currently is. It does not hand you the quantity. It hands you the rule, and the answer is whatever curve obeys that rule at every instant.

LawEquationState
Radioactive decayN˙=−kN\dot{N} = -kNnumber of nuclei NN
Newton's law of coolingT˙=−k(T−Troom)\dot{T} = -k(T - T_{\text{room}})temperature TT
Spring with frictionmx¨=−kx−cx˙m\ddot{x} = -kx - c\dot{x}position and velocity
Logistic populationP˙=rP(1−P/K)\dot{P} = rP(1 - P/K)population PP

The dot is a time derivative: x˙=dx/dt\dot{x} = dx/dt. Look at what every row shares. The right-hand side is local: it needs only the present state, not the history.

That is why the form is everywhere. Physics, chemistry and ecology usually know the local rule (forces, reaction rates, birth and death rates) far better than they know the long-run outcome, and a differential equation is the machine that turns one into the other.

2. The vocabulary that tells you how hard it will be

Four labels predict most of what follows:

  • Order: the highest derivative present. Cooling is first order; the spring, with x¨\ddot{x}, is second order.
  • Linear or nonlinear: linear if the unknown and its derivatives appear only to the first power, never multiplied together or inside a function such as sin⁡x\sin x. The P2P^2 hidden in the logistic law makes it nonlinear.
  • Autonomous: time does not appear explicitly on the right-hand side, so x˙=f(x)\dot{x} = f(x). The rule is the same today as tomorrow.
  • ODE or PDE: an ordinary differential equation has one independent variable, usually time. A partial differential equation, such as the heat equation, has several, such as time and position.

Key idea: linear equations have a complete theory: solutions add, and general formulas exist. Nonlinear equations usually have no formula at all. That gap is why serious work on nonlinear systems studies the shape of solutions rather than their algebra.

3. Rate proportional to amount: the exponential

The simplest nontrivial equation is x˙=kx\dot{x} = kx. Separate the variables, putting every xx on one side and every tt on the other, then integrate:

dxx=k dt⇒ln⁡∣x∣=kt+C⇒x(t)=x0ekt\frac{dx}{x} = k\,dt \quad\Rightarrow\quad \ln|x| = kt + C \quad\Rightarrow\quad x(t) = x_0 e^{kt}

The constant of integration became the starting value x0x_0. That is general: a first-order equation has a one-parameter family of solutions, and one initial condition picks the member.

For decay, k<0k < 0, and the time to halve is the same no matter how much you start with:

t1/2=ln⁡2∣k∣t_{1/2} = \frac{\ln 2}{|k|}

A constant half-life is the fingerprint of the mechanism. If each nucleus, molecule or customer leaves at a fixed per-capita rate, independently of the others, you get exponential decay, and a plot of ln⁡x\ln x against tt is a straight line. Curvature in that plot says the per-capita rate is not constant, so the model is wrong.

4. Crowding: the logistic equation

Pure exponential growth cannot last. Pierre-Francois Verhulst's 1838 fix was to let the per-capita growth rate fall linearly as the population nears a carrying capacity KK:

P˙=rP(1−PK)⇒P(t)=K1+K−P0P0 e−rt\dot{P} = rP\left(1 - \frac{P}{K}\right) \quad\Rightarrow\quad P(t) = \frac{K}{1 + \frac{K - P_0}{P_0}\,e^{-rt}}

It is still separable, by partial fractions, and the solution is the S-curve: near-exponential growth while PP is small, fastest growth at P=K/2P = K/2, and a flattening approach to KK.

Predict first

A population starts above its carrying capacity, at P0=2KP_0 = 2K. What does the logistic equation predict?

5. When does a solution exist, and is it the only one?

An initial value problem pairs an equation with a starting state: x˙=f(x,t)\dot{x} = f(x, t) with x(0)=x0x(0) = x_0. The Picard-Lindelof theorem guarantees exactly one solution, at least for a short time, when ff is continuous and Lipschitz in xx, meaning its slope in xx stays bounded near the start.

Both halves of that promise can fail:

Gotcha: x˙=x\dot{x} = \sqrt{x} with x(0)=0x(0) = 0 has two solutions, x(t)=0x(t) = 0 and x(t)=t2/4x(t) = t^2/4, because x\sqrt{x} has infinite slope at zero. And x˙=x2\dot{x} = x^2 with x(0)=1x(0) = 1 has the unique solution x=1/(1−t)x = 1/(1 - t), which blows up at t=1t = 1. Existence is local, not forever.

Uniqueness is the property everything later depends on. It means the present state determines the entire future. In a state space it means two trajectories can never cross: if they met at a point, that point would have two different futures.

6. Every equation becomes a first-order system

Second-order equations are not a separate subject. Introduce velocity as a new variable and any order collapses into a system of first-order equations. The undamped spring x¨=−x\ddot{x} = -x becomes

x˙=v,v˙=−x\dot{x} = v, \qquad \dot{v} = -x

Now the state is the pair (x,v)(x, v), and the equation is a vector field: at each point of the plane it attaches an arrow saying where the state goes next. That plane is the state space, called phase space in physics, and a solution is a curve that follows the arrows. Here the curves are circles, x2+v2=constx^2 + v^2 = \text{const}, which is energy conservation drawn as geometry.

This is the standard form numerical solvers expect, y˙=f(t,y)\dot{\mathbf{y}} = \mathbf{f}(t, \mathbf{y}), and an nnth-order equation becomes nn coupled first-order ones. Control engineering makes the same move in state-space models, covered in this catalogue's lesson on state-space models and pole placement.

7. Seeing solutions without solving: slope fields

For a first-order equation x˙=f(t,x)\dot{x} = f(t, x) you can draw the answer before you find it. At each point (t,x)(t, x) draw a short segment with slope f(t,x)f(t, x). Solutions are the curves tangent to every segment they pass through.

  1. Pick a grid of points and evaluate ff at each one.
  2. Draw the short segments. Isoclines, the curves where ff is constant, speed this up, since every segment along one is parallel.
  3. Trace a few curves along the segments from different starting values.

For the logistic equation, the field is flat along P=0P = 0 and P=KP = K, so those horizontal lines are themselves solutions. Segments tilt upward between them and downward above KK. You have recovered the whole qualitative story without integrating anything.

For an autonomous equation the segments do not depend on tt at all, so the entire picture collapses onto a single vertical line of arrows. That observation is the starting point of one-dimensional dynamics.

8. Stepping forward numerically: Euler and Runge-Kutta

Most equations have no closed form, so in practice you step forward numerically. Euler's method uses the current slope for the whole step, yn+1=yn+h f(yn)\mathbf{y}_{n+1} = \mathbf{y}_n + h\,\mathbf{f}(\mathbf{y}_n). The classical fourth-order Runge-Kutta method (RK4) samples the slope four times per step and takes a weighted average.

import numpy as np

def f(s):                        # spring: x' = v, v' = -x
    x, v = s
    return np.array([v, -x])

def euler(s, h):
    return s + h * f(s)

def rk4(s, h):
    k1 = f(s); k2 = f(s + h/2*k1)
    k3 = f(s + h/2*k2); k4 = f(s + h*k3)
    return s + h/6 * (k1 + 2*k2 + 2*k3 + k4)

h = 0.1
for step in (euler, rk4):
    s = np.array([1.0, 0.0])     # x(0) = 1, v(0) = 0
    for _ in range(200):         # integrate to t = 20
        s = step(s, h)
    print(step.__name__, round(s[0], 6))

The exact answer is x(20)=cos⁡20≈0.408082x(20) = \cos 20 \approx 0.408082. Run as written, Euler prints 1.264886 and RK4 prints 0.408097, for the same step size.

9. Why Euler spirals outward, and what to use instead

For the spring, each Euler step multiplies the energy 12(x2+v2)\tfrac{1}{2}(x^2 + v^2) by exactly 1+h21 + h^2; expand one step to check. After 200 steps of h=0.1h = 0.1 that is 1.01200≈7.31.01^{200} \approx 7.3, so the energy rose from 0.5 to about 3.66. The numerical orbit spirals out of a circle the true orbit never leaves.

MethodGlobal error scales likeSlope evaluations per stepError in x(20)x(20), h=0.1h = 0.1Error in x(20)x(20), h=0.01h = 0.01
Eulerhh10.860.044
RK4h4h^441.5×10−51.5 \times 10^{-5}1.5×10−91.5 \times 10^{-9}

The error orders are the standard results found in any numerical analysis text, for instance Hairer, Norsett and Wanner's Solving Ordinary Differential Equations I; the error columns were measured with the code above.

In practice: call a library. SciPy's solve_ivp defaults to an adaptive Runge-Kutta 5(4) pair with relative tolerance 10−310^{-3}, per its documentation. That is loose: on this problem it misses cos⁡20\cos 20 by about 0.005. Tighten rtol for quantitative work, and switch to an implicit method such as Radau or BDF when the problem is stiff, mixing very fast and very slow time scales.

10. From a mechanism to an answer

Closed forms are the exception. Most real equations end on the qualitative branch, the numerical branch, or both, and every branch ends with a check against data.

flowchart TD
  A["Mechanism: a local rule for change"] --> B["Write the equation and the initial state"]
  B --> C["Classify: order, linearity, autonomy"]
  C --> D["Linear or separable"]
  C --> E["Nonlinear with no formula"]
  D --> F["Closed-form solution"]
  E --> G["Qualitative picture: fixed points and stability"]
  E --> H["Numerical integration with error control"]
  F --> I["Check the model against data"]
  G --> I
  H --> I

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. Which of these equations is nonlinear?
    • dT/dt = -k(T - 20)
    • dP/dt = rP(1 - P/K)
    • m x'' = -kx - c x'
    • dN/dt = -kN
  2. A quantity decays with the same half-life no matter how much of it there is. What does that imply about the mechanism?
    • The amount lost per hour is constant
    • It will reach exactly zero after two half-lives
    • The governing equation must be second order
    • Each unit leaves at a constant per-capita rate, independently of the others
  3. Why can two trajectories of dx/dt = f(x), with f smooth, never cross in state space?
    • At a crossing the state would have two different futures, which uniqueness forbids
    • Energy is conserved along every trajectory
    • Solutions always exist for all time
    • The equation is always linear near a crossing
  4. You rewrite x''' + x' = sin t as a system of first-order equations. How many equations does the system have?
    • One
    • Two
    • Three
    • Four
  5. Euler's method has global error proportional to the step size h. Roughly what does halving h do to the error at a fixed final time?
    • Divides it by 16
    • Halves it
    • Leaves it unchanged
    • Doubles it

Related lessons

Math
advanced

Stiff Equations, Stability Regions, and Adaptive Step Size

Why an ODE solver can blow up at step sizes accuracy would never demand. Learn stability regions on the test equation, what makes a problem stiff, how implicit methods and A-stability fix it at the cost of Newton solves, how BDF and Radau escape Dahlquist's barrier, and how adaptive solvers choose each step.

12 steps·~18 min
Math
intermediate

Chaos: The Lorenz System, Sensitive Dependence, and Strange Attractors

Three variables are enough for deterministic equations to become unpredictable. Work through the Lorenz system's fixed points and loss of stability, the shrinking volume behind its strange attractor, Lyapunov exponents and the predictability horizon, a measurement you can run yourself, and the period-doubling route to chaos in the logistic map.

10 steps·~15 min
Math
intermediate

The Phase Plane: Linear Systems, Eigenvalues, and Limit Cycles

Two variables make oscillation possible. Classify every fixed point of a linear system from its eigenvalues or from trace and determinant, linearize nonlinear systems with the Jacobian, analyse the Lotka-Volterra predator-prey model and its conserved quantity, and see why limit cycles are the robust oscillators and why the plane cannot be chaotic.

10 steps·~15 min
Math
intermediate

Flows on a Line: Fixed Points, Stability, and Bifurcations

Read a one-dimensional differential equation without solving it. Find fixed points, judge their stability from a slope, see why a line cannot oscillate, and classify the bifurcations that make a system tip. A harvested fishery shows a collapse threshold, hysteresis, and the slow recovery that warns before the jump.

10 steps·~15 min