What a differential equation is
A differential equation is an equation for an unknown function that involves its derivative. In the unknown is a function . The equation says that at every time , the slope of is half its value.
With one input variable, as here, it is an ordinary differential equation, or ODE. Module 6.3 meets equations for functions of two variables.
Units follow the derivative. If is in grams and in hours, then is in grams per hour, and 0.5 is a rate per hour. So grows by 50% of its size per hour: its relative rate (lesson 2.3.4).
The order of an equation is its highest derivative. and are first order; is second order, the subject of module 6.2. This module treats first-order equations written as : the slope is a given function of the time and the current value.
The simplest have no on the right. is solved by every antiderivative (lesson 2.5.2). A differential equation is integration in which the slope may also depend on the answer.
What counts as a solution
A solution is a function that makes the equation true at every of an interval. To check a candidate, substitute it: work out both sides and compare them.
Rule: Solution of a differential equation
Differentiate the candidate, put it into the right-hand side, and subtract. The difference must be 0 for every in an interval, not just at one point.
Three candidates for :
- has , and . They agree for every : a solution.
- has , but . The two sides always differ by 0.5: not a solution.
- has and . These agree only at and . Two points are not enough: not a solution.
Try it
The residual is , the left side minus the right. SymPy works it out for each candidate; a solution leaves 0.
The last line finds where happens to satisfy the equation: only at two instants.
Initial conditions
Every function solves , whatever the constant . The solutions form a family, as the antiderivatives did in lesson 2.5.2. One known value picks one member.
A known value is an initial condition, and the equation with it is an initial value problem. With , . With instead, , so .
When and its partial derivative (lesson 4.1.2) are continuous, exactly one solution passes through each starting point, at least for a while. So two solutions of the same equation never cross.
The slope field
The equation gives the slope of the solution through any point , before any solution is known. Draw a short line with that slope at each point of a grid: this is the slope field. A solution is a curve that runs along the lines everywhere.
For , the slope at is , at it is 0, and at it is 1.6. Here the slope depends only on , so every column of the field looks the same.
Each short line has the slope the equation gives at that point, and each curve follows the lines. Solutions of settle on the equilibrium 2; solutions of move away from the equilibrium 0.
Equilibrium solutions
If for every , the constant is a solution, with slope 0 throughout. It is an equilibrium. For it is , and for it is . The logistic equation has two: and .
An equilibrium is stable when nearby solutions move towards it and unstable when they move away. Above 2, is negative, so falls; below 2 it rises. So 2 is stable, while for a positive grows and a negative one falls: 0 is unstable.
Separable equations
An equation is separable when its slope is a function of times a function of : . Then the terms can go to one side and the terms to the other, and each side is integrated in its own variable.
Rule: Separable equation
Divide by , integrate both sides and keep one . Solve for , then use the initial condition to fix . Dividing loses any constant solution with : those are the equilibria, so add them back.
Moving across is shorthand, as was in lesson 2.6.1. If is an antiderivative of , the chain rule gives , and integrating that in is the rule.
Exponential growth and decay
Take with a constant , so and .
- 1
- 2
- 3
At , , so is the starting value .
Rule: Growth and decay
gives growth, decay and a constant. The relative rate is at every time (lesson 2.3.4). The size doubles, or halves, every units of time.
For with , each unit of time multiplies by :
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 1 | 1.648721 | 2.718282 | 4.481689 | 7.389056 |
It doubles every units of time. Decay at halves the size every units.
Settling on an equilibrium
separates with and . Integrate with the linear substitution , (lesson 2.6.1). Then raise to both sides, as above, and let fix the constant:
The gap to the equilibrium, , decays at the rate 0.8. Each unit of time multiplies it by , and it halves every .
Rule: Settling on an equilibrium
With , the gap decays like from either side, so every solution settles on the stable equilibrium . The rate says how fast; says where.
These are the curves in the first panel of the figure, with and :
| 0 | 1 | 2 | 3 | 5 | |
|---|---|---|---|---|---|
| from | 4 | 2.8987 | 2.4038 | 2.1814 | 2.0366 |
| from | 0 | 1.1013 | 1.5962 | 1.8186 | 1.9634 |
Try it
The loop prints the growth table, then the doubling time and the half-life.
The last loop prints the solutions of from 4 and from 0.
When is not exponential
Not every separable equation gives an exponential. Take with . Separating gives , so and once fixes .
Two functions satisfy that: and . The start is positive, so the solution is ; from it would be the negative root. Substituting checks it: . At it is 2.236068, 2.828427, 3.605551 and 4.472136.
Solutions that blow up
with looks harmless. Separating gives , so and . At , 0.99 and 0.999 it is 10, 100 and 1000: it blows up at (lesson 2.1.2).
So a solution may exist only on an interval, here , even when the equation itself is defined everywhere. Dividing by also lost the equilibrium .
Equations that do not separate
is a sum, not a product , and no rearranging makes it one. It is a linear equation, which lesson 6.1.2 solves with an integrating factor.
Try it
sp.dsolve solves a differential equation; ics gives the initial condition. Each line prints the right-hand side and the solution.
SymPy multiplies out as 8/5 - 4*y(t)/5, and writes as -1/(t - 1).
classify_ode lists the methods that apply. The last line asks whether separation is one of them for .
Euler's method
Most differential equations have no solution in familiar functions, but every one has a slope field to follow. Euler's method follows it in straight steps of length in . From the start, move along the line with the slope for one step, then read the slope again.
Rule: Euler's method
Each step follows the tangent line of lesson 2.2.1 at the start of the step. A smaller means more steps, each closer to the curve.
For with and , each step multiplies by . The exact solution multiplies it by over the same step, so Euler falls behind:
| 0 | 0.5 | 1 | 1.5 | 2 | |
|---|---|---|---|---|---|
| Euler | 1 | 1.25 | 1.5625 | 1.953125 | 2.441406 |
| exact | 1 | 1.284025 | 1.648721 | 2.117 | 2.718282 |
| error | 0 |
The errors are negative because the curve bends up, so each tangent line lies below it (lesson 2.4.2). The shortfalls build up from step to step.
The error is proportional to
At the error is with , with and with . Halving the step about halves the error: Euler's method is first order, like the forward difference of lesson 2.8.1. Even 2,000 steps leave an error of 0.000679; lesson 6.1.2's solve_ivp does far better.
A step that is too long can overshoot. For , each Euler step multiplies the gap by . With that factor is : from 4 the first step lands on 1.6, below the equilibrium, then 2.08 and 1.984. With it is , and the steps run 4, , 5.92, : the numbers blow up while the true solution settles.
Try it
euler returns the lists of times and values. The first loop prints the table above; the second, the error at for smaller and smaller steps.
The last two lines take steps of 1.5 and 3 on from 4.
Below, the dark curve is the exact solution of and the coloured path is Euler's method. Move the start above and below 2, then compare with : from , the error at shrinks from to . Set to watch each step jump past the equilibrium.
Explore
Each short line has the slope the equation gives at that point. A solution follows the lines. Move the starting value, then step along the field with Euler's method and shrink the step to follow the exact curve.
The dark curve is the exact solution; the coloured one is Euler's method.
- Exact solution at t = 5
- 2.03663
- Euler, 10 steps of 0.5
- 2.01209, off by −0.02454
The buttons at the top switch to , to the logistic equation and to an equation with a rate that rises with . Case study 6.1.4 uses that last one to price a bond.
Common mistakes
- Check a solution at every , not at one point. satisfies at and only.
- The constant multiplies. gives , not . Fix it with the initial condition.
- Dividing by loses the equilibria. solves , though separating never finds it.
- Let the initial condition choose the root. From , gives , not .
- A solution may stop. solves only for .
- Not every equation separates. is a sum; it needs lesson 6.1.2.
- Euler's error shrinks only in proportion to , and too long a step can overshoot an equilibrium or blow up.
Differential equations and separable equations
0 of 13 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- A differential equation links an unknown function to its derivative; its order is the highest derivative. A solution makes it true at every of an interval: check by substituting.
- An initial condition picks one solution from the family. Through each starting point passes one solution, so solutions do not cross.
- The slope field draws the slope at each point. A constant with is an equilibrium, stable or unstable.
- Separable : , one , then the initial condition; add back the equilibria.
- gives ; gives . Some solutions blow up in finite time, such as .
- Euler's method: . Its error is about proportional to , and a long step can overshoot.