Chapter 4: Introduction to Differential Equations
4.2 Direction Fields and Numerical Methods
Study guide for Calculus Volume 2 (Gilbert Strang, 2016 edition)
Independent study guide. Not affiliated with OpenStax or Rice University.
Big idea
Most differential equations cannot be solved in closed form. That sounds like bad news, and it would be if a formula were the only thing a solution could be. It is not. A first-order equation $\frac{dy}{dx} = f(x,y)$ hands you something valuable even before you try to solve it: at every point of the plane it tells you the slope that a solution curve through that point must have.
Draw a short segment with that slope at a grid of points and you get a direction field, a picture of the slopes of all solutions at once. Solution curves are then the curves that stay tangent to the segments everywhere. You can trace one with a pencil starting from any point, and what you trace is a qualitatively correct graph of the solution through that point. Long-run behavior, constant solutions, and whether nearby solutions pull together or drift apart are all visible in the picture.
Following the field with a pencil suggests how to follow it with arithmetic. Start at the initial point, read the slope there, and walk in a straight line for a short horizontal distance instead of curving. You land slightly off the true curve. Read the slope at the new point, walk again, and repeat. That is Euler’s method, and it converts a differential equation into a table of numbers that any calculator can produce.
The cost is accuracy. Each step replaces a curve by its tangent line, and the errors do not cancel; they accumulate, and later steps compound errors inherited from earlier ones. Understanding how the error shrinks as the step shrinks is as much a part of the method as the formula itself.
Decoder
The equation assigns a slope to every point of the plane, and a solution is a curve whose tangent line at each of its points is the slope assigned there.
The content is in “at each of its points”. The slope is not a property of the curve you are hunting for; it is a property of the location. Two different solution curves passing near each other in the same region carry nearly the same slope, which is why the field looks like a smooth flow rather than a tangle.
A direction field is easiest to sketch along isoclines, the curves where $f(x,y)$ takes a constant value. On such a curve every segment has the same slope, so you draw a whole family of parallel dashes at once. The isocline for the value $0$ is the most useful of all: solution curves cross it horizontally, which is where maxima and minima have to be.
The mistake to avoid is confusing an isocline with a solution. An isocline is generally not a solution curve, because a solution has to be tangent to the field, while an isocline merely collects points where the field has one particular slope. The two coincide only when the isocline happens to have exactly the slope it carries.
Definitions and results
Direction field. For $\frac{dy}{dx} = f(x,y)$, the picture obtained by drawing at each point $(x,y)$ of a grid a short segment of slope $f(x,y)$. It is a picture of the equation, drawn without solving it.
Solution curve. A curve tangent to the field at each of its points. Through each point where $f$ is well behaved there is exactly one, so solution curves do not cross.
Isocline. The set where $f(x,y) = c$ for a fixed $c$. Along it every field segment has slope $c$. The zero isocline locates the horizontal tangents.
Autonomous equation. An equation of the form $\frac{dy}{dt} = f(y)$, with no $t$ on the right. Its field depends only on the height, so the picture is unchanged as you slide horizontally, and every horizontal translate of a solution is again a solution.
Equilibrium solution. A constant function $y = c$ with $f(c) = 0$, so the equation gives slope $0$ for all time and the solution never moves. Equilibria are found by solving $f(y) = 0$, which is algebra, not calculus.
Stability. An equilibrium is stable when solutions starting near it move toward it, and unstable when they move away. Read this from the sign of $f$ on each side: $f > 0$ pushes up, $f < 0$ pushes down.
Euler’s method. For $\frac{dy}{dx} = f(x,y)$ with $y(x_0) = y_0$, choose a step size $h$ and iterate
$$ x_{n+1} = x_n + h, \qquad y_{n+1} = y_n + h\,f(x_n, y_n) $$
Each line of the table replaces the solution curve by its tangent line over one step.
Error behavior. Euler’s method is first order: the accumulated error over a fixed interval is roughly proportional to $h$. Halving the step size roughly halves the error and doubles the work. The error is systematic, not random, so it usually lies on one side of the true value.
Worked examples
Sketching a field from its isoclines
Consider $\dfrac{dy}{dx} = x + y$.
The isocline for slope $c$ is the line $x + y = c$, that is, $y = -x + c$. So the field is constant along each line of slope $-1$, and the value it carries is the intercept. Along $y = -x$ the slopes are $0$, so solution curves are flat when they cross that line. Above it slopes are positive and grow; below it slopes are negative.
One isocline is also a solution here. On the line $y = -x - 1$ the field value is $x + (-x-1) = -1$, and the line itself has slope $-1$. Tangency holds at every point, so $y = -x - 1$ solves the equation. Check by substitution: the left side is $-1$ and the right side is $x + (-x - 1) = -1$. Every other solution curve bends away from this line, upward above it and downward below it.
An equilibrium and which way solutions move
Consider $\dfrac{dy}{dt} = 2 - y$.
Setting $2 - y = 0$ gives the single equilibrium $y = 2$, so the constant function $y(t) = 2$ is a solution. For $y < 2$ the right side is positive and solutions rise; for $y > 2$ it is negative and solutions fall. Both sides move toward the equilibrium, so $y = 2$ is stable and every solution approaches the height $2$ as $t$ grows, no matter where it starts.
Notice how little work that took. No formula for the solution was needed, and the conclusion covers all initial conditions at once.
Stepping forward with Euler’s method
Approximate the solution of $\dfrac{dy}{dx} = x + y$ with $y(0) = 1$ on $[0, 0.8]$, using $h = 0.2$.
| $n$ | $x_n$ | $y_n$ | $f(x_n,y_n)$ | $h f$ | $y_{n+1}$ |
|---|---|---|---|---|---|
| 0 | 0.0 | 1.0000 | 1.0000 | 0.2000 | 1.2000 |
| 1 | 0.2 | 1.2000 | 1.4000 | 0.2800 | 1.4800 |
| 2 | 0.4 | 1.4800 | 1.8800 | 0.3760 | 1.8560 |
| 3 | 0.6 | 1.8560 | 2.4560 | 0.4912 | 2.3472 |
So the method predicts $y(0.8) \approx 2.3472$.
This equation happens to be solvable, which lets us grade the estimate. The exact solution with $y(0) = 1$ is $y = 2e^{x} - x - 1$, and substituting confirms it: $y' = 2e^x - 1$, while $x + y = x + 2e^x - x - 1 = 2e^x - 1$. At $x = 0.8$ the true value is $2e^{0.8} - 1.8 \approx 2.6511$.
The estimate is low by about $0.304$, roughly $11$ percent. That is not a rounding artifact; it is the method. Every step used the slope at the left end of the interval, and since the slopes are increasing here, every step understated the rise. The errors all point the same way and add up.
What a smaller step buys
Redo the same problem with $h = 0.4$, which takes two steps. From $(0, 1)$ the slope is $1$, so $y_1 = 1 + 0.4(1) = 1.4$ at $x = 0.4$. There the slope is $0.4 + 1.4 = 1.8$, so $y_2 = 1.4 + 0.4(1.8) = 2.12$ at $x = 0.8$.
The coarse run is low by about $0.531$; the finer run was low by about $0.304$. Halving the step cut the error to roughly $57$ percent of what it had been, which is the behavior a first-order method predicts. Getting one more decimal place this way costs about ten times the work, which is why practical solvers use methods that do better per step.
Practice
First the picture. These items ask you to match an equation with its field, to find equilibrium solutions and classify them, and to read long-run behavior off a sketch.
Practice
Generated problems for this section, graded instantly.
Then the arithmetic. Build the table one row at a time, keep track of which point the slope is read at, and compare the result to the exact answer when one is available.
Practice
Generated problems for this section, graded instantly.
Quiz
Five items on reading direction fields, identifying equilibria and their stability, and carrying out Euler’s method.
Quiz
5 problems with a score at the end.