sqrt' :: Double -> Double -> Double sqrt' x guess | guessIsGoodEnough = guess | otherwise = sqrt' x improvedGuess where -- Test the precision of the guess precision = 1e-15 guessIsGoodEnough = abs (guess * guess - x) < precision * x -- Improve our guessed square improvedGuess = (guess + x / guess) / 2 main = putStrLn.show $ 1.0/((sqrt' 1234567899 1) + (sqrt' 1234567898 1))