20-CS-122-001 Computer Science II Spring 2012
Cube root algorithm

Virtual functions, classes, inheritance, lists, queues, stacks, applications

Given: a real number n.
Find: the cube root of n.

    need to find m so that m*m*m = n.
which is the same as m = n/(m*m).
or 2m = (m + n/(m*m)).
and finally m = (m + n/(m*m))/2.

    Let m = n be the input number
    Input a number d representing precision
    Let oldm be initialized to -1
    Repeat the following until abs(oldm-m) < d:
       Set oldm to m
       Set m to (m+(n/(m*m)))/2
    Output m