Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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:

http://i.stack.imgur.com/5zK7i.png

share|improve this question

marked as duplicate by Mr.Wizard Jul 19 '13 at 0:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
This sounds more like a math question to me. Are you asking why it levels off as n grows larger? –  cartonn Dec 10 '12 at 0:37
    
Similar questions: mathematica.stackexchange.com/questions/10820/… –  xzczd Dec 10 '12 at 3:17

1 Answer 1

up vote 3 down vote accepted

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  *)
share|improve this answer

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