# Elementary Differential Equations and Boundary Value Problems - Boyce W.E.

**Download**(direct link)

**:**

**227**> 228 229 230 231 232 233 .. 609 >> Next

t0, ti,t2, . . . , tn7 . . . .

In Section 2.7 we pointed out that a computer program for Euler’s method has the structure given below. The specific instructions can be written in any convenient programming language.

The Euler Method

Step 1. define f ( t, y)

Step 2. input initial values t0 and y0

Step 3. input step size h and number of steps n

Step 4. output t0 and y0

Step 5. for j from 1 to n do

Step 6. k 1 = f (t, y)

y = y + h * k1 t = t + h Step 7. output t and y

Step 8. end

Some examples of Euler’s method appear in Section 2.7. As another example, consider the initial value problem

y = 1 - t + 4y, (5)

y(0) = 1. (6)

Equation (5) is a first order linear equation, and it is easily verified that the solution satisfying the initial condition (6) is

y = ô(t) = 41 - 16 + 19 e4t. (7)

Since the exact solution is known, we do not need numerical methods to solve the initial value problem (5), (6). On the other hand, the availability of the exact solution makes it easy to determine the accuracy of any numerical procedure that we use on this problem. We will use this problem throughout the chapter to illustrate and compare different numerical methods. The solutions ofEq. (5) diverge rather rapidly from each other, so we should expect that it will be fairly difficult to approximate the solution

(7) well over any considerable interval. Indeed, this is the reason for choosing this

particular problem; it will be relatively easy to observe the benefits of using more accurate methods.

8.1 The Euler or Tangent Line Method

421

EXAMPLE

1

Using the Euler formula (4) and step sizes h = 0.05, 0.025, 0.01, and 0.001, determine approximate values of the solution y = ô(³) of the problem (5), (6) on the interval

0 < t < 2.

The indicated calculations were carried out on a computer and some of the results are shown in Table 8.1.1. Their accuracy is not particularly impressive. For h = 0.01 the percentage error is 3.85% at t = 0.5, 7.49% at t = 1.0, and 14.4% at t = 2.0. The corresponding percentage errors for h = 0.001 are 0.40%, 0.79%, and 1.58%, respectively. Observe that if h = 0.001, then it requires 2,000 steps to traverse the interval from t = 0 to t = 2. Thus considerable computation is needed to obtain even reasonably good accuracy for this problem using the Euler method. When we discuss other numerical approximation methods later in this chapter, we will find that it is possible to obtain comparable or better accuracy with much larger step sizes and many fewer computational steps.

TABLE 8.1.1 A Comparison of Results for the Numerical Solution of y = 1 — t + 4y, y(0) = 1 Using the Euler Method for Different Step Sizes h

t h = 0.05 h = 0.025 h = 0.01 h = 0.001 Exact

0.0 1.0000000 1 .0000000 1.0000000 1 . 0000000 1 . 0000000

0.1 1.5475000 1.5761188 1 .5952901 1 .6076289 1 . 6090418

0.2 2.3249000 2.4080117 2.4644587 2.5011159 2.5053299

0.3 3.4333560 3.6143837 3.7390345 3.8207130 3.8301388

0.4 5.0185326 5.3690304 5.6137120 5.7754845 5.7942260

0.5 7.2901870 7.9264062 8.3766865 8.6770692 8.7120041

1.0 45.588400 53.807866 60.037126 64.382558 64.897803

1.5 282.07187 361.75945 426.40818 473.55979 479.25919

2.0 1745.6662 2432.7878 3029.3279 3484.1608 3540.2001

To begin to investigate the errors in using numerical approximations and also to suggest ways to construct more accurate algorithms it is helpful to mention some alternative ways to look at the Euler method.

First, let us write the differential equation (1) at the point t = tn in the form

d- (n) = f[tn ,ô(ãï )]. (8)

Then we approximate the derivative in Eq. (8) by the corresponding (forward) difference quotient, obtaining

ô((ï+1) — ô((ï)

tn+1 — tn

= f [n ,ô(Ï )]. (9)

Finally, if we replace ô(^ï+1) and ô(´ï) by their approximate values yn+1 and yn, respectively, and solve for yn+1, we obtain the Euler formula (3).

Another point of view is to write the problem as an integral equation, as follows. Since y = ô( ´) is a solution of the initial value problem (1), (2), by integrating from t

to tn 1 we obtain

ftn+1 ftn+1

² ô'(t) dt =1 f[t,ô(1)] dt

tn ^n

or t

rln+1

**227**> 228 229 230 231 232 233 .. 609 >> Next