Differential-Equations Β· Unit 2 Β· Video 5 Β· Interactive Practice

Ask the Direction Field Twice: Improved Euler and Why Halving hh Quarters the Error

IKey Formulas

FormulaNameRole in one step
An=f(xn,yn)A_n = f(x_n, y_n)First slopeThe field where you stand
y~n+1=yn+h An\tilde y_{n+1} = y_n + h\,A_nTemporary pointPredict: take the old Euler step
Bn=f ⁣(xn+1, y~n+1)B_n = f\!\left(x_{n+1},\, \tilde y_{n+1}\right)Second slopePoll the field at that temporary point
yn+1=yn+h An+Bn2y_{n+1} = y_n + h\,\dfrac{A_n + B_n}{2}Improved Euler stepCorrect: step with the average

Key Insight: The step in xx is untouched, xn+1=xn+hx_{n+1} = x_n + h; only the slope changes. Euler's error runs like C1hC_1 h, this one like C2h2C_2 h^2 β€” so halving the step quarters the error.

IIOne Step, Five Lines

Two readings of the field, one temporary point, and an average that lands near the curve.

Line 1 β€” the slope where you stand
An=f(xn,yn)⟹A0=f(1,1)=1A_n = f(x_n, y_n) \qquad\Longrightarrow\qquad A_0 = f(1,1) = 1
The field here is yβ€²=yy' = y, so the line element at (1,1)(1,1) has slope 11 β€” exactly the slope Euler's method uses.

πŸ’‘ One method, four names: Heun's method, improved Euler, modified Euler, and RK2 β€” Runge–Kutta with two slope readings per step.

IIIWhat the Second Reading Buys

Start anywhere in the field of yβ€²=x2βˆ’y2y' = x^2 - y^2: how far apart do the two slopes land?

IVThe Order of the Method

Errors against step size, on a logarithmic scale: the steeper line is the second-order method.

πŸ’‘ "Second order" describes the method, not the equation: the exponent belongs to hh, and the order of the differential equation itself plays no part in it.

VQuiz Questions

Problem 1 Β· One Improved Euler Step

Given: yβ€²=x+yy' = x + y with y(0)=1y(0) = 1 and h=0.2h = 0.2 β€” find y1y_1 by the improved Euler method.

βœ… Correct! The average slope is 1+1.42=1.2\tfrac{1 + 1.4}{2} = 1.2, so y1=1+(0.2)(1.2)=1.24y_1 = 1 + (0.2)(1.2) = 1.24 β€” against the exact 1.24281.2428, while plain Euler's 1.201.20 is off by more than ten times as much.
❌ That is y~1\tilde y_1, not y1y_1. 1.201.20 is the temporary Euler point β€” the scratch value you feed back into ff to get B0B_0. The step still has to be retaken with the average.
❌ You stepped with B0B_0 alone. 1+(0.2)(1.4)=1.281 + (0.2)(1.4) = 1.28 uses only the second slope. The method uses the average of A0A_0 and B0B_0.
❌ The division by 2 went missing. 1+(0.2)(1+1.4)=1.481 + (0.2)(1 + 1.4) = 1.48 adds both slopes instead of averaging them.
❌ Not quite. Run the five lines in order: A0A_0, then y~1\tilde y_1, then B0B_0, then x1x_1, then y1y_1.
Show solution

Line 1 β€” the slope where you stand:

A0=f(0,1)=0+1=1A_0 = f(0, 1) = 0 + 1 = 1

Line 2 β€” the temporary Euler point:

y~1=1+(0.2)(1)=1.2\tilde y_1 = 1 + (0.2)(1) = 1.2

Line 3 β€” poll the field there (at x1=0.2x_1 = 0.2, not at x0x_0):

B0=f(0.2,Β 1.2)=0.2+1.2=1.4B_0 = f(0.2,\ 1.2) = 0.2 + 1.2 = 1.4

Lines 4 and 5 β€” advance and correct:

x1=0+0.2=0.2,y1=1+(0.2) 1+1.42=1+(0.2)(1.2)=1.24x_1 = 0 + 0.2 = 0.2, \qquad y_1 = 1 + (0.2)\,\frac{1 + 1.4}{2} = 1 + (0.2)(1.2) = \mathbf{1.24}

The exact solution is y=2exβˆ’xβˆ’1y = 2e^x - x - 1, giving y(0.2)=1.2428y(0.2) = 1.2428. Improved Euler misses by 0.00280.0028; Euler's 1.201.20 misses by 0.04280.0428.

Problem 2 Β· Where Is the Second Slope Measured?

Given: the improved Euler step for yβ€²=f(x,y)y' = f(x,y) β€” identify the correct definition of the second slope BnB_n.

βœ… Correct! BnB_n is the field's slope at the far end of the Euler strut β€” new xx, temporary yy. That endpoint is the only place the strut actually reaches.
❌ Circular. yn+1y_{n+1} is the answer you are still computing; it is produced from BnB_n. The tilde exists precisely to keep these two names apart.
❌ The xx never moved. The strut runs from xnx_n to xn+1x_{n+1}, so its endpoint is (xn+1,y~n+1)\left(x_{n+1}, \tilde y_{n+1}\right) β€” you kept the old xx with the new yy.
❌ That is a different method. Sampling the field at the midpoint of the strut is the midpoint method (also second order), not the averaging of two endpoint slopes.
❌ Not quite. BnB_n is read where the Euler strut lands: the new xx, paired with the temporary yy.
Show solution

The strut is the plain Euler step. It starts at (xn,yn)(x_n, y_n) and ends at

(xn+1, y~n+1)=(xn+h,Β yn+h An).\left(x_{n+1},\, \tilde y_{n+1}\right) = \left(x_n + h,\ y_n + h\,A_n\right).

The second slope is simply the direction field evaluated there:

Bn=f ⁣(xn+1, y~n+1)B_n = f\!\left(x_{n+1},\, \tilde y_{n+1}\right)

The tilde matters. y~n+1\tilde y_{n+1} is a temporary value used to make one more evaluation of ff; the real new point is the one the averaged slope produces,

yn+1=yn+h An+Bn2,y_{n+1} = y_n + h\,\frac{A_n + B_n}{2},

and it is generally different from y~n+1\tilde y_{n+1}. Writing f(xn+1,yn+1)f(x_{n+1}, y_{n+1}) would define BnB_n in terms of a number that does not exist yet.

Problem 3 Β· Second Order in Practice

Given: on yβ€²=x2βˆ’y2y' = x^2 - y^2, y(0)=1y(0) = 1, improved Euler's error at x=0.2x = 0.2 is about 1.0Γ—10βˆ’31.0 \times 10^{-3} when h=0.1h = 0.1 β€” estimate its error when h=0.025h = 0.025.

βœ… Correct! Two halvings quarter the error twice: 10βˆ’3Γ·16=6.3Γ—10βˆ’510^{-3} \div 16 = 6.3 \times 10^{-5}. The measured value is 6.1Γ—10βˆ’56.1 \times 10^{-5}.
❌ Only one halving, and only a halving. Going from h=0.1h = 0.1 to h=0.025h = 0.025 is two halvings, and each one divides a second-order error by 44, not by 22.
❌ That is first-order behaviour. Dividing by 22 per halving is Euler's rule. Here eβ‰ˆC2h2e \approx C_2 h^2, so each halving divides by 44.
❌ One halving too few. 1.3Γ—10βˆ’41.3 \times 10^{-4} is roughly the error at h=0.05h = 0.05; halving once more quarters it again.
❌ Not quite. Count the halvings from 0.10.1 to 0.050.05 to 0.0250.025, then apply the factor a second-order method promises for each one.
Show solution

Improved Euler is second order, so its error behaves like

eβ‰ˆC2h2.e \approx C_2 h^2 .

Replacing hh by h/2h/2 replaces h2h^2 by h2/4h^2/4:

C2(h2)2=14 C2h2.C_2\left(\frac{h}{2}\right)^2 = \frac{1}{4}\,C_2 h^2 .

From h=0.1h = 0.1 to h=0.025h = 0.025 is two halvings, so the error is divided by 4Γ—4=164 \times 4 = 16:

eβ‰ˆ1.0Γ—10βˆ’316=6.3Γ—10βˆ’5.e \approx \frac{1.0 \times 10^{-3}}{16} = 6.3 \times 10^{-5}.

Measured values on this equation: 1.0Γ—10βˆ’31.0 \times 10^{-3} at h=0.1h = 0.1, then 2.5Γ—10βˆ’42.5 \times 10^{-4}, then 6.1Γ—10βˆ’56.1 \times 10^{-5} β€” ratios of about 44 each time.

Euler's method on the same problem goes 1.58Γ—10βˆ’21.58 \times 10^{-2}, 7.5Γ—10βˆ’37.5 \times 10^{-3}, 3.7Γ—10βˆ’33.7 \times 10^{-3}: ratios of about 22, because eβ‰ˆC1he \approx C_1 h.

Problem 4 Β· The Whole Step, Start to Finish

Given: yβ€²=yβˆ’xy' = y - x with y(0)=2y(0) = 2 and h=0.5h = 0.5, so that A0=2A_0 = 2 and y~1=3\tilde y_1 = 3 β€” find the second slope and then the improved value of y1y_1.

What is the second slope B0B_0?

What is y1y_1?

βœ… Correct! B0=3βˆ’0.5=2.5B_0 = 3 - 0.5 = 2.5, the average is 2.252.25, and y1=2+(0.5)(2.25)=3.125y_1 = 2 + (0.5)(2.25) = 3.125 β€” against the exact 3.14873.1487, where Euler's 3.0003.000 is more than five times further off.
❌ You reported y~1\tilde y_1, not ff of it. B0B_0 is the field's slope at (0.5, 3)(0.5,\, 3): f=yβˆ’x=3βˆ’0.5=2.5f = y - x = 3 - 0.5 = 2.5.
❌ That is A0A_0 again. 22 is the slope back at (0,2)(0, 2). The second reading is taken at the far end of the strut, where both coordinates have moved.
❌ Only xx advanced. f(0.5, 2)=1.5f(0.5,\, 2) = 1.5 keeps the old yy. The strut carried yy up to y~1=3\tilde y_1 = 3 as well.
❌ Not quite. Evaluate f(x,y)=yβˆ’xf(x,y) = y - x at the strut's endpoint (x1,y~1)=(0.5, 3)\left(x_1, \tilde y_1\right) = (0.5,\, 3).
❌ That is plain Euler. 2+(0.5)(2)=32 + (0.5)(2) = 3 uses A0A_0 alone and ignores the second reading entirely.
❌ You stepped with B0B_0 alone. 2+(0.5)(2.5)=3.252 + (0.5)(2.5) = 3.25 swaps one single slope for another instead of averaging the two.
❌ The average was never taken. 2+(0.5)(2+2.5)=4.252 + (0.5)(2 + 2.5) = 4.25 adds the slopes; the formula divides that sum by 22.
❌ Not quite. Average the two slopes first, then take one step of width hh with that average.
Show solution

Here f(x,y)=yβˆ’xf(x,y) = y - x, x0=0x_0 = 0, y0=2y_0 = 2, h=0.5h = 0.5.

Lines 1 and 2 (given): A0=f(0,2)=2βˆ’0=2A_0 = f(0,2) = 2 - 0 = 2, so y~1=2+(0.5)(2)=3\tilde y_1 = 2 + (0.5)(2) = 3.

Line 3 β€” the second slope, at the strut's endpoint (x1,y~1)=(0.5, 3)(x_1, \tilde y_1) = (0.5,\, 3):

B0=f(0.5,Β 3)=3βˆ’0.5=2.5B_0 = f(0.5,\ 3) = 3 - 0.5 = \mathbf{2.5}

Lines 4 and 5 β€” advance and correct:

x1=0.5,A0+B02=2+2.52=2.25x_1 = 0.5, \qquad \frac{A_0 + B_0}{2} = \frac{2 + 2.5}{2} = 2.25 y1=2+(0.5)(2.25)=3.125y_1 = 2 + (0.5)(2.25) = \mathbf{3.125}

Check against the exact solution. y=x+1+exy = x + 1 + e^{x} satisfies yβ€²=1+ex=yβˆ’xy' = 1 + e^x = y - x and y(0)=2y(0) = 2, so

y(0.5)=0.5+1+e0.5=3.1487.y(0.5) = 0.5 + 1 + e^{0.5} = 3.1487.

Euler's 3.0003.000 is low by 0.14870.1487; improved Euler's 3.1253.125 is low by 0.02370.0237 β€” about six times closer for one extra evaluation of ff. Both fall short because yβ€²β€²=ex>0y'' = e^{x} > 0 makes the solution convex.

Solved: 0 / 4