# Borwein's algorithm

In mathematics, Borwein's algorithm is an algorithm devised by Jonathan and Peter Borwein to calculate the value of 1/π. They devised several other algorithms. They published the book Pi and the AGM – A Study in Analytic Number Theory and Computational Complexity.[1]

## Jonathan Borwein and Peter Borwein's version (1993)

Start by setting[citation needed]

{\displaystyle {\begin{aligned}A={}&63365028312971999585426220\\&{}+28337702140800842046825600{\sqrt {5}}\\&{}+384{\sqrt {5}}(10891728551171178200467436212395209160385656017\\&{}+4870929086578810225077338534541688721351255040{\sqrt {5}})^{1/2}\\B={}&7849910453496627210289749000\\&{}+3510586678260932028965606400{\sqrt {5}}\\&{}+2515968{\sqrt {3110}}(6260208323789001636993322654444020882161\\&{}+2799650273060444296577206890718825190235{\sqrt {5}})^{1/2}\\C={}&-214772995063512240\\&{}-96049403338648032{\sqrt {5}}\\&{}-1296{\sqrt {5}}(10985234579463550323713318473\\&{}+4912746253692362754607395912{\sqrt {5}})^{1/2}\end{aligned}}}

Then

${\displaystyle {\frac {\sqrt {-C^{3}}}{\pi }}=\sum _{n=0}^{\infty }{{\frac {(6n)!}{(3n)!(n!)^{3}}}{\frac {A+nB}{C^{3n}}}}}$

Each additional term of the series yields approximately 50 digits. This is an example of a Ramanujan–Sato series.

## Cubic convergence (1991)

Start by setting

{\displaystyle {\begin{aligned}a_{0}&={\frac {1}{3}}\\s_{0}&={\frac {{\sqrt {3}}-1}{2}}\end{aligned}}}

Then iterate

{\displaystyle {\begin{aligned}r_{k+1}&={\frac {3}{1+2(1-s_{k}^{3})^{1/3}}}\\s_{k+1}&={\frac {r_{k+1}-1}{2}}\\a_{k+1}&=r_{k+1}^{2}a_{k}-3^{k}(r_{k+1}^{2}-1)\end{aligned}}}

Then ak converges cubically to 1/π; that is, each iteration approximately triples the number of correct digits.

## Another formula for π (1989)

Start by setting[citation needed]

{\displaystyle {\begin{aligned}A&=212175710912{\sqrt {61}}+1657145277365\\B&=13773980892672{\sqrt {61}}+107578229802750\\C&=(5280(236674+30303{\sqrt {61}}))^{3}\end{aligned}}}

Then

${\displaystyle 1/\pi =12\sum _{n=0}^{\infty }{\frac {(-1)^{n}(6n)!\,(A+nB)}{(n!)^{3}(3n)!\,C^{n+1/2}}}\,\!}$

Each additional term of the partial sum yields approximately 25 digits.

## Quartic algorithm (1985)

Start by setting[2]

{\displaystyle {\begin{aligned}a_{0}&=2{\big (}{\sqrt {2}}-1{\big )}^{2}\\y_{0}&={\sqrt {2}}-1\end{aligned}}}

Then iterate

{\displaystyle {\begin{aligned}y_{k+1}&={\frac {1-(1-y_{k}^{4})^{1/4}}{1+(1-y_{k}^{4})^{1/4}}}\\a_{k+1}&=a_{k}(1+y_{k+1})^{4}-2^{2k+3}y_{k+1}(1+y_{k+1}+y_{k+1}^{2})\end{aligned}}}

Then ak converges quartically against 1/π; that is, each iteration approximately quadruples the number of correct digits. The algorithm is not self-correcting; each iteration must be performed with the desired number of correct digits for π's final result.

## Quadratic convergence (1984)

Start by setting[3]

{\displaystyle {\begin{aligned}a_{0}&={\sqrt {2}}\\b_{0}&=0\\p_{0}&=2+{\sqrt {2}}\end{aligned}}}

Then iterate

{\displaystyle {\begin{aligned}a_{n+1}&={\frac {{\sqrt {a_{n}}}+1/{\sqrt {a_{n}}}}{2}}\\b_{n+1}&={\frac {(1+b_{n}){\sqrt {a_{n}}}}{a_{n}+b_{n}}}\\p_{n+1}&={\frac {(1+a_{n+1})\,p_{n}b_{n+1}}{1+b_{n+1}}}\end{aligned}}}

Then pk converges quadraticly to π; that is, each iteration approximately doubles the number of correct digits. The algorithm is not self-correcting; each iteration must be performed with the desired number of correct digits for π's final result.

## Quintic convergence

Start by setting

{\displaystyle {\begin{aligned}a_{0}&={\frac {1}{2}}\\s_{0}&=5({\sqrt {5}}-2)\end{aligned}}}

Then iterate

{\displaystyle {\begin{aligned}x_{n+1}&={\frac {5}{s_{n}}}-1\\y_{n+1}&=(x_{n+1}-1)^{2}+7\\z_{n+1}&=\left({\frac {1}{2}}x_{n+1}\left(y_{n+1}+{\sqrt {y_{n+1}^{2}-4x_{n+1}^{3}}}\right)\right)^{1/5}\\a_{n+1}&=s_{n}^{2}a_{n}-5^{n}\left({\frac {s_{n}^{2}-5}{2}}+{\sqrt {s_{n}(s_{n}^{2}-2s_{n}+5)}}\right)\\s_{n+1}&={\frac {25}{(z_{n+1}+x_{n+1}/z_{n+1}+1)^{2}s_{n}}}\end{aligned}}}

Then ak converges quintically to 1/π (that is, each iteration approximately quintuples the number of correct digits), and the following condition holds:

${\displaystyle 0

[4]

## Nonic convergence

Start by setting

{\displaystyle {\begin{aligned}a_{0}&={\frac {1}{3}}\\r_{0}&={\frac {{\sqrt {3}}-1}{2}}\\s_{0}&=(1-r_{0}^{3})^{1/3}\end{aligned}}}

Then iterate

{\displaystyle {\begin{aligned}t_{n+1}&=1+2r_{n}\\u_{n+1}&=(9r_{n}(1+r_{n}+r_{n}^{2}))^{1/3}\\v_{n+1}&=t_{n+1}^{2}+t_{n+1}u_{n+1}+u_{n+1}^{2}\\w_{n+1}&={\frac {27(1+s_{n}+s_{n}^{2})}{v_{n+1}}}\\a_{n+1}&=w_{n+1}a_{n}+3^{2n-1}(1-w_{n+1})\\s_{n+1}&={\frac {(1-r_{n})^{3}}{(t_{n+1}+2u_{n+1})v_{n+1}}}\\r_{n+1}&=(1-s_{n+1}^{3})^{1/3}\end{aligned}}}

Then ak converges nonically to 1/π; that is, each iteration approximately multiplies the number of correct digits by nine.