4 ms·
And here's my version of Gauss-Legendre: [[lmp lnp lap lbp ltp lqp lOxp]sD]sT # enable debug tracing [0sn [ln 1+ sn]sN 1sa [la dsc lb + 2/ sa]sA
by xelxebar 7y ago
And here's my version of Gauss-Legendre:
[[lmp lnp lap lbp ltp lqp lOxp]sD]sT # enable debug tracing
[0sn [ln 1+ sn]sN
1sa [la dsc lb + 2/ sa]sA
1 2v/sb [lc lb *v sb]sB
1 4/st [lt lc la- 2^ lq* - st]sT
1sq [lq 2* sq]sQ
]sI
[lDx lNx lAx lBx lTx lQx lnlm>Z]sZ
[la lb+ 2^ lt 4* /]sO
[Ksk k sm lIx lZx lOx lkk]sP # ( iterations precision -- pi )
Usage is the same as with the Chudnovsky version from my other comment. Assuming the above script is located in gl.dc:
$ dc -f gl.dc -e '15 10010 lPxp'
That gives about 10k digits accurately.
It's pretty much just a the implementation one would expect. The only tricky part is ordering the variable updates, since those have interdependencies. Both 'a' and 'b' depend ond each other, so we're force to create an intermediate variable, that's what 'c' is in the above.
Anyway!