Last active
December 14, 2015 16:39
-
-
Save liewsi/5116824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log_factorial_by_stirling_approximation = @(n)(log(2*pi*n)/2 + n.*log(n) - n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 1:250; | |
y1 = log(factorial(n)); | |
y2 = log_factorial_by_stirling_approximation(n); | |
subplot(3,1,1), | |
plot(n,y1, 'k-'), axis([0 max(n) 0 max(y2)]), | |
title('MATLAB faktöryelinin logu') | |
subplot(3,1,2), | |
plot(n,y2, 'b-'), axis([0 max(n) 0 max(y2)]), | |
title('Stirling yaklaşımının logu') | |
subplot(3,1,3), | |
plot(n,abs(y1-y2), 'r-'), title('Fark') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment