Compute Cos In Haskell

[Solved] Compute Cos In Haskell | Haskell - Code Explorer | yomemimo.com
Question : compute cos in haskell

Answered by : frightened-falcon-ey6vc6wmaq3w

fac :: Int -> Int
fac n = if (n == 0) then 1 else n * fac (n-1)
cos :: Double -> Double
cos x = sum [cos| k <- [0..], let cos = (-1) * (x^(2*k) / fromIntegral (fac (2*k))) , abs (cos) > 0.001]

Source : https://stackoverflow.com/questions/54409219/implement-the-law-of-cosine-in-haskell | Last Update : Tue, 18 Jan 22

Answers related to compute cos in haskell

Code Explorer Popular Question For Haskell