Docsity

Numerical Solutions of ODEs: Forward Euler Method and Local Truncation Error Analysis, Study notes of Calculus

Toggle sidebar
bg1
Math 128A Problem Set 10
Numerical Solutions of ODEs
Adrian Down
April 18, 2006
Problem 1
Part a
Using the Forward Euler method,
yn+1 −yn=hyn
⇒yn+1 = (1 + h)yn(1.a.1)
(1.a.1) is a recurrence relation that determines yn+1 given yn. Starting with
y0, I use (1.a.1) to determine all subsequent yk,
y0=x0= 1 y1= (1 + h)y0= 1 + h
y2= (1 + h)y1= (1 + h)2. . . yn= (1 + h)n(1.a.2)
Part b
Substituting n=Nand h=T
Ninto (1.a.2),
yN=1 + T
NN
(1.b.1)
I rewrite (1.b.1) using Taylor expansions, which will make it easier to take
the limit as N→ ∞,
yN=eln“(1+ T
N)N”
=eNln(1+ T
N)(1.b.2)
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Numerical Solutions of ODEs: Forward Euler Method and Local Truncation Error Analysis and more Study notes Calculus in PDF only on Docsity!

Math 128A Problem Set 10

Numerical Solutions of ODEs

Adrian Down

April 18, 2006

Problem 1

Part a

Using the Forward Euler method,

yn+1 − yn = hyn ⇒ yn+1 = (1 + h) yn (1.a.1)

(1.a.1) is a recurrence relation that determines yn+1 given yn. Starting with y 0 , I use (1.a.1) to determine all subsequent yk,

y 0 = x 0 = 1 y 1 = (1 + h)y 0 = 1 + h y 2 = (1 + h)y 1 = (1 + h)^2... yn = (1 + h)n^ (1.a.2)

Part b

Substituting n = N and h = TN into (1.a.2),

yN =

T

N

)N

(1.b.1)

I rewrite (1.b.1) using Taylor expansions, which will make it easier to take the limit as N → ∞,

yN = eln

“ (1+^ TN )N^

”

= eN^ ln(1+^

TN )

(1.b.2)

I Taylor expand the logarithm,

ln (1 + x) = x −

x^2 + O

x^3

⇒ yN = eN

“ (^) T N −^12 T^

2 N 2 +O(^ 1 N 3 )

”

= eT^ −^

12 T N 2 +O( N 1 2 )

= eT^ · e−^ 12 T N (^2) · eO(^

N^1 2 )^

(1.b.3)

Now I Taylor expand the exponentials in (1.b.3),

ex^ = 1 + x + O(x^2 )

⇒ yN = eT

T 2

N

+ O

N 2

1 + O

N 2

= eT

T 2

N

+ O

N 2

(1.b.4)

I use (1.b.4) to form the desired product,

N

yN − eT^

= N eT

T 2

N

+ O

N

T 2 eT^ + O

N

(1.b.5)

Taking the limit as N → ∞ of (1.b.5), the O

N

term approaches 0,

Nlim →∞ N^

yN − eT^

T 2 eT^ (1.b.6)

Problem 2

Part a

Assuming the given form of z, I compute the derivative,

z = x + ı x˙ (2.a.1) ⇒ z˙ = ˙x + ı¨x (2.a.2)

To write yn in complex polar form, I first write 1 − ıh in polar form, R = | 1 − ıh| =

1 + h^2

θ = tan−^1 −h 1 = tan−^1 −h ⇒ 1 − ıh =

1 + h^2 eı^ tan − (^1) −h

⇒ zn =

1 + h^2

)n 2 eın^ tan − (^1) −h (2.b.3)

Part c

To form yN , I take n = N and h = (^) NT in (2.b.3),

zN = RN eıθN^ =

T 2

N 2

)N 2

eıN^ tan − (^1) − TN (2.c.1)

I Taylor expand the magnitude and angle of (2.c.1) to determine the error in the approximate solution.

(1 + x)m^ = 1 + mx + O((mx)^2 )

⇒ RN = 1 +

N

T 2

N 2

+ O

N 2 ·

N 4

⇒ RN − 1 =

T 2

2 N

+ O

N 2

(2.c.2)

tan−^1 x = x −

x^3 + O(x^5 )

⇒ θN = N

T

N

T 3

N 3

+ O

N 5

= −T +

T 3

3 N 2

+ O

N 4

⇒ θN + T =

T 3

3 N 2

+ O

N 4

(2.c.3)

Part d

Taking the real part of (2.c.1),

xN = RN cos θN =

T 2

N 2

cos

N tan−^1 −

T

N

(2.d.1)

I rewrite (2.d.1) using the Taylor expansions obtained in (2.c.2) and (2.c.3).

xN =

T 2

2 N

+ O

N 2

cos

−T + O

N 2

(2.d.2)

I rewrite the cosine term in (2.d.2) using an angle addition formula,

xN =

T 2

2 N

+ O

N 2

×

[

cos (−T ) ·

cos O

N 2

− sin (−T ) · sin

O

N 2

))]

(2.d.3)

I rewrite the trig functions in N that appear in (2.d.3) using the familiar Taylor expansions of the sine and cosine functions. I also use the evenness of the cosine function to write cos −T = cos T ,

cos ζ = 1 + O(ζ^2 ) sin ζ = ζ + O(ζ^3 )

⇒ xN =

T 2

2 N

+ O

N 2

×

[

cos T

1 + O

N 4

− O

N 2

)]

T 2

2 N

cos T + O

N 2

⇒ xN − cos T =

T 2

2 N

cos T + O

N 2

(2.d.4)

Problem 3

Part a

To find the local truncation error, I substitute the exact solution x to the differential equation into the difference equation. I first Taylor expand x(t ± h),

x(t ± h) = x(t) + ˙x(t)(±h) + ¨x(t) 2 (±h)^2 + O(h^3 )

= x(t) ± x˙(t)h + x¨(t) 2 h^2 + O

h^3

(3.a.1)

difference equation,

x(t + h) −

x(t − h) −

x(t) =

x(t) + ˙x(t)h + x¨(t) 2 h^2 + O

h^3

x(t) − x˙(t)h + ¨x(t) 2

h^2 + O

h^3

x(t)

x˙(t)h + x¨(t) 4 h^2 + O(h^3 ) (4.a.1)

I use the fact that x(t) is an exact solution to the differential equation to substitute the explicit form of f (t, x(t)) into the right side of the difference equation.

F (t) = ˙x(t) ⇒ F (t − h) = ˙x(t) − x¨(t)h + O(h^2 ) ⇒ 7 F (t) − F (t − h) = 6 ˙x(t) + ¨x(t)h + O(h^2 )

⇒ h 4

(7F (t) − F (t − h)) =

x˙(t)h + x¨(t) 4

h^2 + O(h^3 ) (4.a.2)

The local truncation error is given by the difference of (4.a.1) and (4.a.2),

(4.a.1) − (4.a.2) =

x˙(t)h +

x¨(t) 4 h^2 + O(h^3 )

x˙(t)h + x¨(t) 4 h^2 + O(h^3 )

= O(h^3 ) (4.a.3)

Part b

I follow the method of problem 3 part b, assuming an elementary solution of the form of (3.b.1). Substituting into the recurrence relation, taking f ≡ 0,

x(t + h) −

x(t) −

x(t − h) = 0

rt+h^ −

rk^ −

rk−^1 = 0

⇒ r^2 −

r −

⇒ 2 r^2 − r − 1 = 0 (4.b.1)

I solve (4.b.1) for r using the Quadratic Formula,

r =

, 1 (4.b.2)

Since all possible values of r have absolute value less than 1, the solution (3.b.1) is stable ∀k. Hence the iteration method is stable.

Problem 5

Part a

To form the difference equation, I make use of the difference of Taylor ex- pansions found in (3.a.2), keeping terms up to fifth order,

x(t + h) − x(t − h) = 2 ˙x(t)h +

x(3)(t)h^3 + O(h^5 )

⇒ a(x(t + h) − x(t − h)) = 2a x˙(t)h +

a 3 x(3)(t)h^3 + O(h^5 ) (5.a.1)

x(t + 2h) − x(t − 2 h) = 4 ˙x(t)h +

x(3)(t)h^3 + O(h^5 ) (5.a.2)

Taking the sum of (5.a.1) and (5.a.2),

(5.a.1) + (5.a.2) = ˙x(t)h (4 + 2a) +

x(3)(t)h^3 (8 + a) + O(h^5 ) (5.a.3)

I use the fact that x(t) is an exact solution to the differential equation to substitute the explicit form of f (t, x(t)) into the the difference equation. The final expression for the local truncation error is,

(5.a.3) − bhf (t, x(t)) = ˙x(t)h (4 + 2a − b)

x(3)(t)h^3 (8 + a) + O(h^5 ) (5.a.4)

To make the local truncation error fifth order in h, I choose a and b such that the coefficients of the first two terms in (5.a.4) are 0,

8 + a = 0 ⇒ a = − 8 (5.a.5) 4 + 2a − b = 0 ⇒ b = − 12 (5.a.6)