CTM: Exercise 3-2
Posted by Urban Hafner
The problem
Cube roots. This chapter uses Newton’s method to calculate square roots. The method can be extended to calculate roots of any degree. For example, the following method calculates cube roots. Given a guess g_ for the cube root of _x, an improved guess is given by (x/g2 + 2g)/3. Write a declarative program to calculate cube roots using Newton’s method.
My solution
Taking the solution from Table 3.8 on page 123 the only thing that has to change is the Improve function. It has to be defined like this:
fun {Improve Guess}
(X/(Guess*Guess) + 2.0*Guess)/3.0
end

