fun mul(x, y) = x * y; fun doubler(x) = 2 * x; fun makeMultiplier(x) = fn (y) => x * y; fun curry(func) = fn x => fn y => func(x, y); fun improve(x) = x - (x * x - c) / (2.0 * x); fun sqrtBody(x) = if isInTolerance(x) then x else sqrtBody(improve(x)); fun isInTolerance(x) = abs(x * x - c) < 0.001; fun sqrt(c) = let fun improve(x) = x - (x * x - c) / (2.0 * x); fun isInTolerance(x) = abs(x * x - c) < 0.001; fun sqrtBody(x) = if isInTolerance(x) then x else sqrtBody(improve(x)); in sqrtBody(1.0) end; (* Modify the above in Exercise 7.13.1 to make a function cbrt that computes cubed roots. *) fun isInTolerance(x, e:real, function) = abs(function(x)) < e; fun toleranceTester(function, e:real) = fn x => abs(function(x)) < e; fun nextGuess(guess, function, derivative) = guess - (function(guess)/derivative(guess)); fun nextGuesser(function, derivative) = fn guess => guess - (function(guess)/derivative(guess)); fun fixedPoint(improve, guess, tester) = if tester(guess) then guess else fixedPoint(improve, improve(guess), tester); fun newtonsMethod(function, derivative, guess) = fixedPoint(nextGuesser(function, derivative), guess, toleranceTester(function, 0.0000001)); fun numDerivative(function) = fn x => (function(x + 0.0001) - function(x))/ 0.0001; fun findRoot(function, guess) = newtonsMethod(function, numDerivative(function), guess); fun sqrt(c) = findRoot(fn x => x * x - c, 1.0); fun sqrt(c) = newtonsMethod(fn x => x * x - c, fn x => 2.0 * x, 1.0); (* Modify the above in Exercise 7.13.3 to make a function cbrt that computes cubed roots. Assume newtonsMethod and the functions it relies on are provided. *)