I already prooved it. I need help on the MATLAB part. Please show what you input
ID: 3044915 • Letter: I
Question
I already prooved it. I need help on the MATLAB part. Please show what you input in MATLAB.
Thank you!
1) Prove the Stirling’s asymptotics n! - yn n” •e" by reasoning as we did in class. The correct asymptotic formula is n! = 127 Vn-n" •e" Use MATLAB and test the approximation above for the first 20 integers. Use the following MATLAB commands >> format long >> n=1:1:20; >> [n' factorial(n)' ( sqrt(2*pi)*sqrt(n). *exp(-n). *(n.^n) )] For which value of n is the approximation decent ?Explanation / Answer
The command is given in this question,
[n' factorial(n)' (sqrt(2*pi)*sqrt(n).*exp(-n).*(n.^n))']
On entering this command in matlab, I got following output. First column is the value of n (from 1 to 20), second column shows the value of n!, and third column shows its approximation using stirlings formula. We see that the approximation improves as n increases. To me it looks decent at n = 20
Let me know if you need more help.
1.00000000000000e+000 1.00000000000000e+000 9.22137008895789e-001
2.00000000000000e+000 2.00000000000000e+000 1.91900435148898e+000
3.00000000000000e+000 6.00000000000000e+000 5.83620959134586e+000
4.00000000000000e+000 2.40000000000000e+001 2.35061751328933e+001
5.00000000000000e+000 1.20000000000000e+002 1.18019167957590e+002
6.00000000000000e+000 7.20000000000000e+002 7.10078184642185e+002
7.00000000000000e+000 5.04000000000000e+003 4.98039583161246e+003
8.00000000000000e+000 4.03200000000000e+004 3.99023954526567e+004
9.00000000000000e+000 3.62880000000000e+005 3.59536872841948e+005
1.00000000000000e+001 3.62880000000000e+006 3.59869561874104e+006
1.10000000000000e+001 3.99168000000000e+007 3.96156250505775e+007
1.20000000000000e+001 4.79001600000000e+008 4.75687486472776e+008
1.30000000000000e+001 6.22702080000000e+009 6.18723947519271e+009
1.40000000000000e+001 8.71782912000000e+010 8.66610017405988e+010
1.50000000000000e+001 1.30767436800000e+012 1.30043072219947e+012
1.60000000000000e+001 2.09227898880000e+013 2.08141144152231e+013
1.70000000000000e+001 3.55687428096000e+014 3.53948328666101e+014
1.80000000000000e+001 6.40237370572800e+015 6.37280462619431e+015
1.90000000000000e+001 1.21645100408832e+017 1.21112786592294e+017
2.00000000000000e+001 2.43290200817664e+018 2.42278684676113e+018
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.