Secant Method Algorithm (Step Wise)
This article explains an algorithm for Secant method step wise for solving non-linear equation numerically.
Secant Method is open method and starts with two initial guesses for finding real root of non-linear equations.
In Secant method if x0 and x1 are initial guesses then next approximated root x2 is obtained by following formula:
x2 = x1 - (x1-x0) * f(x1) / ( f(x1) - f(x0) )
And an algorithm for Secant method involves repetition of above process i.e. we use x1 and x2 to find x3 and so on until we find the root within desired accuracy.
Algorithm: Secant Method
1. Start 2. Define function as f(x) 3. Input initial guesses (x0 and x1), tolerable error (e) and maximum iteration (N) 4. Initialize iteration counter i = 1 5. If f(x0) = f(x1) then print "Mathematical Error" and goto (11) otherwise goto (6) 6. Calcualte x2 = x1 - (x1-x0) * f(x1) / ( f(x1) - f(x0) ) 7. Increment iteration counter i = i + 1 8. If i >= N then print "Not Convergent" and goto (11) otherwise goto (9) 9. If |f(x2)| > e then set x0 = x1, x1 = x2 and goto (5) otherwise goto (10) 10. Print root as x2 11. Stop