Metamath Proof Explorer


Theorem stirlinglem14

Description: The sequence A converges to a positive real. This proves that the Stirling's formula converges to the factorial, up to a constant. In another theorem, using Wallis' formula for π& , such constant is exactly determined, thus proving the Stirling's formula. (Contributed by Glauco Siliprandi, 29-Jun-2017)

Ref Expression
Hypotheses stirlinglem14.1 A = n n ! 2 n n e n
stirlinglem14.2 B = n log A n
Assertion stirlinglem14 c + A c

Proof

Step Hyp Ref Expression
1 stirlinglem14.1 A = n n ! 2 n n e n
2 stirlinglem14.2 B = n log A n
3 1 2 stirlinglem13 d B d
4 simpl d B d d
5 4 rpefcld d B d e d +
6 nnuz = 1
7 1zzd d B d 1
8 efcn exp : cn
9 8 a1i d B d exp : cn
10 nnnn0 n n 0
11 faccl n 0 n !
12 nncn n ! n !
13 10 11 12 3syl n n !
14 2cnd n 2
15 nncn n n
16 14 15 mulcld n 2 n
17 16 sqrtcld n 2 n
18 epr e +
19 rpcn e + e
20 18 19 ax-mp e
21 20 a1i n e
22 0re 0
23 epos 0 < e
24 22 23 gtneii e 0
25 24 a1i n e 0
26 15 21 25 divcld n n e
27 26 10 expcld n n e n
28 17 27 mulcld n 2 n n e n
29 2rp 2 +
30 29 a1i n 2 +
31 nnrp n n +
32 30 31 rpmulcld n 2 n +
33 32 sqrtgt0d n 0 < 2 n
34 33 gt0ne0d n 2 n 0
35 nnne0 n n 0
36 15 21 35 25 divne0d n n e 0
37 nnz n n
38 26 36 37 expne0d n n e n 0
39 17 27 34 38 mulne0d n 2 n n e n 0
40 13 28 39 divcld n n ! 2 n n e n
41 1 fvmpt2 n n ! 2 n n e n A n = n ! 2 n n e n
42 40 41 mpdan n A n = n ! 2 n n e n
43 42 40 eqeltrd n A n
44 nnne0 n ! n ! 0
45 10 11 44 3syl n n ! 0
46 13 28 45 39 divne0d n n ! 2 n n e n 0
47 42 46 eqnetrd n A n 0
48 43 47 logcld n log A n
49 2 48 fmpti B :
50 49 a1i d B d B :
51 simpr d B d B d
52 4 recnd d B d d
53 6 7 9 50 51 52 climcncf d B d exp B e d
54 8 elexi exp V
55 nnex V
56 55 mptex n log A n V
57 2 56 eqeltri B V
58 54 57 coex exp B V
59 58 a1i exp B V
60 55 mptex n n ! 2 n n e n V
61 1 60 eqeltri A V
62 61 a1i A V
63 1zzd 1
64 2 funmpt2 Fun B
65 id k k
66 rabid2 = n | log A n V n log A n V
67 1 stirlinglem2 n A n +
68 relogcl A n + log A n
69 elex log A n log A n V
70 67 68 69 3syl n log A n V
71 66 70 mprgbir = n | log A n V
72 2 dmmpt dom B = n | log A n V
73 71 72 eqtr4i = dom B
74 65 73 eleqtrdi k k dom B
75 fvco Fun B k dom B exp B k = e B k
76 64 74 75 sylancr k exp B k = e B k
77 1 a1i k A = n n ! 2 n n e n
78 simpr k n = k n = k
79 78 fveq2d k n = k n ! = k !
80 78 oveq2d k n = k 2 n = 2 k
81 80 fveq2d k n = k 2 n = 2 k
82 78 oveq1d k n = k n e = k e
83 82 78 oveq12d k n = k n e n = k e k
84 81 83 oveq12d k n = k 2 n n e n = 2 k k e k
85 79 84 oveq12d k n = k n ! 2 n n e n = k ! 2 k k e k
86 nnnn0 k k 0
87 faccl k 0 k !
88 nncn k ! k !
89 86 87 88 3syl k k !
90 2cnd k 2
91 nncn k k
92 90 91 mulcld k 2 k
93 92 sqrtcld k 2 k
94 20 a1i k e
95 24 a1i k e 0
96 91 94 95 divcld k k e
97 96 86 expcld k k e k
98 93 97 mulcld k 2 k k e k
99 29 a1i k 2 +
100 nnrp k k +
101 99 100 rpmulcld k 2 k +
102 101 sqrtgt0d k 0 < 2 k
103 102 gt0ne0d k 2 k 0
104 nnne0 k k 0
105 91 94 104 95 divne0d k k e 0
106 nnz k k
107 96 105 106 expne0d k k e k 0
108 93 97 103 107 mulne0d k 2 k k e k 0
109 89 98 108 divcld k k ! 2 k k e k
110 77 85 65 109 fvmptd k A k = k ! 2 k k e k
111 110 109 eqeltrd k A k
112 nnne0 k ! k ! 0
113 86 87 112 3syl k k ! 0
114 89 98 113 108 divne0d k k ! 2 k k e k 0
115 110 114 eqnetrd k A k 0
116 111 115 logcld k log A k
117 nfcv _ n k
118 nfcv _ n log
119 nfmpt1 _ n n n ! 2 n n e n
120 1 119 nfcxfr _ n A
121 120 117 nffv _ n A k
122 118 121 nffv _ n log A k
123 2fveq3 n = k log A n = log A k
124 117 122 123 2 fvmptf k log A k B k = log A k
125 116 124 mpdan k B k = log A k
126 125 fveq2d k e B k = e log A k
127 eflog A k A k 0 e log A k = A k
128 111 115 127 syl2anc k e log A k = A k
129 76 126 128 3eqtrd k exp B k = A k
130 129 adantl k exp B k = A k
131 6 59 62 63 130 climeq exp B e d A e d
132 131 mptru exp B e d A e d
133 53 132 sylib d B d A e d
134 breq2 c = e d A c A e d
135 134 rspcev e d + A e d c + A c
136 5 133 135 syl2anc d B d c + A c
137 136 rexlimiva d B d c + A c
138 3 137 ax-mp c + A c