0% found this document useful (0 votes)
14 views

4 Secant Method

This lab experiment aims to determine roots of equations using the secant method. The secant method estimates the slope between two points to predict the next root, unlike Newton's method which uses derivatives. Students are instructed to use MATLAB to find roots of sample functions using different initial values and analyze the results.

Uploaded by

ibm2002i
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

4 Secant Method

This lab experiment aims to determine roots of equations using the secant method. The secant method estimates the slope between two points to predict the next root, unlike Newton's method which uses derivatives. Students are instructed to use MATLAB to find roots of sample functions using different initial values and analyze the results.

Uploaded by

ibm2002i
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

LAB EXPERIMENT # 3: ROOT FINDING USING SECANT METHOD

Name: Lecture time:

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

Figure 3: Graphical description of the Secant method.

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

𝑥i+1 = ƒ(𝑥i)(𝑥i − 𝑥i−1)


− ƒ(𝑥i) − ƒ(𝑥i−1)
𝑥i
From the above formula, an initial value is needed. The choice of the initial value will affect the
convergence of the solution.

Termination Criteria:

Defining the approximation error as

s𝑎,i+1(%) = |𝑥i+1−𝑥i| × 100%


𝑥i+1

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).

Then the computations will be terminated if

s𝑎(%) < s𝑠 𝑜𝑟 𝑚𝑎𝑥i𝑚𝑢𝑚 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜ƒ i𝑡𝑒𝑟𝑎𝑡i𝑜𝑛𝑠 i𝑠 𝑟𝑒𝑎𝑐ℎ𝑒𝑑

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

Iteration 𝗑i 𝑓(𝗑i) 𝑓(𝗑i−1) 𝗌𝑎,i(%)


0
1
2
3
4

2. Repeat step 2 using the initial guesses x−1=3∧x 0=2

Iteration 𝗑i 𝑓(𝗑i) 𝑓(𝗑i−1) 𝗌𝑎,i(%)


0
1
2
3
4
5
6

7
3. Use the MATLAB implementation of the Secant method to find a root of the function
ƒ(𝑥) = sin(x) + cos (1+x) -1 :

a- Using the initial guesses x−1=1∧x0 =3 , the approximate root is :

b- Using the initial guesses x−1=−5∧x 0=0 , the approximate root is :

c- Using the initial guesses x−1=1.5∧x 0=8.5 , the approximate root is :

You might also like