On 5/11/14 1:59 PM, Chris Angelico wrote:
julia> prec=524288
524288
julia> with_bigfloat_precision(prec) do
println(atan(BigFloat(1)/5)*16 - atan(BigFloat(1)/239)*4)
end
Would it be quicker (and no less accurate) to represent pi as
atan(BigFloat(1))*4 instead? That's how I originally met a
pi-calculation (as opposed to "PI = 3.14" extended to however much
accuracy someone cared to do).
No. Simple experiment will show you. The atan(x<=1) will converge
faster. For 524288 bits atan(1) formula converged in 3 seconds, and
Machin's formula atan(x<1) converged in 2 seconds. Where it becomes very
apparent is 10K and 100K or above. Also, the difference is much more
noticeable in Python than in Julia, but it is there no-the-less.
But here is the cool part: what if your π function could be broken
down into three very fast converging atan(x<1) functions like this one:
> pi = 24*atan(1/8) + 8*atan(1/57) + 4*atan(1/239) (Shanks used this)
... and then, you have julia send each piece to a separate
processor|core (it does this at its center) and they converge together,
then julia pieces them together at the end. Then things get incredibly
faster.
--
https://mail.python.org/mailman/listinfo/python-list