Sie sind auf Seite 1von 5

AMS 147 Computational Methods and Applications

Exercise #6

1. Consider the midpoint method


yn +1 = yn 1 + 2h F ( yn , t n )

Use Taylor expansion to show that the local truncation error is

( )

en ( h ) = O h 3
Answer:

We expand y(tn+1) and y(tn-1) around tn.

y ( t n ) 2 y( 3) ( t n ) 3
y ( t n +1 ) = y ( t n + h ) = y ( t n ) + y ( t n ) h +
h +
h +
2
6
y ( t n 1 ) = y ( t n  h ) = y ( t n )  y ( t n ) h +

y ( t n ) 2 y( 3) ( t n ) 3
h 
h +
2
6

The local truncation error is

en ( h ) = y ( t n +1 )  y ( t n 1 )  2h F ( y ( t n ) , t n )

(using the expansions above and F y ( t n ) , t n = y ( t n ) )

=2

y( 3) ( t n )
6

h3 =

y( 3) ( t n )
3

h3

2. Consider the trapezoidal method

y n+1 = y n +

h
( F ( y n,t n ) + F ( y n+1,tn +1))
2

Use Taylor expansion to show that the local truncation error is

( )

en ( h ) = O h 3
Answer:

We use F y ( t n ) , t n = y ( t n ) and F y ( t n +1 ) , t n +1 = y ( t n +1 )

-1-

AMS 147 Computational Methods and Applications


We expand y(tn+1) and y(tn+1) around tn.

y ( t n +1 ) = y ( t n + h ) = y ( t n ) + y ( t n ) h +

y ( t n )
2

y ( t n +1 ) = y ( t n + h ) = y ( t n ) + y ( t n ) h +

h +
2

y( 3) ( t n )
2

y( 3) ( t n )
6

h3 + 

h2 + 

The local truncation error is


en ( h ) = y ( t n +1 )  y ( t n ) 

h
 F ( y ( t n ) , t n ) + F ( y ( t n +1 ) , t n +1 ) 
2

y( 3) ( t n ) 2 
y ( t n ) 2 y( 3) ( t n ) 3 h 
= y ( t n ) h +
h +
h   y ( t n ) + y ( t n ) + y ( t n ) h +
h 
2 
2
6
2


1 ( 3)
1 1 
=    y( 3) ( t n ) h 3 =
y (tn ) h 3
12
6 4 
3. Convert y  + (1 + y 2 ) y  + 2y = cos(3t) to a first order ODE system.
Answer:
We treat y(t) and v(t) = y(t) as unknowns.
y ( t ) = v ( t )

v ( t ) = y ( t ) = cos ( 3t )  1 + y 2 ( t ) v ( t )  2y ( t )
==>

v (t )

d  y ( t ) 
=


dt  v ( t )  cos ( 3t )  1 + y 2 ( t ) v ( t )  2y ( t )

4. Consider the model ODE y =   y ,  > 0 . The exact solution is given by y (t ) = y (0) e   t .
The exact solution satisfies

y (t )  0 as t  

Suppose we use the Euler method to solve y  =  y . What condition does the step size h
have to satisfy to ensure that yn be bounded as n   ?

-2-

AMS 147 Computational Methods and Applications

Suppose we use the backward Euler method to solve y  =  y . What condition does the
step size h have to satisfy to ensure that yn be bounded as n   ?

Answer:
For the Euler method, to ensure that yn be bounded as n   , the time step h has to satisfy
h

2


For the backward Euler, yn is bounded as n  

for any time step h > 0.

5. Consider using the Euler method to solve

))

 y =   y  sin 1 + x 2 ,

 y ( 0 ) = 0

 = 1012

To make the numerical solution bounded, we have to use time step h 

2
.


Suppose we need to compute the numerical solution from t = 0 to t = 10.


What is the minimum number of time steps in the computation?
Answer:
Let N be the number of time steps. It satisfies

N=

10
10

= 5  = 5  1012 = 5 Trillion steps
2
h


The computation has at least 5 Trillion time steps!

6. Consider a set of 2 data points

( x1, y1 ) , ( x2 , y2 )
Let p(x) be the linear function that goes through these 2 points.
p ( x1 ) = y1 ,

p ( x2 ) = y2

Write out p(x). What is p ( x ) ?


Answer:
-3-

AMS 147 Computational Methods and Applications

c1 ( x ) =
==>

x  x2
,
x1  x2

c2 ( x ) =

x  x1
x2  x1

p ( x ) = y1c1 ( x ) + y2 c2 ( x )
=

y2 ( x  x1 ) + y1 ( x2  x )
x2  x1

y2  y1
x2  x1

p ( x ) =

7. Consider a set of 3 data points

( h, y1 ) , ( 0, y2 ) , ( h, y3 )
Let p(x) be the quadratic polynomial that goes through these 3 points.
p ( h ) = y1 ,

p ( 0 ) = y2 ,

p ( h ) = y2

Write out p(x). What is p ( x ) ?


Answer:
c1 ( x ) =

( x  x2 ) ( x  x 3 ) = x 2  x h
( x1  x2 ) ( x1  x3 ) 2h 2

c2 ( x ) =

( x  x1 ) ( x  x3 ) = h 2  x 2
h2
( x2  x1 ) ( x2  x3 )

c3 ( x ) =

( x  x1 ) ( x  x2 ) = x 2 + x h
( x3  x1 ) ( x3  x2 ) 2h 2

==>

p ( x ) = y1c1 ( x ) + y2 c2 ( x ) + y3c3 ( x )
=

y1 x 2  x h + y2 2h 2  2x 2 + y3 x 2 + x h

p ( x ) =

2h

y1  2y2 + y3
h2

8. The period of sin(x) is 2.

-4-

AMS 147 Computational Methods and Applications

2 
What is the period of sin  x  ?
5 
Answer:
The period of sin(x) is 2.
==>

2

2 
sin  x + 2  = sin  x 
5

5 

==>

 
2
2 
sin   x +   = sin  x 
5 
5
5

==>


2 
The period of sin  x  is period of .
5 
5

-5-

Das könnte Ihnen auch gefallen