找回密码
 欢迎注册
查看: 4277|回复: 48

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

[复制链接]
发表于 2023-12-22 15:28:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
比如我用莱布尼茨级数来计算圆周率,
Pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11+....
但是你们知道的,级数收敛太慢了,
比如我想精确计算到小数点后第20位,那么我应该对级数计算到多少项呢?
有没有数学分析的办法得到答案?
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-22 15:34:03 | 显示全部楼层
https://mathworld.wolfram.com/GregorySeries.html

或者说我想知道这个级数收敛究竟有多慢。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-23 11:24:18 | 显示全部楼层
用拉马鲁金公式快点

点评

nyy
地球人都知道啊,我就是想知道他的级数有多慢  发表于 2023-12-24 18:18
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-24 03:49:44 | 显示全部楼层
12345.jpg
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-24 08:15:32 | 显示全部楼层

有无穷多项呀,你只选了一下
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-24 10:10:18 | 显示全部楼层
$4\sum_{n=0}^k{\frac{(-1)^n}{2 n+1}}$ 首次达到计算精度:{2, 18, 118, 1687, 10793, 136120, 1530011, 18660303}

点评

nyy
计算一万项的结果是3.141492654,我感觉你的结果不对  发表于 2023-12-25 11:21
nyy
我感觉你的结果算的不对,对比我用mathematica函数算,感觉不对  发表于 2023-12-25 08:50
nyy
2楼的链接都比他的有用  发表于 2023-12-24 18:17
nyy
这个有无穷多项,不是只有一箱  发表于 2023-12-24 17:04
4楼正解  发表于 2023-12-24 15:40
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-25 08:45:21 | 显示全部楼层
本帖最后由 nyy 于 2023-12-25 08:46 编辑
northwolves 发表于 2023-12-24 10:10
$4\sum_{n=0}^k{\frac{(-1)^n}{2 n+1}}$ 首次达到计算精度:{2, 18, 118, 1687, 10793, 136120, 1530011, 1 ...

  1. Clear["Global`*"];(*清除所有变量*)
  2. aa=4*Sum[(-1)^(k+1)*1/(2k-1),{k,1,n}]
  3. aa/.n->10^Range[4]//N[#,10]&
复制代码


计算{10, 100, 1000, 10000}项的结果分别是
{3.041839619, 3.131592904, 3.140592654, 3.141492654}

这个问题,即使mathematica计算,也很慢!

点评

nyy
算了一万项,也没算到小数点后第四位,可真够慢的  发表于 2023-12-25 08:48
nyy
虽然慢,但是也算有个结果  发表于 2023-12-25 08:45
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-25 11:39:06 | 显示全部楼层
nyy 发表于 2023-12-25 08:45
计算{10, 100, 1000, 10000}项的结果分别是
{3.041839619, 3.131592904, 3.140592654, 3.141492654}
  1. p1[n_]:=2(2Log[2]+HarmonicNumber[n-1/2]-PolyGamma[0,1/4+n/2]+PolyGamma[0,3/4])-4/(2n+1)
  2. p2[n_]:=2(2Log[2]+HarmonicNumber[n+1/2]-PolyGamma[0,3/4+n/2]+PolyGamma[0,3/4])
  3. p[n_]:=4Sum[(-1)^k/(2k+1),{k,0,n}];
  4. Table[{n,N[p[n],20],If[OddQ[n],N[p1[n],20],N[p2[n],20]]},{n,100}]
复制代码


{{1,2.6666666666666666667,2.6666666666666666667},{2,3.4666666666666666667,3.4666666666666666667},{3,2.8952380952380952381,2.8952380952380952381},{4,3.3396825396825396825,3.3396825396825396825},{5,2.9760461760461760462,2.9760461760461760462},{6,3.2837384837384837385,3.2837384837384837385},{7,3.0170718170718170718,3.0170718170718170718},{8,3.2523659347188758953,3.2523659347188758953},{9,3.0418396189294022111,3.0418396189294022111},{10,3.2323158094055926873,3.2323158094055926873},{11,3.0584027659273318178,3.0584027659273318178},{12,3.2184027659273318178,3.2184027659273318178},{13,3.0702546177791836696,3.0702546177791836696},{14,3.2081856522619422903,3.2081856522619422903},{15,3.0791533941974261613,3.0791533941974261613},{16,3.2003655154095473734,3.2003655154095473734},{17,3.0860798011238330877,3.0860798011238330877},{18,3.1941879092319411958,3.1941879092319411958},{19,3.0916238066678386317,3.0916238066678386317},{20,3.1891847822775947292,3.1891847822775947292},{21,3.0961615264636412409,3.0961615264636412409},{22,3.1850504153525301298,3.1850504153525301298},{23,3.0999440323738067255,3.0999440323738067255},{24,3.1815766854350312153,3.1815766854350312153},{25,3.1031453128860116075,3.1031453128860116075},{26,3.1786170109992191546,3.1786170109992191546},{27,3.1058897382719464274,3.1058897382719464274},{28,3.1760651768684376554,3.1760651768684376554},{29,3.1082685666989461300,3.1082685666989461300},{30,3.1738423371907494087,3.1738423371907494087},{31,3.1103502736986859166,3.1103502736986859166},{32,3.1718887352371474551,3.1718887352371474551},{33,3.1121872426998340223,3.1121872426998340223},{34,3.1701582571925876454,3.1701582571925876454},{35,3.1138202290235735609,3.1138202290235735609},{36,3.1686147495715187664,3.1686147495715187664},{37,3.1152814162381854331,3.1152814162381854331},{38,3.1672294681862373811,3.1672294681862373811},{39,3.1165965567938323178,3.1165965567938323178},{40,3.1659792728432150339,3.1659792728432150339},{41,3.1177865017588776845,3.1177865017588776845},{42,3.1648453252882894492,3.1648453252882894492},{43,3.1188683137940365756,3.1188683137940365756},{44,3.1638121340187556768,3.1638121340187556768},{45,3.1198560900627117207,3.1198560900627117207},{46,3.1628668427508837637,3.1628668427508837637},{47,3.1207615795929890269,3.1207615795929890269},{48,3.1619986929950508826,3.1619986929950508826},{49,3.1215946525910104785,3.1215946525910104785},{50,3.1611986129870500825,3.1611986129870500825},{51,3.1223636615307394029,3.1223636615307394029},{52,3.1604588996259774981,3.1604588996259774981},{53,3.1230757220558840402,3.1230757220558840402},{54,3.1597729697623060585,3.1597729697623060585},{55,3.1237369337262700225,3.1237369337262700225},{56,3.1591351638147655977,3.1591351638147655977},{57,3.1243525551191134238,3.1243525551191134238},{58,3.1585405893071476118,3.1585405893071476118},{59,3.1249271439289963513,3.1249271439289963513},{60,3.1579849951686657728,3.1579849951686657728},{61,3.1254646699654137403,3.1254646699654137403},{62,3.1574646699654137403,3.1574646699654137403},{63,3.1259686069732877560,3.1259686069732877560},{64,3.1569763589112722521,3.1569763589112722521},{65,3.1264420077662340842,3.1264420077662340842},{66,3.1565171957361588962,3.1565171957361588962},{67,3.1268875661065292666,3.1268875661065292666},{68,3.1560846463985000695,3.1560846463985000695},{69,3.1273076679812338825,3.1273076679812338825},{70,3.1556764623074750172,3.1556764623074750172},{71,3.1277044343354470452,3.1277044343354470452},{72,3.1552906412319987693,3.1552906412319987693},{73,3.1280797568782572727,3.1280797568782572727},{74,3.1549253944621498902,3.1549253944621498902},{75,3.1284353282369843273,3.1284353282369843273},{76,3.1545791190866575299,3.1545791190866575299},{77,3.1287726674737543041,3.1287726674737543041},{78,3.1542503744801237308,3.1542503744801237308},{79,3.1290931417757212151,3.1290931417757212151},{80,3.1539378622726156251,3.1539378622726156251},{81,3.1293979849720021281,3.1293979849720021281},{82,3.1536404092144263705,3.1536404092144263705},{83,3.1296883134060431370,3.1296883134060431370},{84,3.1533569524592975749,3.1533569524592975749},{85,3.1299651395938004989,3.1299651395938004989},{86,3.1530865268770374931,3.1530865268770374931},{87,3.1302293840198946359,3.1302293840198946359},{88,3.1528282540763918111,3.1528282540763918111},{89,3.1304818853613080122,3.1304818853613080122},{90,3.1525813328751201669,3.1525813328751201669},{91,3.1307234093778524073,3.1307234093778524073},{92,3.1523450309994740289,3.1523450309994740289},{93,3.1309546566679232268,3.1309546566679232268},{94,3.1521186778319443908,3.1521186778319443908},{95,3.1311762694549810400,3.1311762694549810400},{96,3.1519016580560173095,3.1519016580560173095},{97,3.1313888375431967967,3.1313888375431967967},{98,3.1516934060711155784,3.1516934060711155784},{99,3.1315929035585527643,3.1315929035585527643},{100,3.1514934010709905753,3.1514934010709905753}}
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-25 11:41:43 | 显示全部楼层
可统一写成这样:
  1. p3[n_]:=2(2Log[2]+HarmonicNumber[n+(-1)^n/2]-PolyGamma[0,(2+(-1)^n)/4+n/2]+PolyGamma[0,3/4]-(1-(-1)^n)/(2n+1))
复制代码

点评

参考文献:2楼链接  发表于 2023-12-25 12:43
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2023-12-25 11:46:31 | 显示全部楼层
  1. Table[{10^n, N[p3[10^n], 20]}, {n, 10}] // MatrixForm
复制代码


\begin{array}{cc}
10 & 3.2323158094055926873 \\
100 & 3.1514934010709905753 \\
1000 & 3.1425916543395430509 \\
10000 & 3.1416926435905432135 \\
100000 & 3.1416026534897939885 \\
1000000 & 3.1415936535887932392 \\
10000000 & 3.1415927535897832385 \\
100000000 & 3.1415926635897931385 \\
1000000000 & 3.1415926545897932375 \\
10000000000 & 3.1415926536897932385 \\
\end{array}

点评

秒出的  发表于 2023-12-25 12:43
nyy
你的函数,难道比我给的计算快很多???????????  发表于 2023-12-25 12:03
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

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

GMT+8, 2024-12-28 03:25 , Processed in 0.045254 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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