Hi there,

I have this exercise which I understand except a very small part at the end which is "for each x use e = 0.1 , 0.001, 0.00001."

Here am I required to get three cubic root values for each x and return the three values by the cubic-root function and then compare them with that value returned by the C++ normal power function??? If it is like that it seems a little bit confusing to me as why are we going to use three values for the tolerance..

Thanks,

-Amy

Exercise:

The cubic rootx^(1/3)of a real numberxcan be computed using ancallediterative method. In this method we start with an initial guessNewton’s MethodYfor the cubic root, and then iteratively compute better approximations using the formula:

Ynew = Y – [Y * Y – x / Y] / [ 2 Y + x / (Y * Y)]

In a given iteration, if the absolute relative difference between Ynew and Y is greater than a certain tolerance e, i.e. if | Ynew - Y | / Y > e , we repeat computing a better value Ynewotherwise we stop.

Write a function to input the real numberxand the tolerance (e) and to return the cubic root ofxusing an initial guess ofY=x. The function should also return the number of iterations needed to achieve the final value of the cubic root.

Use a main function to test the above function by comparing its cubic root with that computed using the usual C++ power function. Choosex= 0.01 , 0.1 , 1 , 10 , 100 and for eachxusee= 0.1 , 0.001, 0.00001. Also, display the number of iterations needed in each case.