In: Computer Science
In class, we have studied the bisection method for finding a root of an equation. Another method for finding a root, Newton’s method, usually converges to a solution even faster than the bisection method, if it converges at all. Newton’s method starts with an initial guess for a root, ?0 , and then generates successive approximate roots ?1 , ?2 , …. ?i , ?i+i, …. using the iterative formula?′(?) Where ?’(xi) is the derivative of function ? evaluated at ? = ?i . The formula generates a new guess, ?j+1, from a previous one, ?j . Sometimes Newton’s method will fail to converge to a root. In this case, the program should terminate after many trials, perhaps 100. The figure above shows the geometric interpolation of Newton’s method where ?0 , ?1 , and ?2 represent successive guesses for the root. At each point ?j , the derivative, ?’(xj), is the slope of the tangent to the curve, ?(?). The next guess for the root, ?j+1, is the point at which the tangent crosses the x-axis. Write a program that uses Newton’s method to approximate the nth root of a number to six decimal places. If ?n = ?, then ?n-? = 0. Finding a root of the second equation will give you n√? . Test your program on √3, 3√10 , and 3√−2. Your program could use c/2 as its initial guess.