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.

Deutsch  English  español  فارسی  français  magyar  Bahasa Indonesia  italiano  日本語  македонски  മലയാളം  Nederlands  polski  prūsiskan  português do Brasil  русский  slovenščina  svenska  中文(简体)  中文(繁體)  +/−

minor quality
Category:Supersedes#Stirling%20error%20vs%20number%20of%20terms.svg

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
InfoField
 The SVG code is valid.
 This diagram was created with Mathematica.
Category:Valid SVG created with Mathematica code:Diagrams#Stirling%20error%20vs%20number%20of%20terms.svg
 The file size of this SVG diagram may be irrationally large because its text has been converted to paths inhibiting translations.
Category:Path text SVG
Source code
InfoField

Mathematica code

b[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:
w:en:Creative Commons
attribution share alike
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.
Category:CC-BY-SA-4.0#Stirling%20error%20vs%20number%20of%20terms.svgCategory:Self-published work
Category:Stirling's approximation
Category:CC-BY-SA-4.0 Category:Path text SVG Category:Self-published work Category:Stirling's approximation Category:Supersedes Category:Valid SVG created with Mathematica code:Diagrams