Chord 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. Calculate x = (a * f(b) - b* f(a)) / (f(b) - f(a));
2. Check if abs(f(x)) < precision.
3. If it is end algorithm and return x.
4. Check if f(a) * f(x) < 0.
5. If it is make x = (x * f(a) - a* f(x)) / (f(a) - f(x)).
6. Else make x = (x * f(b) - b * f(x)) / (f(b) - f(x)).
7. Go to step 2.

Sample Output:

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

root: -2.414201183431953

Chord Method Step By Step

Iteration Numberabxf(xn)
1-30-1-2
2-30-2-1
3-30-2.3333333333333335-0.22222222222222188
4-30-2.4-0.04000000000000026
5-30-2.4117647058823533 -0.006920415224912602
6-30-2.413793103448276-0.0011890606420928984
7-30-2.4141414141414144-2.0406081012080968E-4
8-30-2.414201183431953 -3.501277966366789E-5

Pros:

  • easy to implement.
  • faster thanĀ bisection method.
  • no need to calculate derivative of given function.

Cons:

  • has trouble with some functions.
Java Implementation Python Implementation C++ Implementation C# Implementation



Chord 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