A very important equations in statistical mechanics is Stirling approximation for large num-bers, lnN! =NlnN−N (N >>1). Write a Python program to verify this approximation. More specifically, evaluate the ratio lnN!/NlnN−N for N= 1000000.
Here is my program, but I can't get it to work. It doesn't give me an error, just Python breaks. I haven't been taught a lot of numpy, so I haven't been using that.
from math import log N = 1000000 N_factorial=1 for i in range(1,N + 1): N_factorial = N_factorial*i a = log(N_factorial) b = N*log(N)-N print(a/b)
https://stackoverflow.com/questions/67051439/write-a-python-program-to-verify-the-stirling-approximation April 12, 2021 at 08:44AM
没有评论:
发表评论