4.2 Direction Fields and Numerical Methods

Drawing the field of slopes a differential equation prescribes, reading solution curves and equilibria off it, judging stability without solving, and approximating a solution numerically with Euler's method.

Subject: Calculus II · 67 slides · symbolic lesson

Open the interactive version of this deck

What this lesson covers

The lesson, slide by slide

1. Direction Fields and Numerical Methods

Title

Calculus II · Section 4.2

Seeing, and computing, solutions you cannot write down

2. What this lesson gives you

Objectives

Section 4.1 told you what a solution of a differential equation is and how to check one. It gave no way of finding one, and most differential equations have no formula for their solutions at all. This lesson gives you two ways around that: a picture and an algorithm.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, pp. 365-376 — learning objectives 4.2.1 to 4.2.3

In Section 4.1 you learned to check a proposed solution by substituting it into the equation. That is useful, but it assumes somebody hands you the solution. For most differential equations nobody can, because the solutions cannot be written with the functions you know.

This lesson gives you two tools that work anyway. The first is a picture, the direction field, which shows the shape of every solution at once and lets you read off long-term behaviour, including which constant solutions attract their neighbours and which repel them. The second is an algorithm, Euler's method, which turns the equation into a table of numbers you can compute by hand, in a spreadsheet, or in a few lines of code.

Both rest on one idea you already own: the derivative at a point is the slope of the tangent line there. Keep that in mind and nothing in this lesson will feel arbitrary.

3. Before anything new: the tangent line

Warm-up

Discussion prompt

From Calculus I: estimate the square root of 4.1 using the tangent line to the square-root curve at x = 4. Write the tangent line first, then evaluate it.

Write your tangent line before revealing the answer. The recipe is point plus slope: the curve passes through (4, 2), and the derivative of the square root, one over twice the root, is one quarter there.

Evaluating the line at 4.1 costs one multiplication, and the answer 2.025 is already right to three decimal places. The line and the curve agree to first order near the point of tangency, and drift apart only slowly.

Hold on to this. A differential equation of the form y prime equals f of x and y is a machine that hands you the slope at any point you ask about. Give a tangent line a point and a slope and it will predict the next height. Euler's method, at the end of this lesson, is nothing but this warm-up repeated over and over.

4. The field

Section

Part 1

5. An equation that hands out slopes

Concept

A first-order equation of the form below does not tell you y. It tells you the slope of y at any point you name.

\[ y' = f(x, y) \]

Name the point (1, 2) for the equation y prime equals 3x plus 2y minus 4, and it answers with a number:

\[ y' = 3(1) + 2(2) - 4 = 3 \]

Figure (svg): Eight grid points, each with a short segment whose slope is 3x plus 2y minus 4 at that point, labelled with the slope: minus 4 at the origin, minus 1 at (1, 0), 2 at (2, 0), minus 2 at (0, 1), 1 at (1, 1), 0 at (0, 2), 3 at (1, 2) and 0 at (2, -1).

One substitution per point. Each segment is a promise: any solution passing through that point must leave it at exactly that slope.

So any solution curve that passes through (1, 2) must pass through it with slope 3. Draw that as a short segment, and repeat at every point you like.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 366 — the slope at (1, 2)

Read the equation as a rule, not as a formula to solve. You name a point, and it tells you how steeply any solution through that point must be climbing or falling. At (1, 2) the answer is 3, so a solution curve through (1, 2) leaves it rising three units for every one unit to the right.

The figure shows eight such answers, each drawn as a short segment through its point. Look at how the slopes change: moving right adds 3 to the slope, moving up adds 2. That is just the coefficients of x and y in the equation, now visible as a pattern.

Nothing has been solved yet. You do not know any solution curve. But you already know the direction every solution curve must take at eight different places, and that turns out to be a remarkable amount of information.

6. Building the field of 3x + 2y - 4

Worked example

Compute enough slopes of the equation below to see the pattern of its direction field.

\[ y' = 3x + 2y - 4 \]

Start at the origin

Why: Substitute x equal to 0 and y equal to 0.

\[ f(0, 0) = 0 + 0 - 4 = -4 \]

Move right along the x-axis

Why: Each unit of x adds 3 to the slope.

\[ f(1, 0) = -1, \quad f(2, 0) = 2 \]

Move up the y-axis

Why: Each unit of y adds 2 to the slope.

\[ f(0, 1) = -2, \quad f(0, 2) = 0 \]

Find every flat segment at once

Why: Set the slope equal to zero and solve for y.

\[ 3x + 2y - 4 = 0 \iff y = 2 - \tfrac32 x \]

Find every segment of slope m

Why: Set the slope equal to m instead: a parallel line each time.

\[ 3x + 2y - 4 = m \iff y = 2 + \tfrac{m}{2} - \tfrac32 x \]

Figure (svg): The direction field of y prime equals 3x plus 2y minus 4 on a grid from x equals -2 to 3, with three dashed parallel lines: the line 3x plus 2y equals 4, where every segment is flat, and the lines where the slope is 2 and -2.

The flat segments all lie on one line, and every line parallel to it carries segments of one common slope. Those lines are isoclines, and they are the fast way to draw a field by hand.

Check two flat points on the line

Why: Both (0, 2) and (2, -1) lie on the line of zero slope; substitute them.

\[ f(0, 2) = 0 + 4 - 4 = 0, \qquad f(2, -1) = 6 - 2 - 4 = 0 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 366 — Figure 4.7

The first three steps are plain substitution. Do a handful by hand once, because it makes the pattern obvious: the slope grows by 3 per unit right and by 2 per unit up.

The fourth and fifth steps are the efficient way to work. Instead of computing slopes point by point, ask where the slope takes a particular value. Setting the right-hand side equal to zero gives a whole line of flat segments; setting it equal to any other constant m gives a parallel line of segments with slope m. These lines are isoclines, and with three or four of them you can draw the whole field in a minute.

The check substitutes two points lying on the flat line and gets zero both times, which confirms the algebra. Look at the figure: the segments on the yellow dashed line really are horizontal, and those on the other two dashed lines really do share one slope each.

7. What a direction field is

Concept

direction field (slope field) — A picture of a first-order differential equation: at each point of a grid, a short segment whose slope equals the slope that the equation assigns to a solution passing through that point.

\[ \text{segment at } (x_0, y_0) \text{ has slope } f(x_0, y_0) \]

The field contains exactly the information the equation does, arranged for the eye. Nothing has been solved, and no constant of integration has been chosen: every solution curve of the equation is in the picture at once, waiting to be traced.

Segments are drawn at a fixed length rather than a fixed horizontal run, so a very steep slope still gives a short, readable mark.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 366 — Definition of a direction field

Here is the book's definition in one sentence: at each point, a segment with the slope that a solution through that point would have. The field is the differential equation, drawn.

A useful way to think about it: every solution of the equation is already in the picture. The general solution has an arbitrary constant, and each value of the constant gives one curve through the field. The initial condition is what picks out one of them.

The detail about fixed length matters when you draw by hand. If you drew each segment with the same horizontal run, a slope of 50 would give a segment fifty times taller than it is wide, spearing through the neighbouring points. Fixing the length keeps every mark inside its own cell.

8. Isoclines: where the slopes agree

Concept

An isocline is a curve along which the field has one constant slope. Setting the right-hand side equal to a constant gives it.

\[ f(x, y) = m \]

For the equation y prime equals x squared minus y squared, the isoclines are hyperbolas, and the zero-slope isocline is the pair of diagonals:

\[ x^2 - y^2 = 0 \iff y = \pm x, \qquad x^2 - y^2 = m \text{ a hyperbola for } m \ne 0 \]

Figure (svg): The direction field of y prime equals x squared minus y squared on a square window, with the dashed lines y equals x and y equals minus x where the segments are flat, and two dashed hyperbolas: slope 1 on the left and right branches, slope -1 on the upper and lower branches.

Flat along both diagonals, falling above and below them, rising to the left and right. That sign pattern alone tells you how any solution curve must move.

Draw a few isoclines, put the matching segments along each, and the field is done. The zero isocline is the most valuable one: it is the only place a solution can have a horizontal tangent.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 366 — the field of x squared minus y squared

The word isocline means equal slope. Setting the right-hand side equal to a constant gives a curve, and all along that curve the segments are parallel. For the previous equation these curves were straight lines; for this one they are hyperbolas.

Look at the figure. On the two yellow diagonals the segments are flat. Above the upper diagonal and below the lower one, y squared beats x squared, so the slope is negative. In the left and right wedges x squared wins and the slope is positive. You now know the sign of the slope everywhere without computing a single point.

The zero isocline deserves special attention in every problem. It is the only place where a solution curve can have a horizontal tangent, so it is the only place a rising curve can turn into a falling one or back. You will use exactly this in Checkpoint 4.7.

9. Reading y' = f(x, y) piece by piece

Notation

Annotate

On: \( y'(x) = f\big(x, y(x)\big), \qquad y(x_0) = y_0 \)

  • The slope of the unknown solution curve at the point above x. This is what the field draws.
  • A rule that takes a point of the plane and returns a slope. It may use x, y, both, or neither.
  • Inside f, y is the height of the solution itself. That is why you cannot just integrate: the slope depends on the answer.
  • The initial condition picks one curve out of the field: the one that passes through the point (x₀, y₀).

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 365 — first-order equations of the form y′ = f(x, y)

Step through the notes one at a time. The first two are the reading you have been using: the left side is a slope, the right side is a rule that produces slopes from points.

The third note is the reason these equations are hard. If the right-hand side involved only x, you could integrate it, as you did for years. Here it involves y, the unknown function itself. To know the slope you need the height, and to know the height you need the slope. The direction field and Euler's method both break that circle by working locally: at one point at a time, the height is known and so the slope is known.

The last note is the initial condition. It is the one piece of information that chooses a single curve out of the infinitely many in the field.

10. Newton's law of cooling as a field

Picture it

Figure (svg): The direction field of T prime equals -0.4 times T minus 72, for time t from 0 to 12 and temperature from 30 to 120, with a dashed horizontal line at 72; one solution starts at 110 and falls toward 72, another starts at 40 and rises toward 72.

Every segment tilts toward the line at 72 degrees, steeply when far from it and gently when close. Both curves obey the same equation; only their starting temperature differs.

\[ T'(t) = -0.4\left(T - 72\right) \]

The slope depends only on how far the temperature is from the room's 72 degrees. Above 72 the segments point down, below 72 they point up, and on 72 itself they are flat.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 365 — Figure 4.6

This is the book's opening example, Figure 4.6. T is the temperature of an object and 72 degrees is the temperature of the room. The equation says the object's temperature changes at a rate proportional to its distance from room temperature, and the minus sign says the change is always toward the room.

Look at how the field shows that. High up, far above 72, the segments point steeply down. Close to 72 they flatten out. Below 72 they tilt upward. The line at 72 is entirely flat segments.

The two curves are a hot object cooling and a cold one warming. Both obey the same law, both approach 72, and both approach it more and more slowly. Notice that the field also tells you something the curves only hint at: the object never overshoots room temperature, because the segments on 72 are flat. You will prove this carefully in Part 3.

11. Where is the field of (2x + 4)/(y - 2) vertical?

Prediction

\[ y' = \frac{2x + 4}{y - 2} \]

Predict first

This equation appears on page 366 of the book. Where does its direction field have vertical segments, and where flat ones?

  • Vertical along y = 2, flat along x = −2
  • Vertical along x = −2, flat along y = 2
  • Vertical nowhere, flat along y = 2
  • Vertical along y = x, flat nowhere

Correct: Vertical along y = 2, flat along x = −2

Why: The slope is flat where the numerator 2x + 4 is zero, the vertical line x = −2. It blows up where the denominator y − 2 is zero, the horizontal line y = 2, so the segments there stand vertical (the equation is undefined on that line itself). Swapping the two is the usual slip: flat comes from the top, vertical from the bottom.

\[ 2x + 4 = 0 \iff x = -2 \;(\text{flat}), \qquad y - 2 = 0 \iff y = 2 \;(\text{vertical}) \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 366 — the third example equation

Commit to one option before you reveal. The equation is a quotient, and a quotient is zero where its top is zero and blows up where its bottom is zero.

The top, 2x plus 4, is zero when x is minus 2. So all along the vertical line x equal to minus 2 the segments are flat. The bottom, y minus 2, is zero when y is 2. Approaching that horizontal line the slope becomes enormous, so the segments stand up vertically, and on the line itself the equation is not defined.

People swap these because the lines point the opposite way to their segments: a vertical line of flat segments and a horizontal line of vertical segments. Say it slowly: flat segments where the slope is zero; vertical segments where the slope is infinite.

12. Which variable does the field depend on?

Sorting

Sort into buckets

Sort each equation by the symmetry of its direction field.

Only y: every row of segments is parallel
y′ = y² − 1; y′ = sin² y
Only x or t: every column of segments is parallel
dy/dx = x² cos x; y′ = eᵗ
Both: neither pattern
y′ = y − x; y′ = 3y + xy
yonly
y² − 1 and sin² y never mention x, so every point at the same height gets the same slope: slide the field sideways and it does not change. These are autonomous equations.
xonly
x² cos x and eᵗ never mention y, so every point in the same vertical column gets the same slope. The solutions are antiderivatives, stacked vertically.
both
y − x and 3y + xy (which is (3 + x)y) involve both variables, so neither rows nor columns repeat.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 377 — Exercises 74-83

Sort by looking only at which letters appear on the right-hand side. You do not need to compute anything.

When only y appears, two points at the same height get the same slope, wherever they are left or right. So each horizontal row of the field is a row of parallel segments, and the whole field looks the same when you slide it sideways. These equations are called autonomous, and they are the ones whose equilibria you will classify in Part 3.

When only x or t appears, points in the same vertical column get the same slope, and the equation is really just an antiderivative problem: every solution is one antiderivative shifted up or down. When both appear, as in 3y plus xy, neither pattern holds. Notice that 3y plus xy factors as (3 plus x) times y, which is still a mixture of both.

13. Match each equation to its field

Matching

Figure (svg): Four small direction fields labelled A to D on the square from -2 to 2. A: segments flat along both axes, falling in the first and third quadrants and rising in the second and fourth. B: flat along the t-axis, falling steeply above it and rising steeply below it, the same in every column. C: all segments rising, gently on the left and steeply on the right, the same in every row. D: flat along the y-axis, rising to its left and falling to its right, the same in every row.

Look for three things: where the segments are flat, whether rows or columns repeat, and where the slopes are steepest.

Match the pairs

  • a. y′ = −3y
  • b. y′ = −3t
  • c. y′ = eᵗ
  • d. y′ = −ty
  • A. Field A
  • B. Field B
  • C. Field C
  • D. Field D

Why: −3y depends only on y and is flat on the t-axis: B. −3t depends only on t and is flat on the y-axis: D. eᵗ is positive everywhere and grows to the right: C. −ty is flat on both axes and changes sign from quadrant to quadrant: A.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 378 — Exercises 84-88

Before matching, spend ten seconds on each small field and ask three questions. Where is it flat? Do the rows or the columns repeat? Where is it steepest?

Field B is flat along the horizontal axis and every column looks the same, so its slope depends only on y and vanishes at y equal to 0: that is minus 3y. Field D is flat along the vertical axis and every row is the same: slope depends only on t and vanishes at t equal to 0, which is minus 3t. Field C rises everywhere, gently on the left and steeply on the right, which is the exponential.

Field A is the only one flat on both axes, with signs that change from quadrant to quadrant: minus t times y is zero when either factor is, and negative when t and y have the same sign. Matching by features like these is a skill you will use on exam questions that show a field and ask for its equation.

14. Exercise 74: the field of y' = t cubed and its solutions

Worked example

Draw the field, solve the equation, and check that the solutions follow the field.

\[ y' = t^3 \]

Read the field's symmetry

Why: No y appears, so every point in a column gets the same slope.

\[ f(t, y) = t^3 \quad \text{(independent of } y\text{)} \]

Read the signs

Why: Negative for t below zero, zero at t equal to 0, positive after.

\[ t < 0: y' < 0, \qquad t = 0: y' = 0, \qquad t > 0: y' > 0 \]

Solve by integrating

Why: With no y on the right, the equation is a plain antiderivative problem.

\[ y = \int t^3\,dt = \frac{t^4}{4} + C \]

Figure (svg): The direction field of y prime equals t cubed, where every column of segments is identical, with five solution curves t to the fourth over 4 plus C for C from -2 to 2; the curves are vertical copies of one another.

Slide any solution straight up or down and it still fits the field, because the slope does not care about the height. The constant C is exactly that vertical shift.

Check by differentiating

Why: Every member of the family has the slope the field prescribes.

\[ \frac{d}{dt}\left(\frac{t^4}{4} + C\right) = t^3 \;\checkmark \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 377 — Exercise 74

This exercise asks you to do something the section encourages throughout: draw the field, then solve the equation when you can, and see whether the solutions really follow the arrows.

Because the right-hand side involves only t, every column of the field is a column of parallel segments, flat at t equal to 0, falling to the left and rising to the right. You can read the shape of every solution from that: a curve that falls, flattens at t equal to 0, and rises. That is the shape of a quartic.

Integrating confirms it. The general solution is t to the fourth over 4 plus a constant, and in the figure you can see that the constant just slides the same curve up and down. The check differentiates the family and gets t cubed back, so every member fits the field exactly.

15. Following the field

Section

Part 2

16. Stepping off the point (0, 1)

Worked example

A solution of y prime equals 3x plus 2y minus 4 passes through (0, 1). Estimate its height at x equal to 0.1.

Find the slope at the starting point

Why: Substitute (0, 1) into the right-hand side.

\[ f(0, 1) = 3(0) + 2(1) - 4 = -2 \]

Write the tangent line there

Why: Point (0, 1), slope -2.

\[ L(x) = 1 - 2(x - 0) = 1 - 2x \]

Evaluate at x equal to 0.1

Why: Walk along the tangent line for a run of 0.1.

\[ L(0.1) = 1 - 0.2 = 0.8 \]

Figure (svg): A close-up of the field of y prime equals 3x plus 2y minus 4 near the point (0, 1): the true solution curve through (0, 1) bending downward, the dashed tangent line y equals 1 minus 2x, and a hollow dot at (0.1, 0.8) on the tangent line, just above the curve.

Over a short run the tangent line and the curve are nearly indistinguishable. The gap at x equal to 0.1 is about five thousandths, too small to see at this scale.

Check against the exact solution

Why: The book gives the exact solution through (0, 1); evaluate it at 0.1.

\[ y(0.1) = -0.15 + 1.25 - 0.25e^{0.2} \approx 0.79465 \quad (\text{error } 0.0054) \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 367 — the solution through (0, 1)

This is the book's first use of a field to predict a solution, and it is also the first step of Euler's method, although the book does not name it yet.

You are told only that a solution passes through (0, 1). The equation gives its slope there, minus 2, and a point and a slope give a tangent line. Walk along that line for a run of 0.1 and you land at height 0.8. That is your estimate of the solution at x equal to 0.1.

The check uses the exact solution, which the book supplies, and finds 0.7946. So one short step along a tangent line was off by about five thousandths. In the figure the tangent line and the true curve are almost on top of each other for such a short run; they separate only as you walk further. That separation is the error of the method, and you will measure it carefully in Part 5.

17. The solution curve through (0, 1)

Picture it

Figure (svg): The field of y prime equals 3x plus 2y minus 4 with four solution curves from the family y equals minus three halves x plus five quarters plus C e to the 2x: the highlighted curve through (0, 1), a straight line for C equal to 0, one curve above it that turns sharply upward, and one far below that plunges.

Each curve is tangent to every segment it meets. The one straight-line solution is a watershed: curves above it turn up and escape, curves below it turn down and plunge.

\[ y = -\tfrac32 x + \tfrac54 + Ce^{2x}, \qquad C = -\tfrac14 \text{ through } (0, 1) \]

Repeat the tangent step with ever smaller runs and the steps fuse into a smooth curve that is tangent to the field everywhere: the solution curve. Every other starting point gives another member of the same family.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 367 — Figure 4.8

Imagine repeating the last slide's step with a run of a thousandth, then a millionth, re-reading the slope after every step. The broken line you trace fuses into a smooth curve that follows the field everywhere. That limiting curve is the solution curve through (0, 1), the highlighted curve in the figure.

The formula underneath is a family with one constant C. The value minus one quarter is the member through (0, 1). The value zero gives a straight line, and it is worth checking that a straight line can be a solution: its slope is minus three halves, and substituting it into the right-hand side gives minus three halves too.

Look at what that line does to its neighbours. Curves just above it bend upward and escape; curves just below it bend down and plunge. The field tells you this at a glance, which is exactly the kind of long-term information a picture can give you without any algebra.

18. Checking the solution through (0, 1)

Worked example

Confirm that the book's formula really is the solution of the initial-value problem.

\[ y' = 3x + 2y - 4, \quad y(0) = 1, \qquad y = -\tfrac32 x + \tfrac54 - \tfrac14 e^{2x} \]

Differentiate the formula

Why: The derivative of e to the 2x is 2e to the 2x.

\[ y' = -\tfrac32 - \tfrac12 e^{2x} \]

Substitute the formula into the right-hand side

Why: Replace y by the formula.

\[ 3x + 2\left(-\tfrac32 x + \tfrac54 - \tfrac14 e^{2x}\right) - 4 \]

Expand

Why: Two times each term in the bracket.

\[ = 3x - 3x + \tfrac52 - \tfrac12 e^{2x} - 4 \]

Simplify

Why: The x terms cancel.

\[ = -\tfrac32 - \tfrac12 e^{2x} \]

Check the two sides and the starting value

Why: The right-hand side equals the derivative, and at x equal to 0 the formula gives 1.

\[ y' = 3x + 2y - 4 \;\checkmark, \qquad y(0) = \tfrac54 - \tfrac14 = 1 \;\checkmark \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 367 — the exact solution after Figure 4.8

This is the Section 4.1 skill applied to the book's formula, and it is worth doing once because it builds trust in the picture. Differentiate the proposed solution, substitute it into the right-hand side, and see whether the two sides agree.

The left side is straightforward: the derivative of the exponential term brings down a factor 2. For the right side, substitute the whole formula for y, multiply out, and watch the 3x terms cancel. What is left, minus three halves minus one half of e to the 2x, is exactly the derivative.

Finally the initial condition: at x equal to 0 the exponential is 1, and five quarters minus one quarter is 1. Both requirements are met, so this is the solution, and by uniqueness it is the only one.

19. Checkpoint 4.7: the curve through (-1, 2)

Worked example

Use the field of the equation below to sketch the solution through (-1, 2).

\[ y' = x^2 - y^2, \qquad y(-1) = 2 \]

Find the starting slope

Why: Substitute the point.

\[ f(-1, 2) = 1 - 4 = -3 \]

Locate the flat segments

Why: The zero isocline.

\[ x^2 - y^2 = 0 \iff y = \pm x \]

Read the sign above both diagonals

Why: There y is bigger than the size of x, so the slope is negative: the curve falls.

\[ y > |x| \;\Longrightarrow\; y' < 0 \]

Find where it can turn

Why: A curve falling from above can only level off on the zero isocline; to the right of 0 that is y equal to x.

\[ \text{lowest point on } y = x: \quad (0.578,\, 0.578) \]

Read the sign after the turn

Why: Below the line y equal to x and above y equal to minus x, the size of x wins: the curve rises.

\[ |x| > |y| \;\Longrightarrow\; y' > 0 \]

Figure (svg): The field of y prime equals x squared minus y squared with dashed lines y equals x and y equals minus x, and the solution curve starting at (-1, 2): it falls, crosses y equals minus x without levelling, reaches its lowest point about (0.58, 0.58) on the line y equals x, then rises between the two diagonals.

The curve can only turn around where the field is flat, and the flat set is the pair of diagonals. It bottoms out exactly as it meets the line y equal to x.

Check a point on the way down

Why: An accurate numerical solution gives 0.749 at x equal to 0; the slope there must still be negative, since the turn comes later.

\[ f(0, 0.749) = 0 - 0.561 = -0.561 < 0 \;\checkmark \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 367 — Checkpoint 4.7

This checkpoint asks for a sketch, not a formula, and the way to get a good sketch is to decide the sign of the slope everywhere before drawing anything. The isoclines slide gave you that: negative above and below both diagonals, positive in the left and right wedges, zero on the diagonals.

The starting point (-1, 2) is above both diagonals, and the slope there is minus 3, so the curve heads down. It keeps falling as long as it stays above both diagonals. It can only stop falling where the slope is zero, and the first diagonal it can meet is the line y equal to x, which it reaches at about (0.578, 0.578). After that it is in the right-hand wedge, where slopes are positive, so it rises.

The check picks a point on the way down. An accurate numerical solution puts the curve at 0.749 when x is 0, and the slope there is negative, as it must be if the turning point comes later. You will compute that 0.749 yourself with Euler's method in Part 4.

20. Solution curves never cross

Concept

Suppose two solution curves met at a point. Both would pass through it, so both would solve the same initial-value problem there.

\[ y_1(x_0) = y_2(x_0) = y_0, \qquad y_1' = y_2' = f(x_0, y_0) \]

For the equations of this chapter, with f and its partial derivative in y continuous, an initial-value problem has exactly one solution. So two curves through one point are the same curve.

Figure (svg): The field of y prime equals x minus y with five solution curves x minus 1 plus C e to the minus x for C equal to 3, 1, 0, -1 and -2. All of them approach the straight line y equals x minus 1 from above or below, and no two ever meet.

Neighbouring curves get closer and closer but never touch. If two ever met, the point where they met would have two solutions through it.

\[ y = x - 1 + Ce^{-x}: \quad \text{different } C \text{ never meet, since } Ce^{-x} \ne C'e^{-x} \]

Non-crossing is what makes sketching reliable: once you have drawn one solution, every other solution must stay on its own side of it.

This fact is used in every sketch, so it is worth knowing why it holds. If two solution curves met at a point, each would solve the initial-value problem that starts at that point. For the equations in this chapter, where the right-hand side and its partial derivative with respect to y are continuous, that initial-value problem has exactly one solution. So the two curves are the same curve.

The figure shows the family for y prime equals x minus y. Different constants give curves that crowd closer and closer to the line y equal to x minus 1 but never touch it or each other, because the exponential term never vanishes.

In practice, non-crossing is what lets you fence a sketch in. Once you have drawn one solution, every other solution stays on its own side of it forever. The most useful fences of all are the flat, constant solutions of Part 3.

21. Find the error: a sketch that cuts through y = 2

Error analysis

Annotate

On: \( y' = y(2 - y),\; y(0) = 3 \;\Longrightarrow\; \text{falls through } y = 2 \text{, settles at } y = 0 \)

  • At y = 2 the right-hand side is 2(0) = 0 for every x, so the flat line y = 2 is itself a solution.
  • Crossing y = 2 would put two solutions through one point, which uniqueness forbids. The curve can approach 2 but never reach it.
  • Even below 2 the field points UP (y(2 − y) > 0 for 0 < y < 2), so nothing could fall to 0 anyway.
  • From y(0) = 3 the slope is 3(−1) = −3: the curve falls, flattens, and approaches y = 2 from above as x grows.

Try to find the flaw before revealing the notes. The sketch describes a curve starting at height 3 that falls, passes through 2 and settles at 0.

The first note is the key fact: y equal to 2 makes the right-hand side zero for every x, so the horizontal line y equal to 2 is itself a solution. A curve that crossed it would share a point with another solution, which the previous slide ruled out.

The third note shows the sketch is wrong twice over. Even if the curve somehow got below 2, the field between 0 and 2 points upward, so it could not drift down to 0. The correct sketch falls from 3, flattens, and approaches 2 from above without ever reaching it. Whenever a sketch passes through a flat line of segments, stop and check whether that line is a solution.

22. Before sketching: find where the field is flat

Step zero

\[ y' = y^2 - 2y, \qquad y(0) = 3, \; 1, \; -1 \]

Discussion prompt

Exercises 70 to 72 ask for three sketches in this field. Before drawing any curve, what should you compute, and what does it tell you about each of the three starting values?

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 377 — Exercises 70-73

Write your answer before revealing. The instinct is to start drawing arrows from each starting point, but three seconds of algebra first saves a lot of guesswork.

Factor the right-hand side and set it to zero: y equal to 0 and y equal to 2 are constant solutions, fences that no other curve can cross. Then test the sign of the right-hand side once in each region. At 3 it is positive, at 1 it is negative, at minus 1 it is positive.

Now every sketch is decided. From 3, above both fences, the curve rises and pulls away from 2. From 1, between the fences, it falls toward 0. From minus 1, below both, it rises toward 0. Notice that 0 attracts from both sides and 2 repels on both sides; that observation is exactly what the next part of the lesson names.

23. Put the sketching steps in order

Ranking

Put in order

Order the steps for sketching the solution of an initial-value problem on a direction field.

  1. Draw the flat lines (the zero isocline) that no curve may cross
  2. Mark the starting point given by the initial condition
  3. Read or compute the slope at the current point
  4. Move a short way in that direction
  5. Repeat from the new point, staying tangent to every segment

Why: The flat lines come first because they fence in every sketch. Then start at the initial point and alternate between reading the slope and moving, always re-aiming at the new point.

Arrange the steps before checking. Most of the order is natural: you cannot read a slope before you have a point, and you cannot repeat before you have moved.

The one step people put late is drawing the flat lines. Putting it first is the professional habit. The flat lines tell you where no curve may cross and where a curve can turn around, so they constrain every sketch you draw afterwards, and they cost almost nothing to find.

The last three steps, read the slope, move a little, read again, are also a description of Euler's method. You are doing numerical analysis with a pencil.

24. Equilibria and stability

Section

Part 3

25. Constant solutions: equilibria

Concept

Try a constant function y equal to k in the equation y prime equals (x minus 3)(y squared minus 4). Its derivative is zero, so it is a solution exactly when the right-hand side is zero for every x.

\[ 0 = (x - 3)(k^2 - 4) \quad \text{for all } x \]

\[ k^2 - 4 = 0 \iff k = -2 \text{ or } k = 2 \]

Figure (svg): The field of y prime equals x minus 3 times y squared minus 4 for x from 0 to 5, with the horizontal equilibrium lines y equals 2 and y equals -2 highlighted, and the solution starting at (0, 0.5) rising to hug y equals 2.

Along y equal to 2 and y equal to -2 every segment is flat, all the way across. A horizontal line of flat segments is itself a solution.

equilibrium solution — A constant solution y equal to k of y prime equals f(x, y). To find them, solve f(x, k) equal to zero for every x in the domain.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 368 — Figure 4.9 and the definition of equilibrium solution

A constant function has derivative zero, so it solves the equation exactly when the right-hand side is zero along it, for every x. That turns a differential equation problem into an ordinary algebra problem.

Here the right-hand side is (x minus 3) times (y squared minus 4). For a constant k to work, the product must vanish for every x, not just at x equal to 3. The only way is for the second factor to be zero, which gives k equal to 2 or minus 2. The book's argument shows these are the only constant solutions.

In the figure, the two equilibrium lines are rows of flat segments running all the way across. A solution starting between them, at 0.5, rises and hugs the line at 2. Remember this curve: two slides from now you will follow it further to the right and see something the book's window does not show.

26. Trap: a flat diagonal is not an equilibrium

Trap

The trap

The field of y prime equals x minus y is flat all along the line y equal to x, so:

\[ y = x \text{ is an equilibrium?} \]

Wrong. Flat segments along a line do not make the line a solution.

The fix

Test the line itself: its own slope is 1, but the field along it says 0.

\[ y = x: \quad y' = 1 \ne 0 = x - y \]

Only a horizontal line can be an equilibrium:

\[ f(x, k) = 0 \text{ for all } x \]

Along the line y equal to x the right-hand side x minus y is zero, so every segment there is flat, and it is tempting to call the line a solution. But a curve solves the equation only if its own slope matches the field all along it. The line y equal to x has slope 1 everywhere, and the segments it crosses have slope 0.

A horizontal line is the only line whose own slope is zero, so equilibria are always horizontal lines. Test a constant k: here x minus k would have to vanish for every x, which is impossible, so this equation has no equilibrium at all.

27. Stable, unstable and semi-stable

Concept

An equilibrium is a solution you could sit on forever. The question is what happens if you start slightly off it.

asymptotically stable — Every solution starting close enough to k, above or below, approaches k as x goes to infinity.

asymptotically unstable — No solution starting close to k (other than k itself) approaches k as x goes to infinity.

semi-stable — Neither: solutions approach from one side and leave on the other.

Figure (svg): Three panels with the equilibrium y equals 0 highlighted in each. Left, y prime equals minus y: curves from above and below all flow into the line, labelled stable. Middle, y prime equals y: curves starting just off the line peel away up or down, labelled unstable. Right, y prime equals y squared: curves below the line rise into it, curves above rise away from it, labelled semi-stable.

Stable pulls in from both sides, unstable pushes away on both sides, and semi-stable does one on one side and the other on the other.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 369 — Definition of stability

Equilibria come in kinds, and the kind is decided by what happens to solutions that start close by. Think of a ball resting at the bottom of a bowl, on top of a hill, or on a ledge partway down a slope.

The three panels are drawn from real equations, each with the equilibrium y equal to 0. For y prime equals minus y, solutions are multiples of e to the minus x, and every one of them flows into 0: stable. For y prime equals y, they are multiples of e to the x, and every one except 0 itself runs away: unstable. For y prime equals y squared, the slope is never negative, so everything moves up. Solutions below 0 rise into it; solutions above rise away from it: semi-stable.

When you classify an equilibrium, you are always asking the same two questions: what happens just above it, and what happens just below it.

28. Reading the definition of stability

Notation

Annotate

On: \( \exists\, \varepsilon > 0: \quad y(x_0) = c \in (k - \varepsilon, k + \varepsilon) \;\Longrightarrow\; y(x) \to k \)

  • Some window around k, possibly very thin. Stability is a statement about starting values close to k, not about all starting values.
  • The starting value may be above OR below k. Stable requires both sides to come in.
  • As x goes to infinity. A solution that stays near k for a while and later leaves does not count.
  • Replace approaches by never approaches. Semi-stable is whatever is left: in practice, in on one side and out on the other.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 369 — Definition, parts 1-3

The book's definition is precise, and each piece of it matters. Step through the annotations and connect each to the pictures on the previous slide.

The small number epsilon says the definition only cares about starting values near k. A stable equilibrium may still lose solutions that start far away; the stable equilibrium of y prime equals y squared minus 1 at minus 1 is an example, since solutions starting above 1 run off to infinity.

The phrase as x approaches infinity matters too, and the next few slides show why. A solution may sit near an equilibrium for a long stretch and still leave it later. Stability is about where solutions end up, not where they spend their time. Semi-stable is defined as neither, and in the examples of this section it always means in from one side, out on the other.

29. Autonomous equations: one column says it all

Concept

When the right-hand side depends on y alone, the equation is called autonomous, and the field looks the same in every column.

\[ y' = f(y) \]

Then the sign of f between two equilibria is the whole story: positive means every solution there rises, negative means it falls, and it can never cross the equilibria that fence it in.

\[ f(y) > 0 \;\Rightarrow\; y \nearrow, \qquad f(y) < 0 \;\Rightarrow\; y \searrow \]

So to classify an equilibrium, test the sign of f once just below it and once just above it.

Most of the equilibria you will classify belong to autonomous equations, where the right-hand side depends on y alone. For these, the field is the same in every column, so you can study one column and know the whole picture.

Between two neighbouring equilibria the right-hand side has no zeros, and a continuous function with no zeros keeps one sign. So in each band between equilibria every solution is either rising the whole time or falling the whole time.

That gives a two-test method for classifying any equilibrium: pick a value just below it and a value just above it, and check the sign of f at each. Arrows pointing toward it from both sides mean stable, away on both sides unstable, one of each semi-stable.

30. Trapped between two fences

Intuition

Take an autonomous equation and a solution that starts strictly between two neighbouring equilibria. It cannot cross either of them, and the sign of f does not change in between, so the solution moves in one direction only.

\[ k_1 < y(x_0) < k_2 \;\Longrightarrow\; k_1 < y(x) < k_2 \text{ for all } x \]

A quantity that only increases and never passes a ceiling must level off, and the only place it can level off is where the slope is zero. So it approaches the equilibrium it is heading toward.

That is why the sign pattern is enough: every solution of an autonomous equation either runs to an equilibrium or runs off to infinity.

This slide explains why the sign test is enough. A solution that starts between two neighbouring equilibria can never cross either one, so it stays in that band forever. Inside the band the slope has one sign, so the solution only ever moves one way.

Now use a fact about increasing functions: a function that keeps increasing but never passes a ceiling must level off at some height. A solution can only level off where its slope becomes zero, and in that band the slope is zero only at the fence it is heading toward.

Put together: for an autonomous equation there are only two possible fates for a solution. It approaches an equilibrium, or there is no fence in its way and it runs off to infinity. The phase line on the next slides is simply a map of which fate each starting value gets.

31. Example 4.8: three equilibria, three verdicts

Worked example

Find and classify the equilibrium solutions.

\[ y' = (y - 3)^2(y^2 + y - 2) \]

Factor the quadratic

Why: Two numbers with product -2 and sum 1.

\[ y^2 + y - 2 = (y + 2)(y - 1) \]

Set the right-hand side to zero

Why: Each factor gives an equilibrium.

\[ (y - 3)^2(y + 2)(y - 1) = 0 \iff y = -2, \; 1, \; 3 \]

Test the sign in each interval

Why: One test point per interval.

\[ f(-3) = 144, \quad f(0) = -18, \quad f(2) = 4, \quad f(4) = 18 \]

Classify y equal to -2

Why: Below it solutions rise, above it they fall: both come in.

\[ y = -2: \; + \text{ below}, \; - \text{ above} \;\Rightarrow\; \text{stable} \]

Classify y equal to 1

Why: Below it they fall, above it they rise: both leave.

\[ y = 1: \; - \text{ below}, \; + \text{ above} \;\Rightarrow\; \text{unstable} \]

Classify y equal to 3

Why: The squared factor never changes sign: rise below, rise above.

\[ y = 3: \; + \text{ below}, \; + \text{ above} \;\Rightarrow\; \text{semi-stable} \]

Figure (svg): The field of y prime equals y minus 3 squared times y squared plus y minus 2, for x from 0 to 3 and y from -3 to 4.5, with equilibrium lines at y equals -2, 1 and 3. Solution curves starting below 1 fall or rise into -2; curves starting between 1 and 3 rise toward 3; a curve starting just above 3 rises away.

Curves pour into -2 from both sides, flee 1 in both directions, and approach 3 only from below.

Check with two numerical solutions

Why: Accurate solutions from 0.92 and 2.2 at x equal to 0, followed to x equal to 3.

\[ y(0) = 0.92 \to y(3) \approx -2.000, \qquad y(0) = 2.2 \to y(3) \approx 2.965 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, pp. 370-371 — Example 4.8 and Figure 4.12

The equation is autonomous, so the two-test method applies. First factor completely: the quadratic splits as (y plus 2)(y minus 1), and together with the squared factor that gives three equilibria, at minus 2, 1 and 3.

Next, one test value in each of the four intervals they create. The signs come out plus, minus, plus, plus. Read each equilibrium from the signs on either side. At minus 2, solutions below rise and solutions above fall: both come in, so it is stable. At 1 it is the reverse, so it is unstable. At 3 the squared factor keeps the sign positive on both sides, so solutions below rise into it and solutions above rise away from it: semi-stable.

The figure confirms all three, and the check puts numbers on it. A solution starting at 0.92, just under the unstable equilibrium at 1, has fallen all the way to minus 2 by x equal to 3. One starting at 2.2 has crept up to 2.965, approaching 3 from below, slowly, because the squared factor makes the slope tiny near 3.

32. The phase line: the whole field in one column

Picture it

Figure (svg): The graph of f of y equals y minus 3 squared times y squared plus y minus 2, plotted against y from -3.2 to 4.2, crossing zero at -2 and 1 and touching zero at 3. Beneath it, a horizontal phase line with arrows: pointing right where f is positive, left where f is negative, and dots at -2 (stable), 1 (unstable) and 3 (semi-stable).

Where f is positive the solutions move up (right on the line), where it is negative they move down. The arrows either side of each zero decide its type.

Because the field of an autonomous equation repeats in every column, one column carries all of it. Plot f against y, read off where it is positive and negative, and draw the arrows on a single line.

Because an autonomous field repeats in every column, all its information fits on one line. The top of the figure is the graph of the right-hand side against y. Where the graph is above the axis, solutions increase; where it is below, they decrease.

The arrows on the line underneath record exactly that: right for increasing, left for decreasing. Now each equilibrium is classified by looking at the two arrows beside it. Both pointing in, as at minus 2, means stable. Both pointing out, as at 1, means unstable. Both pointing the same way, as at 3, means semi-stable.

Notice the graph at 3: it touches the axis and turns back instead of crossing. That touch is the picture of a squared factor, and it is always the signature of a semi-stable equilibrium.

33. Complete the sign table for y' = y squared minus 1

Comparison

Comparison matrix

wheresign of y′ = y² − 1solutions move / verdict
y < −1+up
−1 < y < 1−down
y > 1+up
y = −10stable
y = 10unstable

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 377 — Exercise 79

Fill in each blank before checking. This is Exercise 79, and the table is the whole of the two-test method written down.

The equilibria are at minus 1 and 1, where y squared equals 1. Below minus 1, y squared is bigger than 1, so the slope is positive and solutions rise toward minus 1. Between the two, y squared is less than 1, so solutions fall, toward minus 1 again. Above 1 the slope is positive and solutions rise away.

So minus 1 has arrows pointing in from both sides and is stable; 1 has arrows pointing out on both sides and is unstable. If your field sketch disagrees with your table, trust the table and redraw the sketch.

34. Checkpoint 4.8: a factor that depends on x

Worked example

Find and classify the equilibria.

\[ y' = (x + 5)(y + 2)(y^2 - 4y + 4) \]

Factor the quadratic

Why: A perfect square.

\[ y^2 - 4y + 4 = (y - 2)^2 \]

Find the constant solutions

Why: The right-hand side must vanish for every x, so a y factor must be zero.

\[ (x + 5)(k + 2)(k - 2)^2 = 0 \; \forall x \iff k = -2 \text{ or } 2 \]

Look where stability is decided

Why: The definition concerns x going to infinity, and for x beyond -5 the factor x plus 5 is positive.

\[ x > -5: \quad \operatorname{sign} f = \operatorname{sign}\big[(y + 2)(y - 2)^2\big] \]

Test one point in each interval

Why: Use x equal to 0.

\[ f(0, -3) = -125, \quad f(0, 0) = 40, \quad f(0, 3) = 25 \]

Classify y equal to -2

Why: Below it solutions fall away, above it they rise away.

\[ y = -2: \; - \text{ below}, \; + \text{ above} \;\Rightarrow\; \text{unstable} \]

Classify y equal to 2

Why: They rise toward it from below and rise away above.

\[ y = 2: \; + \text{ below}, \; + \text{ above} \;\Rightarrow\; \text{semi-stable} \]

Figure (svg): The field of y prime equals x plus 5 times y plus 2 times y minus 2 squared, for x from -7 to 3, with equilibrium lines at y equals -2 and 2 and a dashed vertical line at x equals -5 where every segment changes direction. To the right of it, solution curves starting between -2 and 2 rise into y equals 2, and curves starting below -2 fall away.

For x greater than -5 the factor x plus 5 is positive, so the signs come from the y factors alone, and those decide the verdict as x grows.

Check with a numerical solution

Why: Start at 0.8 just after x equal to -5 and follow it: it creeps up toward 2, as semi-stable from below predicts.

\[ y(-4.6) = 0.8 \;\longrightarrow\; y(3) \approx 1.992 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 371 — Checkpoint 4.8

This equation is not autonomous: the factor x plus 5 changes sign at x equal to minus 5, so the whole field reverses direction there. You can see it in the figure, where every segment tilts one way to the left of the dashed line and the other way to the right.

Finding the equilibria still works the same way: the right-hand side must be zero for every x, so one of the y factors must be zero, which gives minus 2 and 2. For stability, remember that the definition is about x going to infinity. Once x is past minus 5, the factor x plus 5 is positive and the signs are decided by the y factors alone.

The squared factor at 2 should now make you suspect semi-stable, and the test values confirm it: positive below 2 and positive above. At minus 2 the signs are negative below and positive above, so solutions leave on both sides. The numerical check follows a solution from 0.8 and finds it at 1.992 by x equal to 3, creeping up to 2 from below exactly as predicted.

35. Follow the arrows past x = 3

Anomaly

Figure (svg): The field of y prime equals x minus 3 times y squared minus 4 for x from 0 to 8, with equilibrium lines y equals 2 and -2 and a dashed line at x equals 3. The solution from (0, 0.5) rises to hug y equals 2, stays there until about x equals 5, then falls back through 0.5 at x equals 6 and settles onto y equals -2. The solution from (0, -1.9) does the same. The solution from (0, 2.3) dips to 2 and later shoots upward.

The picture is mirror-symmetric about x equal to 3. Whatever a solution does on the way in, it undoes on the way out, and far to the right it is -2 that attracts.

Predict first

Over the window 0 to 5, the solution with y(0) = 0.5 climbs to 2 and stays within a ten-thousandth of it, and the book reads that as y = 2 being stable. What does the solution do as x keeps growing?

  • Stays at 2 forever
  • Crosses 2 and climbs
  • Falls back and settles at −2
  • Oscillates between −2 and 2

Correct: Falls back and settles at −2

Why: For x beyond 3 the factor x − 3 turns positive and every arrow between −2 and 2 points down. The solution passes back through 0.5 at x = 6 and approaches −2. Far to the right it is −2 that attracts from both sides and 2 that repels, so a window that stops too early gives the verdicts the wrong way round.

\[ \int\frac{dy}{y^2 - 4} = \int(x - 3)\,dx \;\Longrightarrow\; \tfrac14\ln\left|\frac{y - 2}{y + 2}\right| = \tfrac12(x - 3)^2 + C \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, pp. 368-370 — Figures 4.9 to 4.11

Commit to an answer before revealing. This slide revisits the equation of the book's Figures 4.9 to 4.11, whose field depends on x through the factor x minus 3.

The book's figures show the solution from 0.5 over a short window, where it rises to 2 and sits there, and the book concludes that 2 is stable. But to the right of x equal to 3 the factor x minus 3 turns positive and every arrow between minus 2 and 2 flips to point down. The solution sits within a ten-thousandth of 2 until about x equal to 5, then peels away, passes back through 0.5 at x equal to 6, and settles onto minus 2.

The formula at the bottom explains the symmetry. Separating variables, a method from Section 4.3, gives a solution that depends on x only through (x minus 3) squared, so every solution is a mirror image of itself about x equal to 3. For large x, minus 2 attracts from both sides and 2 repels, the opposite of the book's reading. The lesson: stability is about x going to infinity, so never judge it from a window that stops early, especially when the right-hand side involves x.

36. Trap: calling a semi-stable equilibrium stable

Trap

The trap

In Example 4.8, solutions just below 3 do approach it, so:

\[ y = 3 \text{ attracts} \Rightarrow \text{stable?} \]

Wrong. Stable needs both sides.

The fix

Just above 3 the right-hand side is positive too, so solutions rise away.

\[ f(3.1) = (0.1)^2(10.71) \]

\[ = 0.1071 > 0 \]

A squared factor never changes sign: same flow on both sides, so semi-stable.

This slip comes from checking only one side. Solutions just below 3 do approach it, and a figure showing only curves from below makes 3 look stable. Just above 3 the slope is small but positive, so a solution there drifts upward and never returns.

Train your eye on squared factors. A factor like (y minus 3) squared is never negative, so it cannot change the sign of the right-hand side as y passes 3. The flow goes the same way on both sides, which is exactly the semi-stable pattern.

37. An equation with no equilibrium

Counterexample

Discussion prompt

Someone claims: every first-order equation y′ = f(x, y) has at least one equilibrium solution. Give a counterexample and say what its field looks like.

Write your counterexample before revealing. The claim sounds plausible because every equation you have met so far had some flat line in its field.

An equilibrium needs the right-hand side to be zero for some constant y, for every x. For y squared plus 1 that never happens, because a square plus one is at least one. Every segment in the field slopes upward, and every solution climbs forever; in fact the solutions are tangent functions, which climb to infinity in finite time.

The equation y prime equals e to the t is another counterexample, and so is y prime equals x minus y from the earlier trap. Equilibria are special features that some equations have, not something every equation is owed.

38. Euler's method

Section

Part 4

39. Why compute instead of solve

Intuition

The equation y prime equals x squared minus y squared looks innocent, but none of the solution methods of this chapter can solve it, and its solutions cannot be written with the functions you know.

The field still shows you their shape. What it cannot give you is a number: the height of the solution through (-1, 2) at x equal to 0, to four decimal places. For that you follow the field with arithmetic instead of with a pencil.

That arithmetic is simple enough to run in a spreadsheet or a ten-line program, which is how almost every differential equation in science and engineering actually gets solved.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 365 — numerical methods

The next section teaches a real solution method, separation of variables, and later sections add more. But each method works only for equations of a particular shape, and the equation y prime equals x squared minus y squared is not of any of those shapes. Its solutions exist, and the field shows them clearly, but there is no formula in elementary functions.

A picture answers qualitative questions: does the solution rise or fall, where does it turn, what does it approach. It cannot tell you that the solution through (-1, 2) is at 0.749 when x is 0. Engineers, physicists and economists need that kind of number.

Euler's method gets it by following the field numerically. It is the simplest numerical method there is, and the ideas you learn with it, step size, local error, accumulated error and instability, carry over to the more accurate methods used in real software.

40. From a tangent line to a step

Concept

At a point on the solution, the equation gives the slope, and a slope and a point give a tangent line.

\[ L(x) = y_0 + f(x_0, y_0)(x - x_0) \]

Step right by a small amount h, called the step size, and read the new height off the tangent line:

\[ x_1 = x_0 + h \]

\[ y_1 = L(x_1) = y_0 + h\, f(x_0, y_0) \]

Figure (svg): The parabola y equals x squared minus 3x plus 3 near x equals 0, and from the point (0, 3) an arrow along the tangent line of slope -3 to the point (0.5, 1.5). The true curve at x equals 0.5 is at 1.75, a quarter above the arrow's tip. The run of the arrow is marked h equals 0.5.

Euler walks along the tangent line for a run of h, then stops and looks up the new slope. The true curve bends away from the tangent, so each step misses a little.

Now stand at the new point, ask the equation for a new slope, and step again. That is the whole method.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 372 — Figure 4.13

This is the warm-up, rewritten for a differential equation. At the starting point you know the height and, from the equation, the slope. That gives the tangent line, the first line on the slide.

Choose a step size h, move right by h, and read the height off the tangent line. Because the run is h and the slope is the right-hand side at the starting point, the rise is h times that slope. That gives the formula for the new height.

The figure shows one step on the parabola from the book's Figure 4.13. From (0, 3) the slope is minus 3, so a run of 0.5 gives a fall of 1.5 and lands at 1.5. The true curve is at 1.75 there, because it bends upward while the tangent line goes straight. Then the method starts again from the new point, with a new slope.

41. Reading Theorem 4.1 piece by piece

Notation

Annotate

On: \( x_n = x_0 + nh, \qquad y_n = y_{n-1} + h\, f(x_{n-1}, y_{n-1}) \)

  • The x-values are equally spaced: n steps of size h from the starting point.
  • Start from where the previous step ended, not from the true solution, which you do not know.
  • The run of the step. Slope times run is the rise, so h·f is how far y moves.
  • The slope at the START of the step. The whole step is taken with this one slope, even though the true slope changes along the way.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 373 — Theorem 4.1 and equation 4.2

Theorem 4.1 is the step of the previous slide, written once for every n. Step through the notes in order.

The x-values march forward in equal steps of h. The new height is the old height plus a rise, and the rise is h times a slope. The most important detail is which slope: the one at the start of the step, evaluated at the previous point. That is the only point where both coordinates are known, since the true solution is unknown and the next point has not been computed yet.

The second note is the source of accumulated error. Each step starts from the previous estimate, not from the true solution, so any error made earlier is carried into every later step. Keep that in mind when you reach the error slides in Part 5.

42. Euler on y' = 2x - 3 with h = 0.5

Worked example

Run four steps of Euler's method from (0, 3), then compare with the exact solution.

\[ y' = 2x - 3, \quad y(0) = 3, \quad h = 0.5 \]

Step 1: slope at (0, 3)

Why: The slope is minus 3.

\[ y_1 = 3 + 0.5(2 \cdot 0 - 3) = 3 - 1.5 = 1.5 \]

Step 2: slope at (0.5, 1.5)

Why: The slope is minus 2.

\[ y_2 = 1.5 + 0.5(2 \cdot 0.5 - 3) = 1.5 - 1 = 0.5 \]

Step 3: slope at (1, 0.5)

Why: The slope is minus 1.

\[ y_3 = 0.5 + 0.5(2 \cdot 1 - 3) = 0.5 - 0.5 = 0 \]

Step 4: slope at (1.5, 0)

Why: The slope is zero: this step is flat.

\[ y_4 = 0 + 0.5(2 \cdot 1.5 - 3) = 0 \]

Find the exact solution

Why: No y on the right, so integrate, then use y(0) equal to 3.

\[ y = x^2 - 3x + C, \quad C = 3 \]

Figure (svg): The parabola y equals x squared minus 3x plus 3 from x equals 0 to 2, and the Euler polygon with step 0.5 through (0, 3), (0.5, 1.5), (1, 0.5), (1.5, 0) and (2, 0), always below the parabola. Red vertical bars mark the errors 0.25, 0.5, 0.75 and 1, growing steadily.

The polygon starts on the curve and slips further below it at every step: the errors are 0.25, 0.5, 0.75 and 1, growing in exact proportion to x.

Check the Euler value at x equal to 2

Why: The exact value is 1; Euler reached 0.

\[ y(2) = 4 - 6 + 3 = 1, \qquad y_4 = 0, \qquad \text{error} = 1 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, pp. 371-372 — Figure 4.13

This is the book's first Euler example, chosen because the exact solution is known, so you can see the error directly. The right-hand side depends only on x, which makes every slope easy to compute.

Each step has the same shape: evaluate the slope at the current point, multiply by 0.5, add. The slopes are minus 3, minus 2, minus 1 and 0, and the heights go 3, 1.5, 0.5, 0, 0. Writing every product in full is slow, but it is the habit that prevents the traps on the next few slides.

The check compares with the exact solution, a parabola, at x equal to 2: the true value is 1 and Euler reached 0. The figure shows why the error keeps growing. The parabola curves upward, every tangent line runs below it, and each new step starts from a point that is already too low. The red bars grow by exactly 0.25 each step, a pattern you will explain in Part 5.

43. The book's first two steps for y' = x squared minus y squared

Worked example

Take two steps of size 0.1 from (-1, 2), writing each tangent line in full, the way the book does.

\[ y' = x^2 - y^2, \quad y(-1) = 2, \quad h = 0.1 \]

Slope at the start

Why: Substitute (-1, 2).

\[ f(-1, 2) = 1 - 4 = -3 \]

Tangent line at (-1, 2)

Why: Point-slope form, then simplify.

\[ L(x) = 2 - 3(x + 1) = -3x - 1 \]

First step

Why: x moves to -0.9.

\[ y_1 = L(-0.9) = 2.7 - 1 = 1.7 \]

New slope at (-0.9, 1.7)

Why: 0.81 minus 2.89.

\[ f(-0.9, 1.7) = 0.81 - 2.89 = -2.08 \]

New tangent line

Why: Point-slope form again.

\[ L(x) = 1.7 - 2.08(x + 0.9) = -2.08x - 0.172 \]

Second step

Why: x moves to -0.8.

\[ y_2 = L(-0.8) = 1.664 - 0.172 = 1.492 \]

Check with the formula of Theorem 4.1

Why: The one-line version gives the same number without writing any line.

\[ y_2 = y_1 + h\,f(x_1, y_1) = 1.7 + 0.1(-2.08) = 1.492 \;\checkmark \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, pp. 372-373 — the worked steps before Table 4.2

The book introduces Euler's method on this equation by writing out each tangent line in full. It is slower than the formula, but it shows clearly that every step really is a linear approximation.

From (-1, 2) the slope is minus 3 and the tangent line simplifies to minus 3x minus 1. Evaluating at minus 0.9 gives 1.7. From (-0.9, 1.7) the new slope is 0.81 minus 2.89, which is minus 2.08, and the new tangent line gives 1.492 at minus 0.8.

The check shows that you never need to write the line out. Old height plus step times slope gives 1.492 in one line. From now on use the formula, but remember what it means: stand at a point, look along the field, walk a short way.

44. Table 4.2: ten steps to x = 0

Worked example

Continue to x equal to 0 with the formula, keeping every digit and rounding only for display.

Step 3

Why: Slope at (-0.8, 1.492).

\[ y_3 = 1.492 + 0.1(0.64 - 2.226064) = 1.492 - 0.158606 = 1.333394 \]

Step 4

Why: Slope at (-0.7, 1.333394).

\[ y_4 = 1.333394 + 0.1(0.49 - 1.777938) = 1.204600 \]

Steps 5 to 10, the same way

Why: Each row uses only the row before it.

n5678910
xₙ−0.5−0.4−0.3−0.2−0.10
yₙ1.09551.00050.91640.84140.77460.7156

Figure (svg): The field of y prime equals x squared minus y squared between x equals -1 and 0, with the accurate solution curve from (-1, 2) and the Euler polygon with step 0.1, which runs just below the curve and ends at 0.7156 against the true value 0.7490.

Ten steps, each aimed by the slope at the start of the step. The polygon falls a little too fast, and by x equal to 0 it sits about 0.033 below the true curve.

Check against an accurate solution

Why: A fine-step numerical solution gives 0.7490 at x equal to 0.

\[ y(0) \approx 0.7490, \quad y_{10} = 0.7156, \quad \text{error} \approx 0.033 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 373 — Table 4.2

The remaining steps are pure bookkeeping. Keep six or more decimal places while computing and round only when you write the table, or rounding errors will creep into the last digits.

A warning if you compare with the printed Table 4.2: the book's row for n equal to 6 shows 1.0004, which is 1.0005 when correctly rounded, and the entries for n equal to 7 to 10 are misprinted with a leading 1, as 1.9164 and so on. The correct values fall steadily, as the negative slopes demand: 0.9164, 0.8414, 0.7746, 0.7156.

The check compares with an accurate numerical solution, 0.7490 at x equal to 0. Euler is low by about 0.033. The figure shows the reason: the true curve is bending upward as it approaches its turning point, so every tangent-line step undershoots it.

45. Trap: taking the slope at the new point

Trap

The trap

A tempting version of the first step of Example 4.9:

\[ y_1 = y_0 + h\,f(x_1, y_0) \]

\[ = 2 + 0.1(3(0.1)^2 - 4 + 1) = 1.703 \]

Wrong. It mixes the new x with the old y.

The fix

Euler aims each step with the slope at the point you are standing on, which is the only point you fully know. Both coordinates come from the start of the step.

\[ y_1 = y_0 + h\,f(x_0, y_0) \]

\[ = 2 + 0.1(0 - 4 + 1) = 1.7 \]

This slip is easy to make when you work row by row: you have already written the new x in the table, so you plug it in. But the height that goes with it has not been computed yet, so the pair you substitute, new x and old y, is not a point on anything.

Theorem 4.1 is explicit: both arguments of f are the previous point's. The mixed version happens to give 1.703 here, close to the correct 1.7 because the x term is small, and that closeness is what makes the error dangerous. It will not stay small in problems where the slope depends strongly on x.

46. Find the error: the step size went missing

Error analysis

Annotate

On: \( y_1 = y_0 + f(x_0, y_0) = 2 + (0 - 4 + 1) = -1 \)

  • This is a slope, the rise per unit of x. On its own it is the rise over a run of 1, not over a run of h.
  • The step's rise is slope times run: h·f(x₀, y₀) = 0.1(−3) = −0.3.
  • A drop of 3 in a run of 0.1 would be a slope of −30. The answer should be 1.7.
  • One small step should move y a little. A jump from 2 to −1 is a sign that h was forgotten.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 375 — Example 4.9, first row

Read the line and find the mistake before revealing the notes. Every piece of arithmetic in it is correct.

The error is conceptual: the slope was added to the height directly. A slope is a rate, rise per unit of run. To turn it into a rise you multiply by the run, which is the step size 0.1. Without it, the computation takes a step of length 1, ten times too long.

The last note is a habit worth keeping. With a small step the height should change only a little. A jump from 2 to minus 1 in a step of 0.1 would need a slope of minus 30, and the equation gives minus 3. Whenever a single step moves further than you expect, check that h is in the formula.

47. Example 4.9: a table from x = 0 to 1

Worked example

Use Euler's method with step 0.1 to tabulate the solution for x between 0 and 1.

\[ y' = 3x^2 - y^2 + 1, \quad y(0) = 2, \quad h = 0.1 \]

Row 1

Why: Slope at (0, 2) is 0 minus 4 plus 1.

\[ y_1 = 2 + 0.1(-3) = 1.7 \]

Row 2

Why: Slope at (0.1, 1.7) is 0.03 minus 2.89 plus 1.

\[ y_2 = 1.7 + 0.1(-1.86) = 1.514 \]

Row 3

Why: Slope at (0.2, 1.514) is 0.12 minus 2.292196 plus 1.

\[ y_3 = 1.514 + 0.1(-1.172196) = 1.396780 \]

Rows 4 to 10

Why: The same move, seven more times.

n45678910
xₙ0.40.50.60.70.80.91.0
yₙ1.32871.30011.30611.34351.41001.50321.6202

Figure (svg): The accurate solution of y prime equals 3x squared minus y squared plus 1 from (0, 2), which falls to a minimum near x equals 0.55 and climbs to 1.670 at x equals 1, with the Euler polygon of step 0.1, which falls too far, bottoms out lower and ends at 1.620.

The first step, aimed at slope -3, overshoots the curve's early drop; the polygon never recovers the lost height.

Check against an accurate solution

Why: A fine-step solution gives 1.6698 at x equal to 1.

\[ y(1) \approx 1.6698, \quad y_{10} = 1.6202, \quad \text{error} \approx 0.050 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, pp. 374-375 — Example 4.9 and Table 4.3

This is the book's full worked example, and the first three rows are shown with every slope computed so you can follow the pattern. Each row needs the right-hand side at the previous point: three times x squared, minus y squared, plus 1.

Rows 4 to 10 continue the same way. Notice the slope changes sign between rows 4 and 5, so the heights stop falling and start rising. The accurate solution turns around near x equal to 0.54, and the Euler table turns at about the same place.

The check compares with an accurate numerical value at x equal to 1, which is 1.6698. Euler's 1.6202 is low by about 0.05. The figure shows where it went wrong: the first step, aimed with slope minus 3, drops too far while the true curve is already flattening, and the table never makes up the difference.

48. Checkpoint 4.9: when the solution steepens

Worked example

Use step 0.1 to tabulate the solution for x between 1 and 2.

\[ y' = x^3 + y^2, \quad y(1) = -2, \quad h = 0.1 \]

Row 1

Why: Slope at (1, -2) is 1 plus 4.

\[ y_1 = -2 + 0.1(5) = -1.5 \]

Row 2

Why: Slope at (1.1, -1.5) is 1.331 plus 2.25.

\[ y_2 = -1.5 + 0.1(3.581) = -1.1419 \]

Row 3

Why: Slope at (1.2, -1.1419) is 1.728 plus 1.303936.

\[ y_3 = -1.1419 + 0.1(3.031936) = -0.838706 \]

Rows 4 to 10

Why: The slopes grow quickly once y turns positive.

n45678910
xₙ1.41.51.61.71.81.92.0
yₙ−0.5487−0.24420.09930.50991.02721.71592.6962

Figure (svg): The accurate solution of y prime equals x cubed plus y squared from (1, -2), climbing ever more steeply to 3.563 at x equals 2, and the Euler polygon of step 0.1 lagging further and further below it, ending at 2.696.

When the slope itself keeps growing, every step uses a slope that is already out of date, and the lag compounds.

Check against an accurate solution

Why: A fine-step solution gives 3.5628 at x equal to 2, so ten Euler steps are far off here.

\[ y(2) \approx 3.5628, \quad y_{10} = 2.6962, \quad \text{error} \approx 0.87 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 376 — Checkpoint 4.9

The procedure is identical; only the equation changes. Keep careful track of signs early on: y starts negative, but y squared is positive, so every slope in this problem is positive and the heights rise at every step.

Once y turns positive around x equal to 1.6, both terms on the right-hand side are growing and the slope takes off: 5 at the start, over 15 by the end.

The check shows why this matters. An accurate solution reaches 3.563 at x equal to 2, while Euler reaches only 2.696, an error of 0.87. When the slope increases quickly along a step, the slope at the start of the step is badly out of date by the end, and each step's shortfall feeds the next. The same step size that gave an error of 0.05 in Example 4.9 gives an error almost twenty times as large here.

49. Two Euler steps, by hand

Fill the middle

\[ y' = y + t^2, \quad y(0) = 3, \quad h = 0.2 \]

\[ y_1 = y_0 + 0.2\left(y_0 + t_0^2\right), \qquad y_2 = y_1 + 0.2\left(y_1 + t_1^2\right) \]

Fill in the blanks

After the first step the estimate is 3.6, and after the second step it is 4.328.

Why: First step: slope 3 at (0, 3), rise 0.2 times 3, which is 0.6. Second step: slope 3.6 plus 0.04, which is 3.64, at (0.2, 3.6); the rise is 0.728. The exact solution given in Exercise 97 is 4.4991 at t equal to 0.4, so two steps are low by about 0.17.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 379 — Exercise 97

Fill in both blanks before checking. This is Exercise 97, and the only way to get the second blank is to get the first one right, which is exactly how Euler's method works.

First step: at (0, 3) the slope is 3 plus 0, so the rise is 0.2 times 3, which is 0.6, and the new height is 3.6. Second step: now at (0.2, 3.6) the slope is 3.6 plus 0.04, which is 3.64, and the rise is 0.728. The new height is 4.328.

The exact solution, which the book gives, is 4.499 at t equal to 0.4, so two steps are already low by 0.17. The solution grows like an exponential, curving up away from every tangent line, which is the same reason the parabola example came out low.

50. Slide h and watch Euler's polygon

Tweak it

Parameter explorer

The graph is Euler's polygon for y′ = y, y(0) = 1, whose true solution is eˣ (7.389 at x = 2). Slide the step size h. How does the height at x = 2 change as h shrinks?

\[ y_{n+1} = (1 + {h})\,y_n, \quad y(0) = 1 \]

  • h — from 0.05 to 1: step size h

For y prime equals y, each Euler step multiplies the height by 1 plus h, so the polygon's corners are at the powers of 1 plus h. Start with h at 1: two steps take you to 4, while the true solution is at 7.389.

Now slide h down slowly. At 0.5 the polygon reaches about 5.06, at 0.25 about 5.96, and at 0.05 about 7.04. Every polygon lies below the true exponential, because the exponential curves upward away from each tangent line, and the gap shrinks steadily as the steps get shorter.

You might recognise the limit: 1 plus h, raised to the power 2 over h, approaches e squared as h goes to zero. Euler's method for this equation is the compound-interest formula, and shrinking the step is compounding more often.

51. Step size and error

Section

Part 5

52. One step's miss is of size h squared

Concept

Start a step exactly on the true solution. Taylor's theorem compares where the curve goes with where the tangent line goes:

\[ y(x_0 + h) = y_0 + h\,y'(x_0) + \tfrac12 h^2 y''(c) \]

\[ \text{Euler: } y_1 = y_0 + h\,y'(x_0) \]

\[ y(x_0 + h) - y_1 = \tfrac12 h^2 y''(c) \]

The miss depends on the curvature and on h squared. For the parabola of y prime equals 2x minus 3, the second derivative is 2, so every step from a point on the curve misses by exactly h squared.

\[ y'' = 2 \;\Rightarrow\; \text{miss} = h^2: \quad h = 0.5 \text{ gives } 0.25 \]

To understand Euler's error, first look at a single step that starts exactly on the true solution. Taylor's theorem with remainder, which you will meet properly in Chapter 6, says the true curve equals its tangent line plus a correction involving the second derivative and h squared.

Euler keeps the tangent line and throws the correction away, so the miss on one step is one half of h squared times the second derivative somewhere in the step. Two things control it: how sharply the solution bends, and the square of the step size.

For the parabola of y prime equals 2x minus 3, the second derivative is exactly 2 everywhere, so every step that starts on the curve misses by exactly h squared. With h equal to 0.5 that is 0.25, which is exactly the first red bar in the parabola figure. Halve the step and each miss becomes a quarter as big.

53. Halving h on y' = 2x - 3

Worked example

Find Euler's value exactly for any step size, and compare two step sizes at x equal to 4.

Add up the rises

Why: Every step uses the slope at its left end, x equal to kh.

\[ y_n = 3 + h\sum_{k=0}^{n-1}(2kh - 3) \]

Sum the arithmetic series

Why: The integers 0 to n minus 1 add to n(n minus 1) over 2.

\[ y_n = 3 + h^2 n(n - 1) - 3nh \]

Write it in terms of x equal to nh

Why: The middle term is nh times nh minus h.

\[ y_n = 3 + x(x - h) - 3x \]

Subtract from the exact solution

Why: Everything cancels except one term.

\[ \text{error} = (x^2 - 3x + 3) - y_n = xh \]

Evaluate at x equal to 4

Why: Step sizes 0.5 and 0.25.

\[ h = 0.5: \; y = 5, \; \text{error } 2; \qquad h = 0.25: \; y = 6, \; \text{error } 1 \]

Figure (svg): Two panels, each showing the parabola y equals x squared minus 3x plus 3 from 0 to 4 and an Euler polygon starting at (0, 3). Left, step 0.5: the polygon ends at 5 when the curve is at 7, an error bar of 2. Right, step 0.25: the polygon ends at 6, an error bar of 1.

Twice as many steps, half the error. The red bar at x equal to 4 shrinks from 2 to 1 exactly.

Check against the step-by-step tables

Why: Running the steps directly: 8 steps of 0.5 end at 5, 16 steps of 0.25 end at 6, and the exact value is 16 minus 12 plus 3.

\[ y(4) = 7: \quad 7 - 5 = 2 = 4(0.5), \quad 7 - 6 = 1 = 4(0.25) \;\checkmark \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 374 — Figure 4.14

Here you can find Euler's answer exactly for every step size, which is rare and very instructive. Because the right-hand side ignores y, the heights are just the starting value plus a sum of rises, and the rises form an arithmetic series.

Summing the series and writing everything in terms of x, which is n times h, gives Euler's height as a simple quadratic. Subtract it from the exact parabola and almost everything cancels, leaving an error of exactly x times h. So the error grows in proportion to how far you have travelled, and in proportion to the step size.

The figure is the book's Figure 4.14 with the error marked. At x equal to 4 the true value is 7; with h equal to 0.5 Euler reaches 5, and with 0.25 it reaches 6. The check compares the formula with the step-by-step values and they agree exactly: halving the step halved the error from 2 to 1.

54. Adding up the misses: error proportional to h

Concept

Reaching a fixed x takes x over h steps. Each step misses by roughly a constant times h squared, and the misses accumulate:

\[ \frac{x}{h} \text{ steps} \times Kh^2 \text{ each} = Kx\,h \]

So halving the step roughly halves the error at a given x. That makes Euler a first-order method.

hEuler at x = 1 for y′ = yerror
0.52.25000.4683
0.252.44140.2769
0.12.59370.1245
0.052.65330.0650
0.012.70480.0135

Figure (svg): Five dots showing Euler's error at x equals 1 for y prime equals y, y of 0 equals 1, against the step size h: 0.468 at h equals 0.5, 0.277 at 0.25, 0.125 at 0.1, 0.065 at 0.05 and 0.013 at 0.01. As h shrinks they fall onto a dashed straight line through the origin with slope e over 2.

As h shrinks the dots fall onto a straight line through the origin: the error becomes proportional to h, which is what calling Euler's method first order means.

Errors made early are also carried forward: each step starts from the previous step's wrong height, so errors pile up instead of cancelling.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 373 — step size and accuracy

Put the last two slides together. To reach a fixed x you take x over h steps. Each misses by something like a constant times h squared. The total is x over h times h squared, which is a constant times x times h. Double the number of steps and each miss drops by a factor of four, so the total halves.

The table tests this on a different equation, y prime equals y, where the misses also get carried forward and grow. The errors at x equal to 1 still shrink in proportion to h, and in the figure the dots for small h fall onto a straight line through the origin with slope about e over 2; for large h the carried-forward errors bend them below it.

Methods whose error is proportional to h are called first order. That is honest but slow: every extra correct decimal place costs ten times as many steps. It is the same trade-off you saw with the numerical integration rules of Section 3.6, where Simpson's rule improved on the midpoint rule by a higher power of the step.

55. Guess the error at h = 0.001

Estimation

Predict first

For y′ = y, y(0) = 1, Euler's error at x = 1 was 0.0135 with h = 0.01. Estimate the error with h = 0.001, which takes a thousand steps.

  • About 0.0014
  • About 0.00014
  • About 0.013
  • About 0.000002

Correct: About 0.0014

Why: First order: ten times smaller h gives about ten times smaller error. The actual value is 0.001358, since (1.001) to the thousandth power is 2.716924 against e = 2.718282. Ten times the work buys only one more correct decimal place, which is why better methods than Euler's exist.

\[ e - (1.001)^{1000} = 2.718282 - 2.716924 = 0.001358 \]

Commit to a guess before revealing. The previous slide is all you need: the error is roughly proportional to the step size.

Going from a step of 0.01 to a step of 0.001 divides h by ten, so the error should drop by a factor of about ten, from 0.0135 to about 0.0014. The actual computation, a thousand multiplications by 1.001, gives 0.001358.

Now look at the cost. Ten times as many steps bought one more correct decimal place. To get six correct decimals you would need about a million steps. That is why real software uses higher-order methods, such as the Runge-Kutta methods, whose error shrinks like the fourth power of h, and why the accurate values in this lesson were computed with one of them.

56. Exercise 94: five steps of y' = -3y

Worked example

Estimate the solution at t equal to 1 with 5 steps, and compare with the exact solution.

\[ y' = -3y, \quad y(0) = 1, \quad h = 0.2 \]

Write one step

Why: Factor out the current value.

\[ y_{n+1} = y_n + 0.2(-3y_n) = 0.4\,y_n \]

Unroll the recursion

Why: Five multiplications by 0.4.

\[ y_n = 0.4^n, \qquad y_5 = 0.4^5 = 0.01024 \]

Find the exact solution

Why: The derivative must be minus 3 times the function itself: an exponential.

\[ y = e^{-3t}, \qquad y(1) = e^{-3} \approx 0.049787 \]

Figure (svg): The curve y equals e to the minus 3t from t equals 0 to 1 and the Euler polygon with step 0.2, dropping to 0.4, 0.16, 0.064, 0.0256 and 0.01024, always below the curve.

Each step multiplies by 0.4, while the true decay over the same stretch multiplies by about 0.549. Euler decays too fast.

Check the exact solution and measure the error

Why: It satisfies the equation, and Euler is off by 79 percent of the true value.

\[ y' = -3e^{-3t} = -3y \;\checkmark, \qquad \frac{0.049787 - 0.01024}{0.049787} \approx 0.794 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 379 — Exercise 94

When the right-hand side is a constant times y, every Euler step multiplies the height by the same factor, here 1 minus 0.6, which is 0.4. So five steps give 0.4 to the fifth power, about one hundredth.

The exact solution is the exponential e to the minus 3t, and at t equal to 1 it is about 0.0498. The check confirms the exponential satisfies the equation, then measures the error: Euler's value is only about a fifth of the true one, a relative error of 79 percent.

The figure shows why. Over each step the true solution shrinks by a factor of e to the minus 0.6, about 0.549, but Euler shrinks it by 0.4. The tangent line of a decaying exponential is steeper than the curve's average slope over the step, so Euler decays too fast. Five steps is simply too few for a solution that changes this quickly.

57. Exercise 96: Euler against an exact solution

Worked example

Five steps over the interval from 0 to 1, compared with the exact solution the book supplies.

\[ y' = 3t - y, \quad y(0) = 1, \quad h = 0.2 \]

Steps 1 and 2

Why: Slopes minus 1 and minus 0.2.

\[ y_1 = 1 + 0.2(0 - 1) = 0.8, \quad y_2 = 0.8 + 0.2(0.6 - 0.8) = 0.76 \]

Steps 3 and 4

Why: Slopes 0.44 and 0.952.

\[ y_3 = 0.76 + 0.2(0.44) = 0.848, \quad y_4 = 0.848 + 0.2(0.952) = 1.0384 \]

Step 5

Why: Slope 2.4 minus 1.0384.

\[ y_5 = 1.0384 + 0.2(1.3616) = 1.31072 \]

t0.20.40.60.81.0
Euler0.80000.76000.84801.03841.3107
exact0.87490.88130.99521.19731.4715

Figure (svg): The exact solution y equals 3t plus 4 e to the minus t minus 3, dipping to a minimum near t equals 0.29 and rising to 1.472 at t equals 1, and the Euler polygon of step 0.2, which dips lower and ends at 1.311.

Same shape, lower curve: the polygon turns too late at the bottom and spends the rest of the interval catching up.

Check the exact solution, then the error

Why: Differentiate 3t plus 4e to the minus t minus 3 and compare with 3t minus y.

\[ y' = 3 - 4e^{-t} = 3t - y \;\checkmark, \qquad 1.4715 - 1.3107 = 0.1608 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 379 — Exercise 96

Five steps, each with the slope 3t minus y at the start of the step. Keep the t-values straight: they are 0, 0.2, 0.4, 0.6 and 0.8 for the five slopes.

The table puts the Euler values beside the exact ones. The exact solution dips to a minimum near t equal to 0.29 and then rises; Euler dips too, but lower, and turns later. From then on it runs parallel but below, ending about 0.16 short at t equal to 1.

The check does two things. It confirms the book's exact solution by differentiating it and substituting, which is always worth doing before using a formula as a benchmark. Then it measures the error at the end of the interval. Compare with the previous exercise: here the error is about 11 percent, not 79, because this solution changes more gently over each step.

58. Exercise 116: a step that is far too big

Worked example

Approximate the solution at t equal to 10 using a step of 5.

\[ y' = -2y, \quad y(0) = 2, \quad h = 5 \]

Write one step

Why: Factor out the current value.

\[ y_{n+1} = y_n + 5(-2y_n) = -9\,y_n \]

Two steps reach t equal to 10

Why: Multiply by -9 twice.

\[ y_1 = -18, \qquad y_2 = 162 \]

Compare with the exact solution

Why: Exercise 114 checks it.

\[ y = 2e^{-2t}, \qquad y(10) = 2e^{-20} \approx 4.1 \times 10^{-9} \]

Figure (svg): The true solution 2 e to the minus 2t, which drops to almost zero at once and hugs the t-axis, and the Euler polygon with step 5 from (0, 2) to (5, -18) to (10, 162), swinging below and then far above the axis.

The true solution is gone by t equal to 2. Euler, stepping 5 units at a time, multiplies by -9 at each step and explodes.

Check the factor that decides

Why: Each step multiplies by 1 minus 2h; decay needs that factor between -1 and 1.

\[ |1 - 2h| < 1 \iff 0 < h < 1, \qquad h = 5: \; 1 - 10 = -9 \]

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 380 — Exercises 114-118

This exercise shows the worst thing a step size can do. With h equal to 5, each step multiplies the height by 1 minus 10, which is minus 9. The true solution decays smoothly toward zero; Euler jumps to minus 18 and then to 162.

The figure makes the absurdity plain. The true solution is indistinguishable from zero by t equal to 2, while the Euler polygon swings wildly and grows. This is not a small inaccuracy but a qualitatively wrong answer: a decaying solution computed as an exploding one.

The check finds the rule. Each step multiplies by 1 minus 2h, and for the computed values to decay that factor must lie strictly between minus 1 and 1, which needs h between 0 and 1. The general lesson: for a rapidly decaying solution, a step that is too big does not just lose accuracy, it makes the method unstable. Exercises 117 and 118 push the same equation further.

59. Putting it together

Section

Part 6

60. Pattern: studying y' = f(x, y) without solving it

Pattern

Figure (svg): A cycle of four boxes joined by arrows: start at the point x n, y n; compute the slope m equals f of x n, y n; move up by h times m to get y n plus 1; move right by h to get x n plus 1; and the arrow returns to the first box with n increased by one.

Four moves, repeated. The only place the differential equation enters is the slope box.
  1. Draw the field: substitute points, or draw isoclines f(x, y) = m, starting with m = 0.
  2. Find the equilibria: solve f(x, k) = 0 for every x. They are horizontal lines no solution crosses.
  3. Classify each: test the sign of f just below and just above (for x large, if f involves x).
  4. Sketch: start at the initial point, stay tangent to the segments, never cross another solution.
  5. For numbers, run Euler: yₙ = yₙ₋₁ + h·f(xₙ₋₁, yₙ₋₁); halve h to roughly halve the error; keep h small enough not to overshoot.

This is the order to work in when you meet a first-order equation you cannot solve, and it runs from cheap to expensive. Drawing the field and finding the equilibria cost only algebra. Classifying the equilibria costs a few sign tests. Together they tell you the long-term fate of every solution.

The diagram is Euler's method as a loop: at a point, ask the equation for the slope, take a step of rise h times the slope and run h, and repeat from the new point. The equation enters at exactly one place, the slope box, which is why the same program works for any equation.

The last item is the numerical rule of thumb from Part 5. Halving h roughly halves the error, so you can judge an answer's accuracy by running it twice and comparing, and a step that is too large can make the method blow up.

61. A cooling cup of coffee, step by step

Real world

Figure (svg): Coffee temperature against time in minutes: the exact curve 72 plus 108 e to the minus 0.4t falling from 180 toward the room temperature 72, and the Euler polygon with one-minute steps falling faster: 136.8 after one minute, 110.88 after two and 95.33 after three, against the exact 144.4, 120.5 and 104.5.

The slope at the start of each minute is the steepest slope of that minute, so every Euler step cools the coffee too much.

Discussion prompt

Coffee at 180 °F sits in a 72 °F room and obeys T′ = −0.4(T − 72), time in minutes. Use Euler's method with one-minute steps to estimate the temperature after 3 minutes, and say whether the estimate is too high or too low.

OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods §4.2, p. 365 — Newton's law of cooling, Figure 4.6

Try the three steps yourself before revealing. The equation is Newton's law of cooling from the start of the lesson, with the coffee starting at 180 degrees.

Each step subtracts 0.4 times the current distance from 72, which means the distance to room temperature shrinks by a factor of 0.6 per step: 108, then 64.8, then 38.88, then 23.328. Adding back the 72 gives 136.8, 110.88 and 95.328.

The exact solution at 3 minutes is about 104.5 degrees, so Euler is about 9 degrees too cold. The figure shows why the error is always in that direction: the coffee cools fastest at the start of each minute, Euler uses that fastest rate for the whole minute, and so it overshoots the cooling every time. If you needed the answer to a degree, the halving rule says to shrink the step several times.

62. Check: reading a slope off the equation

Check

Check your understanding

What slope does the direction field of y′ = x² − 3y assign at the point (2, −1)?

  • A. 7 (correct)
  • B. 1
  • C. −5
  • D. 2

Answer: A

Why: Substitute x = 2 and y = −1: 4 − 3(−1) = 4 + 3 = 7. Every solution through (2, −1) passes through it with slope 7.

Why B tempts people
That is 4 − 3, which drops the sign of y: −3 times −1 is +3, not −3.
Why C tempts people
That swaps the coordinates, using x = −1 and y = 2: 1 − 6 = −5.
Why D tempts people
That reads the x-coordinate as the slope. The slope comes from substituting the point into the right-hand side.

This is the basic move of every direction field: substitute the point into the right-hand side. The only care needed is with signs.

With x equal to 2 and y equal to minus 1, x squared is 4, and minus 3 times minus 1 is plus 3, so the slope is 7. The wrong answers come from dropping the sign on y, swapping the coordinates, or reading a coordinate as the slope.

63. Check: classifying equilibria

Check

Check your understanding

Which equilibrium of y′ = y(y − 2)(y + 1) is stable?

  • A. y = −1
  • B. y = 0 (correct)
  • C. y = 2
  • D. none of them

Answer: B

Why: The signs of f are − below −1, + between −1 and 0, − between 0 and 2, and + above 2. At y = 0 solutions rise from below and fall from above, so both sides come in: stable.

Why A tempts people
Below −1 the solutions fall away and between −1 and 0 they rise away: unstable.
Why C tempts people
Between 0 and 2 the solutions fall away from 2 and above 2 they rise away: unstable.
Why D tempts people
With three simple zeros the signs must alternate, so at least one equilibrium has arrows pointing in from both sides.

Use the sign test: the equilibria are minus 1, 0 and 2, and the right-hand side alternates sign between them, starting negative on the far left.

That makes 0 the only equilibrium with arrows pointing in from both sides. At minus 1 and at 2 the arrows point away on both sides, so they are unstable. With three simple zeros the pattern must alternate, so stable and unstable equilibria take turns.

64. Check: running Euler's method

Check

Check your understanding

Euler's method with h = 0.5 for y′ = x + y, y(0) = 1: what is the estimate at x = 1?

  • A. 2.5 (correct)
  • B. 3.125
  • C. 1.5
  • D. 3.437

Answer: A

Why: Step 1: slope 0 + 1 = 1, so y₁ = 1 + 0.5(1) = 1.5. Step 2: slope 0.5 + 1.5 = 2 at (0.5, 1.5), so y₂ = 1.5 + 0.5(2) = 2.5.

Why B tempts people
That uses the slope at the END of each step's x with the old y, the trap from earlier: 1.75, then 3.125.
Why C tempts people
That is only one step. Reaching x = 1 with h = 0.5 takes two steps.
Why D tempts people
That is the exact value 2e − 2 ≈ 3.437. Euler's estimate is lower, since the true solution curves upward away from each tangent line.

Two steps are needed to get from 0 to 1 with a step of 0.5. The first uses the slope at (0, 1), which is 1; the second uses the slope at (0.5, 1.5), which is 2.

The wrong answers show three different slips: mixing the new x with the old y, stopping after one step, and reporting the exact solution instead of Euler's estimate. The exact value, 2e minus 2, is higher than Euler's, because the solution curves upward away from each tangent line.

65. Explain why Euler's errors pile up

Explain it to yourself

Discussion prompt

For y′ = 2x − 3 the error after the steps was exactly x times h. In two or three sentences, explain why the error grows with x, and why halving h halves it.

Write your explanation before revealing. The strongest answers mention both halves of the story: how big each step's miss is, and why the misses add up instead of cancelling.

Each step misses by h squared because the tangent line cannot follow the parabola's bend. Each step starts from the previous step's answer, so the misses are carried forward and accumulate. The number of steps needed to reach x is x over h, so the total miss is x over h times h squared, which is x times h.

That one line explains both observations: the error grows as x grows because more steps have been taken, and halving h halves the error because you take twice as many steps, each missing by a quarter as much.

66. Exit ticket

Exit ticket

\[ y' = y(3 - y), \qquad y(0) = 1 \]

Discussion prompt

Find and classify the equilibria, then take two Euler steps with h = 0.5. Does the answer surprise you?

This combines the two halves of the lesson. The equilibria come from factoring: y times (3 minus y) is zero at 0 and at 3. The sign test shows the right-hand side is negative below 0, positive between 0 and 3, and negative above 3, so 0 is unstable and 3 is stable.

The Euler steps are quick: slope 2 at height 1, rise 1, then slope 2 at height 2, rise 1. After two steps the estimate is exactly 3, and since the slope at 3 is zero, Euler would stay there forever.

That should surprise you. The true solution approaches 3 but never reaches it, since a solution cannot meet the equilibrium line; at x equal to 1 it is about 2.728. A large step overshot the curve's gentle approach and landed on the fence. Smaller steps would approach 3 gradually, the way the true solution does.

67. Recap

Recap

ideahowwhat it tells you
direction fieldsegment of slope f(x, y) at each pointthe shape of every solution, without solving
isoclinef(x, y) = m; m = 0 firstwhere solutions can turn; a fast way to draw the field
equilibriumf(x, k) = 0 for all xa constant solution; a fence no curve crosses
stabilitysign of f just below and above kstable, unstable or semi-stable
Euler's methodyₙ = yₙ₋₁ + h·f(xₙ₋₁, yₙ₋₁)numbers; error roughly proportional to h

\[ y_n = y_{n-1} + h\,f(x_{n-1}, y_{n-1}), \qquad \text{error} \approx Kh \]

Next, Section 4.3 solves a whole class of equations exactly, the separable ones, and you will be able to compare those formulas with the fields and Euler tables of this lesson.

Stewart, Calculus: Early Transcendentals 8e, §9.2 Direction Fields and Euler's Method §9.2, pp. 591-598 — the same material in Stewart

The direction field is the equation drawn: one segment of the prescribed slope at each point. Isoclines, especially the zero isocline, let you draw it quickly and show where solutions can turn. Solution curves follow the segments and never cross.

Equilibria are the horizontal lines along which the right-hand side vanishes for every x. For an autonomous equation, two sign tests beside each equilibrium classify it as stable, unstable or semi-stable, and the phase line records the result. When the right-hand side involves x, judge stability by what happens as x goes to infinity, not by a short window.

Euler's method follows the field numerically, one tangent-line step at a time. Its error is roughly proportional to the step size, and a step that is too large can make it blow up. In Section 4.3 you will solve separable equations exactly and be able to test both the pictures and the tables of this lesson against formulas.

Sources

  1. OpenStax Calculus Volume 2, §4.2 Direction Fields and Numerical Methods — Strang & Herman, OpenStax / Rice University, CC BY-NC-SA 4.0, pp. 365-380
  2. Stewart, Calculus: Early Transcendentals 8e, §9.2 Direction Fields and Euler's Method — James Stewart, Cengage Learning, 2016, pp. 591-598

Want this taught 1-on-1? Alexander tutors Calculus II — $55/session, free consultation.

Book on Wyzant · Text (657) 465-8108