1
$\begingroup$

I was plotting the relative error of the $e^{11/12 -n}n^{n+1/2}$ approximation to $n!$ as $n$ gets larger and larger, and at some very large value of $n$ Mathematica gives this plot:

enter image description here

Can somebody explain what exactly the plot means? Of course, I understand that, for larger and larger $n$, the relative error tends to a limit, but I am not sure how to interpret this plot. In particular, I don't understand how the error can show greater variation as $n$ grows large.

Thanks.

Edit: I want to add that when $n$ is an order of magnitude less what I get is something like this:

https://i.sstatic.net/5zK7i.png

$\endgroup$
2
  • $\begingroup$ This sounds more like a math question to me. Are you asking why it levels off as n grows larger? $\endgroup$
    – cartonn
    Commented Dec 10, 2012 at 0:37
  • $\begingroup$ Similar questions: mathematica.stackexchange.com/questions/10820/… $\endgroup$
    – xzczd
    Commented Dec 10, 2012 at 3:17

1 Answer 1

3
$\begingroup$

Looks like numerical error, try increasing the WorkingPrecision

Plot[Abs[(Exp[11/12 - n] n^(n + 1/2) - n!)/n!]
   ,{n, 10, 10^7}
   ,WorkingPrecision -> 100]

plot

WorkingPrecision is an option for various numerical operations that specifies how many digits of precision should be maintained in internal computations.

Edit You might also find Limit interesting

Limit[(Exp[11/12 - n] n^(n + 1/2) - n!)/n!, n -> Infinity]
N[%,50]
(* -1 + E^(11/12)/Sqrt[2 \[Pi]] *)
(* -0.0022692878024401615486447545367879811325821284314703  *)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.