Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- asinℝp :: (Fractional a, Ord a) => Fastℕ -> a -> a
- asinℝp precision x
- | x>0 = res
- | x < 0 = 0-res
- | otherwise = 0
- where
- res=(abs x)+(sum [asinTerm (abs x) (toInteger i) | i <- [1..precision]])
- asinTerm :: (Fractional a) => a -> ℕ -> a
- asinTerm x n = ((x^oddTerm) *(fromIntegral $ factorialskip (oddTerm-2))) / (fromIntegral $ (factorialskip (evenTerm))*(oddTerm))
- where
- oddTerm :: ℕ
- oddTerm = 2*n + 1
- evenTerm :: ℕ
- evenTerm = 2*n
- factorialskip :: ℕ -> ℕ
- factorialskip 0 = 1
- factorialskip 1 = 1
- factorialskip n = n * factorialskip (n-2)
- cosℝp :: (Fractional a) => Fastℕ -> a -> a
- cosℝp precision x = 1-(sum [cosTerm x (toInteger i) | i <- [1..precision]])
- cosTerm :: (Fractional a) => a -> ℕ -> a
- cosTerm x i = (x^evenTerm / fromIntegral (factorial evenTerm))*(-1)^(i-1)
- where evenTerm = 2*i
- sinℝp :: (Fractional a) => Fastℕ -> a -> a
- sinℝp precision x = sum [sinTerm x (toInteger i) | i <- [1..precision]]
- sinTerm :: (Fractional a) => a -> ℕ -> a
- sinTerm x i = (x^oddTerm / fromIntegral (factorial oddTerm))*(-1)^(i-1)
- where oddTerm = 2*i - 1
- factorial :: ℕ -> ℕ
- factorial 1 = 1
- factorial n = n * factorial (n-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement