Docsity

Initial Value Problems, Lecture notes of Calculus

Partial preview of the text

Download Initial Value Problems and more Lecture notes Calculus in PDF only on Docsity!

Part I

Initial Value Problems

22 CHAPTER 2. INTRODUCTION TO INITIAL VALUE PROBLEMS

conditions corresponds to the order of the differential equation; for example, for a first order ODE we specify the value of y(t) at an initial time t 0 and for a second order ODE we specify the value of both y(t) and y′(t) at t 0. For obvious reasons, these extra conditions are called initial conditions. The goal is to determine the value of y(t) for subsequent times, t 0 < t ≤ T where T denotes a final time. We begin this chapter by providing a few applications where IVPs arise. These problems provide examples where an exact solution is known so they can be used to test our numerical schemes. Instead of analyzing each IVP, we write a generic first order IVP which serves as our prototype problem for describing various approaches for approximating a solution to the IVP. We provide conditions which guarantee that the IVP has a unique solution and that the solution varies a small amount when the initial conditions are perturbed by a small amount. Once we have specified our prototype first order IVP we introduce the idea of approximating its solution using a difference equation. In general, we have to give up the notion of finding an analytic solution which gives an expression for the solution at any time and instead find a discrete solution which is an approximation to the exact solution at a set of finite times. The basic idea is that we discretize our domain, in this case a time interval, and then derive a difference equation which approximates the differential equation in some sense. The difference equation is in terms of a discrete function and only involves differences in the function values; that is, it does not contain any derivatives. Our hope is that as the difference equation is imposed at more and more points (which much be chosen in a uniform manner) then its solution approaches the exact solution to the IVP. One might ask why we only consider a prototype equation for a first order IVP when many IVPs include higher order equations. At the end of this chapter we briefly show how a higher order IVP can be converted into a system of first order IVPs. In Chapter 3 we derive the Euler methods which are the simplest numerical meth- ods for approximating the solution to a first order initial value problem. Because the methods are simple, we can easily derive them plus give graphical interpreta- tions to gain intuition about approximations. Once we analyze the errors made in replacing the continuous differential equation by a difference equation, we see that the methods only converge linearly which is quite slow. This is the motivation for looking at higher accurate methods in the following chapter. We look at several numerical examples and verify the linear convergence of the methods and we see that in certain situations one of the methods tends to oscillate and even“blow up” while the other always provides reliable results. This motivates us to study the numerical stability of methods. In Chapter 4 we provide a survey of numerical schemes for solving our prototype IVP. In particular, we present two classes of methods. The first class of methods consist of single step methods which use the solution at the previous time along with approximations at some intermediate time points to approximate the solution at the next time level. The second class of methods is called multistep methods which use the calculated approximations at several previous times to approximate the solution at the next time level. In particular, we look at Runge-Kutta methods (single step) and multistep methods in detail. Other topics included in this chapter

2.1. EXAMPLES OF IVPS 23

are predictor-corrector methods and extrapolation methods. For many real-world applications a mathematical model involves several unknown functions which are inter-related. Typically there is a differential equation for each unknown which involves some or all of the other unknowns. If each differential equation is first order and the initial value of each unknown is given, then we have a system of first order IVPs. Systems are discussed in Chapter 5. Also in this chapter we briefly consider adaptive time stepping methods. For simplicity, in all the previous work we assume that the approximations are generated at evenly spaced points in time. Of course, in practice this is very inefficient because there may be times when the solution changes rapidly so small time increments are needed and other instances when the solution varies slowly so that a larger time increment needs to be used.

2.1 Examples of IVPs

For the simplest type of IVP we have a first order ODE with one initial condition which is the value of the unknown at the initial time. An example of such an IVP is an exponential model for population growth/decay where we assume the rate of growth or decay of the population p(t) is proportional to the amount present at any time t, i.e., p′(t) = rp(t) for some constant r and we know the initial population, i.e., p(0) = p 0. Thus, the IVP for the exponential growth model with growth rate r is given by { (^) p′(t) = rp(t) t > 0 p(0) = p 0. (2.1)

If r < 0 then the differential equation models exponential decay as in the example of radioactive decay. If r > 0 then the differential equation models exponential growth as in the case of bacteria growth in a large petri dish. Why is this growth/decay called exponential? To answer this question we solve the differential equation an- alytically to get the population at any time t as p(t) = p 0 ert^ which says the population behaves exponentially. This solution can be verified by demonstrating that it satisfies the differential equation p′(t) = rp(t) and the initial condition; we have p(t) = p 0 ert^ ⇒ p′(t) = rp 0 ert^ = rp(t)

and p(0) = p 0. In § 2.2 we see how this analytic solution is obtained. This exponential model makes sense for applications such as bacteria growth in an area not confined by space because the model assumes there is an endless supply of resources and no predators. A more realistic population model is called logistic growth where a condition is imposed which gives a carrying capacity of the system; i.e., the population is not allowed to grow larger than some prescribed value. When the population is considerably below this threshold the two models produce similar results but for larger values of time logistic growth does not allow unbounded growth as the exponential model does. The logistic model we consider restricts the growth rate in the following way

r = r 0

p K

2.1. EXAMPLES OF IVPS 25

The analytic solutions are

pe(t) = 10^3 e.^294 t^ p`(t) = 10

7 (9000e−.^294 t^ + 1000)

,

where we have used (2.4) to get p`(t). To compare the results, we plot the exact solutions to the IVPs as well as giving a table of the bacteria population (truncated to the nearest whole number) from each model for a range of hours. As we see from the plots and the table, the predicted size of the bacteria colony is close for small values of t but as the time increases the exponential model predicts boundless growth whereas the logistic model predicts a population which never exceeds the carrying capacity of 10,000.

logistic growth

carrying capacity

exponential growth

2 4 6 8 10 12 14

5000

10 000

15 000

20 000

t 0 1 2 4 6 8 10 15 20 pe(t) 1000 1341 1800 3241 5835 10506 18915 82269 357809 p`(t) 1000 1297 2116 2647 3933 5386 6776 9013 9754

Instead of a first order ODE in the IVP we might have a higher order equation such as the harmonic oscillator equation. This models an object attached to a wall with a spring and the unknown function is the displacement of the object from the wall at any time. At the initial time t = 0 the system is in equilibrium so the displacement y(t) is zero. This is illustrated pictorially in the figure on the left below. The figure on the right illustrates the situation where at a later time t the object has moved to the right an amount y(t) so the spring is stretched.

initial displacement y = 0

wall object mass = m

y = 0

object moved to right by y(t)

wall object mass = m y(t)

Using basic laws of physics the second order ODE which models this spring-mass system is my′′(t) = −ky(t) − cy′(t) ,

26 CHAPTER 2. INTRODUCTION TO INITIAL VALUE PROBLEMS

where m is the mass of the object, k is the spring constant in Hooke’s law (force = - spring constant times the displacement), and c is the coefficient of friction. Because the differential equation is second order, we must specify two initial conditions at the same instance of time; here we specify the initial displacement y(0) = 0 and the initial velocity y′(t) = ν. If there is no friction then the differential equation models a simple harmonic oscillator. In this case the IVP becomes

y′′(t) = −ω^2 y(t) y(0) = 0 y′(0) = ν ,

where ω =

k/m. Clearly sin ωt and cos ωt satisfy this differential equation so the general solution is y(t) = C 1 sin ωt + C 2 cos ωt for constants C 1 , C 2. Satisfying the initial condition y(0) = 0 implies C 2 = 0 and C 1 is determined by setting y′(t) = ωC 1 cos ωt equal to ν at t = 0; i.e., C 1 = ν/ω. Since the solution to the simple harmonic oscillator equation is y(t) = (ν/ω) sin ωt, the solution should be periodic as indicated graphically in the next example. If the coefficient of friction is nonzero, then the equation is more difficult to solve analytically because we have to consider three cases depending on the sign of the term c^2 − 4 ω^2. However, the inclusion of the friction term will not cause problems when we discretize.

Example 2.2. simple harmonic oscillator

Assume we have an object of mass m = 5 attached to a wall with a spring whose Hooke’s constant is k = 0. 45. Assume that y(t) denotes the displacement of the object at any time t, that the initial displacement is zero and the initial velocity is 4. Write the IVP for this problem assuming first that the coefficient of friction is zero and give the exact solution. Verify that the solution satisfies the DE and initial conditions. Plot the solution for 0 ≤ t ≤ 5.

Note that ω =

√ k/m =

√

  1. 45 /5 =

√ 0 .09 = 0. 3. The IVP is given by

no friction:

{ y′′(t)^ =^ −^0.^09 y(t) y(0) = 0 y′(0) = 2

whose exact solution is

y(t) =^2

. 3

sin(0. 3 t) = 6.667 sin(0. 3 t).

To verify that this is the exact solution we first see that it satisfies the initial conditions:

y(0) = 0 y′(t) = 0. 3 2

. 3 cos(0. 3 t) ⇒ y′(0) = 2 cos(0) = 2.

To verify that it satisfies the DE we need y′′(t) = −2(0.3) sin(0. 3 t) which can be written as y′′(t) = −(.3)^2

[ (^2)

. 3 sin(.^3 t)

] = − 0. 9 y(t). The plot below illustrates the periodicity of the solution.

28 CHAPTER 2. INTRODUCTION TO INITIAL VALUE PROBLEMS

In the first IVP, the ODE is linear whereas in the second one the ODE is nonlinear in the unknown. Clearly, these IVPs are special cases of the following general IVP.

General first order IVP

Given scalars t 0 , y 0 , T and a function f (t, y), find y(t) satisfying

y′(t) = f (t, y) for t 0 < t ≤ T (2.8a) y(t 0 ) = y 0. (2.8b)

Here f (t, y) is the given derivative of y(t) which we refer to as the slope and y 0 is the known value at the initial time t 0. For example, for IVP I in (2.7) we have f (t, y) = sin πt, i.e., the slope is only a function of time whereas in IVP II we have f (t, y) = t − y^2 so that the slope is a function of both t and y. The ODE in IVP I is linear in the unknown and in IVP II it is nonlinear due to the y^2 term so that both linear and nonlinear differential equations are included in the general equation (2.8a). For certain choices of f (t, y) we are able to find an analytic solution to (2.8). In the simple case when f = f (t), i.e., f is a function of t and not both t and y∫ , we can solve the ODE exactly if we can obtain an antiderivative of f (t), i.e., if f (t) dt can be evaluated. For example, for the first IVP in (2.7) we have

y′(t) = sin πt ⇒

y′(t) dt =

sin πt dt ⇒ y(t) + C 1 = −

π

cos πt + C 2

and thus the general solution is y(t) = − (^) π^1 cos πt + C. The solution to the differ- ential equation is not unique because C is an arbitrary constant; actually there is a family of solutions which satisfy the differential equation. To determine a unique solution we must specify y(t) at some point such as its initial value. In IVP I in (2.7) y(0) = 0 so y(0) = − (^) π^1 cos 0 + C = 0 which says that the unique solution to the IVP is y(t) = − (^1) π cos πx + (^) π^1. If f (t, y) is more complicated than simply a function of t then other techniques are available to try to find the analytic solution. These techniques include methods such as separation of variables, using an integrating factor, etc. Remember that when we write a code to approximate the solution of the IVP (2.8) we always want to test the code on a problem where the exact solution is known so it is useful to know some standard approaches. The following example illustrates how the method of separation of variables is used to solve some first order ODEs; other techniques are explored in the exercises.

Example 2.3. separation of variables for finding the analytic solution

Consider the differential equation y′(t) = −ty(t) and find its general solution using the method of separation of variables; illustrate the family of solutions graphically. Verify

2.2. GENERAL FIRST ORDER IVP 29

that the solution satisfies the differential equation and then impose the initial condition y(0) = 2 to determine a unique solution to the IVP.

Because f (t, y) is a function of both y and t we can not directly integrate the differential equation with respect to∫ t to obtain the solution because this would require determining ty(t) dt and y is unknown. For the technique of separation of variables we move all terms involving the unknown to the left-hand side of the equation and all terms involving the independent variable to the other side of the equation. Of course, this technique does not work for all equations but it is applicable for many. For this ODE we rewrite the equation as dy y = −tdt ⇒

∫ dy y dt = −

∫ t dt

so that we integrate to get the general solution

ln y + C 1 = − t^2 2

  • C 2 ⇒ eln^ y+C^1 = e−^

t 22 +C 2 ⇒ eC^1 y(t) = e−^

t 22 eC^2 ⇒ y(t) = Ce−^

t 22 .

Note that when we integrate an equation we have an arbitrary constant for each integral. Here we have specifically indicated this but because the sum of two arbitrary constants C 1 , C 2 is another arbitrary constant C in the sequel we only give one constant. Since the general solution to this differential equation involves an arbitrary constant C there is an infinite family of solutions which satisfy the differential equation; i.e., one for each choice of C. A family of solutions is illustrated in the figure below; note that as t → ±∞ the solution approaches zero.

C = 2

C = 1

C = - 2

C = - 1

C = 1 ê 2

C = - 1 ê 2

  • 4 - 2 2 4
    • 2
    • 1

1

2

We can always verify that we haven’t made an error in determining the solution by demon- strating that it satisfies the differential equation. Here we have

y(t) = Ce−^

t 22 ⇒ y′(t) = C

( − 2 t 2

) e−^

t 22 = −t

( Ce−^

t 22 ) = −ty(t)

so the equation is satisfied.

To determine a unique solution we impose the value of y(t) at some point; here we set y(0) = 2 to get the particular solution y(t) = 2e−t (^2) / 2 because

y(0) = 2, y(t) = Ce−^ t 22 ⇒ 2 = Ce^0 ⇒ C = 2.

Even if we are unable to determine the analytic solution to (2.8), we can still gain some qualitative understanding of the behavior of the solution. This is done by

2.2. GENERAL FIRST ORDER IVP 31

The conditions that guarantee well-posedness of a solution to (2.8) are well known and are presented in Theorem 1. Basically the theorem requires that the derivative of y(t) (given by f (t, y)) be continuous and, moreover, this derivative is not allowed to change too quickly as y changes. A basic problem in calculus is to determine how much a continuous function changes as the independent variables change; clearly we would like a function to change a small amount as an indepen- dent variable changes but this is not always the case. The concept of Lipschitz continuity^1 gives a precise measure of this “degree of continuity”. To understand this concept first think of a linear function g(x) = ax + b and consider the effect changing x has on the dependent variable g(x). We have

|g(x 1 ) − g(x 2 )| = |ax 1 + b − (ax 2 + b)| = |a| |x 1 − x 2 |.

This says that as the independent variable x varies from x 1 to x 2 the change in the dependent variable g is governed by the slope of the line, i.e., a = g′(x). For a general function g(x) Lipschitz continuity on an interval I requires that the magnitude of the slope of the line joining any two points x 1 and x 2 in I must be bounded by a real number. Formally, a function g(x) defined on a domain D ⊂ R^1 is Lipschitz continuous on D if for any x 1 6 = x 2 ∈ D there is a constant L such that |g(x 1 ) − g(x 2 )| ≤ L|x 1 − x 2 | ,

or equivalently |g(x 1 ) − g(x 2 )| |x 1 − x 2 |

≤ L.

Here L is called the Lipschitz constant. This condition says that we must find one constant L which works for all points in the domain. Clearly the Lipschitz constant is not unique; for example, if L = 5, then L = 5. 1 , 6 , 10 , 100 , etc. also satisfy the condition. If g(x) is differentiable then an easy way to determine the Lipschitz constant is to find a constant such that |g′(x)| ≤ L for all x ∈ D. The linear function g(x) = ax + b is Lipschitz continuous with L = |a| = |g′(x)|. Lipschitz continuity is a stronger condition than merely saying the function is continuous so a Lipschitz continuous function is always continuous but the converse is not true. For example, the function g(x) =

x is continuous on D = [0, 1] but is not Lipschitz continuous on D because g′(x) = 1/(

x) is not bounded near the origin. There are functions which are Lipschitz continuous but not differentiable. For example, consider the continuous function g(x) = |x| on D = [− 1 , 1]. Clearly it is not differentiable on D because it is not differentiable at x = 0. However, it is Lipschitz continuous with L = 1 because the magnitude of the slope of the secant line between any two points is always less than or equal to one. Consequently, Lipschitz continuity is a stronger requirement than continuity but a weaker one than differentiability. For the existence and uniqueness result for (2.8), we need f (t, y) to be Lipschitz continuous in y so we need to extend the above definition by just holding t fixed. Formally, for fixed t we have that a function g(t, y) defined for y in a prescribed

(^1) Named after the German mathematician Rudolf Lipschitz (1832-1903).

32 CHAPTER 2. INTRODUCTION TO INITIAL VALUE PROBLEMS

domain is Lipschitz continuous in the variable y if for any (t, y 1 ), (t, y 2 ) there is a constant L such that

|g(t, y 1 ) − g(t, y 2 )| ≤ L|y 1 − y 2 |. (2.9)

We are now ready to state the theorem which guarantees existence and unique- ness of a solution to (2.8) as well as guaranteeing that the solution depends continu- ously on the data; i.e., the problem is well-posed. Note that y(t) is defined on [t 0 , T ] whereas f (t, y) must be defined on a domain in R^2. Specifically the first argument t is in [t 0 , T ] but y can be any real number so that D = {(t, y) | t ∈ [t 0 , T ], y ∈ R^1 }; a shorter notation for expressing D is D = [t 0 , T ]×R^1 which we employ.

Theorem 2.1 : Existence and uniqueness for IVP (2.8)

Let D = [t 0 , T ] × R^1 and assume that f (t, y) is continuous on D and is Lipschitz continuous in y on D; i.e., it satisfies (2.9). Then the IVP (2.8) has a unique solution in D and moreover, the problem is well-posed.

In the sequel we only consider IVPs which are well-posed, that is, which have a unique solution that depends continuously on the data.

2.3 Discretization

Even if we know that a solution to (2.8) exists for some choice of f (t, y), we may not be able to find the closed form solution to the IVP; that is, a representation of the solution in terms of a finite number of simple functions. Even for the sim- plified case of f (t, y) = f (t) this is not always possible. For example, consider f (t) = sin t^2 which has no explicit formula for its antiderivative. In fact, a symbolic algebra software package like Mathematica gives the antiderivative of sin t^2 in terms of the Fresnel Integral which is represented by an infinite power series near the ori- gin; consequently there is no closed form solution to the problem. Although there are numerous techniques for finding the analytic solution of first order differential equations, we are unable to easily obtain closed form analytic solutions for many equations. When this is the case, we must turn to a numerical approximation to the solution where we give up finding a formula for the solution at all times and instead find an approximation at a set of distinct times. Discretization is the name given to the process of converting a continuous problem into a form which can be used to obtain numerical approximations. Probably the most obvious approach to discretizing a differential equation is to approximate the derivatives in the equation by difference quotients to obtain a difference equation which involves only differences in function values. The solution to the difference equation will not be a continuous function but rather a discrete function which is defined over a finite set of points. When plotting the discrete solution one often draws a line through the points to get a continuous curve but

34 CHAPTER 2. INTRODUCTION TO INITIAL VALUE PROBLEMS

learn new methods we prove or merely state the theoretical rate of convergence. In § 1.2.3 the approach for determining the numerical rate of convergence is explained.

1 2 3 4

Ê

Ê Ê (^) Ê Ê Ê^ Ê

Ê

Ê

‡ ‡ ‡ ‡ ‡ (^) ‡ ‡ (^) ‡ (^) ‡ (^) ‡ ‡ ‡ (^) ‡ ‡ ‡ ‡ ‡ ‡^ ‡^ ‡^ ‡^

‡ ‡^ ‡ ‡

‡^ ‡

‡ ‡ ‡ ‡

‡

‡

Ï Ï Ï Ï Ï Ï ÏÏÏ ÏÏÏÏÏÏ ÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏ ÏÏÏÏ ÏÏÏ Ï^ Ï^ Ï

Ï^ Ï Ï^ Ï Ï^ Ï

Ï^ Ï

Ï^ Ï

Ï^ Ï

Ú Ú Ú Ú (^) Ú Ú (^) Ú Ú Ú Ú^ Ú^

Ú^ Ú

Ú

Ú

Ú

Ú

1 2 3 4

Figure 2.1: The exact solution to an IVP is shown as a solid curve. In the figure on the left a discrete solution using ∆t = 0. 5 is plotted. From this plot, it is not possible to say that the discrete solution is approaching the exact solution. However, in the figure on the right the discrete solutions for ∆t = 0. 5 , 0. 25 , 0. 125 , and 0. are plotted. From this figure, the discrete approximations appear to be approaching the exact solution as ∆t decreases.

When we implement a numerical method on a computer the error we make is due to both roundoff and discretization error. Rounding error is due to using a computer which has finite precision. First of all, we may not be able to represent a number exactly; this is part of roundoff error and is usually called representation error. Even if we use numbers which can be represented exactly on the computer, we encounter rounding errors when these numbers are manipulated such as when we divide two integers like 3 and 7. In some problems, roundoff error can accumulate in such a way as to make our results meaningless. Discretization error is caused by replacing the continuous problem with a discrete problem. For example, a discretization error results when we replace y′(tn+1) by the difference quotient

y(tn+1) − y(tn)

/∆t. We have control over discretization error by choosing a method which approximates quantities like the derivative more accurately. Our main control over roundoff error is the computer precision we use in the implementation.

2.4 Higher Order IVPs

The general IVP (2.8) contains a first order ODE and in the next two chapters we look at methods for approximating its solution. What do we do if we have a higher order IVP such as the harmonic oscillator equation given in Example 2.2? The answer is we write the higher order IVP as a system of first order IVPs. Then the methods we learn to approximate the solution of the IVP (2.8) can be applied directly; this is explored in Chapter 5. Suppose we have the second order IVP

y′′(t) = 2 y′(t) − sin(πy) + 4t 0 < t ≤ 2 y(0) = 1 y′(0) = 0 ,

2.4. HIGHER ORDER IVPS 35

where now the right-hand side is a function of t, y and y′. The methods we learn in Chapter 3 and Chapter 4 only apply to first order IVPs. However, we can easily convert this second order IVP into two coupled first order IVPs. To do this, we let w 1 (t) = y(t), w 2 (t) = y′(t) and substitute into the equations and initial conditions to get a first order system for w 1 , w 2

w′ 1 (t) = w 2 (t) 0 < t ≤ 2 w′ 2 (t) = 2 w 2 (t) − sin(πw 1 ) + 4t 0 < t ≤ 2 w 1 (0) = 1 w 2 (0) = 0.

Note that these two differential equations are coupled, that is, the differential equa- tion for w 1 depends on w 2 and the equation for w 2 depends on w 1. In general, if we have the pth order IVP for y(t)

yp = f (t, y, y′, y′′, · · · , y[p−1]) t 0 < t ≤ T y(t 0 ) = α 1 , y′(t 0 ) = α 2 , y′′(t 0 ) = α 3 , · · · y[p−1](t 0 ) = αp

then we convert it to a system of p first-order IVPs by letting w 1 (t) = y(t), w 2 (t) = y′(t), · · · , wp(t) = yp−1 which yields the first order coupled system

w′ 1 (t) = w 2 (t) w′ 2 (t) = w 3 (t) .. . w′ p− 1 (t) = wp(t) w′ p(t) = f (t, w 1 , w 2 ,... , wp)

along with the initial conditions wk = αk, k = 1, 2 ,... , p. Thus any higher order IVP that we encounter can be transformed into a coupled system of first order IVPs.

Example 2.5. converting a high order ivp into a system

Write the fourth order IVP

y4 + 2y′′(t) + 4y(t) = 5 y(0) = 1, y′(0) = − 3 , y′′(0) = 0, y′′′(0) = 2

as a system of first order equations.

We want four first order differential equations for wi(t), i = 1, 2 , 3 , 4 ; to this end let w 1 = y, w 2 = y′, w 3 = y′′, and w 4 = y′′′. Using the first two expressions we have w 1 ′ = w 2 , and the second and third gives w′ 2 = w 3 , the third and fourth gives w′ 3 = w 4 and the original differential equation provides the last first order equation w 4 ′ + 2w 3 + 4w 1 = 5. The system of equations is thus

w′ 1 (t) − w 2 (t) = 0 w′ 2 (t) − w 3 (t) = 0 w′ 3 (t) − w 4 (t) = 0 w 4 ′ + 2w 3 + 4w 1 = 5

along with the initial conditions

w 1 (0) = 1, w 2 (0) = − 3 , w 3 (0) = 0, and w 4 (0) = 2.

Chapter 3

The Euler Methods

There are many approaches to deriving discrete methods for the general first order IVP (2.8) but the simplest methods use the slope of a secant line to approximate the derivative in (2.8a). In this chapter we consider two methods for solving the prototype IVP (2.8) which are obtained by using this approximation to y′(t) at two different values of t. We see that the two methods require very different implementations and have different stability properties.

We begin this chapter with the forward Euler method which is described by a simple formula but also has a graphical interpretation. Numerical examples which demonstrate how the method is applied by hand are provided before a computer implementation is discussed. The discretization error for forward Euler is derived in detail by first obtaining a local truncation error which is caused by approximating y′(t) and then obtaining the global error which is due to the local truncation error and an accumulated error over the time steps. We see that the global error is one order of magnitude less than the local truncation error which is the typical relationship we see for the methods described here. A computer implementation of the forward Euler method is given and several examples demonstrate that the numerical results agree with the theoretical rate of convergence. However, for one example and certain choices of step size, the forward Euler produces results which oscillate.

The second method considered here is the backward Euler method which has strikingly different properties than the forward Euler method. The implementation for the prototype IVP (2.8) typically requires solving a nonlinear equation at each time step compared with a linear equation for the forward Euler method. However, it does not produce unreliable results for some problems and some choices of the time step as the forward Euler method does. Lastly we briefly discuss the concepts of consistency, stability and convergence of numerical methods to begin to understand why numerical methods may produce oscillating or unbounded results.

38 CHAPTER 3. THE EULER METHODS

3.1 Forward Euler Method

The forward Euler method is probably the best known and simplest method for ap- proximating the solution to the IVP (2.8). This method was named after Leonhard Euler^1 and is often just referred to as “the Euler method.” There are many ways to derive the method but in this chapter we use the slope of the secant line between (tn, y(tn) and (tn+1, y(tn+1) to approximate y′(tn). Because we use a secant line approximation, this gives us a graphical interpretation of the method. In this sec- tion we explore an implementation of the algorithm, demonstrate that the method converges linearly and provide numerical results.

3.1.1 Derivation and Graphical Interpretation

The forward Euler method can be derived from several different viewpoints, some of which we explore in this and the next chapter. The simplest approach is just to use a secant line to approximate the derivative y′(t). Recall that the definition of y′(t) is

y′(t) = lim ∆t→ 0

y(t + ∆t) − y(t) ∆t

so if ∆t is small so that the point

t + ∆t, y(t + ∆t)

is close to

t, y(t)

, then the slope of the secant line is a good approximation to the slope f (t, y) of the tangent line at

t, y(t)

. In the figure below we compare the secant line approximation to the actual slope y′(t) for two different choices of ∆t; here ∆t 2 = ∆t 1 / 3 so the slope of the secant line joining

t, y(t)

and

t + ∆t 2 , y(∆t 2 )

(represented by the cyan line) is much closer to y′(t) (tangent line represented in red) then the secant line joining

t, y(t)

and

t + ∆t 1 , y(∆t 1 )

(represented by blue line). Of course, how small we require ∆t also depends on how rapidly y′(t) is changing.

t

y

t (^) t + ∆t 2 t + ∆t 1

tangent line at

( t, y(t)

) with slope y′(t)

secant line through( t, y(t)

) ( and t + ∆t 1 , y(t + ∆t 1 )

)

secant line through

( t, y(t)

) and

( t + ∆t 2 , y(t + ∆t 2 )

)

(^1) Euler (1707-1783) was a Swiss mathematician and physicist.