Evaluation of Ai(x) with Reduced...

Post on 15-Oct-2020

2 views 0 download

Transcript of Evaluation of Ai(x) with Reduced...

Evaluation of Ai(x)with Reduced Cancellation

Sylvain Chevillard, Marc Mezzarobba

Inria, France

ARITH 21, Austin, TexasApril 10, 2013

The Airy Function Ai(x)

–0.6

–0.4

–0.2

0

0.2

0.4

0.6

–8 –6 –4 –2 2 4 6 8x

Ai′′(x)=xAi(x) Ai(0)=1

32/3Γ(2/3)Ai′(0)=− 1

31/3Γ(1/3)

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Multiple-Precision Evaluation for x> 0

Standard Approach

“Small” x:

Taylor Series at 0

• catastrophic cancellation

for moderately large x

• need pwork≫ pres

“Large” x:

Asymptotic Expansion at ∞

This talk

New evaluation algorithm for “small” x with pwork≈ pres

Complete error analysis

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Catastrophic Cancellation

0

5e+06

1e+07

1.5e+07

2e+07

20 40 60 80 100

|ynxn|

“lost” digits≈ log (max |ynxn|)− log |y(x)|

(x= 10)

Ai(x)= A−Bx+A6x3− B

12x4+

A180

x6− B504

x7+A

12960x9−�

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Another ExampleThe Error Function

–1

–0.5

0

0.5

1

–6 –4 –2 2 4 6x

erf(x)=2

π√

(x− 1

3x3+

110

x5− 142

x7+1216

x9−�

)

catastrophic cancellationMarc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

But...

[Abramowitz & Stegun 1972, p. 297]

Algorithm

1. Compute2

π√

n=0

∞2n x2n+1

1 · 3� (2n+1)positive terms, no cancellation

2. Compute exp (x2)

3. Divide

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Where

does this formula

come from?

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

The Gawronski-Müller-Reinhard Method

Or: How Complex Analysis “explains” the previous trick

Idea: Find F and G such that

1. y(x)=G(x)

F (x)

2. F and G computable with little cancellation

W. Gawronski, J. Müller, M. Reinhard. SIAM J. Num. An., 2007

M. Reinhard. Phd thesis, Universität Trier, 2008

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Asymptotics

Ai(z)∼exp

(−2

3z3/2

)

2 π√

z1/4

as z→∞in any sector

{z ∈C|−ϕ< arg z < ϕ}with ϕ> 0

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Asymptotics

|Ai(r eiθ)| ≈ exp (h(θ) rρ)

for large r

Ai(z)∼exp

(−2

3z3/2

)

2 π√

z1/4

Order ρ=3/2

Indicator h(θ)=−23cos

3 θ2

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Lost in Cancellation

ill-conditioned

well-conditioned

lost digits≈ log(maxn

|yn (r eiθ)n|)− log |y(r eiθ)|≈ rρ (maxh−h(θ))

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

The GMR Method

{|F (z)| ≈ exp (hF(θ) r

ρ)|G(z)| ≈ exp (hG(θ) r

ρ)⇒

∣∣∣∣G(z)

F (z)

∣∣∣∣≈ exp [(hG(θ)−hF(θ))�

hG/F(θ)

rρ]

Idea (refined): look for

• an auxiliary series F ,

• a modified series G= yF ,

both of order ρ,

such that hF and hG ≈ their max for θ=0

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Indicators

Ai(x) Ai(j−1x) Ai(j x)

F (x)=Ai(j x)Ai(j−1 x) G(x)=Ai(x)Ai(j x)Ai(j−1x)

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

How do we

evaluate

the auxiliary series?

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Computer Algebra to the Rescue

A function y is D-finite (holonomic) when it satisfies a linear ODE withpolynomial coefficients.

Examples: Ai(x), exp (x), erf(x) Ai′′(x)= xAi(x)

If f(x), g(x) are D-finite, then:

• f(x)+ g(x) and f(x) · g(x) tooF (x)=Ai(j x) ·Ai(j−1 x) F ′′′(x)= 4xF ′(x)+ 2F (x)

• The Taylor coefficients of f(x) obey a linear recurrence relation withpolynomial coefficients

F (x)=∑

n=0

∞Fnx

n Fn+3=2 (2n+1)

(n+1) (n+2) (n+3)Fn

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

The Auxiliary Series F (x)

D-Finiteness

Fn+3=2 (2n+1)

(n+1) (n+2) (n+3)Fn

F0=1

34/3Γ(

2

3

)2 F1=

1

2 3√

πF2=

1

32/3Γ(

1

3

)2

• Two-term recurrence ⇒ Easy to evaluate

• Obviously Fn> 0 ⇒ Minimal cancellation

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

The Modified Series G(x)

G(x)=Ai(x)F (x)=∑

n=0

∞Gnx

3n

D-Finiteness

Gn+2=10 (n+1)2Gn+1−Gn

(n+1) (n+2) (3n+4) (3n+5)

G0=1

9Γ(

2

3

)3 G1=

1

18Γ(

2

3

)3 −

1

3Γ(

1

3

)3

G(x)= 0.44749 · 10−1+ 0.50371 · 10−2 x3+ .14053 · 10−3x6

+ .17388 10−5x9+ .12091 · 10−7 x12+ .53787 · 10−10x15+�

Observe that Gn > 0 (proof?)Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Bad News

The recursive computation of Gn is

unstable

(Gn is a minimal solution of the recurrence)

The computation of the sum∑

n=0

∞Gnx

n is stable (no cancellation)

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

All Is Not Lost

Miller’s backward recurrence method allows one to compute minimalsolutions in a numerically stable way

Final Algorithm

1. Compute error bounds, choose working precision (how?)

2. Compute F (x) by direct recurrence

3. Compute G(x) using Miller’s method

4. Divide

Numerically stable in practice (proof?)

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

I didn’t actually

prove

anything

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Making the Analysis Rigorous

• Prove that (Gn) is a minimal solution

[⇒ Miller’s method works]

• Prove that Gn> 0

[⇒ no cancellation] Main issue:

need bounds on Gn

• Bound the tails of the series F and G

• Bound the roundoff errors in∑

Fnxn

• Bound the method error of Miller’s algorithm

• Bound additional roundoff errors due to Miller’s method [M&vdS 1976]

R.M.M. Matthiej & A. van der Sluis, Numerische Mathematik , 1976

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Controlling Gn

Main Technical Lemma

Gn∼ γn=1

4 3√

π 9nn!2with

∣∣∣∣Gn

γn− 1

∣∣∣∣6 2.4n−1/4 for all n> 1

Corollary: Gn> 0 (for large n, then for all n)

Idea of the proof

• Gn=1

2π i

∮G(z)

z3n+1 dz

• saddle-point method

• Ai(z)∼ e−2

3z3/2

2 π√

z1/4+ error bound

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Conclusion

Summary

• New well-conditioned formula for Ai(x),

obtained by an extension of the GMR method

• Rigorous error analysis on this example

• Ready-to-use multiple-precision algorithm for Ai(x)

implementation & suppl. material at http://hal.inria.fr/hal-00767085

Next question: How much of this is specific to Ai(x)?

• Entire function

• Ability to find auxiliary series

• D-finiteness [constraints on the order of the recurrences?]

• Asymptotic estimate with error bound

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation

Credits & Public Domain Dedication

This document uses

• the image http://commons.wikimedia.org/wiki/File:AiryAi_Abs_Surface.png from

Wikimedia Commons, by User:Inductiveload, placed in the public domain;

• the image http://www.flickr.com/photos/panr/4410697542/, by Robert Cutts,

disstributed under a Creative Commons Attribution 2.0 licence (http://creativecom-

mons.org/licenses/by/2.0/);

• icons from the Oxygen icon set (http://www.oxygen-icons.org/), distributed

under the Creative Commons Attribution-ShareAlike 3.0 license (http://creativecom-

mons.org/licenses/by-sa/3.0/).

To the extent possible under law, Marc Mezzarobba has waived all copyright and related or

neighboring rights to the rest of the present document Evaluation of Ai(x) with Reduced

Cancellation. This work is published from: France.

Marc Mezzarobba (Inria) Evaluation of Ai(x) with Reduced Cancellation