# Cubic Root by Newton's Iterative Method

• 03-15-2005
amirahasanen1
Cubic Root by Newton's Iterative Method
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 root x^(1/3) of a real number x can be computed using an iterative method called Newton’s Method. In this method we start with an initial guess Y for 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 number x and the tolerance (e) and to return the cubic root of x using an initial guess of Y = 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. Choose x = 0.01 , 0.1 , 1 , 10 , 100 and for each x use e = 0.1 , 0.001, 0.00001. Also, display the number of iterations needed in each case.
• 03-15-2005
IfYouSaySo
It sounds like just an exercise that will help you see how things work. In the end, you will have three values for the cube root that you generated, and one value for the cube root that the c++ power function generates. From this, you will get an idea of what value of e your c++ implementation uses for it's power function. You will also see how accurate (or inaccurate) certain values of e are.

Does this answer your question, or are you looking for something more specific? I think I probably shouldn't post code, since this is for school, but maybe if you post what code you have, I can give more suggestions.
• 03-15-2005
amirahasanen1
Yes, you should not post code :) I just wanted to understand what the exercise itself requires me to do for now so that I start working on the code, but then if I faced problems with my code I'd post it here.
So now I will get three values for cubic root of x using different e's and then compare them to that one using C++ power function.
Thank you,

-Amy