20 lines
722 B
Plaintext
20 lines
722 B
Plaintext
fun stirling ← <real x|√(2 * PI / x) * ((x / E) ** x)
|
|
fun lanczos ← real by real x
|
|
List p ← real[0.99999999999980993, 676.5203681218851, -1259.1392167224028,
|
|
771.32342877765313, -176.61502916214059, 12.507343278686905,
|
|
-0.13857109526572012, 0.0000099843695780195716, 0.00000015056327351493116]
|
|
int g ← 7
|
|
if x < 0.5 do return PI / (sin(PI * x) * lanczos(1 - x)) end
|
|
x -← 1
|
|
real a ← p[0]
|
|
real t ← x + g + 0.5
|
|
for int i ← 1; i < p.length; ++i
|
|
a +← p[i] / (x + i)
|
|
end
|
|
return √(2 * PI) * (t ** (x + 0.5)) * (E ** (-t)) * a
|
|
end
|
|
writeLine("x", "\t", "Stirling", "\t\t\t", "Lanczos")
|
|
for real x ← 0.1; x ≤ 2 ; x +← 0.1
|
|
writeLine(x, "\t", stirling(x), "\t", lanczos(x))
|
|
end
|