Backward error analysis versus singularities – HP 15c User Manual

Page 161

Advertising
background image

Appendix: Accuracy of Numerical Calculations

161

when we wish to calculate f(x), the best we could hope to get is f(x + Δx), but we actually get
F(xx)=(f+δf)(xx+δx), where |δf| ≤ ε|f| and |δx| ≤ η|x|.

What we get is scarcely worse than the best we could hope for provided the tolerances ε and
η are small enough, particularly if |Δx| is likely to be at least roughly as big as η|x|. Of course,
the best we could hope for may be very bad, especially if f possesses a singularity closer to x
than the tolerances upon x's perturbation Δx and δx.

Backward Error Analysis Versus Singularities

The word "singularity" refers to both a special value of the argument x and to the way f(x)
misbehaves as x approaches that special value. Most commonly, f(x) or its first derivative
f'(x) may become infinite or violently oscillatory as x approaches the singularity. Sometimes
the singularities of ln|f| are called singularities of f, thereby including the zeros of f among its
singularities; this makes sense when the relative accuracy of a computation of f is at issue, as
we shall see. For our purposes the meaning of "singularity" can be left a little vague.

What we usually want to do with singularities is avoid or neutralize them. For instance, the
function



otherwise

2

1

0

if

2

cos

1

)

(

x

x

x

x

c

has no singularity at x = 0 even though its constituents 1 − cos x and x

2

(actually, their

logarithms) do behave singularly as x approaches 0. The constituent singularities cause
trouble for the program that calculates c(x). Most of the trouble is neutralized by the choice
of a better formula

 





otherwise.

2

1

0

2

if

2

2

2

sin

2

1

)

(

x

x

x

x

c

Now the singularity can be avoided entirely by testing whether x/2 = 0 in the program that
calculates c(x).

Backward error analysis complicates singularities in a way that is easiest to illustrate with the
function λ(x) = ln(1 + x) that solved the savings problem in example 2. The procedure used
there calculated u = 1 + x (rounded) = 1 + x + Δx. Then

otherwise.

)

1

(

)

ln(

1

u

if

)

(

u

x

u

x

x

This procedure exploits the fact that λ(x)/x has a removable singularity at x = 0, which means
that λ(x)/x varies continuously and approaches 1 as x approaches 0. Therefore, λ(x)/x is
relatively closely approximated by λ(xx) / (xx) when |Δx| < 10

-9

, and hence

λ(x) = x(λ(x)/x) ≈ x(λ(xx)/(xx)) = x(ln(u)/(u−1)),

Advertising