0% found this document useful (0 votes)
74 views7 pages

Derivation of The Method

The secant method is a root-finding algorithm that uses successive lines intersecting a function at two points to approximate roots. It can be viewed as a finite difference approximation of Newton's method. The method works by first using two initial x-values to construct the line between those points, then finding the x-value where that line crosses y=0. This new x-value replaces one of the initial values, and the process repeats to convergence. The secant method converges superlinearly to a simple root if the initial values are close. It requires evaluating only the function, not its derivative. An example C++ program demonstrates using the secant method to find a root of cos(x)-x^3=0

Uploaded by

Nipun Umat
Copyright
© Attribution Non-Commercial (BY-NC)
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)
74 views7 pages

Derivation of The Method

The secant method is a root-finding algorithm that uses successive lines intersecting a function at two points to approximate roots. It can be viewed as a finite difference approximation of Newton's method. The method works by first using two initial x-values to construct the line between those points, then finding the x-value where that line crosses y=0. This new x-value replaces one of the initial values, and the process repeats to convergence. The secant method converges superlinearly to a simple root if the initial values are close. It requires evaluating only the function, not its derivative. An example C++ program demonstrates using the secant method to find a root of cos(x)-x^3=0

Uploaded by

Nipun Umat
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 7

SECANT:a straight line intersecting the curve at two or more points(from latin

word secans:to cut)

In numerical analysis, the secant method is a root-finding algorithm that uses a


succession of roots of secant lines to better approximate a root of a function f.
The secant method can be thought of as a finite difference approximation of
Newton's method. However, the method was developed independently of
Newton's method, and predated the latter by over 3000 years

The method

The first two iterations of the secant method. The red curve shows the function f
and the blue lines are the secants.

The secant method is defined by the recurrence relation

As can be seen from the recurrence relation, the secant method requires two
initial values, x0 and x1, which should ideally be chosen to lie close to the root.

Derivation of the method


Starting with initial values x0 and x1, we construct a line through the points
(x0,f(x0)) and (x1,f(x1)), as demonstrated in the picture on the right. In point-
slope form, this line has the equation

We find the root of this line - the value of x such that y=0 - by solving the
following equation for x:

The solution is

We then use this value of x as x2 and repeat the process using x1 and x2 instead
of x0 and x1. We continue this process, solving for x3, x4, etc., until we reach a
sufficiently high level of precision (a sufficiently small difference between xn
and xn-1).

...

Convergence

The iterates xn of the secant method converge to a root of f, if the initial values
x0 and x1 are sufficiently close to the root. The order of convergence is α, where

is the golden ratio. In particular, the convergence is superlinear.

This result only holds under some technical conditions, namely that f be twice
continuously differentiable and the root in question be simple (i.e., with
multiplicity 1).
If the initial values are not close to the root, then there is no guarantee that the
secant method converges.

Comparison with other root-finding methods

The secant method does not require that the root remain bracketed like the
bisection method does, and hence it does not always converge. The false
position method uses the same formula as the secant method. However, it does
not apply the formula on xn−1 and xn, like the secant method, but on xn and on the
last iterate xk such that f(xk) and f(xn) have a different sign. This means that the
false position method always converges.

The recurrence formula of the secant method can be derived from the formula
for Newton's method

by using the finite difference approximation

If we compare Newton's method with the secant method, we see that Newton's
method converges faster (order 2 against α ≈ 1.6). However, Newton's method
requires the evaluation of both f and its derivative at every step, while the secant
method only requires the evaluation of f. Therefore, the secant method may well
be faster in practice. For instance, if we assume that evaluating f takes as much
time as evaluating its derivative and we neglect all other costs, we can do two
steps of the secant method (decreasing the logarithm of the error by a factor α² ≈
2.6) for the same cost as one step of Newton's method (decreasing the logarithm
of the error by a factor 2), so the secant method is faster. If however we
consider parallel processing for the evaluation of the derivative, Newton's
method proves its worth, being faster in time, though still spending more steps.
The following C++ code is written : to find the positive number x where cos(x)
= x3. This problem is transformed into a root-finding problem of the form f(x) =
cos(x) − x3 = 0.

In the code below, the secant method continues until one of two conditions
occur:

1. | xn + 1 − xn | < ε or,
2. n > m

for some given m and ε.

#include <stdio.h>
#include <math.h>
#include<conio.h>

double f(double x)
{
return cos(x) - x*x*x;
}

double SecantMethod(double xn_1, double xn, double e, int m)


{
int n;
double d;
for (n = 1; n <= m; n++)
{
d = (xn - xn_1) / (f(xn) - f(xn_1)) * f(xn);
if (fabs(d) < e)
return xn;
xn_1 = xn;
xn = xn - d;
}
return xn;
}
int main(void)
{
clrscr();
cout<<"\WE HAVE TO FIND THE ROOTS OF THE EQUATION cos x
– x^3=0";
cout<<"\nEnter the first coordinate of the initial approximation:- ";
cin>>xn;
cout<<"\nEnter the second coordinate of the initial approximation:- ";
cin>>xn_1;
cout<<"\nEnter the accuracy level or tolerance expected:- ";
cin>>e;
cout>>(“\nThe output is :”SecantMethod(xn, xn_1,e, 100));
return 0;
}

OUTPUT
The equation is x^2-4x+3=0
Enter the first coordinate of the initial approximation:-
0
Enter the second coordinate of the initial approximation:-
1
Enter the accuracy level or tolerance expected:-
5E-11
The output is:0.865474033101614
------------------------------------------------------------------------------------------------
-------------

MINOR PROJECT IN C++


TOPIC : THE SECANT METHOD FOR FINDING THE
ROOT OF A GIVEN EQUATION
NAME:Nipun Umat

ROLL NO.:2k8/EE/844

D.T.U.(D.C.E.)

You might also like