File:Stirling error vs number of terms.svg
This file supersedes the file StirlingError1.svg. It is recommended to use this file rather than the other one.
|
Summary
| Description |
English: Plot of the error in the Stirling series for a fixed argument with increasing numbers of series terms. |
| Date | |
| Source | Own work |
| Author | Glosser.ca |
| Other versions | File:StirlingError.svg Image:StirlingError.png File:StirlingError1.svg |
| SVG development | Category:Valid SVG created with Mathematica code:Diagrams#Stirling%20error%20vs%20number%20of%20terms.svg |
| Source code | Mathematica codeb[0] = b[1] = 1;
b[n_] := b[n] =
1/(n + 1) (b[n - 1] - Sum[k b[k] b[n + 1 - k], {k, 2, n - 1}])
a[n_] := (2 n + 1)!! b[2 n + 1]
Approx[z_, n_] := Sqrt[2 \[Pi] z] (z/E)^z Sum[a[k] z^-k, {k, 0, n}]
err[z_, n_] := Abs[(Approx[z, n] - z!)/z!]
Block[{$MaxExtraPrecision = 150},
ListLogPlot[
{
err[10, #] & /@ Range[0, 200],
err[20, #] & /@ Range[0, 200],
err[30, #] & /@ Range[0, 200]
},
Joined -> True,
Frame -> True,
ImageSize -> Large,
PlotStyle -> Thick,
FrameStyle -> Directive[Black],
FrameLabel -> {"Number of terms", "Relative Error"},
FrameTicks -> {{Automatic, Automatic}, {Range[0, 200, 25],
Automatic}},
GridLines -> {Range[0, 200, 25], Automatic},
GridLinesStyle -> Directive[LightGray, Dashed],
PlotLegends -> Placed[
LineLegend[{10, 20, 30}, LegendLabel -> "Argument, n:"],
Top
]
]
]
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.