100 likes | 287 Views
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. Newton’s method. X old = 5.318
E N D
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 Lecture 11 Rootfinding – Newton’s and secant methods
Newton’s method Lecture 11 Rootfinding – Newton’s and secant methods
Xold = 5.318 f(xold) = 3.296 df/dx@ xold =7.955 Define slope: Xnew = 4.839 Xnew = 5.318 Xold = 4 f(xold) = -3.48 df/dx@ xold = 2.64 Lecture 11 Rootfinding – Newton’s and secant methods
Newton Method Calculations xold f(xold) df/dx@xold xnew 4.00 -3.48 2.64 5.31818 5.31818 3.2967 7.95467 4.90375 4.90375 0.394565 6.08148 4.83887 4.83887 0.008993 5.80503 4.837315 4.837315 0.0000051 5.79848 4.837315 Lecture 11 Rootfinding – Newton’s and secant methods
x init = -4.00 x root= -2.51601 steps = 4 x init = 4.00 x root= 4.83731 steps = 4 x init = 2.00 x root= 0.456469 steps = 3 Newton’s method Answer depends on where you start. Lecture 11 Rootfinding – Newton’s and secant methods
Function for Newton’s Method newtonexample.cpp code can be found in the Examples page. Lecture 11 Rootfinding – Newton’s and secant methods
X2 X4 = 4.8513 X2 = 4.5210 X3 = 4.7303 f(x2) = -1.6287 f(x3) = -0.5967 Secant method X1 = 6 f(x1) = 9.88 x1 and x0 don’t have to bound solution X0 = 4 f(x0) = -3.48 Lecture 11 Rootfinding – Newton’s and secant methods
Secant method table f(xn-1) xn-1 xn f(xn) xn+1 n 1 4.0000 -3.4800 6.0000 9.8800 4.5210 4.7303 9.8800 2 6.0000 4.5210 -1.6287 -1.6287 3 4.7303 -0.5967 4.8513 4.5210 4.8368 -0.5967 -0.0815 4.8513 4.7303 4 -.0032 5 4.8513 4.8373 -0.0815 4.8373 Lecture 11 Rootfinding – Newton’s and secant methods
Secant method function secantexample.cpp code can be found in the Examples page. Lecture 11 Rootfinding – Newton’s and secant methods
Comparing methods:Iterations required to reach a tolerance of 0.0001 Method Initial x x Root #Iterations substitution 4.0 4.8373 18 bisection 4.0, 6.0 4.8373 17 Newton’s 4.0 4.8373 4 Secant 4.0, 6.0 4.8373 5 Lecture 11 Rootfinding – Newton’s and secant methods