{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\nWe show that $\\ln n! - (n + \\frac{1}{2}) \\ln n + n$ converges, by bounding its successive differences. Then the [[Wallis product|0XCYA4YERS]] identifies the limit.\n\n*Part 1: a convergent sequence.*\n\n1. For each integer $n \\ge 1$, let $d_n = \\ln(n!) - (n + \\tfrac{1}{2}) \\ln n + n$. Here $\\ln$ is the [[natural logarithm|0044CPHJBV]].\n2. By the [[logarithm of a product|0K2FNY6DYV]], $\\ln((n + 1)!) = \\ln(n!) + \\ln(n + 1)$. Substituting this into $d_n - d_{n+1}$ and collecting terms gives\n$$d_n - d_{n+1} = (n + \\tfrac{1}{2}) \\big( \\ln(n + 1) - \\ln n \\big) - 1.$$\n3. For $-1 \u003c t \u003c 1$, let $\\varphi(t) = \\ln(1 + t) - \\ln(1 - t)$. By the [[derivative of the logarithm|07X1QA6BRW]], the [[chain rule|0RXX2PT1MQ]] and [[linearity of differentiation|0M0TKFRX2A]], $\\varphi'(t) = \\frac{1}{1 + t} + \\frac{1}{1 - t} = \\frac{2}{1 - t^2}$.\n4. Let $0 \u003c x \u003c 1$. The function $t \\mapsto \\frac{2}{1 - t^2}$ is continuous on $[0, x]$, by [[continuity of quotients|0GR2APWTAC]]. Also $\\varphi(0) = 0$.\n5. By the [[fundamental theorem of calculus|0NHGY0N0JB]] and steps 3 and 4, $\\varphi(x) = \\int_0^x \\frac{2}{1 - t^2} \\, dt$.\n6. Let $0 \\le t \\le x$. Since $(1 - t^2)(1 + t^2) = 1 - t^4 \\le 1$, we get $\\frac{2}{1 - t^2} \\ge 2 + 2t^2$.\n7. Also $\\frac{2}{1 - t^2} = 2 + \\frac{2t^2}{1 - t^2} \\le 2 + \\frac{2t^2}{1 - x^2}$, since $1 - t^2 \\ge 1 - x^2 \u003e 0$.\n8. By [[monotonicity of the integral|0MBWQKM8QR]], the [[integral of a power|0Q3HYFT9RQ]] and [[linearity of the integral|080RWVVSB6]], steps 5 to 7 give\n$$2x + \\frac{2x^3}{3} \\le \\varphi(x) \\le 2x + \\frac{2x^3}{3(1 - x^2)}.$$\n9. Fix $n \\ge 1$ and put $x = \\frac{1}{2n + 1}$. Then $\\frac{1 + x}{1 - x} = \\frac{n + 1}{n}$ and $n + \\frac{1}{2} = \\frac{1}{2x}$.\n10. By the [[logarithm of a quotient|0J7PHRBNNS]], $\\varphi(x) = \\ln \\frac{1 + x}{1 - x} = \\ln(n + 1) - \\ln n$. So step 2 gives $d_n - d_{n+1} = \\frac{\\varphi(x)}{2x} - 1$.\n11. Dividing step 8 by $2x$ gives $\\frac{x^2}{3} \\le d_n - d_{n+1} \\le \\frac{x^2}{3(1 - x^2)}$.\n12. With $x = \\frac{1}{2n+1}$, we have $\\frac{x^2}{1 - x^2} = \\frac{1}{(2n + 1)^2 - 1} = \\frac{1}{4n(n + 1)}$. So step 11 gives\n$$0 \u003c d_n - d_{n+1} \\le \\frac{1}{12 n (n + 1)} = \\frac{1}{12} \\Big( \\frac{1}{n} - \\frac{1}{n + 1} \\Big).$$\n13. By step 12, $(d_n)$ is [[decreasing|0KN22AAW5R]].\n14. Let $e_n = d_n - \\frac{1}{12 n}$. By step 12, $e_n - e_{n+1} = (d_n - d_{n+1}) - \\frac{1}{12}(\\frac{1}{n} - \\frac{1}{n+1}) \\le 0$. So $(e_n)$ is increasing.\n15. Since $\\ln 1 = 0$, we get $d_1 = 1$. By step 14, $d_n \\ge e_n \\ge e_1 = \\frac{11}{12}$ for all $n$.\n16. The sequence $(-d_n)$ is increasing and bounded above by $-\\frac{11}{12}$. By the [[monotone convergence theorem|0FM6N4R0VB]], it converges. So $d_n \\to C$ for some real number $C$.\n\n*Part 2: the limit is $\\ln \\sqrt{2\\pi}$.*\n\n17. For $n \\ge 1$, let $a_n = \\frac{n! \\, e^n}{n^n \\sqrt{n}}$.\n18. By the [[exponential of a sum|0E8HNVBCSP]] and induction on $n$, $e^n = \\exp(1)^n = \\exp(n)$. So $\\ln(e^n) = n$, by the definition of $\\ln$.\n19. By the [[logarithm of a power|0V948DE5KA]], $\\ln(n^n) = n \\ln n$ and $2 \\ln \\sqrt{n} = \\ln n$.\n20. By steps 18 and 19, and the logarithm of a product and of a quotient, $\\ln a_n = \\ln(n!) + n - n \\ln n - \\frac{1}{2} \\ln n = d_n$. So $a_n = \\exp(d_n)$.\n21. The exponential function is differentiable by [[$\\exp' = \\exp$|0EX9GFJ0B3]]. So it is continuous, since [[differentiable functions are continuous|07ZMX4ANJS]].\n22. By step 21 and [[sequential continuity|0PAQM3H57X]], $a_n = \\exp(d_n) \\to \\exp(C)$. Put $\\alpha = \\exp(C)$. Then $\\alpha \u003e 0$, since [[the exponential function is positive|0P9BNBW2W3]].\n23. For each $N$, $n \\ge N$ implies $2n \\ge N$. So also $a_{2n} \\to \\alpha$.\n24. Let $q_n = \\frac{a_n^2}{a_{2n}}$. By the limit rules for [[products|0734RSVF2V]] and [[quotients|03S6GWWKEZ]], and $\\alpha \\ne 0$, we get $q_n \\to \\frac{\\alpha^2}{\\alpha} = \\alpha$.\n25. Substituting the definition of $a_n$ and $a_{2n}$, the factors $e^{2n}$ and $n^{2n}$ cancel. Using $\\sqrt{2n} = \\sqrt{2} \\sqrt{n}$, this gives\n$$q_n = \\frac{(n!)^2 \\, 2^{2n} \\sqrt{2}}{(2n)! \\, \\sqrt{n}}, \\qquad q_n^2 = \\frac{2 \\cdot 2^{4n} (n!)^4}{((2n)!)^2 \\, n}.$$\n26. Let $P_n = \\prod_{k=1}^{n} \\frac{4k^2}{4k^2 - 1}$ be the partial products of the Wallis product. The numerators multiply to $\\prod_{k=1}^n (2k)^2 = 2^{2n} (n!)^2$.\n27. Write $4k^2 - 1 = (2k - 1)(2k + 1)$. Since $(2n)!$ is the product of the even numbers $2k$ and the odd numbers $2k - 1$ for $k \\le n$, we get $\\prod_{k=1}^{n} (2k - 1) = \\frac{(2n)!}{2^n n!}$.\n28. Shifting the index, $\\prod_{k=1}^{n} (2k + 1) = (2n + 1) \\prod_{k=1}^{n} (2k - 1)$. With steps 26 and 27,\n$$P_n = \\frac{2^{4n} (n!)^4}{(2n + 1) \\, ((2n)!)^2}.$$\n29. Comparing steps 25 and 28, $q_n^2 = P_n \\cdot \\frac{2(2n + 1)}{n} = P_n \\big( 4 + \\frac{2}{n} \\big)$.\n30. By the [[Wallis product|0XCYA4YERS]], $P_n \\to \\frac{\\pi}{2}$. Since [[$1/n \\to 0$|08QAX4H1PF]], the [[sum rule|0RAM4E07NR]] gives $4 + \\frac{2}{n} \\to 4$. By the product rule, $q_n^2 \\to 2\\pi$.\n31. By step 24 and the product rule, also $q_n^2 \\to \\alpha^2$. A sequence has at most one limit, so $\\alpha^2 = 2\\pi$. Since $\\alpha \u003e 0$, $\\alpha = \\sqrt{2\\pi}$.\n\n*Part 3: conclusion.*\n\n32. For $n \\ge 1$, let $s_n = \\sqrt{2\\pi n} \\, (n/e)^n$ and $\\rho_n = \\frac{n!}{s_n}$. Then $\\rho_n = \\frac{n! \\, e^n}{\\sqrt{2\\pi} \\sqrt{n} \\, n^n} = \\frac{a_n}{\\sqrt{2\\pi}}$.\n33. By steps 22 and 31, $\\rho_n \\to \\frac{\\alpha}{\\sqrt{2\\pi}} = 1$. This is the ratio form of the statement.\n34. Let $\\varepsilon \u003e 0$. By step 33, there is $N$ with $|\\rho_n - 1| \\le \\varepsilon$ for all $n \\ge N$. Then $|n! - s_n| = |\\rho_n - 1| \\, s_n \\le \\varepsilon s_n$ for $n \\ge N$.\n35. By the definition of [[little o notation|04TSHB9H8D]], step 34 says $n! - s_n = o(s_n)$. So $n! \\sim \\sqrt{2\\pi n} \\, (n/e)^n$, by the definition of [[asymptotic equivalence|00SB5EA3VW]].\n\n## Idea\n\nThe quantity $d_n = \\ln n! - (n + \\frac{1}{2}) \\ln n + n$ changes by at most $\\frac{1}{12n(n+1)}$ per step, and these changes have a finite total. So $n!$ is asymptotic to $\\alpha \\sqrt{n} (n/e)^n$ for some constant $\\alpha \u003e 0$. Comparing $n!$ with $(2n)!$ turns the constant into the Wallis product, which forces $\\alpha = \\sqrt{2\\pi}$.\n",
  "commit": "4a3290d299c8b2cd6493fce2296920ba7f82d942",
  "front": {
    "kind": "proof",
    "msc": [
      "41A60",
      "05A10"
    ],
    "name": "Proof of Stirling's formula by a monotone sequence and the Wallis product",
    "proves": "0KC0F51T6A",
    "sources": [
      {
        "locator": "Equation for discrete cases",
        "url": "https://en.wikipedia.org/wiki/Stirling%27s_approximation"
      }
    ],
    "tag": "SE8YGSNANQ",
    "uses": [
      "0044CPHJBV",
      "0K2FNY6DYV",
      "0J7PHRBNNS",
      "0V948DE5KA",
      "07X1QA6BRW",
      "0RXX2PT1MQ",
      "0M0TKFRX2A",
      "0GR2APWTAC",
      "0NHGY0N0JB",
      "0MBWQKM8QR",
      "0Q3HYFT9RQ",
      "080RWVVSB6",
      "0KN22AAW5R",
      "0FM6N4R0VB",
      "0E8HNVBCSP",
      "0EX9GFJ0B3",
      "07ZMX4ANJS",
      "0PAQM3H57X",
      "0P9BNBW2W3",
      "0734RSVF2V",
      "03S6GWWKEZ",
      "0RAM4E07NR",
      "08QAX4H1PF",
      "0XCYA4YERS",
      "04TSHB9H8D",
      "00SB5EA3VW"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/SE8YGSNANQ/",
  "links": [
    {
      "field": "proves",
      "target": "0KC0F51T6A"
    },
    {
      "field": "uses",
      "target": "0044CPHJBV"
    },
    {
      "field": "uses",
      "target": "0K2FNY6DYV"
    },
    {
      "field": "uses",
      "target": "0J7PHRBNNS"
    },
    {
      "field": "uses",
      "target": "0V948DE5KA"
    },
    {
      "field": "uses",
      "target": "07X1QA6BRW"
    },
    {
      "field": "uses",
      "target": "0RXX2PT1MQ"
    },
    {
      "field": "uses",
      "target": "0M0TKFRX2A"
    },
    {
      "field": "uses",
      "target": "0GR2APWTAC"
    },
    {
      "field": "uses",
      "target": "0NHGY0N0JB"
    },
    {
      "field": "uses",
      "target": "0MBWQKM8QR"
    },
    {
      "field": "uses",
      "target": "0Q3HYFT9RQ"
    },
    {
      "field": "uses",
      "target": "080RWVVSB6"
    },
    {
      "field": "uses",
      "target": "0KN22AAW5R"
    },
    {
      "field": "uses",
      "target": "0FM6N4R0VB"
    },
    {
      "field": "uses",
      "target": "0E8HNVBCSP"
    },
    {
      "field": "uses",
      "target": "0EX9GFJ0B3"
    },
    {
      "field": "uses",
      "target": "07ZMX4ANJS"
    },
    {
      "field": "uses",
      "target": "0PAQM3H57X"
    },
    {
      "field": "uses",
      "target": "0P9BNBW2W3"
    },
    {
      "field": "uses",
      "target": "0734RSVF2V"
    },
    {
      "field": "uses",
      "target": "03S6GWWKEZ"
    },
    {
      "field": "uses",
      "target": "0RAM4E07NR"
    },
    {
      "field": "uses",
      "target": "08QAX4H1PF"
    },
    {
      "field": "uses",
      "target": "0XCYA4YERS"
    },
    {
      "field": "uses",
      "target": "04TSHB9H8D"
    },
    {
      "field": "uses",
      "target": "00SB5EA3VW"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/SE8YGSNANQ.md",
  "msc": [
    "41A60",
    "05A10"
  ],
  "name": "Proof of Stirling's formula by a monotone sequence and the Wallis product",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/SE8/SE8YGSNANQ.md",
  "status": null,
  "tag": "SE8YGSNANQ",
  "uri": "m2://SE8YGSNANQ",
  "url": "https://math2.tamnd.com/wiki/proof-of-stirlings-formula-by-a-monotone-sequence-and-the-wallis-product/",
  "writing": {
    "tag": "SE8YGSNANQ",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
