Jump to content

Gamma function: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
Line 5,371:
{{libheader|Wren-math}}
The ''gamma'' method in the Math class is based on the Lanczos approximation.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
import "./math" for Math
 
var stirling = Fn.new { |x| (2 * Num.pi / x).sqrt * (x / Math.e).pow(x) }
Line 5,379:
for (i in 1..20) {
var d = i / 10
Fmt.print("$4.2f\t$16.14f\t$16.14f", d, stirling.call(d), Math.gamma(d))
System.write("%(Fmt.f(4, d, 2))\t")
System.write("%(Fmt.f(16, stirling.call(d), 14))\t")
System.print("%(Fmt.f(16, Math.gamma(d), 14))")
}</syntaxhighlight>
 
Line 5,390 ⟶ 5,388:
0.10 5.69718714897717 9.51350769866875
0.20 3.32599842402239 4.59084371199881
0.30 2.36253003626962 2.9915689876876099156898768759
0.40 1.84147633593624 2.21815954375769
0.50 1.52034690106628 1.77245385090552
9,492

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.