Docsity

Solving Nonlinear Equations and Zero Finding: Secant and Newton's Methods, Study notes of Mathematics

Partial preview of the text

Download Solving Nonlinear Equations and Zero Finding: Secant and Newton's Methods and more Study notes Mathematics in PDF only on Docsity!

Computational Methods CMSC/AMSC/MAPL 460

Solving nonlinear equations and zero finding

Ramani Duraiswami,

Dept. of Computer Science

Secant method

-^

Instead in the secant methodchoose two points

-^

Fit straight line and evaluateits zero

xk+

= x

− k

f(x

)(xk

k^

–x

k-

)/(f(x

)-f(xk

k-

-^

Choose next point and repeat

-^

Convergence is superlinear

-^

ek+

=c. e

φk

-^

½

Convergence analysis

•^

For iterative algorithms, we want to know how the error decreasesafter each iteration

-^

We also want to check how much each iteration costs

-^

Optimal algorithm is the one that achieves a given error for a givencost

-^

Algorithm

convergence

function evaluations per step

•^

Bisection

Linear

One

•^

Secant

Superlinear

One

•^

Newton

Quadratic

Two

•^

Which method is better?

-^

Define better:

-^

Bisection guaranteed to converge, but slow

-^

Secant one evaluation per step Newton: two

-^

Newton quadratic convergence Secant super linear

-^

Newton needs derivative, which may be unavailable

Comparing convergence

-^

Suppose cost of function evaluations for derivative andfunction are similar

-^

Then let Newton method converge in

n

steps to error

-^

So e

2n 0

-^

Secant will require

s

steps to ensure e

1.62s 0

-^

So cost of Newton is 2n while that of secant is s

-^

Which is larger?

-^

Take logs: 2n log e

0

log

-^

So 2n

| log

| / |log e

n

(| log

| / |log e

-^

For secant: s

(| log

| / |log e

-^

So Cost

Newton

/Cost

Secant

-^

So Secant is cheaper!

Inverse Quadratic Interpolation

-^

Secant method fits a straight line topredict zero from two previous values

-^

We could instead fit a parabola to predictthe zero from three values!

-^

However parabola may not intersect x axis(straight line will always)–

In this case roots will be complex

-^

Idea of inverse quadratic interpolation–

Fit a parabola x=f(y

2 ) instead of a parabola

y=f(x

2 )

-^

Evaluate it at 0

-^

Problem: polynomial interpolation needsthe points (here function values) to bedistinct

-^

Cannot guarantee this!

-^

So method may not converge

-^

However near solution it converges veryrapidly

k = 0;fa=f(a)fb=f(b)fc=f(c)while abs(c-b) > eps*abs(c)

x = polyinterp([fa,fb,fc],[a,b,c],0)a = b;fa=fb;b = c;fb=fc;c = x;fc=f(x);k = k + 1; end

Guaranteed methods: Zeroin

-^

Start with

a

and

b

so that

f

( a

) and

f

( b

) have opposite

signs.

-^

Use a secant step to give

c

between

a

and

b

-^

Repeat until

|b

a| <

ε^

|b|

or

f

( b

  • Arrange

a

,^ b

, and

c

so that

-^

f ( a

) and

f (

b ) have opposite signs.

  • |

f ( b

) | < |f

( a

) |

-^

c^

is the previous value of

b

.

-^

If

c

a

, consider an IQI step.

-^

If

c

a

, consider a secant step.

-^

If the IQI or secant step is in the interval [a,b], take it.

-^

If the step is not in the interval, use bisection.

Golden Search

•^

Let [0,2/3] be the reduced domain

-^

At next step we cannot reuse our function evalution at 1/3 (whichis the mid-point of our interval)

-^

Instead we must evaluate the function at 2/9 and 4/9.

-^

Thus each iteration requires two function evaluations.

-^

Can we instead choose points (not at 1/3 and 2/3) but at some otherpoints

ρ

and 1-

ρ,

so that the point can be reused in the next step

•^

So

ρ

ρ

ρ)/

•^

ρ^

(^2) ρ

ρ

•^

(^2) ρ

ρ

•^

ρ=(

•^

ρ= 1+(1-

φ=0.382..

•^

Length of interval is reduced by a factor of

φ

0.618 each step

-^

So to converge to machine epsilon we require 52/0.

'

75 steps

Improved Golden Search:

fminbd

•^

As the search proceeds, we will have three points in the intervalwith the minimum

-^

Fit a parabola and find the minimum

-^

If the minimum is within the interval, we can choose it as the nextpoint

-^

To stop: recall near a minimum derivative vanishes

-^

So

f(x)=f(x

)+b(x-x*

)*^

2

•^

Let

x-x

δ^

and

f(x

)=a*

f(x)=a+b

•^

If the interval

δ^

is as small as machine

ε

, then the change in the

value of f will of the order of machine

ε

•^

SO it is not computable

-^

Rather change can at most be about the square root of machine

ε

•^

This is employed in Matlab function

fminbd

and in the book

software function

fmintx

Multidimensional Newton’s Method

•^

f^1

( x

)=f

(x 1

, x 1

, …, x 2

)N
•^

f^2

( x

)=f

(x 2

, x 1

, …, x 2

)N
•^
•^

fM

( x

)=f

M^

(x

, x 1

, …, x 2

)N
•^

f^1

( x

  • h

)=f

(x 1

, x 1

, …, x 2

)+N

f^1

·^ h

•^
•^

fM

( x

h )=f

(x 1

, x 1

, …, x 2

)+N

fM

·^ h

•^

f^1

= [

∂^

f^1

/^ ∂

x

1

∂^

f^1

/^ ∂

x

f^1

/^ ∂

x

N^

]
•^
•^

fM

= [

∂^

fM

/^ ∂

x

1

∂^

fM

/^ ∂

x

fM

/^ ∂

x

N^

]
•^

f (

x +

h )=

f (

x )+

Jh

=^0
•^

Solve

Jh=-f

to find the step

•^

x^ k+

=x

+hk