fork download
  1. iter :: (Num a, Ord a) => (a -> a) -> a -> a -> a -> a
  2. iter f eps fx x | (fx - x)^2 < eps = fx
  3. | otherwise = iter f eps (f fx) fx
  4.  
  5. root4 :: Double -> Double
  6. root4 a = iter (\x -> (3*x + a/(x*x*x))/4) 1e-32 (a/4) 0
  7.  
  8. main = print (root4 16)
  9.  
Success #stdin #stdout 0s 4584KB
stdin
Standard input is empty
stdout
2.0