math 175: numerical analysis ii lecturer: jomar fajardo rabajante imsp, uplb 2 nd semester ay...

27
MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Upload: bryan-watson

Post on 24-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

MATH 175: NUMERICAL ANALYSIS II

Lecturer: Jomar Fajardo RabajanteIMSP, UPLB

2nd Semester AY 2012-2013

Page 2: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

CHAPTER 1: NUMERICAL METHODS IN SOLVING NONLINEAR EQUATIONS

This chapter involves numerically solving for the roots of an equation or zeros of a function.

e.g. Solve for x in

This problem may boil down in solving for the root of orsolving for the zeros of

2732 2 xxx

0242 2 xx242)( 2 xxxf

Page 3: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Go back to HS Math or Math 17

• The whole of Elementary Algebra (including college algebra) generally focuses on the ways and means of easily solving equations (or systems of equations)…

Why do we factor? Why do we simplify? Do these methods have real life applications? Probably, none?

Ahhh… Solving equations has...

Page 4: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Recall

MATH MODELING IN HIGH SCHOOL AND EARLY MATH SERIES…

Example: Age problem!!!

We need a working EQUATION in solving this problem… and how can we solve it?

Page 5: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Recall

Let us say we have a quadratic equation:- we can use factoring- we can use completing the square- we can use quadratic formula

But what if we have a cubic equation- we can use Cardano’s formula

Page 6: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Deadlock…

What if we have a polynomial of degree 8?Note that, from a theorem in Algebra (by Abel), we cannot have a closed-form formula for polynomials of degree higher than 4.

Or an equation involving transcendentals?e.g. 4)sin(5)cos(

2

xexx

Page 7: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

A Naïve way…

GRAPH IT!!!

Then get the zeros of f !!!

4)sin(5)cos()(

4)sin(5)cos(2

2

x

x

exxxf

exx

Page 8: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

You can use MS Excel, GraphCalc, Grapes, etc…

Page 9: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

A Naïve way…

Ah, eh… but what is the exact value?

Or if we cannot get the exact value, what is the nearest solution? (say with error at most 10-4)

4)sin(5)cos()(

4)sin(5)cos(2

2

x

x

exxxf

exx

Page 10: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

First Method: Exhaustive search or Incremental search

Just use MS Excel…

Let’s say we want to get this zero

Page 11: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

=COS(A123)+5*SIN(A123)+EXP(A123^2)-4

=A122+0.0001

Page 12: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

We want f(x)=0, so if f(0.3919)=-0.000082≈0, then our APPROXIMATE solution is 0.3919.

Smaller step sizes increases our accuracy.

However, we cannot measure the order of convergence.

Page 13: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

First Method: Exhaustive search or Incremental search

Exhaustive search may miss a blip:

Page 14: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection (a bracketing method)

Recall IVT (specifically the Intermediate Zero Theorem) and Math 174 discussion about Bisection Method

Page 15: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection1. Given f(x), choose the initial interval [x1,1 ,x2,1] such

that f(x1,1)*f(x2,1)<0.

Input tol, the tolerance error level. Input kmax, maximum number of iterations. Define a counter, say k, to keep track of the number of bisections performed.

2. For k<kmax+2 (starting k=2), compute x3,k := (x1,k-1 + x2,k-1)/2. Set x3,1 := x1,1 . If |x3,k – x3,k-1|<tol then print results and exit the program (the root is found in k-1 iterations). Otherwise, if f(x1,k-1)*f(x3,k)<0 then set x2,k := x3,k and x1,k := x1,k-1 , else set x1,k := x3,k and x2,k := x2,k-1.

3. If convergence is not obtained in kmax+1 iterations, inform the user that the tolerance criterion was not satisfied, and exit the program.

Page 16: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

DIFFERENT STOPPING CRITERIONRecall Math 174

Terminate when:

tolx

xx

tolxx

fxf

k

kk

kk

tolk

,3

1,3,3

1,3,3

,3 )(

If tol=10-n, then x3,k should approximate the true value to n decimal places orn significant digits

delikado

Page 17: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

DIFFERENT STOPPING CRITERIONRecall Math 174

Terminate when:

bigk

bigk

xx

fxf

kk

,3

,3

max

)(

Iterations have gone on “long enough”

Page 18: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection

Notice that this algorithm locates only one root of the equation at a time. When an equation has multiple roots, it is the choice of the initial interval provided by the user which determines which root is located.

The contrary condition, f(a)*f(b)>0 does NOT imply that there are no real roots in the interval [a,b].

Convergence of bisection method is guaranteed provided that IVT (IZT) is always met in every iteration.

Page 19: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection

The bisection algorithm will fail in this case

2xy

Page 20: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection

The bisection algorithm may also fail in these cases:-not continuous on the initial interval -multiple roots (may fail to converge to the desired root). It is better to bracket only one root.

Page 21: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection

How many iterations do we need to have an answer accurate at least up to m decimal places?

Let n be the number of iterations, n>1.

Note that the computed n should be rounded-up to the nearest integer.

mabn 10)(log2

Page 22: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection

DERIVATIONLength of the 1st interval: b – aLength of the 2nd interval: (b – a)/2 Length of the n-th interval: (b – a)/2n–1

At the n-th iteration we get the midpoint, so the length of the interval will become: (b – a)/2n

Page 23: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection

DERIVATIONLet x* be the exact root.

mnn

abxx

10

2*

m

nm

abn

ab

10log

210

2

n

HENCE, THE (worst-case) NUMBER OF ITERATIONS NEEDED IS:

Page 24: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

ORDER OF CONVERGENCE(Q-convergence)

Given an asymptotic error constant λ>0, the sequence {x3,k} converges to x* with order p>0 iff

p

k

k

k xx

xx

*1

*

lim

Order of convergence: pIf p=1, rate of convergence: O(λk)

Page 25: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

ORDER OF CONVERGENCEWhen p=1

If 0<λ<1, then the sequence {x3,k} converges to x* linearly

If λ=1, then the sequence {x3,k} converges to x* sublinearly

If λ=0, then the sequence {x3,k} converges to x* superlinearly, meaning it is possibly also of quadratic order, or possibly of higher order (but definitely faster than mere linear, e.g. p=1.6, p=2, p=3, etc…)

As λ becomes nearer to 0, the convergence gets faster.

Page 26: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

ORDER OF CONVERGENCEWhen p=r>1

If 0<λ<∞, then the sequence {x3,k} converges to x* with order r

If λ=∞, then the sequence {x3,k} converges to x* with order less than r

If λ=0, then the sequence {x3,k} converges to x* possibly also with order r+1 or possibly of higher order (but definitely faster than mere order r)

As λ becomes nearer to 0, the convergence gets faster.

Page 27: MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY 2012-2013

Second Method: Bisection

ORDER OF CONVERGENCE

21 k

k

errorerrorRecall:

2

1lim

*

*lim

11

1,3

,3

k

k

kk

k

k error

error

xx

xx

Hence, bisection method converges to the root linearly (p=1… slow!)

Rate of convergence: O(1/2k)

meaning the error is reduced by half in every iteration.