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

Algorithm:

IN: 
Function f, which is continous function and value: a - being intital guess - the closer to root, the better. Function fD, which is the derivative of function f.
OUT: 
Root in given interval.
1. Make x = a and prevX = a.
2. Check if abs(f(x)) < precision.
3. If it is end algorithm and return x.
4. Make x = prevX - (f(prevX) / fD(prevX)).
5. Make prevX = x.
6. Go to step 2.

Sample Output:

f(x) = x * (x + 2) -1
-3

root: -2.414201183431953
Iteration NumberaprevXxf(x)
1-3-3-32.0
2-3-32.50.25
3-32.5-2.4160.0069
4-3-2.416-2.4146.007E-6

Pros:

  • easy to implement (without approximating the derivative of function!).
  • very fast method (not counting some special functions).
  • no need to find initial interval, simply choose a number and one of the roots should be found.

Cons:

  • has trouble with some functions.
  • If a stationary point of given function is encountered, there will be devision by zero, because of the derivative being zero.
  • need to calculate derivative of given function.
  • may miss root.

 

Java Implementation Python Implementation C++ Implementation C# Implementation



Newton Method Algoritm
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