Plots showing the relative error of a stirling approximation.

<<peeters`

Clear[stirling, plot]
stirling[N_] = Sqrt[2 Pi N] N^N E^(-N) ;
stirling[n] // TraditionalForm
plot = Module[{s,f, r, p},
r = 50 ;
s = Table[{n, stirling[n]}, {n, 1, r}] // N ;
f = Table[{n, Factorial[n]}, {n, 1, r}] // N  ;
d = Table[(Factorial[n] - stirling[n])/Factorial[n], {n, 1, r}]  // N ;
 p = ListPlot[d, PlotRange -> Full, AxesLabel->{n,1 -stirling[n]/n!}] ;
(* {d, p} *)
p
]
stirling[1] // N

SetDirectory["C:\\Users\\Peeter\\cygwin_home\\physicsplay\\notes\\phy452\\figures"]

peeters`exportForLatex["stirlingErrorFig3", plot]