The secant method is used to find the root of an equation f(x) = 0. It is started from two distinct estimates x1 and x2 for the root. It is an iterative procedure involving linear interpolation to a root. The iteration stops if the difference between two intermediate values is less than convergence factor.
Input : equation = x3 + x - 1 x1 = 0, x2 = 1, E = 0.0001 Output : Root of the given equation = 0.682326 No. of iteration=5
Initialize: x1, x2, E, n // E = convergence indicator calculate f(x1),f(x2) if(f(x1) * f(x2) = E); //repeat the loop until the convergence print 'x0' //value of the root print 'n' //number of iteration } else print "can not found a root in the given interval"
Root of the given equation = 0.682326 No. of iterations = 5
Time Complexity = O(1)
This article is contributed by Niteesh Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find the repeating and the missing number using two equations
- Smallest root of the equation x^2 + s(x)*x - n = 0, where s(x) is the sum of digits of root x.
- Using Chinese Remainder Theorem to Combine Modular equations
- System of Linear Equations in three variables using Cramer's Rule
- Find n-variables from n sum equations with one missing
- Find 'N' number of solutions with the given inequality equations
- Find the values of X and Y in the Given Equations
- Find n positive integers that satisfy the given equations
- Find if two given Quadratic equations have common roots or not
- Runge-Kutta 2nd order method to solve Differential equations
- Gill's 4th Order Method to solve Differential Equations
- Find root of a number using Newton's method
- Gaussian Elimination to Solve Linear Equations
- Linear Diophantine Equations
- Number of solutions to Modular Equations
- Data Science - Solving Linear Equations
- Data Science | Solving Linear Equations
- Pair of integers (a, b) which satisfy the given equations
- C program to find square root of a given number
- Find square root of number upto given precision using binary search