Program to demonstrate Secant method Program to demonstrate the Aitken Steffenson iteration method Explanation File of Program above (Steffen) NEW; Program to demonstrate Brent's method Explanation File of Program above (Zbrent) NEW; Define six real functions for Pegasus method Module to find a real root of a real function f(x) by Pegasus.
Secant method is considered to be the most effective approach to find the root of a non-linear function. It is a generalized from the Newton-Raphson method and does not require obtaining the derivatives of the function. So, this method is generally used as an alternative to Newton Raphson method.
Secant method falls under open bracket type. The programming effort may be a tedious to some extent, but the secant method algorithm and flowchart is easy to understand and use for coding in any high level programming language.
This method uses two initial guesses and finds the root of a function through interpolation approach. Here, at each successive iteration, two of the most recent guesses are used. That means, two most recent fresh values are used to find out the next approximation.
Features of Secant Method:
- No. of initial guesses – 2
- Type – open bracket
- Rate of convergence – faster
- Convergence – super linear
- Accuracy – good
- Approach – interpolation
- Programming effort – tedious
Secant Method Algorithm:
- Start
- Get values of x0, x1 and e
*Here x0 and x1 are the two initial guesses
e is the stopping criteria, absolute error or the desired degree of accuracy* - Compute f(x0) and f(x1)
- Compute x2 = [x0*f(x1) – x1*f(x0)] / [f(x1) – f(x0)]
- Test for accuracy of x2
If [ (x2 – x1)/x2 ] > e, *Here [ ] is used as modulus sign*
then assign x0 = x1 and x1 = x2
goto step 4
Else,
goto step 6 - Display the required root as x2.
- Stop
Secant Method Flowchart:
Also see,
Secant Method C Program
Secant Method MATLAB Program
Secant method is an improvement over the Regula-Falsi method, as successive approximations are done using a secant line passing through the points during each iteration. Following the secant method algorithm and flowchart given above, it is not compulsory that the approximated interval should contain the root.
Secant method is faster than other numerical methods, except the Newton Raphson method. Its rate of convergence is 1.62, which is quite fast and high. However, convergence is not always guaranteed in this method. But, overall, this method proves to be the most economical one to find the root of a function.
- 1The Secant Method
- 1.5Exercises
The secant method is an algorithm used to approximate the roots of a given function f. The method is based on approximating f using secant lines.
The Algorithm[edit]
The secant method algorithm requires the selection of two initial approximations x0 and x1, which may or may not bracket the desired root, but which are chosen reasonably close to the exact root.
Secant Method Algorithm |
---|
Given f(x)=0: Let x0 and x1 be initial approximations. where xn is a better approximation of the exact root, assuming convergence. Repeat iterative step until either
|
Order of Convergence[edit]
We would like to be able to find the order of convergence, p, for the secant method. Hence, we want to find some p so that where C is a constant.
Given a function f, let x be such that f(x)=0 and let xn-1 and xn be approximations to x. Assume x is a simple root and f is twice continuously differentiable (from the assumptions leading to convergence noted on Wikipedia). Let the error at the nth step be denoted by en: en=xn-x. Then we have:
.
Since f(x)=0 and recalling that en=xn-x, we can rewrite the last line above as:String Module Error: function rep expects a number as second parameter, received '
'(1) |
'
Next, let's just consider the numerator in (1).
Secant Method Matlab Example
Let where . ThusString Module Error: function rep expects a number as second parameter, received '
'(2) |
Fortran Program For Secant Method Worksheet
String Module Error: function rep expects a number as second parameter, received ''According to the Mean Value Theorem, on [xn-1,xn], there exists some between xn-1 and xn such that String Module Error: function rep expects a number as second parameter, received '
'(3) |
'Now using a Taylor expansion of around , we haveString Module Error: function rep expects a number as second parameter, received '
'(4) |
'
Next, we can combine equations (2), (3), and (4) to show that .
Returning to (1
), we now have:String Module Error: function rep expects a number as second parameter, received '
'(5) |
'
Again applying the Mean Value Theorem, there exists some in [xn-1,xn] such that . Then (5) becomes:
Next, recall that we have convergence of order p when for some constant . Our goal is to figure out what p is for the secant method.
Let
.
Then we have:.
We want , again where is some constant. Since and are constants and (assuming convergence) we must have . Thus .[1]
A Numerical Example[edit]
The function has a root between -3 and -4. Let's approximate this root accurate to four decimal places.
Let x0 = -3 and x1 = -4.
Next, using our recurrence formula where
and
we have:
In the next iteration, we use f(x1) = .6835 and f(x2) = .0342 and see that
Similarly, we can compute x4 and x5. These calculations have been organized in the table below:
0 | 1 | 2 | 3 | 4 | 5 | |
-3 | -4 | -3.2983 | -3.2613 | -3.2665 | -3.2665 |
Hence the iterative method converges to -3.2665 after 4 iterations.
Pseudo Code[edit]
Below is pseudo code that will perform iterations of the secant method on a given function f.
Exercises[edit]
Exercise 1[edit]
Find an approximation to correct to four decimal places using the secant method on .
We know .
Let x0 = 2 and x1 = 3. Then f(x0) = f(2) = -1 and f(x1) = f(3) = 4.
In our first iteration, we have:
In the second iteration, f(x1) = 4, f(x2) = -0.16 and we thus have
Similarly, x3 and x4 can be calculated, and are shown in the table below:
0 | 1 | 2 | 3 | 4 | 5 | |
2 | 3 | 2.2 | 2.2333 | 2.2361 | 2.2361 |
Thus after 4 iterations, the secant method converges to 2.2361, an approximation to correct to four decimal places.
Exercise 2[edit]
Find a root of by performing five iterations of the secant method beginning with x0 = -1 and x1 = 0.
1st Iteration: x0 = -1, x1 = 0, f(x0) = -0.63212, and f(x1) = 1. Then2nd Iteration: x1 = 0, x2 = -.6127, f(x1) = 1, and f(x2) = -.07081. Then
3rd Iteration: x2 = -.6127, x3 = -.57218, f(x2) = -.07081, and f(x3) = -.00789. Then
4th Iteration: x3 = -.57218, x4 = -.5671, f(x3) = -.00789, and f(x4) = 6.7843*10-5. Then
5th Iteration: x4 = -.5671, x5 = -.56714, f(x4) = 6.7843*10-5, and f(x5) = 5.1565*10-6. Then
Thus after 5 iterations, the method converges to -.56714 as one of the roots of .
Quiz[edit]
The following is a quiz covering information presented on the associated secant method page on Wikipedia as well as the current page.
References[edit]
- ↑http://www.radford.edu/~thompson/Fall10/434/Chapter4/secant_convergence.pdf