如何根据莱布尼茨级数求圆周率得到应该多少项?
比如我用莱布尼茨级数来计算圆周率,Pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11+....
但是你们知道的,级数收敛太慢了,
比如我想精确计算到小数点后第20位,那么我应该对级数计算到多少项呢?
有没有数学分析的办法得到答案? https://mathworld.wolfram.com/GregorySeries.html
或者说我想知道这个级数收敛究竟有多慢。 用拉马鲁金公式快点 ShuXueZhenMiHu 发表于 2023-12-24 03:49
有无穷多项呀,你只选了一下 $4\sum_{n=0}^k{\frac{(-1)^n}{2 n+1}}$ 首次达到计算精度:{2, 18, 118, 1687, 10793, 136120, 1530011, 18660303} 本帖最后由 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 ...
Clear["Global`*"];(*清除所有变量*)
aa=4*Sum[(-1)^(k+1)*1/(2k-1),{k,1,n}]
aa/.n->10^Range//N[#,10]&
计算{10, 100, 1000, 10000}项的结果分别是
{3.041839619, 3.131592904, 3.140592654, 3.141492654}
这个问题,即使mathematica计算,也很慢! nyy 发表于 2023-12-25 08:45
计算{10, 100, 1000, 10000}项的结果分别是
{3.041839619, 3.131592904, 3.140592654, 3.141492654}
p1:=2(2Log+HarmonicNumber-PolyGamma+PolyGamma)-4/(2n+1)
p2:=2(2Log+HarmonicNumber-PolyGamma+PolyGamma)
p:=4Sum[(-1)^k/(2k+1),{k,0,n}];
Table[{n,N,20],If,N,20],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}} 可统一写成这样:
p3:=2(2Log+HarmonicNumber-PolyGamma+PolyGamma-(1-(-1)^n)/(2n+1))
Table[{10^n, 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}