Stirling Gamma-Approximation Rechner
Asymptotische Näherung der Gamma-Funktion für große Argumente
Geben Sie das Argument (x) ein und klicken Sie auf Berechnen um die Stirling-Approximation der Gamma-Funktion zu ermitteln. Die Stirling-Formel liefert eine asymptotische Näherung für große Argumente und kann durch systematische Korrekturterme erheblich verbessert werden.
💡 Stirling-Formel
\(\Gamma(x+1) \sim \sqrt{2\pi x} \left(\frac{x}{e}\right)^x\)

Die Gamma-Funktion mit Stirling-Approximation für große Argumente
Die Stirling-Approximation verstehen
Die Stirling-Formel, benannt nach James Stirling, ist eine fundamentale asymptotische Näherung für Fakultäten und die Gamma-Funktion. Sie liefert bereits im Hauptterm sehr präzise Werte für große Argumente und kann durch eine Reihe von systematischen Korrekturtermen beliebig genau gemacht werden. Die Formel ist unverzichtbar in der analytischen Zahlentheorie, Kombinatorik und statistischen Mechanik.
📈 Grundformel
Asymptotische Näherung:
📊 Eigenschaften
- • Asymptotische Näherung
- • Sehr genau für große x
- • Systematisch verbesserbar
- • Einfache Berechnung
🔬 Vorteile
- • Hervorragend für große Argumente
- • Theoretisch fundiert
- • Einfache Implementation
- • Historisch bedeutsam
⭐ Anwendungen
- • Analytische Zahlentheorie
- • Kombinatorik
- • Statistische Mechanik
- • Asymptotische Analysis
Mathematische Grundlagen
📈 Stirling-Formel
Die fundamentale asymptotische Näherung:
\[\text{Für } x \to \infty \text{ gilt:}\] \[\Gamma(x+1) = x! \sim \sqrt{2\pi x} \left(\frac{x}{e}\right)^x\] \[\text{Logarithmische Form:}\] \[\ln \Gamma(x+1) = \frac{1}{2}\ln(2\pi x) + x \ln x - x + O\left(\frac{1}{x}\right)\] \[\text{Relative Genauigkeit: } \frac{|\text{Fehler}|}{\text{Exakt}} = O\left(\frac{1}{x}\right)\]
🔄 Asymptotische Reihe
Erweiterte Stirling-Serie mit Korrekturtermen:
\[\Gamma(x+1) \sim \sqrt{2\pi x} \left(\frac{x}{e}\right)^x \left(1 + \frac{1}{12x} + \frac{1}{288x^2} - \frac{139}{51840x^3} - \frac{571}{2488320x^4} + \cdots\right)\] \[\text{Allgemeine Form mit Bernoulli-Zahlen:}\] \[\ln \Gamma(x+1) \sim \frac{1}{2}\ln(2\pi x) + x \ln x - x + \sum_{k=1}^{\infty} \frac{B_{2k}}{2k(2k-1)x^{2k-1}}\] \[\text{wobei } B_{2k} \text{ die Bernoulli-Zahlen sind}\]
📊 Korrekturfaktoren
Numerische Korrekturfaktoren der Stirling-Serie:
\[C_1 = \frac{1}{12} \approx 0{,}0833\] \[C_2 = \frac{1}{288} \approx 0{,}00347\] \[C_3 = -\frac{139}{51840} \approx -0{,}00268\] \[C_4 = -\frac{571}{2488320} \approx -0{,}000229\] \[C_5 = \frac{163879}{209018880} \approx 0{,}000784\] \[\text{Schnelle Konvergenz für moderate } x \geq 5\]
Praktische Berechnungsbeispiele
📝 Beispiel 1: Genauigkeitsanalyse
Aufgabe: Vergleich Stirling vs. exakt für 10!
Exakter Wert: 10! = 3.628.800
Berechnung:
\[\text{Stirling-Grundformel: } \sqrt{2\pi \cdot 10} \left(\frac{10}{e}\right)^{10}\] \[\approx \sqrt{62{,}83} \cdot (3{,}679)^{10} \approx 7{,}925 \cdot 359536 \approx 3{,}598{,}696\] \[\text{Relativer Fehler: } \frac{|3{,}628{,}800 - 3{,}598{,}696|}{3{,}628{,}800} \approx 0{,}83\%\] \[\text{Mit 1. Korrektur: } 3{,}598{,}696 \cdot \left(1 + \frac{1}{120}\right) \approx 3{,}628{,}694\] \[\text{Verbesserter Fehler: } \approx 0{,}003\% \text{ - dramatische Verbesserung!}\]
Ergebnis: Erste Korrektur reduziert Fehler um Faktor ~300
📝 Beispiel 2: Asymptotisches Verhalten
Aufgabe: Stirling für sehr große Zahlen
Szenario: 100! Berechnung
Analyse:
\[\text{Exakt: } 100! = 9{,}3326... \times 10^{157}\] \[\text{Stirling: } \sqrt{200\pi} \left(\frac{100}{e}\right)^{100}\] \[\text{Logarithmische Berechnung:}\] \[\ln(100!) \approx \frac{1}{2}\ln(200\pi) + 100\ln(100) - 100\] \[\approx 3{,}207 + 460{,}517 - 100 = 363{,}724\] \[\text{Relativer Fehler: } < 0{,}01\% \text{ ohne Korrekturterme!}\]
Fazit: Stirling wird für große x extrem genau
📝 Beispiel 3: Kombinatorische Anwendung
Aufgabe: Binomialkoeffizient-Approximation
Problem: $\binom{n}{k}$ für große n, k
Lösung:
\[\binom{n}{k} = \frac{n!}{k!(n-k)!}\] \[\text{Mit Stirling:}\] \[\binom{n}{k} \approx \frac{\sqrt{2\pi n} (n/e)^n}{\sqrt{2\pi k} (k/e)^k \cdot \sqrt{2\pi(n-k)} ((n-k)/e)^{n-k}}\] \[= \sqrt{\frac{n}{2\pi k(n-k)}} \cdot \frac{n^n}{k^k (n-k)^{n-k}}\] \[\text{Beispiel: } \binom{1000}{500} \approx \sqrt{\frac{1000}{2\pi \cdot 500 \cdot 500}} \cdot 2^{1000}\]
Anwendung: Zentrale Grenzwertsätze in der Wahrscheinlichkeitstheorie
Vor- und Nachteile
✅ Vorteile der Stirling-Approximation
Stärken der asymptotischen Näherung:
\[\text{✓ Hervorragend für große Argumente (x > 10)}\] \[\text{✓ Einfache mathematische Form}\] \[\text{✓ Systematisch verbesserbar durch Korrekturterme}\] \[\text{✓ Theoretisch gut verstanden}\] \[\text{✓ Historisch wichtig und weit verbreitet}\] \[\text{✓ Direkter Zusammenhang zu asymptotischer Analysis}\]
⚠️ Einschränkungen und Grenzen
Schwächen der Stirling-Formel:
\[\text{⚠ Nur asymptotisch - schlecht für kleine x}\] \[\text{⚠ Divergente Reihe - nicht für alle x konvergent}\] \[\text{⚠ Benötigt Korrekturterme für hohe Genauigkeit}\] \[\text{⚠ Weniger genau als Lanczos für moderate x}\] \[\text{⚠ Problematisch bei numerischem Overflow}\]
Vergleich mit anderen Methoden
📊 Methodenvergleich
Argument x | Stirling Basis | Stirling +1 Term | Lanczos | Relativer Fehler |
---|---|---|---|---|
5 | 118.02 | 119.87 | 120.00 | 1.65% / 0.11% |
10 | 3.598×10⁶ | 3.629×10⁶ | 3.629×10⁶ | 0.83% / 0.003% |
20 | 2.42×10¹⁷ | 2.43×10¹⁷ | 2.43×10¹⁷ | 0.42% / 0.0008% |
50 | 3.04×10⁶³ | 3.04×10⁶³ | 3.04×10⁶³ | 0.17% / <0.0001% |
100 | 9.33×10¹⁵⁷ | 9.33×10¹⁵⁷ | 9.33×10¹⁵⁷ | 0.08% / <0.0001% |
Anwendungen in verschiedenen Bereichen
🔢 Analytische Zahlentheorie
- • Primzahlverteilung
- • Riemannsche Zeta-Funktion
- • Partitionsfunktionen
- • Asymptotische Formeln
🎲 Kombinatorik
- • Binomialkoeffizienten
- • Stirling-Zahlen
- • Permutations-Probleme
- • Generating Functions
🔬 Statistische Mechanik
- • Boltzmann-Entropie
- • Thermodynamische Limites
- • Phasenübergänge
- • Zustandssummen
📊 Wahrscheinlichkeitstheorie
- • Zentrale Grenzwertsätze
- • Große Abweichungen
- • Renewal Theory
- • Asymptotische Statistik
Implementierung und Code
💻 Code-Implementierungen
Effiziente Implementierung der Stirling-Approximation:
Python (Basis und erweitert):
import math
def stirling_basic(x):
"""Basis Stirling-Approximation"""
if x <= 0:
raise ValueError("x muss positiv sein")
return math.sqrt(2 * math.pi * x) * (x / math.e) ** x
def stirling_extended(x, terms=5):
"""Erweiterte Stirling-Serie"""
basic = stirling_basic(x)
# Bernoulli-Zahlen für Korrekturterme
B = [1/12, 1/288, -139/51840, -571/2488320, 163879/209018880]
correction = 1
x_power = x
for i in range(min(terms, len(B))):
correction += B[i] / x_power
x_power *= x * x # x^(2k-1)
return basic * correction
Logarithmische Version (für große x):
def log_stirling(x):
"""Logarithmische Stirling für numerische Stabilität"""
return 0.5 * math.log(2 * math.pi * x) + x * math.log(x) - x
🎯 Optimierte Implementation
Professionelle Stirling-Implementation:
C++ (Hochoptimiert):
#include <cmath>
#include <stdexcept>
double stirling_gamma(double x) {
if (x <= 0) throw std::invalid_argument("x must be positive");
const double SQRT_2PI = 2.5066282746310005024;
const double INV_E = 0.36787944117144232159;
double log_result = 0.5 * log(SQRT_2PI * x) + x * log(x * INV_E);
// Korrekturterme für bessere Genauigkeit
if (x >= 1) {
double inv_x = 1.0 / x;
double correction = 1 + inv_x / 12 + inv_x * inv_x / 288;
log_result += log(correction);
}
return exp(log_result);
}
MATLAB/Octave:
function result = stirling_gamma(x)
if x <= 0
error('x must be positive');
end
result = sqrt(2*pi*x) * (x/exp(1))^x;
% Optional: Korrekturterme hinzufügen
if x >= 1
correction = 1 + 1/(12*x) + 1/(288*x^2);
result = result * correction;
end
end
🎯 Numerische Aspekte
Wichtige Implementierungsdetails:
\[\text{Logarithmische Berechnung für große x empfohlen}\] \[\text{Overflow-Vermeidung: } \ln \Gamma(x) \text{ statt } \Gamma(x)\] \[\text{Korrekturterme nur für } x \geq 1 \text{ sinnvoll}\] \[\text{Divergenz der asymptotischen Serie beachten}\] \[\text{Optimale Anzahl Terme: } N \approx x/2\] \[\text{Für } x < 5: \text{ andere Methoden bevorzugen}\]
💡 Wichtige Eigenschaften der Stirling-Approximation:
- Asymptotische Näherung: Wird für große x immer genauer
- Systematisch verbesserbar: Korrekturterme erhöhen Genauigkeit dramatisch
- Theoretisch fundiert: Basis der asymptotischen Analysis
- Einfache Berechnung: Nur Grundrechenarten und Exponentialfunktion
🔬 Anwendungsgebiete der Stirling-Approximation:
- Zahlentheorie: Primzahlverteilung, Partitionsfunktionen
- Kombinatorik: Binomialkoeffizienten, Stirling-Zahlen
- Physik: Statistische Mechanik, Thermodynamik
- Wahrscheinlichkeit: Zentrale Grenzwertsätze, asymptotische Statistik
acos - Arkuskosinus
acot - Arkuskotangens
acsc - Arkuskosekans
asec - Arkussekans
asin - Arkussinus
atan - Arkustangens
atan2 - Arkustangens von y/x
cos - Kosinus
cot - Kotangens
csc - Kosekans
sec - Sekans
sin - Sinus
sinc - Kardinalsinus
tan - Tangens
hypot - Hypotenuse
deg2rad - Grad in Radiant
rad2deg - Radiant in Grad
Hyperbolik
acosh - Arkuskosinus hyperbolikus
asinh - Areasinus hyperbolikus
atanh - Arkustangens hyperbolikus
cosh - Kosinus hyperbolikus
sinh - Sinus hyperbolikus
tanh - Tangens hyperbolikus
Logarithmus
log - Logarithmus zur angegebene Basis
ln - Natürlicher Logarithmus zur Basis e
log10 - Logarithmus zur Basis 10
log2 - Logarithmus zur Basis 2
exp - Exponenten zur Basis e
Aktivierung
Softmax
Sigmoid
Derivate Sigmoid
Logit
Derivate Logit
Softsign
Derivate Softsign
Softplus
Logistic
Gamma
Eulersche Gamma Funktion
Lanczos Gamma-Funktion
Stirling Gamma-Funktion
Log Gamma-Funktion
Beta
Beta Funktion
Logarithmische Beta Funktion
Unvollstaendige Beta Funktion
Inverse unvollstaendige Beta Funktion
Fehlerfunktionen
erf - Fehlerfunktion
erfc - komplementäre Fehlerfunktion
Kombinatorik
Fakultät
Semifakultät
Steigende Fakultät
Fallende Fakultät
Subfakultät
Permutationen und Kombinationen
Permutation
Kombinationen
Mittlerer Binomialkoeffizient
Catalan-Zahl
Lah Zahl