Secant method is used for finding root of the function in given interval.

Algorithm:

IN: 
Function f, which is continous function and interval [a,b]. Function must satisfy given equation: f(a) * f(b) < 0 - signs of that values are different, which means that given function in given interval has at least one root in interval [a,b].
OUT: 
Root in given interval.
1. Make xn1 = a, xn = b, x = xn1.
2. Check if abs(f(x)) < precision.
3. If it is end algorithm and return x.
4. Make x = xn - ((f(xn) * (xn - xn1)) / (f(xn) - f(xn1))).
5. Make xn1 = xn and xn = x.
6. Go to step 2.

Sample Output:

f(x) = x * (x + 2) -1
[-3, 0]

root: -2.414201183431953

Chord Method Step By Step

Iteration Numberabxn1xnxf(x)
1-3-1-3-1-32
2-3-1-1-2-2-1
3-3-1-2-3-32
4-3-1-3-3-2.333-0.2222
5-3-1-3-2.333-2.4-0.04
6-3-1-2.333-2.4-2.410.00118
7-3-1-2.4-2.41-2.414-6.007E-6

Pros:

Cons:

  • has trouble with some functions.
  • initial approximations are not accurate enough.

 

Java Implementation Python Implementation C++ Implementation C# Implementation



Secant Method Algorithm
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. You can read more about it the Cookies&Privacy Policy Section Above. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this. You can read more about it the Cookies&Privacy Policy Section.

Close