Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Approx where
- approxGolden :: Int -> Double
- approxGolden n = approx n 1 1
- where
- approx 0 p q = q / p
- approx n p q = approx (n - 1) q (p + q)
- golden :: Double
- golden = approxGolden 64
- approxEuler :: Int -> Double
- approxEuler n = approx 0 1 0 where
- approx m a r = if m == n
- then r
- else approx (m + 1) a' r'
- where
- a' = (fromInteger . toInteger) (m + 1) * a
- r' = r + (1 / a)
- euler :: Double
- euler = approxEuler 64
Add Comment
Please, Sign In to add comment