Author: | Crest |
---|---|
Mode: | haskell |
Date: | Sun, 9 Nov 2008 16:32:37 |
-- Approximate the square root of a Double $x to at least the accuracy of $epsilon. squareRoot :: Double -> Double -> Double squareRoot x eps = loop x where loop :: Double -> Double loop y | abs( (y * y) - x ) <= eps = y | otherwise = loop (0.5 * (y + (x / y)))