Hoşgeldin Misafir

Stirling's approximation accuracy

by_suntA

18 Tem 2022
13 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
Python:
import matplotlib.pyplot as plt

import math





stirling = lambda n: math.sqrt(2 * math.pi * n) * (n/math.e) ** n

br = 5



x = [_ for _ in range(br)]

y = [math.factorial(_) for _ in range(br)]



x1 = [_ for _ in range(br)]

y1 = [stirling(_) for _ in range(br)]



plt.plot(x, y, label="factorial")

plt.plot(x1, y1, label="Stirling's approximation")

plt.legend()



plt.title("Stirling's approximation accuracy")

plt.xlabel("x")

plt.ylabel("y")

plt.show()