Lecture on Numerical Analysis

9
M. Dumbser 1 / 9 Analisi Numerica Università degli Studi di Trento Dipartimento d‘Ingegneria Civile ed Ambientale Dr.-Ing. Michael Dumbser Lecture on Numerical Analysis Dr.-Ing. Michael Dumbser 17 / 12 / 2007

description

Lecture on Numerical Analysis. Dr.-Ing. Michael Dumbser. 17 / 12 / 2007. Ordinary Differential Equations. An equation of the form. is called a nonlinear ordinary differential equation (ODE) of first order. The simplest first order ODE is the equation. with. - PowerPoint PPT Presentation

Transcript of Lecture on Numerical Analysis

Page 1: Lecture on Numerical Analysis

M. Dumbser

1 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

Lecture on Numerical Analysis

Dr.-Ing. Michael Dumbser

17 / 12 / 2007

Page 2: Lecture on Numerical Analysis

M. Dumbser

2 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

Ordinary Differential Equations

)),(( ttyfdt

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

aydt

dy

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

adty

dy

)(tyy with

t

t

y

y

adty

dy

00

ttyy aty

00ln

00lnln ttayy 00

ln ttay

y 0

0)( ttaeyty

Page 3: Lecture on Numerical Analysis

M. Dumbser

3 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

Ordinary Differential Equations

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

2aydt

dy

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

adty

dy

2

)(tyy with

t

t

y

y

adty

dy

00

2 tt

y

y

aty 0

0

1

00

11tta

yy

1

00

1)(

tta

yty

Page 4: Lecture on Numerical Analysis

M. Dumbser

4 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

Numerical Methods for the Integration of ODE

The simplest numerical method for the integration of first order ODEs is theso-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 accuratefinite difference scheme to approximate the derivative on the left hand side of the ODEand to compute the operator on the right hand side at the current state yn and time tn:

),( tyfdt

dy

),(1

nnnn

tyft

yy

),(1 nnnn tyftyy

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

),( 111 nnnn tyftyy

ttt nn 1

Page 5: Lecture on Numerical Analysis

M. Dumbser

5 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

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

211 nnnn tyftyy

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 nnnn tyf

tyy

11

),(

n

n

n

n

t

t

t

t

dttyfdt

dy

1

),(1

n

n

t

t

nn dttyfyy

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

),( 21

211 nnnn tyftyy

The corrector is then:

Page 6: Lecture on Numerical Analysis

M. Dumbser

6 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael 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:

43211 22

6kkkk

tyy nn

),(1nn tyfk

),( 2122tntn tkyfk

),( 2223tntn tkyfk

),( 34 tttkyfk nn

Page 7: Lecture on Numerical Analysis

M. Dumbser

7 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

Exercise 1Write 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.

ydt

dy 2y

dt

dy 1)0( y ]10;0[t

Page 8: Lecture on Numerical Analysis

M. Dumbser

8 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

Exercise 2Wite 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:

m1mi-1 mi

mi+1 mN

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

ii vdt

dx

The forces acting on point mass i are

iiiii kLxxF

1 111 iiiii kLxxF

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

iii

i FFmdt

dv 1

01 F0

NF

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

Page 9: Lecture on Numerical Analysis

M. Dumbser

9 / 9

Analisi NumericaUniversità degli Studi di TrentoDipartimento d‘Ingegneria Civile ed AmbientaleDr.-Ing. Michael Dumbser

Exercise 3Wite 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:

vdt

xd

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

2

PS

PS

PS

PSG

xx

mm

xx

xxF

The ODE system for the velocity vector of the planet is

GP

P Fmdt

vd 1

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