We want to estimate y(0.5) for the solution to dxdy=y−x with y(0)=2. But we don't have a formula for y, so we can't just plug in 0.5.
What we do have is the slope. The differential equation gives the slope y−x at any point, and our solution passes through (0,2). A point and a slope are all a tangent line needs.
Tangent line at x=a
y≈f(a)+f′(a)(x−a)
So the slope-field segment at (0,2) is a piece of the tangent line to our solution, and we can follow that line out to x=0.5.
dxdy(0,2)=2−0=2
Use the tangent line at (0,2) to estimate y(0.5) for dxdy=y−x with y(0)=2
Text solution
Tangent line, then plug in 0.5We get the slope straight from the equation, 2−0=2, so the line through (0,2) is
y≈2+2(x−0)=2+2x
y(0.5)≈2+2(0.5)=3
Compare with the exact solutionThis equation happens to have the solution y=x+1+ex: its derivative 1+ex equals y−x, and y(0)=2. So 3 is a little low.
y(0.5)=1.5+e0.5≈3.15
2
Deciding whether an estimate is too big or too small
The tangent line gave y(0.5)≈3, and the actual solution gave 3.15, so our estimate was too small. But if we don't have the formula for the solution, how can we tell whether an estimate is too big or too small?
If a curve is concave up, it lies above its tangent lines, so the tangent-line estimate is too small. If it's concave down, it lies below its tangent lines, and the estimate is too big.
Concavity comes from the sign of the second derivative, dx2d2y, so we need to get it from the differential equation alone. Let's find it at (0,2), and then at a second starting point, (0,0).
Decide whether the tangent-line estimate is too big or too small for dxdy=y−x
Text solution
Differentiate both sidesy is a function of x, so its derivative is dxdy, not 0. Treating y as a constant would give −1 and the wrong answer. In the same way, y2 would give 2ydxdy.
dx2d2y=dxd(y−x)=dxdy−1
At (0,2): too smallThe slope there is 2, so the curve is concave up and lies above its tangent line. The estimate 3 is too small.
dx2d2y=2−1=1>0
At (0,0): too bigThe slope there is 0−0=0, so the tangent line is y=0 and the estimate of y(0.5) is 0. The curve is concave down, so 0 is too big.
dx2d2y=0−1=−1<0
Is the tangent-line estimate always too big or always too small for the same equation?
3
Stepping with Euler's method
What if we use the same tangent line to estimate y(1)? It gives 4, but the exact solution gives 2+e, about 4.72. So 4 is quite a bit too small.
tangent line at (0,2):y(1)y(1)≈2+2(1)=4=2+e≈4.72
tangent line at (0,2):y(1)≈2+2(1)=4y(1)=2+e≈4.72
The tangent line keeps a slope of 2 the whole way, while the slope y−x on the actual solution keeps increasing. So instead, we follow the line only to x=0.5, find a fresh slope at the new point, and follow a new line from there. Going from 0 to 1 in two equal steps, each step has size 0.5.
Estimate y(1) for dxdy=y−x with y(0)=2 using two steps of 0.5
Text solution
First step, from (0,2)The change in y is the slope times the step.
slope=2−0=2
2×0.5=1
→(0.5,3)
Fresh slope at (0.5,3)This point is a little below our curve, since y(0.5)≈3.15. So 2.5 is the slope of a nearby solution, a much better direction than 2.
slope=3−0.5=2.5
2.5×0.5=1.25
→(1,4.25)
Stepping to the leftTo estimate y(−0.5), use a step of −0.5. The true value is 0.5+e−0.5≈1.11.
y(−0.5)≈2+2(−0.5)=1
Taking a step along a tangent line and then recalculating the slope at the new point is called Euler's method. The step can be negative, to go left.
new xnew y=x+step=y+(slope at (x,y))×step
We can keep track of the steps in a table, with one row per point.
x
y
slope=y−x
change in y=slope×0.5
0
2
2
1
0.5
3
2.5
1.25
1
4.25
4
Smaller steps and concavity
With two steps of 0.5, we got y(1)≈4.25. That's closer than the 4 from a single tangent line, but both are still less than 2+e≈4.72. So let's see how much closer four smaller steps of 0.25 get us, and why every estimate stays too small.
Estimate y(1) with four steps of 0.25 for dxdy=y−x with y(0)=2, and check whether the estimate is too small
Text solution
Four steps of 0.25At each point, the slope is y−x, and y changes by the slope times 0.25.
(0,2)→(0.25,2.5)
→(0.5,3.0625)
→(0.75,3.703125)
→(1,4.44)
Concave up above y=x+1The line y=x+1 is itself a solution, since its slope and y−x are both 1. Above it, dx2d2y=y−x−1 is positive, and every point of our path lies above it. So every solution curve through our path is concave up.
Each step lands on a lower curveEach step follows the tangent line of a concave-up solution curve, so it ends below that curve. Solution curves can't cross, so the path keeps landing on lower curves and stays below y=x+1+ex. Every estimate is too small.
Halving the step size gets us closer to 4.72, but it takes twice as many steps, and here every estimate stays below it.
1 step: 4
2 steps: 4.25
4 steps: 4.44
y(1)=2+e≈4.72
To see why without the exact solution, we check the sign of the second derivative along the whole path, not just at (0,2). Every corner sits above y=x+1, where every solution curve is concave up.
dx2d2y=dxdy−1=(y−x)−1=y−x−1
y−x−1>0for y>x+1
How does taking smaller steps change Euler’s estimate?
Summary
Tangent line from a differential equation
dxdy=y−x at (0,2):2−0=2→y≈2+2x
dxdy=y−x at (0,2):2−0=2→y≈2+2x
Plug both coordinates of the given point directly into the differential equation to find the slope. The tangent line gives an estimate of the solution without needing a formula for y.
Overestimate or underestimate from concavity
dx2d2y=dxd(y−x)=dxdy−1=2−1=1>0
dxd(y2)=2ydxdy
To find dx2d2y, differentiate the differential equation with respect to x. Remember that y is a function of x, so the derivative of y is dxdy, and the derivative of y2 is 2ydxdy. If dx2d2y>0 at the point, the solution curve is concave up and lies above its tangent line, so the tangent-line estimate is too small. If dx2d2y<0, the curve is concave down and lies below its tangent line, so the estimate is too big.
Updating the slope with Euler's method
new xnew y=x+step=y+(slope at (x,y))×step
new xnew y=x+step=y+(slope at (x,y))×step
x
y
slope=y−x
change in y=slope×0.5
0
2
2
1
0.5
3
2.5
1.25
1
4.25
Instead of keeping one slope the whole way, take a short step along the tangent line. At each new point, calculate the new slope from its coordinates and multiply by the step size to get the next change in y. For n equal steps, the step size is the target x minus the starting x, divided by n. So going from x=0 to x=1 in 2 steps gives a step size of 0.5. To step to the left, use a negative step size.
Step size and concavity in Euler's method
1 step: 4
2 steps: 4.25
4 steps: 4.44
y(1)≈4.72
When we take smaller steps, we recalculate the slope more often and get a closer estimate of the true value. If dx2d2y>0 along the path, the solution curves are concave up, so each step ends below the curve through its start and Euler's method underestimates. If dx2d2y<0 along the path, it overestimates.
5
Practice
Enter decimals exactly as your steps give them, without rounding.
1
The function y=f(x) is the solution of the differential equation dxdy=x2−y with f(2)=3. (a) Write an equation of the tangent line to the graph of f at x=2, and use it to approximate f(2.1). (b) Is your approximation an overestimate or an underestimate? Explain.
To find the slope at (2,3), plug both coordinates into dxdy=x2−y.
If you got 3.4 Check the slope of the tangent line. dxdy depends on both x and y, so plug in y=3 as well as x=2.
(b)
The tangent lineThe differential equation has both x and y, so plug in x=2 and y=3 to find the slope.
dxdy(2,3)=22−3=1
Write the tangent line using the point (2,3) and slope 1, then plug in x=2.1.
y=3+1(x−2),f(2.1)≈3+1(0.1)=3.1
ConcavityDifferentiating x2−y gives 2x−dxdy. At (2,3), the second derivative is positive, so the curve is concave up and the tangent line lies below it. So 3.1 is an underestimate.
dx2d2y=2x−dxdy=2(2)−1=3>0
2
Let y be the solution of dxdy=x−y2 with y(0)=1. (a) Use the tangent line at x=0 to approximate y(0.2). (b) Is your approximation an overestimate or an underestimate? Explain.
(b)
When you differentiate y2 with respect to x, remember that y is a function of x. What does the chain rule give?
If you got overestimate Check your derivative of y2. Because y depends on x, the chain rule gives 2ydxdy, not just 2y.
The tangent line estimatePlug (0,1) into the differential equation to get the slope, write the tangent line, and plug in x=0.2.
dxdy(0,1)=0−12=−1,y≈1−x,y(0.2)≈0.8
The second derivativeBecause y is a function of x, the chain rule gives an extra factor of dxdy when we differentiate y2.
dx2d2y=1−2ydxdy
Plugging in (0,1) and dxdy=−1 gives 3. Because the second derivative is positive, the curve is concave up and the estimate is an underestimate.
at (0,1):dx2d2y=1−2(1)(−1)=3>0
3
Let y be the solution of dxdy=y−x2 with y(1)=2. Use Euler's method with two steps of equal size, starting at x=1, to approximate y(0).
We're moving backwards from x=1 to x=0 in two steps. What is the step size?
If you got 3.625 Check the sign of your step size. Stepping from x=1 backwards to x=0 makes the step size −0.5, not +0.5.
The step sizeWe're moving left from x=1 to x=0, so the step size is negative.
step=20−1=−0.5
Start at (1,2), compute the slope, and multiply by −0.5 to find the change in y.
from (1,2):slopechange in y=2−12=1=1×(−0.5)=−0.5→(0.5,1.5)
Recompute the slope at (0.5,1.5) and take the second step of −0.5 to reach x=0.
from (0.5,1.5):slopechange in y=1.5−0.52=1.25=1.25×(−0.5)=−0.625→(0,0.875)
4
Let y=g(x) be the solution of dxdy=2x−3y with g(0)=k. Euler's method with step size 1, starting at x=0, gives g(2)≈10. Find k.
At (1,−2k), plug x=1 and y=−2k into 2x−3y. What is the new slope?
If you got k=−1 Check the signs when you evaluate 2x−3y at (1,−2k). Multiplying −3 by −2k gives +6k.
At (0,k), the slope is −3k, so over a step of 1 the change in y is −3k.
from (0,k):slopeg(1)=2(0)−3k=−3k≈k+(−3k)(1)=−2k
At (1,−2k), compute the new slope and add the change in y over the second step.
from (1,−2k):slopeg(2)=2(1)−3(−2k)=2+6k≈−2k+(2+6k)(1)=2+4k
Set this estimate equal to 10 and solve for k.
2+4k=10→k=2
5
(Challenge) Let y be the solution of dxdy=y with y(0)=1. (a) Show that Euler's method with n equal steps from x=0 to x=1 gives y(1)≈(1+n1)n. (b) What does this estimate approach as n grows?
With n equal steps from 0 to 1, each step is n1. If the slope is y, what do you multiply y by to get the new y-value?
If you got 2 Recompute the slope after each step. The slope is y, so it changes at each point rather than staying 1.
One stepBecause the slope is y, each step of size n1 adds y⋅n1, and that multiplies the current value by 1+n1.
step=n1,new y=y+y⋅n1=y(1+n1)
Starting at y=1, each of the n steps multiplies by another factor of 1+n1.
1→1+n1→(1+n1)2→⋯→(1+n1)n
The limit as n increasesAs n goes to infinity, the estimate approaches e, which is the exact value of the solution y=ex at x=1.