Metamath Proof Explorer


Theorem stirlinglem15

Description: The Stirling's formula is proven using a number of local definitions. The main theorem stirling will use this final lemma, but it will not expose the local definitions. (Contributed by Glauco Siliprandi, 29-Jun-2017)

Ref Expression
Hypotheses stirlinglem15.1 n φ
stirlinglem15.2 S = n 0 2 π n n e n
stirlinglem15.3 A = n n ! 2 n n e n
stirlinglem15.4 D = n A 2 n
stirlinglem15.5 E = n 2 n n e n
stirlinglem15.6 V = n 2 4 n n ! 4 2 n ! 2 2 n + 1
stirlinglem15.7 F = n A n 4 D n 2
stirlinglem15.8 H = n n 2 n 2 n + 1
stirlinglem15.9 φ C +
stirlinglem15.10 φ A C
Assertion stirlinglem15 φ n n ! S n 1

Proof

Step Hyp Ref Expression
1 stirlinglem15.1 n φ
2 stirlinglem15.2 S = n 0 2 π n n e n
3 stirlinglem15.3 A = n n ! 2 n n e n
4 stirlinglem15.4 D = n A 2 n
5 stirlinglem15.5 E = n 2 n n e n
6 stirlinglem15.6 V = n 2 4 n n ! 4 2 n ! 2 2 n + 1
7 stirlinglem15.7 F = n A n 4 D n 2
8 stirlinglem15.8 H = n n 2 n 2 n + 1
9 stirlinglem15.9 φ C +
10 stirlinglem15.10 φ A C
11 nnnn0 n n 0
12 11 adantl φ n n 0
13 2cnd φ n 2
14 picn π
15 14 a1i φ n π
16 13 15 mulcld φ n 2 π
17 nncn n n
18 17 adantl φ n n
19 16 18 mulcld φ n 2 π n
20 19 sqrtcld φ n 2 π n
21 ere e
22 21 recni e
23 22 a1i n e
24 epos 0 < e
25 21 24 gt0ne0ii e 0
26 25 a1i n e 0
27 17 23 26 divcld n n e
28 27 11 expcld n n e n
29 28 adantl φ n n e n
30 20 29 mulcld φ n 2 π n n e n
31 2 fvmpt2 n 0 2 π n n e n S n = 2 π n n e n
32 12 30 31 syl2anc φ n S n = 2 π n n e n
33 32 oveq2d φ n n ! S n = n ! 2 π n n e n
34 15 sqrtcld φ n π
35 2cnd n 2
36 35 17 mulcld n 2 n
37 36 sqrtcld n 2 n
38 37 adantl φ n 2 n
39 34 38 29 mulassd φ n π 2 n n e n = π 2 n n e n
40 nfmpt1 _ n n A n 4 D n 2
41 7 40 nfcxfr _ n F
42 nfmpt1 _ n n n 2 n 2 n + 1
43 8 42 nfcxfr _ n H
44 nfmpt1 _ n n 2 4 n n ! 4 2 n ! 2 2 n + 1
45 6 44 nfcxfr _ n V
46 nnuz = 1
47 1zzd φ 1
48 nfmpt1 _ n n n ! 2 n n e n
49 3 48 nfcxfr _ n A
50 nfmpt1 _ n n A 2 n
51 4 50 nfcxfr _ n D
52 faccl n 0 n !
53 11 52 syl n n !
54 53 nnrpd n n ! +
55 2rp 2 +
56 55 a1i n 2 +
57 nnrp n n +
58 56 57 rpmulcld n 2 n +
59 58 rpsqrtcld n 2 n +
60 epr e +
61 60 a1i n e +
62 57 61 rpdivcld n n e +
63 nnz n n
64 62 63 rpexpcld n n e n +
65 59 64 rpmulcld n 2 n n e n +
66 54 65 rpdivcld n n ! 2 n n e n +
67 3 66 fmpti A : +
68 67 a1i φ A : +
69 eqid n A n 4 = n A n 4
70 eqid n D n 2 = n D n 2
71 67 a1i n A : +
72 2nn 2
73 72 a1i n 2
74 id n n
75 73 74 nnmulcld n 2 n
76 71 75 ffvelrnd n A 2 n +
77 4 fvmpt2 n A 2 n + D n = A 2 n
78 76 77 mpdan n D n = A 2 n
79 78 76 eqeltrd n D n +
80 79 adantl φ n D n +
81 1 49 51 4 68 7 69 70 80 9 10 stirlinglem8 φ F C 2
82 nnex V
83 82 mptex n 2 4 n n ! 4 2 n ! 2 2 n + 1 V
84 6 83 eqeltri V V
85 84 a1i φ V V
86 eqid n 1 1 2 n + 1 = n 1 1 2 n + 1
87 eqid n 1 2 n + 1 = n 1 2 n + 1
88 eqid n 1 n = n 1 n
89 8 86 87 88 stirlinglem1 H 1 2
90 89 a1i φ H 1 2
91 53 nncnd n n !
92 37 28 mulcld n 2 n n e n
93 58 sqrtgt0d n 0 < 2 n
94 93 gt0ne0d n 2 n 0
95 nnne0 n n 0
96 17 23 95 26 divne0d n n e 0
97 27 96 63 expne0d n n e n 0
98 37 28 94 97 mulne0d n 2 n n e n 0
99 91 92 98 divcld n n ! 2 n n e n
100 3 fvmpt2 n n ! 2 n n e n A n = n ! 2 n n e n
101 99 100 mpdan n A n = n ! 2 n n e n
102 101 99 eqeltrd n A n
103 4nn0 4 0
104 103 a1i n 4 0
105 102 104 expcld n A n 4
106 79 rpcnd n D n
107 106 sqcld n D n 2
108 79 rpne0d n D n 0
109 2z 2
110 109 a1i n 2
111 106 108 110 expne0d n D n 2 0
112 105 107 111 divcld n A n 4 D n 2
113 7 fvmpt2 n A n 4 D n 2 F n = A n 4 D n 2
114 112 113 mpdan n F n = A n 4 D n 2
115 114 112 eqeltrd n F n
116 115 adantl φ n F n
117 17 sqcld n n 2
118 1cnd n 1
119 36 118 addcld n 2 n + 1
120 17 119 mulcld n n 2 n + 1
121 75 nnred n 2 n
122 1red n 1
123 75 nngt0d n 0 < 2 n
124 0lt1 0 < 1
125 124 a1i n 0 < 1
126 121 122 123 125 addgt0d n 0 < 2 n + 1
127 126 gt0ne0d n 2 n + 1 0
128 17 119 95 127 mulne0d n n 2 n + 1 0
129 117 120 128 divcld n n 2 n 2 n + 1
130 8 fvmpt2 n n 2 n 2 n + 1 H n = n 2 n 2 n + 1
131 129 130 mpdan n H n = n 2 n 2 n + 1
132 131 129 eqeltrd n H n
133 132 adantl φ n H n
134 112 129 mulcld n A n 4 D n 2 n 2 n 2 n + 1
135 3 4 5 6 stirlinglem3 V = n A n 4 D n 2 n 2 n 2 n + 1
136 135 fvmpt2 n A n 4 D n 2 n 2 n 2 n + 1 V n = A n 4 D n 2 n 2 n 2 n + 1
137 134 136 mpdan n V n = A n 4 D n 2 n 2 n 2 n + 1
138 114 131 oveq12d n F n H n = A n 4 D n 2 n 2 n 2 n + 1
139 137 138 eqtr4d n V n = F n H n
140 139 adantl φ n V n = F n H n
141 1 41 43 45 46 47 81 85 90 116 133 140 climmulf φ V C 2 1 2
142 6 wallispi2 V π 2
143 climuni V C 2 1 2 V π 2 C 2 1 2 = π 2
144 141 142 143 sylancl φ C 2 1 2 = π 2
145 144 oveq1d φ C 2 1 2 1 2 = π 2 1 2
146 9 rpcnd φ C
147 146 sqcld φ C 2
148 1cnd φ 1
149 148 halfcld φ 1 2
150 2cnd φ 2
151 2pos 0 < 2
152 151 a1i φ 0 < 2
153 152 gt0ne0d φ 2 0
154 150 153 recne0d φ 1 2 0
155 147 149 154 divcan4d φ C 2 1 2 1 2 = C 2
156 14 a1i φ π
157 124 a1i φ 0 < 1
158 157 gt0ne0d φ 1 0
159 156 148 150 158 153 divcan7d φ π 2 1 2 = π 1
160 156 div1d φ π 1 = π
161 159 160 eqtrd φ π 2 1 2 = π
162 145 155 161 3eqtr3d φ C 2 = π
163 162 fveq2d φ C 2 = π
164 9 rprege0d φ C 0 C
165 sqrtsq C 0 C C 2 = C
166 164 165 syl φ C 2 = C
167 163 166 eqtr3d φ π = C
168 167 adantr φ n π = C
169 168 oveq1d φ n π 2 n n e n = C 2 n n e n
170 146 adantr φ n C
171 92 adantl φ n 2 n n e n
172 170 171 mulcomd φ n C 2 n n e n = 2 n n e n C
173 39 169 172 3eqtrd φ n π 2 n n e n = 2 n n e n C
174 173 oveq2d φ n n ! π 2 n n e n = n ! 2 n n e n C
175 2re 2
176 175 a1i φ n 2
177 pire π
178 177 a1i φ n π
179 176 178 remulcld φ n 2 π
180 0le2 0 2
181 180 a1i φ n 0 2
182 0re 0
183 pipos 0 < π
184 182 177 183 ltleii 0 π
185 184 a1i φ n 0 π
186 176 178 181 185 mulge0d φ n 0 2 π
187 12 nn0red φ n n
188 12 nn0ge0d φ n 0 n
189 179 186 187 188 sqrtmuld φ n 2 π n = 2 π n
190 176 181 178 185 sqrtmuld φ n 2 π = 2 π
191 190 oveq1d φ n 2 π n = 2 π n
192 13 sqrtcld φ n 2
193 18 sqrtcld φ n n
194 192 34 193 mulassd φ n 2 π n = 2 π n
195 192 34 193 mul12d φ n 2 π n = π 2 n
196 176 181 187 188 sqrtmuld φ n 2 n = 2 n
197 196 eqcomd φ n 2 n = 2 n
198 197 oveq2d φ n π 2 n = π 2 n
199 195 198 eqtrd φ n 2 π n = π 2 n
200 191 194 199 3eqtrd φ n 2 π n = π 2 n
201 189 200 eqtrd φ n 2 π n = π 2 n
202 201 oveq1d φ n 2 π n n e n = π 2 n n e n
203 202 oveq2d φ n n ! 2 π n n e n = n ! π 2 n n e n
204 91 adantl φ n n !
205 94 adantl φ n 2 n 0
206 22 a1i φ n e
207 25 a1i φ n e 0
208 18 206 207 divcld φ n n e
209 95 adantl φ n n 0
210 18 206 209 207 divne0d φ n n e 0
211 63 adantl φ n n
212 208 210 211 expne0d φ n n e n 0
213 38 29 205 212 mulne0d φ n 2 n n e n 0
214 9 rpne0d φ C 0
215 214 adantr φ n C 0
216 204 171 170 213 215 divdiv1d φ n n ! 2 n n e n C = n ! 2 n n e n C
217 174 203 216 3eqtr4d φ n n ! 2 π n n e n = n ! 2 n n e n C
218 99 ancli n n n ! 2 n n e n
219 218 adantl φ n n n ! 2 n n e n
220 219 100 syl φ n A n = n ! 2 n n e n
221 220 eqcomd φ n n ! 2 n n e n = A n
222 221 oveq1d φ n n ! 2 n n e n C = A n C
223 33 217 222 3eqtrd φ n n ! S n = A n C
224 1 223 mpteq2da φ n n ! S n = n A n C
225 102 adantl φ n A n
226 225 170 215 divrec2d φ n A n C = 1 C A n
227 1 226 mpteq2da φ n A n C = n 1 C A n
228 146 214 reccld φ 1 C
229 82 mptex n 1 C A n V
230 229 a1i φ n 1 C A n V
231 3 a1i k A = n n ! 2 n n e n
232 simpr k n = k n = k
233 232 fveq2d k n = k n ! = k !
234 232 oveq2d k n = k 2 n = 2 k
235 234 fveq2d k n = k 2 n = 2 k
236 232 oveq1d k n = k n e = k e
237 236 232 oveq12d k n = k n e n = k e k
238 235 237 oveq12d k n = k 2 n n e n = 2 k k e k
239 233 238 oveq12d k n = k n ! 2 n n e n = k ! 2 k k e k
240 id k k
241 nnnn0 k k 0
242 faccl k 0 k !
243 nncn k ! k !
244 241 242 243 3syl k k !
245 2cnd k 2
246 nncn k k
247 245 246 mulcld k 2 k
248 247 sqrtcld k 2 k
249 22 a1i k e
250 25 a1i k e 0
251 246 249 250 divcld k k e
252 251 241 expcld k k e k
253 248 252 mulcld k 2 k k e k
254 55 a1i k 2 +
255 nnrp k k +
256 254 255 rpmulcld k 2 k +
257 256 sqrtgt0d k 0 < 2 k
258 257 gt0ne0d k 2 k 0
259 nnne0 k k 0
260 246 249 259 250 divne0d k k e 0
261 nnz k k
262 251 260 261 expne0d k k e k 0
263 248 252 258 262 mulne0d k 2 k k e k 0
264 244 253 263 divcld k k ! 2 k k e k
265 231 239 240 264 fvmptd k A k = k ! 2 k k e k
266 265 264 eqeltrd k A k
267 266 adantl φ k A k
268 nfcv _ k 1 C A n
269 nfcv _ n 1
270 nfcv _ n ÷
271 nfcv _ n C
272 269 270 271 nfov _ n 1 C
273 nfcv _ n ×
274 nfcv _ n k
275 49 274 nffv _ n A k
276 272 273 275 nfov _ n 1 C A k
277 fveq2 n = k A n = A k
278 277 oveq2d n = k 1 C A n = 1 C A k
279 268 276 278 cbvmpt n 1 C A n = k 1 C A k
280 279 a1i φ k n 1 C A n = k 1 C A k
281 280 fveq1d φ k n 1 C A n k = k 1 C A k k
282 simpr φ k k
283 146 adantr φ k C
284 214 adantr φ k C 0
285 283 284 reccld φ k 1 C
286 285 267 mulcld φ k 1 C A k
287 eqid k 1 C A k = k 1 C A k
288 287 fvmpt2 k 1 C A k k 1 C A k k = 1 C A k
289 282 286 288 syl2anc φ k k 1 C A k k = 1 C A k
290 281 289 eqtrd φ k n 1 C A n k = 1 C A k
291 46 47 10 228 230 267 290 climmulc2 φ n 1 C A n 1 C C
292 146 214 recid2d φ 1 C C = 1
293 291 292 breqtrd φ n 1 C A n 1
294 227 293 eqbrtrd φ n A n C 1
295 224 294 eqbrtrd φ n n ! S n 1