Euler's Method

We can use the idea behind slope fields to find approximate solutions to differential equations. In fact, when the computer generated solutions on the slope field in the last section, it was using a variation of Euler's Method to do so. Okay, so the question is: if we don't know exactly what the solution is, how can we still draw it? The key is that what we do know is the slope at any given point, and we know the starting point (we have to be given an initial condition in order to be able to do this).

Pretend that you're an investigator who's tracking a criminal. You know where he was last seen, and you have gotten inside his head to the point that you can predict at any point which way he would go if he were there. What would you do? Of course, you'd head to the criminal's last known location, and start heading the way that he would. Be careful, though; he might change direction, so if you just keep going straight forever, you'll get lost very quickly.

Okay, back up again to the criminal's last known location. Now start heading off in the direction that he would, but don't go very far. After a few steps, stop and reconsider, then head off in the direction he would go from this location. If you keep doing this process of going in the right direction, then stopping and recalibrating, you'll have a good chance of following at least close to the path of the criminal.

This illustrates the idea behind Euler's Method. We know where the solution begins and we know exactly what direction it would go at any point. We can put these two together to draw an approximate solution. The shorter our steps (meaning the more often we stop to recalibrate), the better our approximation will be, but that takes more computing power, so there's a tradeoff there. Essentially, though, we're approximating the solution with a series of short linear segments, as shown here.

Euler's Method

The Algorithm

We're given two things: y=F(x,y)y'=F(x,y) (the differential equation; we'll use FF instead of y,y', but it's nothing different) and y(x0)=y0y(x_0)=y_0 (the initial condition). We'll also have a step size h,h, which will either be given or we'll have to choose it. Our starting point, then is (x0,y0),(x_0,y_0), and all we need is a way to get from one point to the next. This is the algorithm.

Getting the next xx value is the easy part. This is just the previous xx value plus the step size: x1=x0+hx_1 = x_0 + h

The tricky part, then, is finding the next yy value from the previous one; for this, we turn to the slope. Remember that slope is rise over run: F(x0,y0)=y1y0x1x0=y1y0hhF(x0,y0)=y1y0y1=y0+hF(x0,y0)\begin{aligned} F(x_0,y_0) &= \dfrac{y_1 - y_0}{x_1 - x_0} = \dfrac{y_1 - y_0}{h}\ hF(x_0,y_0) &= y_1 - y_0\ y_1 &= y_0 + hF(x_0,y_0) \end{aligned}

In general, we find each point using the previous point: xn=xn1+hyn=yn1+hF(xn1,yn1)\ans{\begin{aligned} x_n &= x_{n-1} + h\ y_n &= y_{n-1} + hF(x_{n-1}, y_{n-1}) \end{aligned}}


Use Euler's Method with a step size of h=0.2h=0.2 to estimate y(0.6)y(0.6) if y=x+y and y(0)=1.y' = x + y \textrm{ and } y(0) = 1.


I like to build a table for these problems: nxnynF(xn,yn)001\begin{array}{c c c c} n & x_n & y_n & F(x_n, y_n)\ \hline 0 & 0 & 1 & \end{array}

What we've inserted so far simply comes from the initial condition: when n=0,n=0, xn=x0=0x_n=x_0=0 and yn=y0=1.y_n=y_0=1. Next, we can easily go down and add all the xx values that we need (up through 0.60.6) just by adding 0.20.2 each time we add a row: nxnynF(xn,yn)00110.220.430.6\begin{array}{c c c c} n & x_n & y_n & F(x_n, y_n)\ \hline 0 & 0 & 1 & \ 1 & 0.2 & & \ 2 & 0.4 & & \ 3 & 0.6 & & \end{array}

For the rest of the process, we bounce back and forth between yny_n and F(xn,yn)F(x_n,y_n): first we find the first FF value, then use that to find the next yy value, which lets us find the next FF value, and so on. For instance, to find the first FF value, we note that F(x,y)=x+yF(x0,y0)=x0+y0=0+1=1.F(x,y)=x+y \longrightarrow F(x_0,y_0)=x_0+y_0=0+1=1.

Then, to find the next yy value, we use the formula above: yn=yn1+hF(xn1,yn1)y1=y0+hF(x0,y0)=1+(0.2)(1)=1.2\begin{aligned} y_n &= y_{n-1} + hF(x_{n-1}, y_{n-1})\ y_1 &= y_0 + hF(x_0,y_0)\ &= 1 + (0.2)(1)\ &= 1.2 \end{aligned}

Repeating this process, we can fill in the rest of the table: nxnynF(xn,yn)001110.21.21.420.41.481.8830.61.856\begin{array}{c c c c} n & x_n & y_n & F(x_n, y_n)\ \hline 0 & 0 & 1 & 1 \ 1 & 0.2 & 1.2 & 1.4 \ 2 & 0.4 & 1.48 & 1.88 \ 3 & 0.6 & 1.856 & \end{array}

Finally, we can estimate that when x=0.6,x=0.6, y1.856.\ans{y \approx 1.856.}

Notice that we didn't bother filling in any more in the table than we needed to; we stopped at x=0.6,x=0.6, and we didn't bother filling in the last FF value.

  1. Use Euler's Method with a step size of h=0.1h=0.1 to estimate y(1.5)y(1.5) if y=1xyy'=1-xy and y(1)=1.y(1)=1.

  2. nxnynF(xn,yn)011011.\begin{array}{c c c c} n & x_n & y_n & F(x_n, y_n)\ \hline 0 & 1 & 1 & 0 \ 1 & 1.1 & 1 & -0.1 \ 2 & 1.2 & 0.99 & -0.188 \ 3 & 1.3 & 0.9712 & -0.2626 \ 4 & 1.4 & 0.9449 & -0.3229 \ 5 & 1.5 & 0.9127 & \end{array}

    Therefore, y(1.5)0.9127.\textrm{Therefore, } y(1.5) \approx 0.9127.