← Back to Math 055

2.6 A Numerical Method (Euler’s Method): Class Notes

2.6a

Recall the equation of the tangent line of the solution curve for the differential equation y′=f(x,y), y(x0)=y0 is y=y0+f(x0,y0)(x−x0).

Tip: This is the point-slope form y−y1=m(x−x1), with slope m=f(x0,y0).

Definition

This is known as the linearization of f at (x0,y0).

Euler method: tangent line steps of size h approximating a solution curve

A solution curve of y′=f(x,y) passes through (x0,y0). Its tangent line L(x) there has slope f(x0,y0). Moving a distance h to the right, to x1=x0+h, the tangent line reaches the point (x1,y1), while the curve is at (x1,y(x1)); the vertical gap between them is the error. From (x1,y1), a second line segment with slope f(x1,y1) leads to (x2,y2).

If we consider (x1,y1) with x-value x1=x0+h (a small distance h to the right of x0), we have

y1=y0+hf(x0,y0).

(x1,y1) is an approximation to (x1,y(x1)), which is on the solution curve. Using (x1,y1) and the slope given by y′=f(x,y) at that point, we get

y2=y1+hf(x1,y1)

and (x2,y2), where x2=x1+h=x0+2h.

This process continues, and we can generalize the results:

xn+1=xn+hyn+1=yn+hf(xn,yn),n=0,1,2,…

Example

Use Euler’s method to obtain a four-decimal approximation of the indicated value. Carry out the recursion by hand, first using h=0.1 and then using h=0.05.

y′=x+y2,y(0)=0;y(0.2)

Solution

Here f(x,y)=x+y2 and (x0,y0)=(0,0).

h=0.1: Each new y-value is the previous y-value plus h times f at the previous point.

x1=0.1,y(0.1)≈y1=0+0.1(0+02)=0x2=0.2,y(0.2)≈y2=0+0.1(0.1+02)=0.01

Answer: y(0.2)≈0.0100  (h=0.1)

h=0.05: Start again from x0=0, y0=0.

x1=0.05,y(0.05)≈y1=0+0.05(0+02)=0x2=0.1,y(0.1)≈y2=0+0.05(0.05+02)=0.0025x3=0.15,y(0.15)≈y3=0.0025+0.05(0.1+0.00252)≈0.0075x4=0.2,y(0.2)≈y4=0.0075+0.05(0.15+0.00752)≈0.0150

Answer: y(0.2)≈0.0150  (h=0.05)

2.6b

Example

Use Euler’s method to obtain a four-decimal approximation of the indicated value. First use h=0.1 and then use h=0.05. Find an explicit solution for each initial-value problem and then construct a table displaying estimated value, actual value, absolute error, and percentage relative error.

y′=2xy,y(1)=1;y(1.5)

Solution

Analytic solution. The DE is separable:

dyy=2xdx⇒ln⁡|y|=x2+c

With y(1)=1: 0=1+c, so c=−1 and y=ex2−1.

The DE is also linear: y′−2xy=0 has μ=e−x2, so

ddx(e−x2y)=0⇒e−x2y=c⇒y=cex2.

With y(1)=1: 1=ce, so c=e−1 and y=ex2e−1=ex2−1.

Answer: y=ex2−1

Euler’s method. Here f(x,y)=2xy, and yn+1=yn+h·2xnyn. The tables list each step with the actual value y(xn)=exn2−1, the absolute error |y(xn)−yn|, and the percentage relative error

|y(xn)−yn|y(xn)·100%.

Euler’s method with h = 0.1
xnynf(xn,yn)actual y(xn)abs. error% rel. error
11.00002.00001.00000.00000.00%
1.11.20002.64001.23370.03372.73%
1.21.46403.51361.55270.08875.71%
1.31.81544.71991.99370.17848.95%
1.42.28746.40462.61170.324312.42%
1.52.92788.78343.49030.562516.12%
Euler’s method with h = 0.05
xnynf(xn,yn)actual y(xn)abs. error% rel. error
11.00002.00001.00000.00000.00%
1.051.10002.31001.10790.00790.72%
1.11.21552.67411.23370.01821.47%
1.151.34923.10321.38060.03142.27%
1.21.50443.61051.55270.04833.11%
1.251.68494.21221.75510.07024.00%
1.31.89554.92831.99370.09824.93%
1.352.14195.78322.27620.13435.90%
1.42.43116.80702.61170.18066.92%
1.452.77148.03713.01170.24037.98%
1.53.17339.51983.49030.31719.08%

For h=0.1, y(1.5)≈2.9278. For h=0.05, y(1.5)≈3.1733. The actual value is y(1.5)=e1.25≈3.4903.

Answer: y(1.5)≈2.9278 (h=0.1),y(1.5)≈3.1733 (h=0.05)

When h is cut in half, the error is cut roughly in half (at x=1.5: 0.5625→0.3171). The error is O(h).