File size: 7,892 Bytes
1f3a244 | 1 2 3 4 5 | {"type": "session", "harness": "my-agent", "id": "ai-0017", "name": "pi algs summarization"}
{"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.\n\nTask: summarize user's text"}}
{"type": "message", "message": {"role": "user", "content": "Yes. There is a genuine higher-convergence alternative to Chudnovsky.\nThe **Berndt–Chan \\(m=3315\\) Ramanujan-type series** gives about **75.3178 decimal digits per term**, versus about **14.1816 digits/term** for Chudnovsky, so it needs about **5.31× fewer terms** for the same number of digits.\nA later Campbell preprint extends this family to about **153.8732 digits/term**, but that construction is substantially more complicated. (arXiv)\nThat does **not** automatically mean it is 5× faster in wall-clock time. Chudnovsky's binary splitting and highly optimized multiplication are extremely effective, which is why record computations still use it. The latest y-cruncher record listed through 2025 was computed with its Chudnovsky machinery. (Number World)\nAlso: **Gauss–Legendre / Brent–Salamin is much faster in convergence per iteration than Chudnovsky**, but there is an important catch: an iteration becomes substantially more expensive as the precision grows.\nThe algorithm is\n$$\na_0=1,\\qquad\nb_0=\\frac1{\\sqrt2},\\qquad\nt_0=\\frac14,\\qquad\np_0=1,\n$$\nand\n$$\na_{n+1}=\\frac{a_n+b_n}{2},\n$$\n$$\nb_{n+1}=\\sqrt{a_nb_n},\n$$\n$$\nt_{n+1}=t_n-p_n(a_n-a_{n+1})^2,\n$$\n$$\np_{n+1}=2p_n.\n$$\nThen\n$$\n\\boxed{\n\\pi=\\lim_{n\\to\\infty}\n\\frac{(a_n+b_n)^2}{4t_n}\n}\n$$\nand it has **quadratic convergence**. (MathWorld)\n### Why it looks ridiculously fast\nThe AGM satisfies\n$$\na_{n+1}-b_{n+1}\n=O\\!\\left((a_n-b_n)^2\\right),\n$$\nso the error essentially squares every iteration.\nThus, roughly,\n$$\nD_{n+1}\\approx 2D_n,\n$$\nwhere \\(D_n\\) is the number of correct decimal digits.\nFor example, the first few approximations are\n$$\n3.1405792505221686\\ldots\n$$\n$$\n3.141592646213543\\ldots\n$$\n$$\n3.141592653589794\\ldots\n$$\nso only a handful of iterations already reaches ordinary floating-point precision.\n---\n## A useful proof of the quadratic convergence\nPut\n$$\nc_n=\\frac{a_n-b_n}{2}.\n$$\nSince\n$$\na_{n+1}=\\frac{a_n+b_n}{2},\n\\qquad\nb_{n+1}=\\sqrt{a_nb_n},\n$$\nwe have\n$$\na_{n+1}^2-b_{n+1}^2\n=\n\\left(\\frac{a_n+b_n}{2}\\right)^2-a_nb_n\n=\n\\frac{(a_n-b_n)^2}{4}\n=c_n^2.\n$$\nTherefore\n$$\na_{n+1}-b_{n+1}\n=\n\\frac{c_n^2}{a_{n+1}+b_{n+1}}.\n$$\nSince \\(a_n,b_n\\to M\\), where\n$$\nM=\\operatorname{AGM}\n\\left(1,\\frac1{\\sqrt2}\\right),\n$$\nwe obtain asymptotically\n$$\na_{n+1}-b_{n+1}\n\\sim\n\\frac{(a_n-b_n)^2}{8M}.\n$$\nHence\n$$\n\\boxed{\n|a_{n+1}-b_{n+1}|\n=\nO(|a_n-b_n|^2)\n}\n$$\nwhich is quadratic convergence.\nThe Brent–Salamin identity then gives\n$$\n\\boxed{\n\\pi\n=\n\\frac{4M^2}\n{1-\\displaystyle\\sum_{j=1}^{\\infty}2^{j+1}c_j^2}\n}\n$$\nwith\n$$\nM=\\operatorname{AGM}\n\\left(1,\\frac1{\\sqrt2}\\right).\n$$\nThis is equivalent to the \\(t_n\\) formulation above. (MathWorld)\n---\n## But is it actually faster than Chudnovsky?\nFor **moderate precision**, AGM is extremely attractive.\nFor **huge precision**, not necessarily.\n| Algorithm | Convergence | Main expensive operation |\n| --------------- | ------------------------------------------: | ------------------------------------------ |\n| Chudnovsky | ~14.18 decimal digits/term | Large integer multiplication |\n| Gauss–Legendre | quadratic, roughly doubles digits/iteration | High-precision square root |\n| Borwein quartic | quartic | Several high-precision operations |\n| Borwein quintic | quintic | More complicated high-precision operations |\nThe amusing part is that **Chudnovsky has terrible-looking convergence by iteration count but excellent computational structure**. Binary splitting turns its series into large integer arithmetic that modern multiplication algorithms handle extremely well.\nSo:\n$$\n\\boxed{\\text{fewer iterations} \\neq \\text{faster computation}}\n$$\nwhich is one of those irritating cases where asymptotic convergence politely refuses to tell you the whole story.\nFor example, to obtain \\(10^6\\) digits, Gauss–Legendre only needs on the order of\n$$\n\\log_2(10^6)\\approx 20\n$$\niterations, but those iterations involve million-digit square roots. Chudnovsky needs roughly\n$$\n\\frac{10^6}{14.18}\\approx 70\\,500\n$$\nseries terms, but binary splitting makes those terms dramatically cheaper to aggregate.\nFor very large record computations, Chudnovsky-style binary splitting therefore remains highly competitive despite its lower convergence order.\n### One important terminology point\nThe **Gauss–Legendre algorithm for \\(\\pi\\)** is not the same thing as **Gauss–Legendre quadrature**. Here \"Gauss–Legendre\" refers to the AGM-based π algorithm, also called the **Brent–Salamin algorithm**. (MathWorld)\nAnd if the actual goal is **\"find something genuinely better than Chudnovsky for arbitrary huge precision\"**, then the interesting direction is not Gauss–Legendre. It is the **quartic/quintic/high-order Borwein algorithms**, or the more recent higher-order modular identities. (MathWorld)"}}
{"type": "message", "message": {"role": "assistant", "content": "### Summary\n\n* **Berndt–Chan \\(m=3315\\)** is a genuine higher-convergence π series:\n\n * ~**75.32 digits/term**\n * Chudnovsky: ~**14.18 digits/term**\n * Therefore ~**5.3× fewer terms** theoretically.\n* A later **Campbell** construction reaches ~**153.87 digits/term**, but is considerably more complicated.\n* **Fewer terms does not mean faster overall**. Chudnovsky's binary splitting makes its terms exceptionally efficient to aggregate, which is why it remains dominant for huge computations.\n\n### Gauss–Legendre / Brent–Salamin\n\nIt uses the AGM:\n\n$$\na_{n+1}=\\frac{a_n+b_n}{2},\\qquad\nb_{n+1}=\\sqrt{a_nb_n}\n$$\n\nwith corresponding \\(t_n,p_n\\), then\n\n$$\n\\pi=\\lim_{n\\to\\infty}\\frac{(a_n+b_n)^2}{4t_n}.\n$$\n\nIts convergence is **quadratic**, meaning the number of correct digits roughly doubles every iteration.\n\nThe key proof is:\n\n$$\na_{n+1}^2-b_{n+1}^2\n=\\frac{(a_n-b_n)^2}{4},\n$$\n\nso\n\n$$\na_{n+1}-b_{n+1}\n=\n\\frac{(a_n-b_n)^2}\n{4(a_{n+1}+b_{n+1})}\n=O((a_n-b_n)^2).\n$$\n\nThus the error is squared each iteration.\n\n### The catch\n\nAt high precision, each AGM iteration requires expensive **high-precision square roots**.\n\nSo roughly:\n\n| Algorithm | Convergence | Main cost |\n| --------------- | ------------------ | --------------------------------- |\n| Chudnovsky | ~14.18 digits/term | Integer multiplication |\n| Gauss–Legendre | Quadratic | High-precision square root |\n| Borwein quartic | Quartic | Several high-precision operations |\n| Borwein quintic | Quintic | More complicated operations |\n\nFor \\(10^6\\) digits:\n\n* Gauss–Legendre: only about **20 iterations**\n* Chudnovsky: about **70,500 terms**\n\nBut those 20 AGM iterations operate on million-digit numbers, while Chudnovsky's **binary splitting + fast multiplication** makes its huge term count computationally efficient.\n\n### Bottom line\n\n$$\n\\boxed{\\text{Convergence rate} \\neq \\text{real-world speed}}\n$$\n\nFor arbitrary huge precision, the more interesting candidates beyond Chudnovsky are **Borwein quartic/quintic methods and newer higher-order modular identities**, rather than simply Gauss–Legendre.\n"}}
|