Lab 3: Function composition and Recursion

Exercise 1: EHP + Life %

Yet another factor that may enter into the effective health pool (EHP) computation is the possibility of equipping items with "+ Life %" modifiers. The value for this modifier is a percentage by which the base HP of a character is increased before dividing it by the damage-taken percentage (as described in the EHP inlab).

Change your ehp and base-hp functions so that they both take an additional input called life%, and adjust your computations accordingly. You should test your results against this online EHP calculator.

For reference, given lvl=60, mlvl=63, vit=1000, dex=300, life%=0.13, armor=4000, resists=200, you should arrive at an EHP of 248618.23.

Exercise 2: Newton's method for cube roots

Newton's approximation method (described in the last inlab) can also be used to compute the cube root. The same approach is used, except that when given a guess g for the cube root of a number x, an improved guess is given by improved guess.

Write a function named newtons-cubed-root that takes two inputs, g and x, and returns an approximation for the cubed root of x using g as the initial guess. Your function should be decomposed into helper functions similar to those described in the inlab.

Exercise 3: Fractal art

Complete the functions fractal-lvl-1, fractal-lvl-2, fractal-lvl-3 and fractal, described in the last inlab. Your fractal function should work correctly for values of lvl up to 10.