       Re: Re: Pi upto a Billion Digits

• To: mathgroup at smc.vnet.net
• Subject: [mg75728] Re: [mg75672] Re: Pi upto a Billion Digits
• From: "Szabolcs Horvát" <szhorvat at gmail.com>
• Date: Wed, 9 May 2007 04:35:18 -0400 (EDT)
• References: <f1msfm\$rnf\$1@smc.vnet.net>

```On 08/05/07, DrMajorBob <drmajorbob at bigfoot.com> wrote:
> On my machine (WinXP, Athlon 3200+, 2GB RAM, Mathematica 6), I estimate
> 3.4 hours:

Did you run the calculation?

>
> Timing[data =
>    Table[Update[];
>     Log@{#, First@Timing[N[Pi, #]]} &[2^k 10^5], {k, 1, 8}]]
>
> {231.921, {{Log, -1.06711}, {Log, -0.226901}, {Log[
>      800000], 0.669879}, {Log, 1.50741}, {Log,
>     2.37052}, {Log, 3.21451}, {Log,
>     4.05123}, {Log, 4.87675}}}
>
> (I doubled two steps more than Szabolcs did.)
>
> The log-log data is VERY linear:
>
> Needs["LinearRegression`"]
> AdjustedRSquared /. Regress[data, x, x]
>
> 0.999901
>
> Clear[a, b, z, logSecs, hours]
> model = a + b z;
> logSecs[z_] = model /. FindFit[data, model, {a, b}, z]
> hours[z_] := Exp[logSecs[Log[z]]]/60^2
> hours[10^9]
>
> -16.0424 + 1.22792 z
>
> 3.37132
>
> Also note, omitting Update[] has NO effect on the timings:
>
> Timing[data =
>    Table[Log@{#, First@Timing[N[Pi, #]]} &[2^k 10^5], {k, 1, 8}]]
>
> {231.703, {{Log, -1.07002}, {Log, -0.207024}, {Log[
>      800000], 0.628609}, {Log, 1.52126}, {Log,
>     2.36471}, {Log, 3.21133}, {Log,
>     4.04989}, {Log, 4.8771}}}
>
> Bobby

Update[] forces Mathematica to recalculate everything instead of using
cached values. If it has no effect in Mathematica 6 that is very
strange (it would mean that Mathematica 6 doesn't cache results in
this case, and that the performance may be worse than in 5.2). Does it
have an effect when you don't use it in Table[], but evaluate the
expressions separately?

In 5.2 it has a very noticeable effect:

In:=
Update[]

In:=
Timing[N[Pi,4*10^5];]

Out=
{3.25 Second,Null}

In:=
Timing[N[Pi,8*10^5];]

Out=
{5.579 Second,Null}

In:=
Update[]

In:=
Timing[N[Pi,8*10^5];]

Out=
{8.187 Second,Null}

In:=
Update[]

In:=
Table[Timing[N[Pi,k 4*10^5];],{k,2}]

Out=
{{3.156 Second,Null},{5.625 Second,Null}}

In:=
Update[]

In:=
Table[Update[];Timing[N[Pi,k 4*10^5];],{k,2}]

Out=
{{3.11 Second,Null},{8.062 Second,Null}}

Szabolcs

```

• Prev by Date: Re: Eigenvalues in Mathematica 6.0.0 are SLOW
• Next by Date: Re: Re: Format->Magnification does not work
• Previous by thread: Re: Re: Pi upto a Billion Digits
• Next by thread: Re: Re: Pi upto a Billion Digits