Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
14
Task/Gamma-function/F-Sharp/gamma-function.fs
Normal file
14
Task/Gamma-function/F-Sharp/gamma-function.fs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
open System
|
||||
|
||||
let gamma z =
|
||||
let lanczosCoefficients = [76.18009172947146;-86.50532032941677;24.01409824083091;-1.231739572450155;0.1208650973866179e-2;-0.5395239384953e-5]
|
||||
let rec sumCoefficients acc i coefficients =
|
||||
match coefficients with
|
||||
| [] -> acc
|
||||
| h::t -> sumCoefficients (acc + (h/i)) (i+1.0) t
|
||||
let gamma = 5.0
|
||||
let x = z - 1.0
|
||||
Math.Pow(x + gamma + 0.5, x + 0.5) * Math.Exp( -(x + gamma + 0.5) ) * Math.Sqrt( 2.0 * Math.PI ) * sumCoefficients 1.000000000190015 (x + 1.0) lanczosCoefficients
|
||||
|
||||
seq { for i in 1 .. 20 do yield ((double)i/10.0) } |> Seq.iter ( fun v -> System.Console.WriteLine("{0} : {1}", v, gamma v ) )
|
||||
seq { for i in 1 .. 10 do yield ((double)i*10.0) } |> Seq.iter ( fun v -> System.Console.WriteLine("{0} : {1}", v, gamma v ) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue