MATH 175: Numerical Analysis II

36
MATH 175: Numerical Analysis II Lecturer: Jomar F. Rabajante 2 nd Sem AY2012-2013 IMSP, UPLB

description

MATH 175: Numerical Analysis II. Lecturer: Jomar F. Rabajante 2 nd Sem AY2012-2013 IMSP, UPLB. RECALL: SOLVING ODEs. Example: The solution to the ODE dy / dt , also written as y’ , is y(t) or y( t,y ) . Obtaining an explicit formula: y(t) Obtaining an implicit formula: y( t,y ) - PowerPoint PPT Presentation

Transcript of MATH 175: Numerical Analysis II

Page 1: MATH 175: Numerical Analysis II

MATH 175: Numerical Analysis II

Lecturer: Jomar F. Rabajante2nd Sem AY2012-2013

IMSP, UPLB

Page 2: MATH 175: Numerical Analysis II

RECALL: SOLVING ODEsExample: The solution to the ODE dy/dt, also written

as y’, is y(t) or y(t,y).

• Obtaining an explicit formula: y(t) • Obtaining an implicit formula: y(t,y)• Obtaining a power series representation for y(t)• Numerically approximating the solution y(t) or y(t,y)• Sketching the geometric representation of y(t)

Page 3: MATH 175: Numerical Analysis II

INITIAL VALUE PROBLEM

• Consider we have an IVP (first-order ODE)

],[)(

),('

batyayytfy

a

Page 4: MATH 175: Numerical Analysis II

1st Method: EULER’S METHOD

Simple derivation:Partition [a,b] in to n – 1 grid (i.e. n points) with equal step size h = (b – a)/n

Start withDetermine the successive slopes:

00 : yw

,),( 1

hwwwtf ii

ii

11 : ii wy

Page 5: MATH 175: Numerical Analysis II

1st Method: EULER’S METHOD

Hence, the Euler’s Method is

00 yw

),(1 iiii wthfww

increment from wi to wi+1 i

ii twt

Page 6: MATH 175: Numerical Analysis II

1st Method: EULER’S METHOD

Example 1: Apply Euler’s Method to

]1,0[1)0(

' 3

ty

ttyy

Page 7: MATH 175: Numerical Analysis II

1st Method: EULER’S METHOD

Example 1: Let h=0.2

10 w

)(2.0 31 iiiii twtww

Page 8: MATH 175: Numerical Analysis II

1st Method: EULER’S METHOD

Example 1: Using MS Excel

step ti wi0 0.0 1.0000001 0.2 1.0000002 0.4 1.0416003 0.6 1.1377284 0.8 1.3174555 1.0 1.630648

Page 9: MATH 175: Numerical Analysis II

0.0 0.2 0.4 0.6 0.8 1.00.000000

0.200000

0.4000000.600000

0.800000

1.0000001.200000

1.4000001.600000

1.800000

wi

Page 10: MATH 175: Numerical Analysis II

1st Method: EULER’S METHOD

Another derivation: (Using Taylor Series)

1

2

)("2

)(')()(

ii

iii

tct

cyhthytyhty

Page 11: MATH 175: Numerical Analysis II

ANALYSIS OF IVP SOLVERS

• LOCAL TRUNCATION OR DISCRETIZATION ERROR & CONSISTENCY

• GLOBAL TRUNCATION OR DISCRETIZATION ERROR & CONVERGENCE

• STABILITY (of the numerical method)

The most important of this is convergence. If the method does not converge, then it is useless.

Page 12: MATH 175: Numerical Analysis II

ANALYSIS OF IVP ITSELF• EXISTENCE OF SOLUTION• UNIQUENESS OF SOLUTION• STABILITY (of the IV Problem)

If the IVP has no solution or has no unique solution then our results from any numerical method (however sophisticated it is) is meaningless.

If our IVP is unstable (sensitive to changes in initial & parameter values), then we may get results which are far from the exact solution. Remember that we are approximating the solutions, so any error may affect our solution.

Page 13: MATH 175: Numerical Analysis II

LOCAL TRUNCATION ERROR

• Measures the error generated by one step of the method, assuming the solution at previous steps was exact.

For one-step methods: (One step means we only need wi in computing wi+1)

iii wye Assuming the solutions at previous steps are exact.

Page 14: MATH 175: Numerical Analysis II

LOCAL TRUNCATION ERROR

Ifthen the numerical method is CONSISTENT.

Notice that a method is consistent if its local error is proportional to the size of the step size h.

0 as 0 ii he

Page 15: MATH 175: Numerical Analysis II

LOCAL TRUNCATION ERRORExample (for Euler’s Method):

)("2

),(2

1 cyhythfyy iiii

),(1 iiii wthfww

22

1 )("2

hcyhei

Assumed correct

Page 16: MATH 175: Numerical Analysis II

LOCAL TRUNCATION ERROR

Example (for Euler’s Method):

This means that the error in each step is proportional to the square of the step size.

22

1 )("2

hcyhei

Page 17: MATH 175: Numerical Analysis II

GLOBAL TRUNCATION ERROR

• Measures the cumulative effect of the errors introduced by all of the time steps taken

• It is the difference between the solution of the differential equation (if this is available) and the solution of the difference equation

If

then the method is CONVERGENT.

0maxlim10

iinih

wy Considering the cumulative errors

Page 18: MATH 175: Numerical Analysis II

GLOBAL TRUNCATION ERRORThe max error should approach zero as we decrease the step size.

In short, a solver is convergent if the approximate solutions converge to the exact solution for each t, as h0.

Page 19: MATH 175: Numerical Analysis II

GLOBAL TRUNCATION ERROR

Considering the accumulated errors.

If for some constant p, then the method is of order p.

We will define order of a numerical method as the “p” on its global error.

)( piiii hOywE

Page 20: MATH 175: Numerical Analysis II

GLOBAL TRUNCATION ERROR

Example (for Euler’s Method):

Naïve analysis: After n steps

22

1 )("2

hcyhe

)()(2 hOhabnhEn constant

Page 21: MATH 175: Numerical Analysis II

GLOBAL TRUNCATION ERRORExample (for Euler’s Method):

Actually,

where L is a Lipschitz constant.

Euler’s Method is a first-order method. Halving the size of h will reduce the error bound to half. This makes Euler’s method a crude method (but very easy to use).

12

)(" )( atLi

ieLcyh

E

Page 22: MATH 175: Numerical Analysis II

GLOBAL TRUNCATION ERROR

An explicit one-step method is convergent if and only if it is consistent.

For a convergent explicit one-step method, if the local truncation error is O(hm+1) then the global error is O(hm) or the method is of order m.

Page 23: MATH 175: Numerical Analysis II

FOCUSING ON CONSISTENCY AND CONVERGENCE

Interpreting Consistency and Convergence:

Consistency means that as h shrinks the difference equation tends to the ODE.

Convergence means that as h shrinks the solution of the difference equation tends to the solution of the ODE.

Page 24: MATH 175: Numerical Analysis II

TRUNCATION VS ROUND-OFF

Take note that the truncation errors that we have presented here are errors arising from the process (or method) itself. This does not yet consider the round-off errors that you or your computer might commit.

Error

Step size h

Round-off error

Discretization errorTotal Error

Page 25: MATH 175: Numerical Analysis II

STABILITY OF THE METHOD

Page 26: MATH 175: Numerical Analysis II

STABILITY OF THE METHOD

REMEMBER: our method is a difference equationRECALL: fixed-point iteration

31 kk xx

Page 27: MATH 175: Numerical Analysis II

STABILITY OF THE METHOD

We need to inspect the stability of the method since we are dealing with computers that may give round-off errors. We need to check how sensitive our method is from small round-off errors.

Page 28: MATH 175: Numerical Analysis II

EXISTENCE AND UNIQUENESS OF SOLUTION

We first discuss Lipschitz condition.DEFINITION: A function f(t,y) satisfies the LIPSCHITZ

CONDITION in the variable y on the rectangle S=[a,b]x[y1,y2] if there exists a constant L (called the Lipschitz constant) satisfying

for each (t,y1), (t,y2) in S.

2121 ),(),( yyLytfytf

Page 29: MATH 175: Numerical Analysis II

EXISTENCE AND UNIQUENESS OF SOLUTION

Example 1: Find the Lipschitz constant for

L=1

,]1,0[),( 3

Sttyytf

2121

213

23

1

1

)()(

yyyyt

tytyttytty

Page 30: MATH 175: Numerical Analysis II

EXISTENCE AND UNIQUENESS OF SOLUTION

Example 2: Find the Lipschitz constant for

L=2

2

sin2),(

R

S

tyytf

21

2121

2

sin2)sin2()sin2(

yy

yyttyty

Page 31: MATH 175: Numerical Analysis II

EXISTENCE AND UNIQUENESS OF SOLUTION

Another way of getting Lipschitz constant:THEOREM: If f is defined on S=[a,b]x[c,d] and there

exists a constant L>0 such that

for all (t,y) in S, then f satisfies a Lipschitz condition in y on S with Lipschitz constant L.

Lytyf

),(

Page 32: MATH 175: Numerical Analysis II

EXISTENCE AND UNIQUENESS OF SOLUTION

Example 3: Find the Lipschitz constant for

You will get

]4/,0[]1,0[2

sec),(

St

ytytf

yytt

yf tansec

2

2L

Page 33: MATH 175: Numerical Analysis II

EXISTENCE AND UNIQUENESS OF SOLUTION

See Existence and Uniqueness Theorem in my MS Thesis (Analysis of Nonlinear Systems Chapter)

Page 34: MATH 175: Numerical Analysis II

STABILITY OF THE IVP

Check for sensitivity to changes in initial conditions.

Check for sensitivity to changes in the values of the parameters.

Do you have any idea how to roughly check for the stability of the IVP? (Do perturbations)

Page 35: MATH 175: Numerical Analysis II

WELL-POSEDNESS

An IVP that has a unique solution and is stable is said to be well-posed.

Before solving an IVP, please check its well-posedness…

Page 36: MATH 175: Numerical Analysis II

Examples• The good

• The bad

• The ugly

yy '

yy '

yyyy 1'

Also, solutions to IVP when y(0)=0 is not unique.