• Non ci sono risultati.

Lecture on Numerical Analysis

N/A
N/A
Protected

Academic year: 2021

Condividi "Lecture on Numerical Analysis"

Copied!
9
0
0

Testo completo

(1)

Lecture on Numerical Analysis

Dr.-Ing. Michael Dumbser

17 / 12 / 2007

(2)

M. Dumbser

Ordinary Differential Equations

) ), ( ( y t t dt f

dy 

An equation of the form

is called a nonlinear ordinary differential equation (ODE) of first order. The simplest first order ODE is the equation

dt ay dy 

The exact solution of this simple ODE is obtained as follows:

y adt dy 

) (t y y

with

t

t y

y

y adt dy

0 0

  ln y

yy0

  at

tt0

0

ln

0

ln yya tt

0

0

ln a t t y

y   y ( t )  y

0

e

a

tt0

(3)

Ordinary Differential Equations

A simple nonlinear ordinary differential equation (ODE) of first order is given by

ay

2

dy  dt

The exact solution of this simple nonlinear ODE can be computed in a similar way:

y adt dy 

2

) (t y y

with

t

t y

y

y adt dy

0 0

2 y

 

tt

y

y at

0

0

1  

 

 

0

0

1

1 a t t

y

y    

0

1

0

) 1 (

 

 

  

a t t

t y

y

(4)

M. Dumbser

Numerical Methods for the Integration of ODE

The simplest numerical method for the integration of first order ODEs is the

so-called explicit (forward) Euler method, invented already in the 18th century by the mathematician Leonhard Euler. It corresponds to the use of a first order accurate

finite difference scheme to approximate the derivative on the left hand side of the ODE and to compute the operator on the right hand side at the current state yn and time tn:

) , ( t y dt f

dy 

) , (

1 n n n

n

t y t f

y

y

) ,

1 n

(

n n

n

y t f y t

y

   

Computing the function f on the right hand side at the unknown time tn+1, we obtain the so-called implicit (backward) Euler method:

) ,

(

1 1

1

n

  

n n

n

y t f y t

y

t t

t

n1

n

 

(5)

Numerical Methods for the Integration of ODE

A simple modification of the forward Euler scheme, which yields a second order accurate method, is based on the following approach: Integrate the ODE from time level tn to time level tn+1:

) ,

(

21 21

1

n

  

n n

n

y t f y t

y

Unfortunately, the value of y is not known at tn+1/2, but we can approximate it making a half time-step of the forward Euler scheme. This means, that first, a so-called predictor is computed at the half time-step t/2:

) , 2 (

21 n n n

n

t f y t

y

y

   

1 1

) , (

n

n n

n

t

t t

t

dt t y dt f

dy

1

) ,

1

(

n

n

t

t n

n

y f y t dt

y

The integral on the right hand side is now evaluated using a one-point Gaussian quadrature formula (the midpoint is the integration point):

) ,

(

21 21

1

n

  

n n

n

y t f y t

y

The corrector is then:

(6)

M. Dumbser

Numerical Methods for the Integration of ODE

One of the most famous and mostly commonly used schemes for ODE integration is the explicit fourth-order scheme of Runge and Kutta:

1 2 3 4

1

2 2

6 t k k k k

y

y

n

n

     )

,

1

(

n n

t y f k

) ,

(

2 1 2

2

f y

n t

k t

n t

k  

) ,

(

2 2 2

3

f y

n t

k t

n t

k  

) ,

(

3

4

f y tk t t

k

n

 

n

 

(7)

Exercise 1

Write a MATLAB script ODECompare.m that integrates the following two ODE:

(1) Use the explicit (forward) Euler method, using different time steps and compare with the exact solutions.

(2) Use the modified second order Euler method (=second order Runge-Kutta scheme) with different time steps, and compare with the exact solutions.

(3) Use the fourth order Runge-Kutta scheme with various time steps. Compare with the exact solutions.

dt y

dy   y

2

dt

dy   y ( 0 )  1 t  [ 0 ; 10 ]

(8)

M. Dumbser

Exercise 2

Wite a MATLAB script Springs.m that integrates the linear ODE system for position and velocity for a system of N point masses, connected by springs as follows:

m1 mi-1 mi mi+1 mN

The ODE system for the positions of the point masses is simply:

i

v

i

dx  dt

The forces acting on point mass i are

i i i

i

i

x x L k

F

1

 

1 1

1

i

i

i i

i

x x L k

F

Where ki are the spring stiffnesses and Li are the lengths of the springs in their undeformed state. The ODE system for the velocities of the point masses is then

i i

i

i

F F

m dt

dv 1

1

 0 F

 0

F

N

Use the second order Runge-Kutta scheme (modified Euler method).

(9)

Exercise 3

Wite a MATLAB script Orbit.m that integrates the linear ODE system for position and velocity for a planet, turning around a star.

The ODE system for the position vector of the planet is:

dt v x

d  

The gravitation force of the star, acting on the planet, is given by:

2 P S

P S P

S

P G S

x x

m m x

x

x

F x    

 

 

 

The ODE system for the velocity vector of the planet is

G P

P

F

m dt

v

d  1 

Riferimenti

Documenti correlati

The aim of the present study is to verify the suitability of using different approaches of de novo assembling sequence reads obtained by NGS procedures (Illumina and 454) to gain

However, by adopting a factorial design, with “Sex” and “Treatment” (e.g., a range of different test drugs or doses) as the experimental factors, a relatively small number of

Therefore, in this work, the attention is focused on Ag 73.2 Cu 17.1 Zr 9.7 (at.%) amorphous/crystalline composite, by studying the effect of cold rolling on the stability of

In fact, MFO is a restriction of the Monadic Second-Order (MSO) logic introduced in Section 3 and, as shown there, for every MSO sentence ϕ there is a Finite-State Automaton (FSA)

Flash quantizer was used in previous implementations of the modulator, [30, 31], in this version to further improve the power consumption a SAR quantizer was used, a few ∆Σ

Inoltre l'intento è stato quello di concentrare, il più possibile, l'attenzione sulla rappresentazione del progetto architettonico e non sulla scienza teorica del

Comparison between the result obtained for the halo power spectrum when using the fit valid for CDM (equation 33, shown in purple) to compute the second-order growth rate and the