e的近似值
e≈99990271801,精确到小数点后9位
e≈(π4+π5)1/6,精确到小数点后7位
Is this the Coolest Approximation for e? 提到了一种用到了 123456789 的近似
e≈(1+9−46×7)3285,精确到小数点后18457734525360901453873570位
从 e 的定义出发
e=n→∞lim(1+n1)n
上面近似中的大数字
946×7=9442=(32)(22)42=3285
确实满足 e 的定义式,近似很有道理,但是我想知道如何得到近似的精度。
判断这个数字精确到 e 的小数点后几位
A=(1+N1)N
lnA=Nln(1+N1)=N(N1−2N21+3N31−⋯)=1−2N1+3N21−⋯
A=elnA=e1−2N1+O(N21)=e1⋅e−2N1⋅eO(N21)
再次利用 ex≈1+x 的近似:
A≈e(1−2N1)=e−2Ne
该近似值的绝对误差大约是 2Ne。
要确定“精确到小数点后多少位”,我们主要看误差项 N1 的数量级。有效位数 D 大约等于 N 的以10为底的对数。
D≈log10(N)
我们可以使用 Python 的 decimal 模块进行高精度计算:
1 2 3 4 5 6 7 8 9 10
| import decimal
decimal.getcontext().prec = 100
power_of_2 = decimal.Decimal(2) ** 85 log10_3 = decimal.Decimal(3).log10() total_digits = power_of_2 * log10_3
print(f"{total_digits:.0f}")
|
可以得到
1
| 18457734525360901453873570
|
确实如此。