Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 11 Rootfinding – Newton’s and secant methods 1 Lecture 11  More root finding methods  Newton’s method  Very fast way to find roots  Requires.

Similar presentations


Presentation on theme: "Lecture 11 Rootfinding – Newton’s and secant methods 1 Lecture 11  More root finding methods  Newton’s method  Very fast way to find roots  Requires."— Presentation transcript:

1 Lecture 11 Rootfinding – Newton’s and secant methods 1 Lecture 11  More root finding methods  Newton’s method  Very fast way to find roots  Requires taking the derivative of f(x)  Can be unstable if ‘unattended’  Secant method  Similar to Newton’s method, but derivative is numerical not analytical

2 Lecture 11 Rootfinding – Newton’s and secant methods 2 Newton’s method

3 Lecture 11 Rootfinding – Newton’s and secant methods 3 Define slope: X old = 4 f(x old ) = -3.48 df/dx@ x old = 2.64 X old = 5.318 f(x old ) = 3.296 df/dx@ x old =7.955 X new = 5.318 X new = 4.839

4 Lecture 11 Rootfinding – Newton’s and secant methods 4 Newton Method Calculations xoldf(xold)df/dx@xoldxnew 4.00-3.48 2.645.31818 5.318183.2967 7.954674.90375 4.903750.394565 6.081484.83887 4.838870.008993 5.805034.837315 4.8373150.0000051 5.798484.837315

5 Lecture 11 Rootfinding – Newton’s and secant methods 5 Newton’s method Answer depends on where you start. x init = 2.00 x root = 0.456469 steps = 3 x init = 4.00 x root = 4.83731 steps = 4 x init = -4.00 x root = -2.51601 steps = 4

6 Lecture 11 Rootfinding – Newton’s and secant methods 6 Function for Newton’s Method newtonexample.cpp code can be found in the Examples page.

7 Lecture 11 Rootfinding – Newton’s and secant methods 7 X 0 = 4 f(x 0 ) = -3.48 Secant method X 2 = 4.5210 X 1 = 6 f(x 1 ) = 9.88 X 3 = 4.7303 x 1 and x 0 don’t have to bound solution f(x 2 ) = -1.6287 f(x 3 ) = -0.5967 X 4 = 4.8513 X2X2

8 Lecture 11 Rootfinding – Newton’s and secant methods 8 n xn-1xn f(xn-1) f(xn)xn+1 1 4.0000-3.48006.00009.88004.5210 26.0000 9.8800 4.5210-1.6287 4.7303 3 4.5210 -1.6287 4.7303 -0.59674.8513 4 4.7303 -0.5967 4.8513 -0.0815 4.8368 54.8513 -0.08154.8373 -.0032 4.8373 Secant method table

9 Lecture 11 Rootfinding – Newton’s and secant methods 9 Secant method function secantexample.cpp code can be found in the Examples page.

10 Lecture 11 Rootfinding – Newton’s and secant methods 10 Comparing methods: Iterations required to reach a tolerance of 0.0001 MethodInitial xx Root#Iterations substitution4.04.837318 bisection4.0, 6.04.837317 Newton’s4.04.83734 Secant4.0, 6.04.83735


Download ppt "Lecture 11 Rootfinding – Newton’s and secant methods 1 Lecture 11  More root finding methods  Newton’s method  Very fast way to find roots  Requires."

Similar presentations


Ads by Google