northwolves
发表于 2023-12-25 12:40:48
s = {2, 18, 118, 1687, 10793, 136120, 1530011, 18660269, 156001208,
1695509435}; Table[{n, N, 30]}, {n, s}] // MatrixForm
\begin{array}{cc}
2 & 3.46666666666666666666666666667 \\
18 & 3.19418790923194119578549953994 \\
118 & 3.14999586659346998324282737797 \\
1687 & 3.14100023658016021431039880615 \\
10793 & 3.14150000952847637080565879976 \\
136120 & 3.14159999999482983463504338118 \\
1530011 & 3.14159200000014818999687635402 \\
18660269 & 3.14159260000000059344736321673 \\
156001208 & 3.14159265999999996961688712845 \\
1695509435 & 3.14159265300000000065019395736 \\
\end{array}
northwolves
发表于 2023-12-25 12:42:30
6楼数据有误,前10项如下: {2, 18, 118, 1687, 10793, 136120, 1530011, 18660269, 156001208, 1695509435}
nyy
发表于 2023-12-25 12:54:32
northwolves 发表于 2023-12-25 12:42
6楼数据有误,前10项如下: {2, 18, 118, 1687, 10793, 136120, 1530011, 18660269, 156001208, 1695509435 ...
你看起来是对的,因为我找到了一个与你接近的结果。
A126809 Minimum number of terms required in the Gregory-Leibniz series, i.e., 4(1 - 1/3 + 1/5 - 1/7 + 1/9 - ...), to obtain a value of Pi correct to n decimal digits.
https://oeis.org/A126809
3, 19, 119, 1688, 10794, 136121, 1530012, 18660270, 156001209, 1695509436, 11136696006, 102111268282, 1260654956982, 10725187563686, 147895359776637, 1313133218365935, 16250291773636035, 118166387818704586, 1860961545617561679, 15963377896404315146
nyy
发表于 2023-12-25 13:04:19
本帖最后由 nyy 于 2023-12-25 13:08 编辑
nyy 发表于 2023-12-25 12:54
你看起来是对的,因为我找到了一个与你接近的结果。
A126809 Minimum number of terms required in the...
对上面的数取自然对数,依次精确到小数点后零位开始。
0 1.09861
1 2.94444
2 4.77912
3 7.4313
4 9.28675
5 11.8213
6 14.2408
7 16.7419
8 18.8654
9 21.2512
10 23.1335
11 25.3493
12 27.8627
13 30.0036
14 32.6275
15 34.8112
16 37.3269
17 39.3109
18 42.0676
19 44.2168
对这两列数进行回归。
y=a*x+b回归,求解结果
DataFit version 9.0.59
Results from project "Untitled1"
Equation ID: a*x+b
Model Definition:
Y = a*x+b
Number of observations = 20
Number of missing observations = 0
Solver type: Nonlinear
Nonlinear iteration limit = 250
Diverging nonlinear iteration limit =10
Number of nonlinear iterations performed = 11
Residual tolerance = .0000000001
Sum of Residuals = -1.16462395283179E-13
Average Residual = -5.82311976415895E-15
Residual Sum of Squares (Absolute) = 1.18948014687759
Residual Sum of Squares (Relative) = 1.18948014687759
Standard Error of the Estimate = .257064642419155
Coefficient of Multiple Determination (R^2) = 0.9996591553
Proportion of Variance Explained = 99.96591553%
Adjusted coefficient of multiple determination (Ra^2) = 0.9996402195
Durbin-Watson statistic = 1.37189817427394
Regression Variable Results
Variable Value Standard Error t-ratio Prob(t)
a 2.29042193984962 9.96853926163001E-03 229.7650518 0.0
b .499532571428571 .110780928926492 4.509192839 0.00027
68% Confidence Intervals
Variable Value 68% (+/-) Lower Limit Upper Limit
a 2.29042193984962 .010194825102869 2.28022711474676 2.30061676495249
b .499532571428571 .113295656013123 .386236915415448 .612828227441694
90% Confidence Intervals
Variable Value 90% (+/-) Lower Limit Upper Limit
a 2.29042193984962 1.72864439335926E-02 2.27313549591603 2.30770838378322
b .499532571428571 .192105208851429 .307427362577142 .69163778028
95% Confidence Intervals
Variable Value 95% (+/-) Lower Limit Upper Limit
a 2.29042193984962 2.09429041347585E-02 2.26947903571487 2.31136484398438
b .499532571428571 .232739653581666 .266792917846905 .732272225010237
99% Confidence Intervals
Variable Value 99% (+/-) Lower Limit Upper Limit
a 2.29042193984962 2.86934434106758E-02 2.26172849643895 2.3191153832603
b .499532571428571 .318871825822013 .180660745606558 .818404397250585
Variance Analysis
Source DF Sum of Squares Mean Square F Ratio Prob(F)
Regression 1 3488.6117205921 3488.6117205921 52791.97903 0
Error 18 1.18948014687759 6.60822303820882E-02
Total 19 3489.80120073898
Adjusted coefficient of multiple determination (Ra^2) = 0.9996402195,由此可见求解结果很棒!
mathematica自身也能回归,看结果挺好的。
northwolves
发表于 2023-12-25 13:10:36
a:=If<1/2,1+2*Floor[(1/(Ceiling/10^(n-1)-Pi)+1)/2],2*Ceiling[(1/2)/(Pi-Floor/10^(n-1))]]-1
Table[{n, a}, {n, 50}]//TableForm
1 2
2 18
3 118
4 1687
5 10793
6 136120
7 1530011
8 18660269
9 156001208
10 1695509435
11 11136696005
12 102111268281
13 1260654956981
14 10725187563685
15 147895359776636
16 1313133218365934
17 16250291773636034
18 118166387818704585
19 1860961545617561678
20 15963377896404315145
21 135932051103571157542
22 1554283475897382471529
23 17662626715564397587762
24 151132271710116102119050
25 1621480078376944259664240
26 12007756595167627295803303
27 148798516355071747953955428
28 1387930608002124805665571032
29 12578160026496293421654498813
30 105231209730817042685043045519
31 1988529378391153472498106713627
32 10296985360295099300242378337134
33 140532280588161380216741968668848
34 1130969465418316613122144411099901
35 11876883832717324052606712046064011
36 172329690253634524448691120059890634
37 1245592780371894546757396650798812590
38 10291305765302421001925255485214600385
39 139481698212026291352792154938807594551
40 1203948046785304256294604316354115306036
41 14409351647261785287940860003798052603575
42 106390051332317419361281881968008708348223
43 1664932655458558697546185038928282779926142
44 10062882366148198857375507339778071671640807
45 106665462672719686056964495868703945738453809
46 1600270947570955944191396831740654374784922782
47 13314547221760633025741680683682907005848330079
48 195854888940921370122870495649678333741246283067
49 1118344282273938514999816256095191322694097116362
50 10618075515346192427279269236869564149056602208656
northwolves
发表于 2023-12-25 13:28:33
https://oeis.org/A126809 里面的公式栏有解释
nyy
发表于 2023-12-25 13:28:33
northwolves 发表于 2023-12-25 13:10
1 2
2 18
3 118
莱布尼茨的这个级数,收敛的不是一般的慢!
nyy
发表于 2023-12-25 13:39:59
northwolves 发表于 2023-12-25 13:28
https://oeis.org/A126809 里面的公式栏有解释
计算圆周率的100位,
割圆术差不多需要开177次根号。
马青公式需要计算72项,
莱布尼茨级数需要计算10^99项(只精确到数量级)
拉马努金级数需要计算前13项!
northwolves
发表于 2023-12-25 15:31:29
下面两个数列等价,收敛于圆周率,但比莱布尼茨级数收敛更慢:$\{3,27,187......\}$
$a=2,a=4,a=( (2 n^2-1) a[ n-1]+(n-1) n (2n+1) a )/(n (
n+1) ( 2 n-1))$
$b=2,b=b*(n/(n + 1))^((-1)^n)$
nyy
发表于 2023-12-26 09:42:57
northwolves 发表于 2023-12-25 13:10
1 2
2 18
3 118
a:=If<1/2,1+2*Floor[(1/(Ceiling/10^(n-1)-Pi)+1)/2],2*Ceiling[(1/2)/(Pi-Floor/10^(n-1))]]-1
你的这个代码写的不好,因为容易与外部的x变量打架,最好把x局部变量化。
我用最笨的改变量名的办法。
a:=If<1/2,1+2*Floor[(1/(Ceiling/10^(n-1)-Pi)+1)/2],2*Ceiling[(1/2)/(Pi-Floor/10^(n-1))]]-1
我线性回归失败,因为你的变量名x与我的回归变量名打架了。