Secant Method Pseudocode

Earlier in Secant Method Algorithm, we discussed about an algorithm for computing real root of non-linear equation using Secant Method. In this tutorial we are going to develop pseudocode for this method so that it will be easy while implementing using programming language.

Complete Pseudocode for Secant Method

1. Start

2. Define function as f(x)

3. Input:
	a. Initial guess x0, x1
	b. Tolerable Error e
	c. Maximum Iteration N


4. Initialize iteration counter step = 1


5. Do 
	If f(x0) = f(x1)
		Print "Mathematical Error"
		Stop
	End If

	x2 = x1 - (x1 - x0) * f(x1) / ( f(x1) - f(x0) )
	x0 = x1
	x1 = x2
	step = step + 1
	If step > N
		Print "Not Convergent"
		Stop
	End If

   While abs f(x2) > e 

6. Print root as x2

7. Stop

Recommended Readings

  1. Secant Method Algorithm
  2. Secant Method Pseudocode
  3. Secant Method Using C with Output
  4. Secant Method Using C++ with Output