Professional Documents
Culture Documents
4 Secant Method
4 Secant Method
Objectives
1. To determine roots of an equation in single variable using Secant method.
2. To understand the MATLAB implementation of the Secant method.
3. To analyze of results using different initial values and error tolerance.
Algorithm
This method is similar to the Newton-Raphson method where an estimate of the root is predicted
by extrapolating a tangent of the function to the x-axis as shown by Figure 3. However, the
secant method uses a difference rather than a derivative to estimate the slope. The Secant
iterative updating formula can be written as
Termination Criteria:
where 𝑥i+1 is the root of current (new) iteration and 𝑥i is the root of previous (old) iteration. The
notation s𝑎,i+1(%) represents the error for current estimate of the root (𝑥i+1).
Pseudocode
FUNCTION SecRoot(x01, x02, es, imax)
i = 1
xi = x01
i = i + 1
xi = x02
DISPLAY x01, x02
eai = ∞
DO
xi+1 = xi – f(xi)(xi - xi-1)/(f(xi) - f(xi-1))
IF xi+1 ≠ 0 THEN
eai+1 = ABS((xi+1 – xi)/xi+1)*100
END IF
DISPLAY i-2, xi, f(xi), f(xi-1), eai
IF eai < es OR iter ≥ imax EXIT
i = i + 1
END DO
SecRoot = xi
END SecRoot
Practical Work
1. Use the MATLAB implementation of the Secant method to find a root of the function
ƒ(𝑥) = 𝑥3 − 2𝑥2 − 6𝑥 + 4 using the initial guesses x−1=−3∧x 0=−4
7
3. Use the MATLAB implementation of the Secant method to find a root of the function
ƒ(𝑥) = sin(x) + cos (1+x) -1 :