7HEuler

Euler's Method - Numerical Solutions

(pronounced OY - Ler)


 * Many D.E.s can't be solved with calculus. A method to obtain approximate solutions is needed.


 * Euler's Method is a method that gives us a set of approximate points which would be close to the solution of a D.E.
 * We could then plot and join the points to produce a graph of the approximate solution.


 * More commonly we use Euler's Method to gain an approximate value for y at a given x value.

Start with a D.E. in the form:

math . \qquad \dfrac{dy}{dx}=f(x,\,y) math

...... ... and with initial conditions (x 0, y 0 )

Each new point we find will be a fixed step to the right (**h**)

... ... So. x 1 = x 0 + h

... ... and. x 2 = x 1 + h

... ... and. x 3 = x 2 + h

... ... and so on.

ie math . \qquad \dfrac{dy}{dx}=f(x_0,\,y_0) math
 * __[[image:7Hdiag01.gif align="right"]]Euler's method__** is based on the assumption that the line segment between x 0 and x 1 is approximately a straight line with a gradient specified by the D.E. at x 0.

Using math . \qquad \text{gradient } = \dfrac{rise}{run} math

We can write math . \qquad f(x_0,\,y_0) = \dfrac{y_1 - y_0}{x_1 - x_0} = \dfrac{y_1 - y_0}{h} math

This can be transposed to make y1 the subject: math . \qquad y_1=y_0+hf(x_0,\,y_0) math


 * We now have the coordinates (x 1, y 1 ) **

This process is repeated using this new point: math \\ . \qquad x_2=x_1+h \\. \\ . \qquad y_2=y_1+hf(x_1,\,y_1) math


 * This gives the coordinates (x 2, y 2 ) **

And so on until we have enough points to cover the desired domain.

Note
 * Making **h** smaller increases the accuracy but means more repetitions of the calculations are needed to cover the desired domain.
 * Doing the same calculation over and over is something computers are very good at.

Example

a) Solve using calculus the D.E.

math . \qquad \dfrac{dy}{dx}=3x^2 math

... ... given the initial conditions (0, 1) and thus find an exact value for y when x = 2.


 * Solution: **

math . \qquad y= \displaystyle{ \int 3x^2 \, dx} =x^3+c math

using (0, 1) gives c = 1, so math . \qquad y=x^3+1 math

Substitute x = 2 into this gives: ... ... (x = 2, y = 9) ... {exact solution to the D.E. at x = 2}

b) Use __Euler's Method__ (h = 0.5) to find an approximate solution for the same D.E. at x = 2

**(x 0, y 0 ) = (0, 1)**

math \\ . \qquad x_1=x_0+h \\. \\ . \qquad x_1=0+0.5=0.5 \\. \\ . \qquad y_1=y_0+h \times 3(x_0)^2 \\. \\ . \qquad y_1=1+0.5 \times 3 \times 0^2 = 1 math

**(x 1, y 1 ) = (0.5, 1)**

math \\ . \qquad x_2=x_1+h \\. \\ . \qquad x_2=0.5+0.5=1.0 \\. \\ . \qquad y_2=y_1+h \times 3(x_1)^2 \\. \\ . \qquad y_2=1+0.5 \times 3 \times 0.5^2 = 1.375 math

**(x 2, y 2 ) = (1.0, 1.375)**

math \\ . \qquad x_3=x_2+h \\. \\ . \qquad x_3=1.0+0.5=1.5 \\. \\ . \qquad y_3=y_2+h \times 3(x_2)^2 \\. \\ . \qquad y_3=1.375+0.5 \times 3 \times 1.0^2 = 2.875 math

**(x 3, y 3 ) = (1.5, 2.875)**

math \\ . \qquad x_4=x_3+h \\. \\ . \qquad x_4=1.5+0.5=2.0 \\. \\ . \qquad y_4=y_3+h \times 3(x_3)^2 \\. \\ . \qquad y_4=2.875+0.5 \times 3 \times 1.5^2 = 6.25 math

**(x 4, y 4 ) = (2.0, 6.25)** ... {approximate solution}

Note that by calculus we get (2, 9)

But Euler (h=0.5) gives (2, 6.25)

This is not very impressive for an approximation. Accuracy can be improved by reducing the step size.



This graph shows the Euler approximation for y'=3x 2 with initial conditions (0, 1) using step size h = 0.5.
 * The blue curve is the exact solution to the D.E.
 * The dotted black lines are the approximate solution produced by Euler's Method.

Straight line segments have the same gradient as the derivative of the blue curve at the start of that segment.

Accuracy of Euler's Method (not part of course)


 * Using a spreadsheet for the above example with h = 0.2 gives:


 * ........ || Step .......... || X .......... || Y .......... ||
 * || 0 || 0 || 1 ||
 * || 1 || 0.2 || 1 ||
 * || 2 || 0.4 || 1.024 ||
 * || 3 || 0.6 || 1.12 ||
 * || 4 || 0.8 || 1.336 ||
 * || 5 || 1.0 || 1.72 ||
 * || 6 || 1.2 || 2.32 ||
 * || 7 || 1.4 || 3.184 ||
 * || 8 || 1.6 || 4.36 ||
 * || 9 || 1.8 || 5.896 ||
 * || 10 || 2.0 || 7.84 ||


 * A summary of results for different values of h :

............ || ........ || **Error** ................. || **%Error** ................. ||
 * ........ || h ............ || **Y (x=2)**
 * || 2 || 1 ||  || 8 || 88.9% ||
 * || 1 || 4 ||  || 5 || 55.6% ||
 * || 0.5 || 6.25 ||  || 2.75 || 30.6% ||
 * || 0.4 || 6.76 ||  || 2.24 || 24.9% ||
 * || 0.2 || 7.84 ||  || 1.16 || 12.9% ||
 * || 0.1 || 8.41 ||  || 0.59 || 6.6% ||
 * || 0.05 || 8.7025 ||  || 0.2975 || 3.3% ||
 * || 0.04 || 8.7616 ||  || 0.2384 || 2.6% ||
 * || 0.02 || 8.8804 ||  || 0.1196 || 1.3% ||
 * || 0.01 || 8.9401 ||  || 0.0599 || 0.7% ||


 * Notice that a very small step size was needed to gain an acceptable degree of accuracy for the solution to this D.E. But a small step size involves many repetitions.
 * Since the process itself is very simple and mechanical, computers can easily be used to apply Euler's Method.


 * Many D.E.s can't be solved with calculus. Euler's Method can be used on such D.E.s to provide solutions to a high degree of accuracy with the aid of a computer.


 * For this course, you will only ever be asked to do a few steps with a relatively large value of h.

.