8.5 Euler's Method: 8.5.1 Example
8.5 Euler's Method: 8.5.1 Example
8.5 Euler's Method: 8.5.1 Example
for some nearby point ξ. We say that the local truncation error is O(∆tn+1 ). An error of
this sort is present in each step of the numerical solution. The accumulation of all the many
local truncation errors gives rise to the global truncation error. Similarly, the global roundoff
error is the accumulation of local roundoff errors in prior steps. The total error is the sum
of the global truncation error and the global roundoff error. If the global truncation error is
O(∆tn ), we say that the numerical procedure is of order n.
∆t2 (2)
x(t + ∆t) = x(t) + ∆t f (t, x) + x (ξ)
2!
xi+1 = xi + ∆t fi (8.7)
8.5.1 Example
Using Euler’s formula xi+1 = xi +∆t fi approximate the solution of x′ = x−t2 +1, x(0) = 0.5.
at t = 2
x0 = x(0.0) = 0.5
x1 = x(0.5) = x0 + ∆t(x0 − t20 + 1) = 0.5 + .5(.5 − 02 + 1) = 1.25
x2 = x(1.0) = x1 + ∆t(x1 − t21 + 1) = 1.25 + .5(1.25 − .52 + 1) = 2.25
x3 = x(1.5) = x2 + ∆t(x2 − t22 + 1) = 2.25 + .5(2.25 − 1.02 + 1) = 3.375
x4 = x(2.0) = x3 + ∆t(x3 − t23 + 1) = 3.375 + .5(3.375 − 1.52 + 1) = 4.4375
If the step length ∆t is changed to 0.2, and the Eulers method is repeated, the value of x(2)
becomes 4.8657845 with the error 0.4396874 as the exact value is 5.3054720.
Lemma 1
For all x ≥ 1 and any positive m, we have 0 ≤ (1 + x)m ≤ emx .
Proof
Applying the Taylors Theorem with f (x) = ex , x0 = 0, and n = 1 gives
x2 ξ
ex = 1 + x + e
2
2
where ξ is between x and zero. Thus 0 ≤ 1 + x ≤ 1 + x + x2 eξ = ex , and, because 1 + x ≥ 0, we
have
0 ≤ (1 + x)m ≤ (ex )m = emx
Lemma 2
If s and t are positive real numbers, {ai }ki=0 is a sequence satisfying a0 ≥ − st , and
ai+1 ≤ (1 + s)ai + t
Proof
For a fixed integer i, the given inequality implies that
ai+1 ≤ (1 + s)ai + t
≤ (1 + s) ((1 + s)ai−1 + t) + t = (1 + s)2 ai−1 + (1 + (1 + s)) t
≤ (1 + s)3 ai−2 + (1 + (1 + s) + (1 + s)2 ) t
..
.
≤ (1 + s)i+1 a0 + (1 + (1 + s) + (1 + s)2 + ⋯ + (1 + s)i ) t
i
1 − (1 + s)i+1
= (1 + s)i+1 a0 + ∑(1 + s)j t = (1 + s)i+1 a0 + t
j=0 1 − (1 + s)
Therefore,
(1 + s)i+1 − 1 t t
ai+1 ≤ (1 + s)i+1 a0 + t = (1 + s)i+1 (a0 + ) −
s s s
Now using the Lemma 8.5.2 with x = 1 + s gives
t t
ai+1 ≤ e(i+1)s (a0 + ) −
s s
Lecture Notes MA5470 Numerical Analysis 75
Proof
When i = 0 the result is clearly true, since x(t0 ) = x0 = α. From the Taylor theorem, we have
∆t2 (2)
x(ti+1 ) = x(ti ) + ∆tf (ti , x(ti )) + x (ξ)
2
for i = 0, 1, ⋯, n − 1, and from the Euler’s formula,
xi+1 = xi + ∆tf (ti , xi )
Therefore,
∆t2 (2)
x(ti+1 ) − xi+1 = x(ti ) − xi + ∆t[f (ti , x(ti )) − f (ti , xi )] + x (ξ)
2
Hence
∆t2 (2)
∣x (ξ)∣
∣x(ti+1 ) − xi+1 ∣ ≤ ∣x(ti ) − xi ∣ + ∆t∣[f (ti , x(ti )) − f (ti , xi )]∣ +
2
Now f satisfies a Lipschitz condition in the second variable with constant L, and
∆t2 M
∣x(ti+1 ) − xi+1 ∣ ≤ (1 + ∆t L) ∣x(ti ) − xi ∣ +
2
∆t2 M
Referring to Lemma 2 and letting ai = ∣x(ti ) − xi ∣, s = ∆t L, t = 2 , we have,
∆t2 M ∆t2 M
∣x(ti+1 ) − xi+1 ∣ ≤ e(i+1)∆tL (∣x(t0 ) − x0 ∣ + )−
2∆tL 2∆tL
Because ∣x(t0 ) − x0 ∣ = 0 and (i + 1)∆t = ti+1 − t0 = ti+1 − a, this implies that
∆tM L(ti −a)
∣x(ti ) − xi ∣ ≤ (e − 1)
2L
for each i = 0, 1, ⋯, n − 1.
The weakness of the above result is the requirement that a bound be known for the sec-
ond derivative of the solution. Although this condition often prohibits us from obtaining a
realistic error bound, it should be noted that if ∂f ∂f
∂t and ∂x both exist, then the chain rule for
partial differentiation implies that
dx′ d ∂f ∂f
x(2) (t) = (t, x(t)) = f (t, x(t)) = + (t, x(t)) . f (t, x(t))
dt dt ∂t ∂x
Therefore, some times it is possible to obtain an error bound for x(2) (t) without explicitly
knowing x(t).
76 Sanyasiraju V S S Yedida [email protected]
Example
The solution to the initial-value problem x′ = x−t2 +1, 0 ≤ t ≤ 2, x(0) = 0.5, was approximated
in 8.5.1 using Eulers method with ∆t = 0.2. Use the error formula (8.8) to find a bounds for
the approximation errors and compare them with the actual errors.
Solution
Because f (t, x) = x − t2 + 1, we have ∂x (t, x)
∂f
= 1 for all x, so L = 1.
1 ∆tM δ
∣x(ti ) − xi ∣ ≤ ( + ) (eL(ti −a) − 1) + ∣δ0 ∣eL(ti −a) (8.9)
L 2 ∆t
for each i = 0, 1, ⋯, n. The error bound (8.5.2) is no longer linear in ∆t. In fact, since
limit ∆t tends zero, as ( ∆tM )
2 + ∆t tends to ∞, the error would expected to become large
δ
for sufficiently small values of ∆t. Calculus can be used to determine a lower bound for the
step size ∆t. Letting E(∆t) = ( ∆tM ) ′
2 + ∆t implies that E = 2 − ∆t2 .
δ M δ
√
• If ∆t < 2δ
M, then E ′ (∆t) < 0 and E(∆t) is decreasing.
√
• If ∆t > 2δ
M, then E ′ (∆t) > 0 and E(∆t) is increasing.
Decreasing ∆t beyond this value tends to increase the total error in the approximation.
Normally, however, the value of δ is sufficiently small that this lower bound for ∆t does not
affect the operation of Eulers method.
Lecture Notes MA5470 Numerical Analysis 77
8.5.3 Problems
1. Use Eulers method to approximate the solutions for each of the following initial-value
problems. Also compare the actual error with error bound
(a) x′ = te3t − 2x, 0 ≤ t ≤ 1, x(0) = 0, with ∆t = 0.5 (Exact solution : x(t) = 51 te3t −
−2t )
25 e + 25 te
1 3t 1
(e) x′ = et−x , 0 ≤ t ≤ 1, x(0) = 1, with ∆t = 0.5 (Exact solution : x(t) = ln(et + e − 1))
√
(f) x′ = 1+x
1+t
, 1 ≤ t ≤ 2, x(1) = 2, with ∆t = 0.5 (Exact solution : x(t) = t2 + 2t + 6 − 1)
√
(g) x′ = −x + t x, 2 ≤ t ≤ 3, x(2) = 2, with ∆t = 0.25 (Exact solution : x(t) =
√
(t − 2 + 2e e−t/2 ) )
2
If we know the value of x at t1, the differential equation enables us to compute the value
of x′ (t). To integrate the differential equation starting at t = 0, we shall need the history of
x(t) starting at t = −1. Thus, the values of x(t) on the interval t ∈ [−1, 0] will have to be
supplied to us as initial values. An example of a specific and well-defined problem of this
type is
Numerical Illustration
Consider
The second of these equations gives the needed initial values for x(t). If t is restricted to
the interval [0, 1], then t − 1 is in [−1, 0], and hence
1 1
x(t + ∆t) = x(t − 1) = (t − 2)3 + , 0 ≤ t ≤ 1
3 3
1
x(1) =
3
x′ = 2x(t − 1) + x(t), t ≥ 0,
x(t) = t2 for − 1 ≤ t ≤ 0
To compute the solution on the interval [0, 1], assume we wish to use the Taylor series, with
step length ∆t, given by
The numerical solution produces values of x(t) at discrete points in the interval [0, 1]. At
the same time, we should store the values of x′ (t), x(2) (t), and x(3) (t) at these same discrete
points for use in the next interval. If we do not change the value of ∆t, we can proceed in
each interval in the same way using the appropriate saved values.
Lecture Notes MA5470 Numerical Analysis 79
8.5.5 Problems
√
1. Verify that the function x(t) = t4 solves the initial-value problem x′ = x, x(0) = 0.
2
Apply Taylor series method of order 1 and explain why the numerical solution differs
2
from the solution t4 .
2. Compute x(0.1) by solving the differential equation x′ = −tx2 , x(0) = 2 with the Taylor-
series method of order 2.
3. Compute x(0.01) by solving the differential equation x′ = x2 xet , x(0) = 1 with the
Taylor-series method of order 3.
4. Compute x(4.1) by solving the differential equation 5tx′ + x2 = 2, x(4) = 1 with the
Taylor-series method of order 2.
5. Apply the Taylor series method of orders (a) two and (b) four with number of points
as 5 to the IVP x′ = x − t2 + 1, 0 ≤ t ≤ 2, x(0) = 0.5.