Direction Fields and Euler's Method
A direction field records the slopes prescribed by a first-order equation. Evaluate a local slope to describe a solution's direction. Euler's method approximates solution values by repeated updates.
What a learner can do afterwards
- Interpret prescribed slopes at points and explain why one horizontal field segment need not give a constant solution
- Take several Euler steps by hand and tabulate the result
- Explain Euler's possible drift and its approximate error reduction when sufficiently small steps are halved under suitable smoothness assumptions
1 · Read
You have checked functions against differential equations. For y'=f(x,y), a direction field assigns slope f(x,y) to each point. A solution has that tangent slope. For y'=x-y at (3,1), the slope is 3-1=2, so the solution rises as x increases. Positive slopes rise, negative slopes fall, and zero slopes are horizontal. A constant y=k is a solution only if f(x,k)=0 throughout the interval; one horizontal segment is not enough.
Euler's method starts at (x0,y0); subscripts count steps. With h>0, use x next=x+h and y next=y+h f(x,y). Calculate the slope at the current point before updating either coordinate. Repeat from the new approximate point, using its approximate y in f. Each step keeps its starting slope fixed, so its segment is straight. The method can produce a table even when no exact formula is available.
Use y'=x+1, y(0)=2 and h=0.5. At (0,2), the slope is 1. The next point is (0.5, 2+0.5 times 1)=(0.5,2.5). At this new point, the slope is 1.5. The next point is (1, 2.5+0.5 times 1.5)=(1,3.25). Each x-value advances by h. Each y-update uses the slope at the point it leaves.
For a smooth equation and solution on a fixed interval, Euler's global error is bounded by a constant times h when h is sufficiently small. If a nonzero leading error term proportional to h dominates, halving h roughly halves the endpoint error. This is not an exact rule for every equation or step size. Halving h doubles the number of steps over the same interval.
Holding the starting slope can introduce error when the exact slope changes during a step. Later approximate points can affect later slopes. If the exact slope increases throughout a step, the first Euler step from the exact starting point underestimates the endpoint value. Drift is not inevitable: for constant y'=c, Euler gives exact values of y=y0+c(x-x0), apart from arithmetic rounding.
A field guides a sketch using local slopes. Euler updates x and y from the current point. Small steps can reduce error; constant-slope solutions can be exact.
Lesson, practice questions and flashcards written for this dataset.
Readings and additional questions written for this dataset. Linked videos are by Khan Academy.
More to read
What a horizontal field segment tells you
For y'=x-y, substitute each point into x-y. At (1,3), the required slope is -2. At (1,1), it is 0. At (1,0), it is 1. These give falling, horizontal and rising segments as x increases.
A direction field repeats this calculation across a grid. A solution sketch starts at its initial point and follows the nearby slopes with its tangent. Sampled segments guide the sketch; they do not give exact endpoint values.
The field is horizontal at every point on y=x. That does not make the line y=x a solution. The line has derivative 1, whereas the equation prescribes slope 0 there.
Nor does one horizontal segment establish a constant solution. A constant function y=k has derivative 0 throughout its interval. It must therefore satisfy x-k=0 throughout that interval. No fixed k can do that.
Use one complete row for each slope
Build an Euler table for y'=x-y with y(0)=2 and h=0.25. Use x next=x+0.25 and y next=y+0.25(x-y). Calculate the slope before changing either coordinate.
At (0,2), the slope is -2. The first update gives x1=0.25 and y1=2+0.25(-2)=1.5.
Use the whole new row for the next slope: 0.25-1.5=-1.25. Then x2=0.5 and y2=1.5+0.25(-1.25)=1.1875.
The rows are (0,2), (0.25,1.5) and (0.5,1.1875). The later slope uses the approximate y from its own row. Mixing a new x with a previous y changes the calculation. So does taking a future point's slope for the step leading to it.
Compare errors at the same input
For y'=2x and y(0)=1, integration gives y=x²+1. The exact value at x=1 is 2.
With h=0.5, Euler uses slopes 0 and 1. Its y-values are 1, 1 and 1.5, so its endpoint error has magnitude 0.5.
With h=0.25, the slopes are 0, 0.5, 1 and 1.5. Its y-values are 1, 1, 1.125, 1.375 and 1.75. The endpoint error has magnitude 0.25. Here halving h halves the error and doubles the step count.
Both calculations finish at x=1. Comparing after an equal number of steps would compare different inputs.
For smooth problems, sufficiently small steps often give this approximate error ratio when a nonzero leading error proportional to h dominates. It is not a promise for every equation or step size. With a constant derivative, Euler may already be exact. Large steps can behave poorly, so inspect the actual results too.
Explore more
2 · Watch
En anglaisTake it off screen
Where it sits
13 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.