From 01a811496fa528a5734c24a196fb6c7fa3c519c0 Mon Sep 17 00:00:00 2001 From: Alexander Solovyov Date: Wed, 13 Feb 2008 00:24:32 +0200 Subject: [PATCH] Stirling's factorial approximation --- extra/math/analysis/analysis.factor | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extra/math/analysis/analysis.factor b/extra/math/analysis/analysis.factor index bde5cad7a0..2973d3d3f2 100644 --- a/extra/math/analysis/analysis.factor +++ b/extra/math/analysis/analysis.factor @@ -108,3 +108,12 @@ PRIVATE> swap -1.0 * exp * ] if ; + +! James Stirling's approximation for N!: +! http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Numerical/Stirling/ + +: stirling-fact ( n -- fact ) + [ pi 2 * * sqrt ] + [ dup e / swap ^ ] + [ 12 * recip 1 + ] + tri * * ;