MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: Precision of AiryAi[0.0]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103566] Re: [mg103530] Re: [mg103519] Re: Precision of AiryAi[0.0]
  • From: danl at wolfram.com
  • Date: Sun, 27 Sep 2009 23:09:00 -0400 (EDT)
  • References: <200909241149.HAA29080@smc.vnet.net> <h9i44n$98i$1@smc.vnet.net>

> Where's the bug?

The bug is that AiryAi[0.0] returns a result that is not MachinePrecision,
but rather an arbitrary precision (aka bignum) result that has
$MachinePrecision. This will be fixed.


> AiryAi1[x_?NumberQ] := SetPrecision[AiryAi[x], MachinePrecision]
>
> ClearSystemCache[]
> Precision@Nest[AiryAi1, 0.0, 100] // Timing
>
> {0.000844, MachinePrecision}
>
> You asked for MachinePrecision, and that's what you got. No problem.
>
> Now for the other problem:
>
> ClearSystemCache[]
> Precision@Nest[AiryAi, 0.0, 100] // Timing
>
> {0.130276, 225.079}
>
> You got more precision than you started with. Why? Because the derivative
> of AiryAi at 0 is less than 1 in absolute value:
>
> AiryAi'[0.]
>
> -0.2588194037928068
>
> So... whenever you apply AiryAi, the result has approximately 74.2%
> smaller error or doubt than the argument.

I fail to see how that derivative translates into 74% less error.


> Clear[f]
> f[a_] := (Sow@Precision@a; AiryAi@a)
> First@Last@Reap@ Nest[f, 0.0, 10]
> Differences@%
>
> {MachinePrecision, 15.9546, 17.9528, 20.098, 22.2037, 24.3188, \
> 26.4316, 28.545, 30.6583, 32.7715}
>
> {1.77636*10^-15, 1.99821, 2.14525, 2.10563, 2.11516, 2.1128, 2.11338, \
> 2.11324, 2.11327}
>
> We gain about 2.1 decimal digits of precision at each step.

Correct.


> That is, the
> answer is "0" at each step, but we're increasingly confident that it's
> CLOSE to zero.

Not correct. The fixed point is not at zero, but rather around 0.283.
Notice that while we gain precision of 2.1 digits per step, we do not
approach the fixed point quite so fast. That derivative indicates why.
Actually it is the derivative at the fixed point that matters, but there
is is also around 1/4 (actually, a nip beneath). What it indicates is that
at each step we move around 3/4 closer to the fixed point (actually, a
little more). This means we expect two bits of convergence per step
(actually, a little, but not a bit, more).

This can be seen as below.

Clear[f]
f[a_] := (Sow[{Precision[a], AiryAi[a]}]; AiryAi[a])
vals = First[Last[Reap@Nest[f, 0.0, 17]]][[All, 2]]
diffs = Differences[vals]
logdiffs = Log[2, Abs[diffs]]
Differences[logdiffs]

{-2.033792366974569, -2.0170733827862860, -2.020880516606609458, \
-2.0199229875288840538, -2.020157903232697864244, \
-2.0200999172953328332223, -2.020114208841934442792724, \
-2.0201106851575892880749150, -2.020111553867977591290426639, \
-2.0201113396959084095017615097, -2.020111392497648392754390825097, \
-2.0201113794799492142522974329761, \
-2.020111382689321379945413530707662, \
-2.0201113818980855082814490657827224, \
-2.020111382093156120045773831251523481}

Those are the 2+ bits/step of convergence.


> [...]
>
> Here's almost the same example, with a different outcome:
>
> Clear[g]
> g[x_] = AiryAi'[0.] x;
> First@Last@Reap@Nest[f, 0.0, 10]

You are nesting f, not g. Maybe you changed the definition of f somewhere
along the way? (Cut/paste dybbuk strikes again. I feel your pain...)


> {MachinePrecision, 15.9546, 15.9546, 15.9546, 15.9546, 15.9546, 15.9546, \
> 15.9546, 15.9546, 15.9546}
>
> {g[0.0], g'[0.0]} // InputForm
>
> {0., -0.25881940379280679840518356018919926961`15.954589770191005}
>
> This time precision doesn't remain precisely MachinePrecision... yet it
> doesn't grow.
>
> Why? Beats the hell out of me!
>
> Bobby

Daniel Lichtblau
Wolfram Research




  • Prev by Date: Re: A question about parallel computation in mathematica
  • Next by Date: Re: BarChart Range
  • Previous by thread: Re: Re: Re: Precision of AiryAi[0.0]
  • Next by thread: Algorithm for computation sequence