重读微积分(一):极限
4 极限常数
圆周率 π \pi π
历史上很早就产生了极限思想,而割圆术就是这种思想的绝佳体现。
设正N边形边长为 a a a,则周长为 L = N a L=Na L=Na,而其边长与边数的关系可以表示为
a = 2 R sin π N → L = 2 N R sin π N a=2R\sin\frac{\pi}{N}\to L=2NR\sin\frac{\pi}{N} a=2RsinNπ→L=2NRsinNπ
圆可以理解为边数为无穷多的正多边形,即
L = lim n → ∞ 2 n R sin π n = 2 π R L=\lim_{n\to\infty}2nR\sin\frac{\pi}{n}=2\pi R L=n→∞lim2nRsinnπ=2πR
由于古人不知道圆周率,所以需要通过不断地测量多边形的边长和周长来逼近,则对于正多边形而言
Π = L 2 R = N sin π N \Pi=\frac{L}{2R}=N\sin\frac{\pi}{N} Π=2RL=NsinNπ
N = c(3:100)
Pi = N*sin(pi/N)
plot(N,Pi,type='l',xlab='N',ylab='Pi')
由于到了后面,误差变得越来越小,所以用对数来看一下误差的变化
N = c(3:10000)
err =log(pi-N*sin(pi/N),10)
plot(N,err,type='l',xlab='N',ylab='err')
可见割到了正10000边形,也只能得到
1
0
−
7
10^{-7}
10−7的精度,通过计算可以得到正10000边形算出的圆周率约为3.14159260
,所以我们至今也无法知道祖冲之他老人家到底是怎么得到的。
options(digits=15)
10000*sin(pi/10000)
[1] 3.14159260191267
圆周率的这种定义其实也提供了一个重要极限,即
π = lim n → ∞ N sin π N → lim x → 0 sin x x = 1 \pi=\lim_{n\to\infty}N\sin\frac{\pi}{N}\to\lim_{x\to0}\frac{\sin x}{x}=1 π=n→∞limNsinNπ→x→0limxsinx=1
自然对数e
很多人喜欢把自然对数和复利计算联系在一起。
假设某银行的年利率为 x x x,即存入W元,一年之后本息合计 W ( 1 + x ) W(1+x) W(1+x);如果一年之后将本息重新存入银行,则再过一年,本息合计为 W ( 1 + x ) 2 W(1+x)^2 W(1+x)2,重复操作 n n n年之后,则其本息之和为 W ( 1 + x ) n W(1+x)^n W(1+x)n。
假设这家银行可以按月算利率,则每月利率为 x 12 \frac{x}{12} 12x,如果按月存取,则每年本息之和为 W ( 1 + x 12 ) 12 W(1+\frac{x}{12})^{12} W(1+12x)12。
假设这家很行可以按照任意时间算利率,若存钱时间为 1 n \frac{1}{n} n1年,则利率为 x n \frac{x}{n} nx,相应地一年的本息之和为 W ( 1 + x n ) n W(1+\frac{x}{n})^n W(1+nx)n。
那么问题来了,是不是随着 n n n逐渐增大,一年的收获会越来越多呢?
为了计算方便,假设 x = 1 x=1 x=1,即正常 W W W存一年,一年之后本息翻倍为2W。
结果发现
最终这个值趋近于一个常数,这个常数就定义为 e e e,看来一年最多翻e倍,这个方法没办法发财了。但至少明白了一个著名的极限
e = lim n → ∞ ( 1 + 1 n ) n = 2.7182818... e=\lim_{n\to\infty}(1+\frac{1}{n})^n=2.7182818... e=n→∞lim(1+n1)n=2.7182818...
当然,银行不太可能有翻倍这么爽的年利率,设为 x x x的话,则有
e x = ( lim n → ∞ ( 1 + 1 n ) n ) x = lim n → ∞ ( 1 + 1 n ) n x = lim m → ∞ ( 1 + x m ) m e^x=(\lim_{n\to\infty}(1+\frac{1}{n})^n)^x=\lim_{n\to\infty}(1+\frac{1}{n})^{nx}=\lim_{m\to\infty}(1+\frac{x}{m})^m ex=(n→∞lim(1+n1)n)x=n→∞lim(1+n1)nx=m→∞lim(1+mx)m
很合理。
欧拉常数 γ \gamma γ
对 e e e两侧以 e e e为底取对数,可得
1 = lim n → ∞ n ln ( 1 + 1 n ) = lim n → ∞ n ln ( n + 1 n ) = lim n → ∞ ln ( n + 1 ) − ln n 1 n 1=\lim_{n\to\infty}n\ln(1+\frac{1}{n})=\lim_{n\to\infty}n\ln(\frac{n+1}{n})=\lim_{n\to\infty}\frac{\ln(n+1)-\ln n}{\frac{1}{n}} 1=n→∞limnln(1+n1)=n→∞limnln(nn+1)=n→∞limn1ln(n+1)−lnn
根据这个式子,我们可以猜测
γ = ∑ n = 1 ∞ 1 n − ∑ n = 1 ∞ [ ln ( n + 1 ) − ln n ] = lim N → ∞ ∑ n = 1 N 1 n − ln N \gamma=\sum_{n=1}^\infty\frac{1}{n}-\sum_{n=1}^\infty[\ln(n+1)-\ln n]=\lim_{N\to\infty}\sum_{n=1}^N\frac{1}{n}-\ln N γ=n=1∑∞n1−n=1∑∞[ln(n+1)−lnn]=N→∞limn=1∑Nn1−lnN
是一个常数:
N = c(1:10000)
for(i in c(1:0000)){
H[i]=sum(1/N[0:i])
}
plot(N,gamma,type='l',xlab='N',ylab='gamma')
gamma[10000]
[1] 0.577265664068198
我们猜对了,这个常数即欧拉常数。
其证明过程也不复杂
ln N = ∫ 1 N 1 x d x = ∫ 1 N 1 x + 1 ⌊ x ⌋ − 1 ⌊ x ⌋ d x = ∑ n = 1 N 1 n + ∫ 1 N 1 x − 1 ⌊ x ⌋ d x \begin{aligned} \ln N&=\int^N_1\frac{1}{x}\text dx=\int^N_1\frac{1}{x}+\frac{1}{\lfloor x\rfloor}-\frac{1}{\lfloor x\rfloor}\text dx\\ &=\sum_{n=1}^N\frac{1}{n}+\int^N_1\frac{1}{x}-\frac{1}{\lfloor x\rfloor}\text dx \end{aligned} lnN=∫1Nx1dx=∫1Nx1+⌊x⌋1−⌊x⌋1dx=n=1∑Nn1+∫1Nx1−⌊x⌋1dx
令 − γ = ∫ 1 N 1 x − 1 ⌊ x ⌋ d x -\gamma=\int^N_1\frac{1}{x}-\frac{1}{\lfloor x\rfloor}\text dx −γ=∫1Nx1−⌊x⌋1dx,则
γ = ∫ 1 N x − ⌊ x ⌋ x ⌊ x ⌋ d x < ∫ 1 N 1 ⌊ x ⌋ 2 d x \gamma=\int^N_1\frac{x-\lfloor x\rfloor}{x\lfloor x\rfloor}\text dx<\int^N_1\frac{1}{\lfloor x\rfloor^2}\text dx γ=∫1Nx⌊x⌋x−⌊x⌋dx<∫1N⌊x⌋21dx
则 γ \gamma γ收敛。