MathGroup Archive 2009

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

Search the Archive

Re: Re: Precision of AiryAi[0.0]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103530] Re: [mg103519] Re: Precision of AiryAi[0.0]
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sun, 27 Sep 2009 07:30:12 -0400 (EDT)
  • References: <200909241149.HAA29080@smc.vnet.net> <h9i44n$98i$1@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

Where's the bug?

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.

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. That is, the  
answer is "0" at each step, but we're increasingly confident that it's  
CLOSE to zero.

But wait! Here's another function with the same properties (apparently):

Clear[g]
g[x_] = N[AiryAi'[0.], MachinePrecision] x;
g[0.0]
g'[0.0]

0.

-0.258819

Another contraction. Won't precision increase, just as it did above?

Clear[f]
f[a_] := (Sow@Precision@a; g@x)
First@Last@Reap@Nest[f, 0.0, 10]

{MachinePrecision, MachinePrecision, MachinePrecision, \
MachinePrecision, MachinePrecision, MachinePrecision, \
MachinePrecision, MachinePrecision, MachinePrecision, \
MachinePrecision}

No, and here's why. The value and derivative of AiryAi are "arbitrary  
precision" numbers:

{AiryAi[0.0], AiryAi'[0.0]} // InputForm

{0.35502805388781723926006337187548776944`15.954589770191005,
  -0.25881940379280679840518356018919926961`15.954589770191005}

But not so for the function g, where both values are MachinePrecision:

{g[0.0], g'[0.0]} // InputForm

{0., -0.2588194037928068}

(It's actually g that matters for this, not g'.)

In computing AiryAi, Mathematica switches to arbitrary precision  
arithmetic... but computing g, it does not.

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]

{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

On Sat, 26 Sep 2009 05:13:14 -0500, Harutyun Amirjanyan  
<amirjanyan at gmail.com> wrote:

> this looks like a bug
> and it's the same in versions 5,6,7
>
> setting every time Precision to MachinePrecision can help
> In[1]:= AiryAi1[x_?NumberQ] :=
>  SetPrecision[AiryAi[x], MachinePrecision]
>
> In[2]:= ClearSystemCache[]
> Precision@Nest[AiryAi1, 0.0, 100] // Timing
>
> Out[3]= {0., MachinePrecision}
>
> In[4]:= ClearSystemCache[]
> Precision@Nest[AiryAi, 0.0, 100] // Timing
>
> Out[5]= {0.687, 225.079}
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Full expansion with a mixture of Times and NonCommutativeMultiply
  • Next by Date: Re: Re: OneIdentity
  • Previous by thread: Re: Precision of AiryAi[0.0]
  • Next by thread: Re: Re: Re: Precision of AiryAi[0.0]