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.


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



1 Answer 1


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]


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]
(* -1 + E^(11/12)/Sqrt[2 \[Pi]] *)
(* -0.0022692878024401615486447545367879811325821284314703  *)

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