Newton method is used for finding root of the function in given interval.
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.
f(x) = x * (x + 2) -1 -3 root: -2.414201183431953
- 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.
- 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