Search

Search papers and lessons

Ordinary Differential Equation

Level 2 · 12 min read

An ordinary differential equation states a rule for how a quantity changes given its current value, and solving it means finding the function that obeys that rule.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Sign in to see your progress

TL;DR

An ordinary differential equation (ODE) is a rule that says how a quantity changes, in terms of the quantity's current value and time. Solving it means finding the function that follows the rule from a given starting point. Most of physics, and much of biology, economics and machine learning, is written in this form, because it is often easier to say how something changes than where it ends up.

Where you'll see it: in Newton's second law for a falling object or a spring, in population growth and drug dosing models, in electrical circuits, and in the continuous-time versions of neural networks and diffusion models.

Intuition

A rule for the slope

Imagine a bank account that grows by 5 percent of its current balance every year. You do not know the balance at year 10 yet, but you know the rule: the rate of change (the derivative) equals 0.05 times the balance. That single line of rule describes the whole future. Start with 100 and the balance follows a curve that always bends upward in proportion to its height.

That is an ODE. The unknown is a function y(t)y(t), and the equation tells you its slope at every point in terms of the height yy. You do not need to guess the curve. You have to find the one curve that matches the rule everywhere, and the starting value picks out which one.

Why does this idea matter? Physical laws are almost always local statements about change. A force tells you acceleration, which is the rate of change of velocity. A reaction rate tells you how fast a concentration falls. Writing the law as an ODE is the most direct description of the law, and solving the ODE is how you turn it into predictions.

−1−0.500.511.520246ty
  • y = e^x
  • y = 2e^x
  • y = 0.5e^x
The ODE y' = y has a whole family of solutions, one for each starting value. Each starting value picks out one curve.

The math

Definition

Definition: Ordinary differential equation

An equation that relates an unknown function y(t)y(t) of one variable to its derivatives, such as y′=f(t,y)y' = f(t, y). Its order is the highest derivative that appears. A solution is a function that satisfies the equation on some interval. An initial value problem adds a condition such as y(t0)=y0y(t_0) = y_0.

"Ordinary" means the unknown depends on one variable. When it depends on several, the equation involves partial derivatives and is called a partial differential equation.

First-order equations and the constant of integration

The simplest case is y′=k yy' = k\,y, where kk is a constant. Try y(t)=Cekty(t) = C e^{kt}, an exponential function. Then y′=kCekt=k yy' = kCe^{kt} = k\,y, so every member of this family solves the equation. The constant CC is fixed by the initial condition. At t=0t = 0 we get y(0)=Cy(0) = C, so C=y0C = y_0 and the solution is y(t)=y0ekty(t) = y_0 e^{kt}.

This is the first pattern to notice. An ODE usually has a family of solutions, and the initial value selects one member. It is the same role the constant of integration plays in an antiderivative, and indeed an ODE of the form y′=g(t)y' = g(t) is solved exactly by taking an antiderivative.

Separable equations

If the right-hand side factors into a function of tt times a function of yy, you can separate the variables:

y′=g(t) h(y)⟹∫dyh(y)=∫g(t) dt.y' = g(t)\,h(y) \quad \Longrightarrow \quad \int \frac{dy}{h(y)} = \int g(t)\,dt.

Both sides can now be integrated separately. This is how you solve most textbook equations by hand.

Linear first-order equations

A linear first-order equation has the form y′+p(t) y=q(t)y' + p(t)\,y = q(t). Multiply both sides by the integrating factor μ(t)=e∫p(t) dt\mu(t) = e^{\int p(t)\,dt}. Because μ′=pμ\mu' = p\mu, the left side becomes the derivative of μy\mu y:

ddt(μ(t) y(t))=μ(t) q(t).\frac{d}{dt}\big(\mu(t)\,y(t)\big) = \mu(t)\,q(t).

Integrate both sides, then divide by μ(t)\mu(t).

Second-order equations and systems

A second-order equation such as y′′+ω2y=0y'' + \omega^2 y = 0 describes a spring or a pendulum near rest. Its general solution is y(t)=Acos⁡(ωt)+Bsin⁡(ωt)y(t) = A\cos(\omega t) + B\sin(\omega t), which has two constants because the equation has two initial conditions, the position and the velocity.

Any higher-order equation can be rewritten as a first-order system. Set v=y′v = y', so y′=vy' = v and v′=−ω2yv' = -\omega^2 y. The state is now the vector Y=(y,v)\mathbf{Y} = (y, v), and the equation reads Y′=F(Y)\mathbf{Y}' = F(\mathbf{Y}). This is the form that numerical solvers and modern machine learning models use.

Numerical solutions

Most ODEs cannot be solved in closed form. The simplest numerical method is Euler's method. Choose a small step hh and repeat

Yn+1=Yn+h F(Yn).\mathbf{Y}_{n+1} = \mathbf{Y}_n + h\,F(\mathbf{Y}_n).

Each step follows the tangent line for a distance hh. The error shrinks as hh shrinks, but it accumulates, and better methods such as Runge-Kutta reduce the error for the same cost.

When does a solution exist?

The Picard-Lindelöf theorem says that if ff is continuous in tt and Lipschitz in yy (its rate of change with respect to yy is bounded near the starting point), then the initial value problem has exactly one solution for a short time around t0t_0. Without that condition, solutions may not be unique, and they may not exist for all time. The first worked example below shows the second case.

Worked examples

Example
Separable equation with finite-time blow-up

Solve y′=y2y' = y^2 with y(0)=1y(0) = 1.

  1. Separate: ∫dyy2=∫dt\displaystyle \int \frac{dy}{y^2} = \int dt.
  2. Integrate: −1y=t+C-\dfrac{1}{y} = t + C.
  3. Apply y(0)=1y(0) = 1: −1=0+C-1 = 0 + C, so C=−1C = -1.
  4. Solve for yy: −1y=t−1-\dfrac{1}{y} = t - 1, so y(t)=11−ty(t) = \dfrac{1}{1 - t}.
  5. Check: y′=1(1−t)2=y2y' = \dfrac{1}{(1-t)^2} = y^2, and y(0)=1y(0) = 1.
  6. The solution grows without bound as tt approaches 1 and does not exist beyond it.

Interpretation: the rule "growth proportional to the square of the size" can produce a value that blows up in finite time. Exponential growth never does this, which is why the two rules behave so differently.

Example
Linear equation with an initial condition

Solve y′+2y=4y' + 2y = 4 with y(0)=5y(0) = 5.

  1. Integrating factor: μ(t)=e∫2 dt=e2t\mu(t) = e^{\int 2\,dt} = e^{2t}.
  2. Multiply through: ddt(e2ty)=4e2t\dfrac{d}{dt}\big(e^{2t}y\big) = 4e^{2t}.
  3. Integrate: e2ty=2e2t+Ce^{2t}y = 2e^{2t} + C.
  4. Divide by e2te^{2t}: y(t)=2+Ce−2ty(t) = 2 + Ce^{-2t}.
  5. Apply y(0)=5y(0) = 5: 5=2+C5 = 2 + C, so C=3C = 3. The solution is y(t)=2+3e−2ty(t) = 2 + 3e^{-2t}.
  6. Check: y′=−6e−2ty' = -6e^{-2t} and y′+2y=−6e−2t+4+6e−2t=4y' + 2y = -6e^{-2t} + 4 + 6e^{-2t} = 4.
  7. As tt grows, e−2te^{-2t} vanishes and yy settles to 2.

Interpretation: the constant 4 pushes the system toward a steady value of 2, and the starting excess decays at rate 2.

Example
Two Euler steps on y' = y

Use Euler's method with step h=0.5h = 0.5 on y′=yy' = y, starting at y(0)=1y(0) = 1.

  1. First step: y1=y0+h y0=1+0.5×1=1.5y_1 = y_0 + h\,y_0 = 1 + 0.5 \times 1 = 1.5.
  2. Second step: y2=y1+h y1=1.5+0.5×1.5=2.25y_2 = y_1 + h\,y_1 = 1.5 + 0.5 \times 1.5 = 2.25.
  3. The exact solution is ete^t, which gives e1≈2.718e^{1} \approx 2.718 at t=1t = 1.
  4. The Euler answer is about 17 percent too low after just two steps.

Interpretation: Euler follows straight tangent lines, and the curve bends away from them. Halving hh reduces the error, but for this problem the error stays visible until the step is very small.

Tradeoffs and failure modes

ODEs are a powerful model, but their solutions are sensitive to assumptions. The table summarises the common situations.

SituationWhat goes wrongBetter choice
Nonlinear equation with no formulaNo closed-form solutionNumerical solver such as Runge-Kutta
Large step size with EulerError grows, solution may be unstableSmaller step, or an implicit method for stiff problems
Stiff problem with fast and slow partsExplicit methods need tiny stepsImplicit methods such as backward Euler
Right-hand side not LipschitzSolution may not be uniqueCheck the conditions before trusting a single answer
Random forcing or noiseDeterministic ODE misses the fluctuations[[stochastic-differential-equation

The most common mistake is to treat a numerical answer as exact. Always check the solution by substituting it back into the equation, and compare results at two step sizes.

History

Isaac Newton and Gottfried Leibniz developed the calculus behind ODEs in the 1670s and 1680s. Newton used his method of fluxions to solve equations of motion, though his work circulated for years before it was published. In the 1690s, Leibniz, Christiaan Huygens and Johann Bernoulli worked out the separation of variables that makes many first-order equations solvable by hand.

Leonhard Euler developed the numerical method that bears his name in the 1760s, using it to approximate solutions when no formula was available. The existence and uniqueness theory came in the late nineteenth century, with Émile Picard's iterative method and Ernst Lindelöf's refinement. These results turned ODEs from a bag of tricks into a subject with clear conditions.

ODEs caught on because they match physical reasoning. Newton's laws, population models and circuit equations all describe change at each moment, and the ODE is the most literal way to write that down.

Check yourself

QuestionSolve y′=3yy' = 3y with y(0)=2y(0) = 2. Give the solution and the value at t=1t = 1.Show answer

The general solution is y=Ce3ty = Ce^{3t}. The initial condition gives C=2C = 2, so y(t)=2e3ty(t) = 2e^{3t}. At t=1t = 1, y=2e3≈40.2y = 2e^{3} \approx 40.2.

QuestionWhy does a first-order ODE generally have a family of solutions rather than a single one, and what extra information selects one of them?Show answer

Solving a first-order equation involves an integration, which introduces an arbitrary constant. For example, y′=kyy' = ky has solutions CektCe^{kt} for every constant CC. Specifying an initial value y(t0)=y0y(t_0) = y_0 fixes the constant, so there is one solution through that point (under the Lipschitz condition, that solution is unique).

QuestionThe equation y′′+4y=0y'' + 4y = 0 has two initial conditions, y(0)=1y(0) = 1 and y′(0)=0y'(0) = 0. Without solving it fully, what kind of motion do you expect, and what is the amplitude?Show answer

This is a harmonic oscillator with ω=2\omega = 2. The solution is y(t)=cos⁡(2t)y(t) = \cos(2t) because y(0)=1y(0) = 1 and y′(0)=0y'(0) = 0. The motion oscillates back and forth between −1-1 and 11, so the amplitude is 1 and the period is π\pi.

QuestionYou solve y′=y2y' = y^2 numerically with Euler's method and get a finite, smooth answer for tt past 1. Why should you be suspicious?Show answer

The exact solution y=1/(1−t)y = 1/(1-t) blows up at t=1t = 1 and has no value beyond it. Euler's method always returns finite numbers, because each step is just arithmetic, so it can quietly step over the blow-up and report values for times where the true solution does not exist. Near t=1t = 1 the computed values should grow very fast and change a lot when you halve the step. Compare two step sizes and check against the analytic solution.

Sources