The idea behind Newton's method is that a differentiable function can be approximated locally by a straight line. So if you know the approximate location of a root, you should be able to get a better estimate for the root by solving the linear equation that approximates the function. A diagram should help here.
The mathematics behind the heuristics are pretty easy. If we have a function f and a guess for a root at x0 then our approximation for the function is:
(email@example.com) java Newton 2 Step: 1 x:4.18504 Value:-0.864144 Step: 2 x:2.46789 Value:0.623881 Step: 3 x:3.26619 Value:-0.124272 Step: 4 x:3.14094 Value:0.000648741 Step: 5 x:3.14159 Value:-9.10111e-11 Zero found at x=3.14159 (firstname.lastname@example.org)Next, lets look at the Java code that produced this output.
|5.2 Java Code for Newton's Method|