Lab 3 - Calculating the cube root

Now that we have some experience setting up a simple Pyhon program, you get to try another similar problem. Instead of the square root, let’s see if we can figure out the cube root.

If X is the number we want the cube root of, and A is our guess, then X should equal A*A*A.

Here is what Newton has to say on the matter:

Start off with some guess for A. Calculate a new guess using this formula:

A = 1/3 *( X/(A*A) + 2 * A)

You might think about why all those parentheses are in there. I want to make sure we ask the computer to evaluate the right value.

Your assignment

Using the example we worked in class, create a new Python program in a file called First, write your code to calculate the cube root of 5, just like we did in class.

Then, modify the program by adding an input statement at the beginning of the program that asks the user to enter the number you want the cube root of. The new line you need is explained on page 49 of your text.

Now, run the program on a number of values you pick. Make sure you see how well you are doing. You should improve the output to make the results more clear.

What to turn in

Place both files in your homework repository, in a folder named Lab3. (Yeah, yeah!, I know. This is a lab, but a short one, so we will put it in the homework repository. Future labs, will have their own personal repositories!)