Professional Documents
Culture Documents
Secant Method
A report in
Numerical Analysis
Prepared by
Mhamad Jabar Amez Amanj
Mhamad Talib Shvan Fuad
Akar Najmadin
Supervised by
Bawar Mohammed Faraj
10 December 2021Table of Contents
Table of Contents.........................................................................................................................................i
Introduction.................................................................................................................................................1
Algorithm of the method.............................................................................................................................2
Example.......................................................................................................................................................3
MATLAB Code of Secant Method................................................................................................................4
Advantages of secant method:....................................................................................................................5
Disadvantages of secant method:...............................................................................................................5
Conclusion...................................................................................................................................................6
References...................................................................................................................................................7
i
Introduction
Secant method is also a recursive method for finding the root for the
polynomials by successive approximation. It’s similar to the Regular-
falsi method but here we don’t need to check f(x1)f(x2)<0 again and
again after every approximation. In this method, the neighbourhoods
roots are approximated by secant line or chord to the function f(x). It’s
also advantageous of this method that we don’t need to differentiate
the given function f(x), as we do in Newton-raphson method.
1
Algorithm of the method
Step 1: Choose two starting points x0 and x1.
Step 2: Let
Step 4: End.
2
Example :
A real root of the equation f(x) = x3 – 5x + 1 = 0 lies in the interval (0, 1). Perform
four iterations of the secant method.
Solution –
We have, x0 = 0, x1 = 1, f(x0) = 1, f(x1) = – 3
x2 = x1 – [( x0 – x1) / (f(x0) – f(x1))]f(x1)
= 1 – [ (0 – 1) / ((1-(-3))](-3)
= 0.25.
f(x2) = – 0.234375
The second approximation is,
x3 = x2 – [( x1 – x2) / (f(x1) – f(x2))]f(x2)
=(– 0.234375) – [(1 – 0.25)/(–3 – (– 0.234375))](– 0.234375)
= 0.186441
f(x3)= 0.074276
The third approximation is,
x4 = x3 – [( x2 – x3) / (f(x2) – f(x3))]f(x3)
= 0.186441 – [( 0.25 – 0.186441) / ( – 0.234375) – (0.074276) ](– 0.234375)
= 0.201736.
f(x4) = – 0.000470
The fourth approximation is,
x5 = x4 – [( x3 – x4) / (f(x3) – f(x4))]f(x4)
= 0.201736 – [( 0.186441 – 0.201736) / (0.074276 – (– 0.000470)](– 0.000470)
= 0.201640
3
MATLAB Code of Secant Method
clc;
f=inline('x^2-2');
x0=input('Enter x0=');
x1=input('Enter x1=');
tol=input('Enter tolarance=');
itr=input('Enter number of iteration=');
p=0;
for i=1:itr
x2=(x0*f(x1)-x1*f(x0))/(f(x1)-f(x0));
if abs(x2-x1)<tol
p=1;
k=i;
break;
else
x0=x1;
x1=x2;
end
end
if p==1
fprintf('Solution is %f at iterations %i',x2,k)
else
fprintf('No convergent solution exist in the given number iteration')
end
4
Advantages of secant method:
1. It converges at faster than a linear rate, so that it is more rapidly
convergent than the bisection method.
5
Conclusion
6
References
https://www.codesansar.com/numerical-methods/secant-method-algorithm.htm
http://hplgit.github.io/Programming-for-Computations/pub/p4c/._p4c-bootstrap-
Matlab027.html
Secant Method of Numerical analysis - GeeksforGeeks
Secant Method - Numeric Method (google.com)