Secant Method C Program

2 Ways To Implement Secant Method in C Programming

Let’s understand the secant method in numerical analysis and implement secant method in C programming language.

What is Secant Method?

The secant method is a root-finding method that uses a succession of the roots of secant lines to find a better approximation of root.


The secant method algorithm is a root bracketing method and is the most efficient method of finding the root of a function. It requires two initial guesses which are the start and end interval points. This method is very similar to the Regula Falsi method.

The secant method is a Quasi-Newton method and it is seen to be faster in execution in some scenarios as compared to Newton-Raphson method and the False Position Method well.

The secant algorithm does not ensure convergence. The rate of convergence of secant method algorithm is 1.618, which is really fast comparatively. The order of convergence of secant method is superlinear.

The equation used in the following secant method c programs are as follows:

  • x3 – 5x + 3
  • x3 – 3x – 8

Secant Method Formula

Secant Method Formula For Numerical Analysis

Secant Method Algorithm

 


  1. Assume an equation f(x) = 0 (which must be defined)
  2. Input Start and End values of the Interval
  3. Do
    xi+1 = xi – (f(xi) – (xi – xi-1)/(f(xi) – f(xi-1))
    where i = 1, 2, 3, 4, …..
    (while no convergence criteria is achieved)

Convergence criteria for Secant Method

 

  1. Fixing apriori the total number of iterations (limit).
  2. Testing the condition (xi+1−xi), is less than some tolerance limit (epsilon).

Note: This code for secant method in C programming is compiled with GNU GCC compiler on CodeLite IDE. However, these codes are compatible with all other operating systems.

Method 1: C Program For Secant Method in Numerical Analysis


Output

Implement Secant Method in C Programming using While Loop

Method 2: Implement Secant Method in C Programming using While Loop

Output

C Program For Secant Method To Find Roots of Equation

Let’s discuss more on secant method C program in the comment section below if you have any compilation errors and any doubts about the same. For more information on secant root finding method, check WikiPedia.

Let's Discuss