Fortran (Was: The "does Python have variables?" debate)

Peter Pearson ppearson at nowhere.invalid
Thu May 29 13:53:16 EDT 2014


On 29 May 2014 14:06:47 GMT, Albert van der Horst wrote:
> In article <lkoi5v$vfj$1 at speranza.aioe.org>,
> Mark H Harris  <harrismh777 at gmail.com> wrote:
>>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.
>
> I know now how to interpret your posts. Using "incredible" for a mere
> factor of at most 3. Balanced views are more convincing.

Won't there be an additional speedup resulting from the computation
of atan(x) converging faster for x=1/8 than for x=1?

-- 
To email me, substitute nowhere->spamcop, invalid->net.



More information about the Python-list mailing list