找回密码
 欢迎注册
楼主: nyy

[求助] 如何根据莱布尼茨级数求圆周率得到应该多少项?

[复制链接]
发表于 2023-12-25 12:40:48 | 显示全部楼层
  1. s = {2, 18, 118, 1687, 10793, 136120, 1530011, 18660269, 156001208,
  2.   1695509435}; Table[{n, N[p3[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}
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-25 12:42:30 | 显示全部楼层
6楼数据有误,前10项如下: {2, 18, 118, 1687, 10793, 136120, 1530011, 18660269, 156001208, 1695509435}
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 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

点评

我的下标是从0开始的  发表于 2023-12-25 13:03
是了,下一项我计算的是11136696005  发表于 2023-12-25 13:00
nyy
结果都比楼上大1位  发表于 2023-12-25 12:55
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 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  ...


对上面的数取自然对数,依次精确到小数点后零位开始。

  1. 0        1.09861
  2. 1        2.94444
  3. 2        4.77912
  4. 3        7.4313
  5. 4        9.28675
  6. 5        11.8213
  7. 6        14.2408
  8. 7        16.7419
  9. 8        18.8654
  10. 9        21.2512
  11. 10        23.1335
  12. 11        25.3493
  13. 12        27.8627
  14. 13        30.0036
  15. 14        32.6275
  16. 15        34.8112
  17. 16        37.3269
  18. 17        39.3109
  19. 18        42.0676
  20. 19        44.2168
复制代码


对这两列数进行回归。
y=a*x+b回归,求解结果
  1. DataFit version 9.0.59                                               
  2. Results from project "Untitled1"                                               
  3. Equation ID: a*x+b                                               
  4. Model Definition:                                               
  5. Y = a*x+b                                               
  6.                                                
  7. Number of observations = 20                                               
  8. Number of missing observations = 0                                               
  9. Solver type: Nonlinear                                               
  10. Nonlinear iteration limit = 250                                               
  11. Diverging nonlinear iteration limit =10                                               
  12. Number of nonlinear iterations performed = 11                                               
  13. Residual tolerance = .0000000001                                               
  14. Sum of Residuals = -1.16462395283179E-13                                               
  15. Average Residual = -5.82311976415895E-15                                               
  16. Residual Sum of Squares (Absolute) = 1.18948014687759                                               
  17. Residual Sum of Squares (Relative) = 1.18948014687759                                               
  18. Standard Error of the Estimate = .257064642419155                                               
  19. Coefficient of Multiple Determination (R^2) = 0.9996591553                                               
  20. Proportion of Variance Explained = 99.96591553%                                               
  21. Adjusted coefficient of multiple determination (Ra^2) = 0.9996402195                                               
  22. Durbin-Watson statistic = 1.37189817427394                                               
  23.                                                
  24. Regression Variable Results                                               
  25. Variable        Value        Standard Error        t-ratio        Prob(t)               
  26. a        2.29042193984962        9.96853926163001E-03        229.7650518        0.0               
  27. b        .499532571428571        .110780928926492        4.509192839        0.00027               
  28.                                                
  29. 68% Confidence Intervals                                               
  30. Variable        Value        68% (+/-)        Lower Limit        Upper Limit               
  31. a        2.29042193984962        .010194825102869        2.28022711474676        2.30061676495249               
  32. b        .499532571428571        .113295656013123        .386236915415448        .612828227441694               
  33.                                                
  34. 90% Confidence Intervals                                               
  35. Variable        Value        90% (+/-)        Lower Limit        Upper Limit               
  36. a        2.29042193984962        1.72864439335926E-02        2.27313549591603        2.30770838378322               
  37. b        .499532571428571        .192105208851429        .307427362577142        .69163778028               
  38.                                                
  39. 95% Confidence Intervals                                               
  40. Variable        Value        95% (+/-)        Lower Limit        Upper Limit               
  41. a        2.29042193984962        2.09429041347585E-02        2.26947903571487        2.31136484398438               
  42. b        .499532571428571        .232739653581666        .266792917846905        .732272225010237               
  43.                                                
  44. 99% Confidence Intervals                                               
  45. Variable        Value        99% (+/-)        Lower Limit        Upper Limit               
  46. a        2.29042193984962        2.86934434106758E-02        2.26172849643895        2.3191153832603               
  47. b        .499532571428571        .318871825822013        .180660745606558        .818404397250585               
  48.                                                
  49. Variance Analysis                                               
  50. Source        DF        Sum of Squares        Mean Square        F Ratio        Prob(F)       
  51. Regression        1        3488.6117205921        3488.6117205921        52791.97903        0       
  52. Error        18        1.18948014687759        6.60822303820882E-02                       
  53. Total        19        3489.80120073898                               
  54.                                                
复制代码


Adjusted coefficient of multiple determination (Ra^2) = 0.9996402195,由此可见求解结果很棒!

mathematica自身也能回归,看结果挺好的。
QQ截图20231225130749.png

点评

其实收敛慢的级数更牛叉一些,不容易发现,只能理论推导  发表于 2023-12-25 13:14
nyy
按回归模型计算,如果要精确到小数点后100位,那么要计算4.88321*10^99项!太多了,收敛太慢了  发表于 2023-12-25 13:10
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-25 13:10:36 | 显示全部楼层

  1. a[n_]:=If[x=Pi*10^(n-1);x-Floor[x]<1/2,1+2*Floor[(1/(Ceiling[x]/10^(n-1)-Pi)+1)/2],2*Ceiling[(1/2)/(Pi-Floor[x]/10^(n-1))]]-1
  2. Table[{n, a[n]}, {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

点评

nyy
你的x,如何局部变量化  发表于 2023-12-26 12:07
nyy
最好有一个证明,我暂时不需要结果  发表于 2023-12-25 13:26
From Jon E. Schoenfield, Nov 11 2016: (Start) The following has been verified to give the correct value of a(n) for all n from a(2)=19 through at least a(10000) = 11673...08624 (a 10000-digit numbe...   发表于 2023-12-25 13:22
3.1415...[a][0]<3.1415...[a]<3.1415...[a+1][0]  发表于 2023-12-25 13:21
与4楼同理。四楼只考虑了偶数项,其实根据第n位小数大于5或小于5,决定该级数从大到小还是从小到大,公式略有差异。  发表于 2023-12-25 13:19
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-25 13:28:33 | 显示全部楼层
https://oeis.org/A126809 里面的公式栏有解释
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-25 13:28:33 | 显示全部楼层
northwolves 发表于 2023-12-25 13:10
1        2
2        18
3        118

莱布尼茨的这个级数,收敛的不是一般的慢!

点评

nyy
不知道还有没有比莱布尼茨级数收敛更慢的级数  发表于 2023-12-25 13:28
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-25 13:39:59 | 显示全部楼层
northwolves 发表于 2023-12-25 13:28
https://oeis.org/A126809 里面的公式栏有解释

计算圆周率的100位,
割圆术差不多需要开177次根号。
马青公式需要计算72项,
莱布尼茨级数需要计算10^99项(只精确到数量级)
拉马努金级数需要计算前13项!

点评

nyy
割圆术需要开167次根号。https://bbs.emath.ac.cn/forum.php?mod=redirect&goto=findpost&ptid=19236&pid=98541  发表于 2023-12-27 12:40
nyy
割圆术差不多开167次根号  发表于 2023-12-25 13:42
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-25 15:31:29 | 显示全部楼层
下面两个数列等价,收敛于圆周率,但比莱布尼茨级数收敛更慢:$\{3,27,187......\}$
$a[0]=2,a[1]=4,a[n]=( (2 n^2-1) a[ n-1]+(n-1) n (2n+1) a[n-2] )/(n (
   n+1) ( 2 n-1))$
$b[0]=2,b[n]=b[n - 1]*(n/(n + 1))^((-1)^n)$

点评

nyy
没看明白为什么收敛于圆周率  发表于 2023-12-26 09:11
nyy
太复杂了  发表于 2023-12-25 15:33
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-26 09:42:57 | 显示全部楼层
northwolves 发表于 2023-12-25 13:10
1        2
2        18
3        118
  1. a[n_]:=If[x=Pi*10^(n-1);x-Floor[x]<1/2,1+2*Floor[(1/(Ceiling[x]/10^(n-1)-Pi)+1)/2],2*Ceiling[(1/2)/(Pi-Floor[x]/10^(n-1))]]-1
复制代码

你的这个代码写的不好,因为容易与外部的x变量打架,最好把x局部变量化。

我用最笨的改变量名的办法。

  1. a[n_]:=If[xx=Pi*10^(n-1);xx-Floor[xx]<1/2,1+2*Floor[(1/(Ceiling[xx]/10^(n-1)-Pi)+1)/2],2*Ceiling[(1/2)/(Pi-Floor[xx]/10^(n-1))]]-1
复制代码


我线性回归失败,因为你的变量名x与我的回归变量名打架了。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-4-27 17:03 , Processed in 0.132702 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表