Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Gamma-function/Haskell/gamma-function-1.hs
Normal file
21
Task/Gamma-function/Haskell/gamma-function-1.hs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
cof :: [Double]
|
||||
cof =
|
||||
[ 76.18009172947146
|
||||
, -86.50532032941677
|
||||
, 24.01409824083091
|
||||
, -1.231739572450155
|
||||
, 0.001208650973866179
|
||||
, -0.000005395239384953
|
||||
]
|
||||
|
||||
ser :: Double
|
||||
ser = 1.000000000190015
|
||||
|
||||
gammaln :: Double -> Double
|
||||
gammaln xx =
|
||||
let tmp_ = (xx + 5.5) - (xx + 0.5) * log (xx + 5.5)
|
||||
ser_ = ser + sum (zipWith (/) cof [xx + 1 ..])
|
||||
in -tmp_ + log (2.5066282746310005 * ser_ / xx)
|
||||
|
||||
main :: IO ()
|
||||
main = mapM_ print $ gammaln <$> [0.1,0.2 .. 1.0]
|
||||
22
Task/Gamma-function/Haskell/gamma-function-2.hs
Normal file
22
Task/Gamma-function/Haskell/gamma-function-2.hs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import Control.Applicative
|
||||
|
||||
cof :: [Double]
|
||||
cof =
|
||||
[ 76.18009172947146
|
||||
, -86.50532032941677
|
||||
, 24.01409824083091
|
||||
, -1.231739572450155
|
||||
, 0.001208650973866179
|
||||
, -0.000005395239384953
|
||||
]
|
||||
|
||||
gammaln :: Double -> Double
|
||||
gammaln =
|
||||
((+) . negate . (((-) . (5.5 +)) <*> (((*) . (0.5 +)) <*> (log . (5.5 +))))) <*>
|
||||
(log .
|
||||
((/) =<<
|
||||
(2.5066282746310007 *) .
|
||||
(1.000000000190015 +) . sum . zipWith (/) cof . enumFrom . (1 +)))
|
||||
|
||||
main :: IO ()
|
||||
main = mapM_ print $ gammaln <$> [0.1,0.2 .. 1.0]
|
||||
7
Task/Gamma-function/Haskell/gamma-function-3.hs
Normal file
7
Task/Gamma-function/Haskell/gamma-function-3.hs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
procedure main()
|
||||
every write(left(i := !10/10.0,5),gamma(.i))
|
||||
end
|
||||
|
||||
procedure gamma(z) # Stirling's approximation
|
||||
return (2*&pi/z)^0.5 * (z/&e)^z
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue