Transcript PPT
Secant Method Mechanical Engineering Majors Authors: Autar Kaw, Jai Paul http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates 7/12/2016 http://numericalmethods.eng.usf.edu 1 Secant Method http://numericalmethods.eng.usf.edu Secant Method – Derivation Newton’s Method f(x) x f x f(xi) i, f(xi ) xi 1 = xi f (xi ) (1) i Approximate the derivative f ( xi ) f(xi-1) xi+2 xi+1 xi X Figure 1 Geometrical illustration of the Newton-Raphson method. 3 f ( xi ) f ( xi 1 ) xi xi 1 (2) Substituting Equation (2) into Equation (1) gives the Secant method xi 1 f ( xi )( xi xi 1 ) xi f ( xi ) f ( xi 1 ) http://numericalmethods.eng.usf.edu Secant Method – Derivation The secant method can also be derived from geometry: f(x) f(xi) The Geometric Similar Triangles AB DC AE DE B can be written as f ( xi ) f ( xi 1 ) xi xi 1 xi 1 xi 1 C f(xi-1) xi+1 E D xi-1 A xi X Figure 2 Geometrical representation of the Secant method. 4 On rearranging, the secant method is given as xi 1 f ( xi )( xi xi 1 ) xi f ( xi ) f ( xi 1 ) http://numericalmethods.eng.usf.edu Algorithm for Secant Method 5 http://numericalmethods.eng.usf.edu Step 1 Calculate the next estimate of the root from two initial guesses xi 1 f ( xi )( xi xi 1 ) xi f ( xi ) f ( xi 1 ) Find the absolute relative approximate error xi 1- xi a = 100 xi 1 6 http://numericalmethods.eng.usf.edu Step 2 Find if the absolute relative approximate error is greater than the prespecified relative error tolerance. If so, go back to step 1, else stop the algorithm. Also check if the number of iterations has exceeded the maximum number of iterations. 7 http://numericalmethods.eng.usf.edu Example 1 A trunnion has to be cooled before it is shrink fitted into a steel hub The equation that gives the temperature x to which the trunnion has to be cooled to obtain the desired contraction is given by the following Figure 3 Trunnion to be slid through equation. the hub after contracting. f x 0.50598 1010 x3 0.38292 107 x 2 0.74363 104 x 0.88318 102 0 8 http://numericalmethods.eng.usf.edu Example 1 Cont. Use the secant method of finding roots of equations a) To find the temperature x to which the trunnion has to be cooled. Conduct three iterations to estimate the root of the above equation. b) Find the absolute relative approximate error at the end of each iteration, and c) 9 the number of significant digits at least correct at the end of each iteration. http://numericalmethods.eng.usf.edu Example 1 Cont. Cool down temperature 0.02 0.015 f(x) 0.01 0.005 0 -400 -300 -200 -100 -0.005 0 100 -0.01 Temperature (F) Figure 4 Graph of the function f(x). f x 0.50598 1010 x3 0.38292 107 x 2 0.74363 104 x 0.88318 102 0 10 http://numericalmethods.eng.usf.edu Example 1 Cont. 8.83210 3 Initial guesses: x1 110, x0 130 Iteration 1 The estimate of the root is 0.01 0.008 0.006 x1 x0 f ( x) 0.004 f ( x) f ( x) 0.002 secant ( x) 0 x1 0.002 0.004 4.48610 3 0.006 7.709110 130 110 130 7.709110 1.1825 10 5 0 f ( x) f x0 x0 x1 f x0 f x1 200 150 200 100 50 x x 0 x 1' x x 1 f(x) x'1, (first guess) x0, (previous guess) Secant line x1, (new guess) Figure 5 Graph of the estimated root after Iteration 1. 0 0 5 3 128.78 The absolute relative approximate error is x1 x0 a x1 100 0.95051% The number of significant digits at least correct is 1. 11 http://numericalmethods.eng.usf.edu Example 1 Cont. 8.83210 3 Iteration 2 The estimate of the root is 0.01 0.008 0.006 x2 x1 f ( x) 0.004 f ( x) f ( x) 0.002 secant ( x) 0 x2 0.002 0.004 4.41110 3 0.006 200 150 100 200 x x 1 x 0 x x 2 50 1.3089 10 128.78 130 128.78 1.3089 10 7.709110 6 0 f ( x) f x1 x1 x0 f x1 f x0 0 0 f(x) x1 (guess) x0 (previous guess) Secant line x2 (new guess) Figure 6 Graph of the estimated root after Iteration 2. 6 128.75 The absolute relative approximate error is x2 x1 a 100 0.016419% x2 The number of significant digits at least correct is 3. 12 5 http://numericalmethods.eng.usf.edu Example 1 Cont. Entered function along given interval with current and next root and the tangent line of the curve at the current root 8.83210 3 0.01 f x2 x2 x1 x3 x2 f x2 f x1 f ( x) 0.005 f ( x) f ( x) secant ( x) 0 0 f ( x) 4.41610 Iteration 3 The estimate of the root is 1.524110 128.75 128.78 128.7548 1.524110 1.3089 10 9 x3 3 0.005 200 150 100 200 x x 2 x 1 x x 3 50 0 9 6 0 f(x) x2 (guess) x1 (previous guess) Secant line x3 (new guess) Figure 7 Graph of the estimated root after Iteration 3. 128.75 The absolute relative approximate error is x3 x2 a 100 1.9097 105 % x3 The number of significant digits at least correct is 6. 13 http://numericalmethods.eng.usf.edu Advantages 14 Converges fast, if it converges Requires two guesses that do not need to bracket the root http://numericalmethods.eng.usf.edu Drawbacks 2 2 1 f ( x) f ( x) 0 0 f ( x) 1 2 2 10 5 10 0 5 x x guess1 x guess2 f(x) prev. guess new guess 10 10 f x Sinx 0 Division by zero 15 http://numericalmethods.eng.usf.edu Drawbacks (continued) 2 2 1 f ( x) f ( x) 0 f ( x) 0 secant ( x) f ( x) 1 2 2 10 5 10 0 5 10 x x 0 x 1' x x 1 f(x) x'1, (first guess) x0, (previous guess) Secant line x1, (new guess) 10 f x Sinx 0 Root Jumping 16 http://numericalmethods.eng.usf.edu Additional Resources For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/secant_me thod.html THE END http://numericalmethods.eng.usf.edu