120 likes | 562 Views
Chapter 2. Solution of Nonlinear Equations: Lecture (III). Outline. Numerical methods (3) Secant method. Secant method. Secant method algorithm: An approximation to the derivative: 1. Start with two initial guesses x 1 and x 2 and . set i = 2. 2. Find the new approximation, x i+1 .
E N D
Chapter 2 Solution of Nonlinear Equations: Lecture (III)
Outline • Numerical methods (3) Secant method
Secant method • Secant method algorithm: An approximation to the derivative: 1. Start with two initial guesses x1 and x2 and . set i = 2. 2. Find the new approximation, xi+1. 3. Verify the convergence. If |f(xi+1)|, stop the process by taking xi+1 as the root. Otherwise, set i=i+1 and go to step 2.
Notes on Secant method • Secant method is similar to Newton’s method but uses a back-ward finite-difference approximation for the derivative, f’(x). • Secant method may not converge (see an example on the left).
Example: Secant method • Example 2.14: Find the root of the equation using Secant method with two initial guesses xl = 0.0 and x2 = 0.5 and the convergence criterion, |f(xi)| with = 10-5.
x1=0.0, x2=0.5, =10-5, i=2 i=i+1 F |f(xi+1)| T x_Root=xi+1 end Secant Method Flowchart
Implement Secant method: by hand • Show work step by step. Keep up to 8 decimal places in your calculations. • Also, summarize the results in the Table below.
Implement Secant method: write an M-file • For the Example given on slide #5, write an M-file to compute the root of the equation using Secant method. • Follow the flowchart provided previously. • Save the M-file as mySecant.m. • A copy of the M-file will be handed out later.