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 , and the equation tells you its slope at every point in terms of the height . 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.
- y = e^x
- y = 2e^x
- y = 0.5e^x
The math
Definition
An equation that relates an unknown function of one variable to its derivatives, such as . 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 .
"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 , where is a constant. Try , an exponential function. Then , so every member of this family solves the equation. The constant is fixed by the initial condition. At we get , so and the solution is .
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 is solved exactly by taking an antiderivative.
Separable equations
If the right-hand side factors into a function of times a function of , you can separate the variables:
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 . Multiply both sides by the integrating factor . Because , the left side becomes the derivative of :
Integrate both sides, then divide by .
Second-order equations and systems
A second-order equation such as describes a spring or a pendulum near rest. Its general solution is , 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 , so and . The state is now the vector , and the equation reads . 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 and repeat
Each step follows the tangent line for a distance . The error shrinks as 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 is continuous in and Lipschitz in (its rate of change with respect to is bounded near the starting point), then the initial value problem has exactly one solution for a short time around . 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
Solve with .
- Separate: .
- Integrate: .
- Apply : , so .
- Solve for : , so .
- Check: , and .
- The solution grows without bound as 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.
Solve with .
- Integrating factor: .
- Multiply through: .
- Integrate: .
- Divide by : .
- Apply : , so . The solution is .
- Check: and .
- As grows, vanishes and settles to 2.
Interpretation: the constant 4 pushes the system toward a steady value of 2, and the starting excess decays at rate 2.
Use Euler's method with step on , starting at .
- First step: .
- Second step: .
- The exact solution is , which gives at .
- 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 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.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Nonlinear equation with no formula | No closed-form solution | Numerical solver such as Runge-Kutta |
| Large step size with Euler | Error grows, solution may be unstable | Smaller step, or an implicit method for stiff problems |
| Stiff problem with fast and slow parts | Explicit methods need tiny steps | Implicit methods such as backward Euler |
| Right-hand side not Lipschitz | Solution may not be unique | Check the conditions before trusting a single answer |
| Random forcing or noise | Deterministic 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 with . Give the solution and the value at .Show answer
The general solution is . The initial condition gives , so . At , .
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, has solutions for every constant . Specifying an initial value fixes the constant, so there is one solution through that point (under the Lipschitz condition, that solution is unique).
QuestionThe equation has two initial conditions, and . Without solving it fully, what kind of motion do you expect, and what is the amplitude?Show answer
This is a harmonic oscillator with . The solution is because and . The motion oscillates back and forth between and , so the amplitude is 1 and the period is .
QuestionYou solve numerically with Euler's method and get a finite, smooth answer for past 1. Why should you be suspicious?Show answer
The exact solution blows up at 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 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
- Ordinary differential equation (Wikipedia): https://en.wikipedia.org/wiki/Ordinary_differential_equation
- Euler method (Wikipedia): https://en.wikipedia.org/wiki/Euler_method
- Picard-Lindelöf theorem (Wikipedia): https://en.wikipedia.org/wiki/Picard%E2%80%93Lindel%C3%B6f_theorem