0% found this document useful (0 votes)
235 views

Branch Cuts For Complex Elementary Functions

This document discusses branch cuts for complex elementary functions like the square root, logarithm, and inverse trigonometric functions. It notes that the sign of zero impacts how these functions are defined at their branch cuts. Following IEEE standards, the functions can be continuous up to their cuts when zero has a sign, but must be discontinuous on one side when zero is unsigned. The document introduces principal value definitions for the functions to resolve ambiguities while still allowing programs to work as expected when following the IEEE zero sign propagation rules.

Uploaded by

Andras Pahi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
235 views

Branch Cuts For Complex Elementary Functions

This document discusses branch cuts for complex elementary functions like the square root, logarithm, and inverse trigonometric functions. It notes that the sign of zero impacts how these functions are defined at their branch cuts. Following IEEE standards, the functions can be continuous up to their cuts when zero has a sign, but must be discontinuous on one side when zero is unsigned. The document introduces principal value definitions for the functions to resolve ambiguities while still allowing programs to work as expected when following the IEEE zero sign propagation rules.

Uploaded by

Andras Pahi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

7 Branch Cuts for Complex

Elementary Functions
or
Much Ado About Nothing's Sign Bit
W. KAHAN

ABSTRACT
Zero has a usab Ie sign bi t on some computers, but not on
others. This accident of computer arithmetic influences the
definition and use of familiar complex elementary functions like
V, arctan and arccosh whose domains are the whole complex plane
with a slit or two drawn in it. The Principal Values of those
functions are defined in terms of the logarithm function from
which they inherit discontinuities across the slit (s). These
discontinuities are crucial for applications to conformal maps
with corners. The behaviour of those functions on their slits
can be read off immediately from defining Principal Expressions
introduced in this paper for use by analysts. Also introduced
herein are programs that implement the functions fairly accu-
rately despite roundoff and other numerical exigencies. Except
at logarithmic branch points, those functions can all be conti-
nuous up to and onto their boundary slits when zero has a sign
that behaves as specified by IEEE standards for floating-point
arithmetic; but those functions must be discontinuous on one
side of each slit when zero is unsigned. Thus does the sign of
zero lay down a trail from computer hardware through programming
language compilers, run-time support libraries and applications
programmers to, finally, mathematical analysts.

I. INTRODUCTION
Conventions dictate the ways nine familiar multiple-valued
complex elementary functions, namely

V. ,Q,n, arcsin, arccos, arctan, arcsinh, arccosh, arc tanh,


UJ
Z ,

shall be represented by single-valued functions called "Principal


Values". These single-valued functions are defined and analytic
166 W. KAHAN BRANCH CUTS 167

throughout the complex plane except for discontinuities across The IEEE standards 754 and p854 take a different approach.
certain straight lines called "slits" so situated as to maximize They prescribe representations for both +0 and -0 but do not
the reign of continuity, conserving as many as possible of the distinguish between them during ordinary arithmetic operations,
properties of these functions' familiar real restrictions to apt so the ambiguity is benign. Rather than think of + 0 and -0 as
segments of the real axis. There can be no dispute about where distinct numerical values, think of their sign bit as an auxili-
to put the slits; their locations are deducible. However, Princi- ary variable that conveys one bit of information (or misinforma-
pal Values have too often been left ambiguous on the slits, tion) about any numerical variable that takes on 0 as its value.
causing confusion and controversy insofar as computer programmers Usually this information is irrelevant; the value of 3 + x is no
have had to agree upon their definitions. This paper's thesis different for x:= +0 than for x := -0, and the same goes for
is that most of that ambiguity can and should be resolved; how- the functions signum (x) and sign(y,x) mentioned above. How-
ever, on computers that conform to the IEEE standards 754 and ever, a few extraordinary arithmetic operations are affected by
p854 for floating-point arithemetic the ambiguity should not be zero I s sign; for example 1/ (+0) +ca but 1/ (-0) = -co .. To re-
eliminated entirely because, paradoxically, what is left of it tain its usefulness, the sign bit must propagate through certain
usually makes programs work better. arithmetic operations according to rules derived from continuity
What has to be ambiguous is the sign of zero. In the past, considerations; for instance (-3)(+0):= -0, (-0)/(-5) =+0,
most people and computers would assign no sign to zero except (-0) - (+0) = -0, etc. These rules are specified in the IEEE
under auress, and then they would treat the sign as + rather standards along with the one rule that had to be chosen arbitra-
than For example, the real function rily:
signum(x) := +1 if x> 0 S -8 := +0 for every string s representing a finite real number.
:= 0 if x o Consequently when t=s, but O¢t¢co, then s - t and t-8
-I if x < 0
both produce + 0 instead of opposi te signs. (That is why, in
illustrates the traditional noncommittal attitude toward zero's
IEEE style arithmetic, s - t and - (t-s) are numerically equal
sign, whereas the Fortran function
but not necessarily indistinguishable.) Implementations of ele-
sign(l.O, := + 1 .0 if x;;. 0
mentary transcendental functions like sin(z) and tan(z) and
:= -1.0 if x < 0 ,
their inverses and hyperbolic analogs, though not specified by
must behave as if zero had a + sign in order that this function
the IEEE standards, are expected to follow similar rules; if
and its first argument have the same magnitude. Just as
[(0) = 0 <1 '(0), then the implementation of I(z) is expected
sign ( I .0, x) is continuous at x 0+, i.e. as x approaches zero
to reproduce the sign of z as well as its value at z = ±O ..
from the right, so can each principal value above be continuous That does happen in several libraries of elementary transcenden-
as its slit is reached from one side but not from the other. tal functions; for instance, it happens on the Motorola 68881
Sides can be chosen in a consistent way among all the elementary
Floating-Point Coprocessor, on Apple computers in their Standard
complex functions, as they have been chosen for the implementa-
Apple Numerical Environment, in Intel's Common Elementary Function
tions built into the Hewlett-Packard hp-15C calculator that will
Libraries for the i8087 and i80287 floating-point coprocessors,
be used to illustrate this approach.
in analogous libraries now supplied with the Sun III, with the must be invariant under reflection in the origin z = O. Finally,
ELXSI 6400 and with the IBM PC/RT, and in the C Math Library the slit(s) must begin and end at branch-points: these are
currently distributed with 4.3 BSD UNIX for machines that con- singularities around which some branch of the function cannot be
form to IEEE 754. With a few unintentional exceptions, it represented by a Taylor nor Laurent series expansion. A slit can
happens also on the hp-71R,hand-held computer, whose arithmetic end at a branch point at infinity.
was designed to conform to IEEE p854. Consequently the slit for v', £n and ZW turns out to be
If a programmer does not find these rules helpful, or if the negative real axis. Then the slits for arcsin, arccos and
he does not know about them, he can ignore them and, as has been arctanh turn out to be those parts of the real axis not between
necessary in the past, insert explicit tests for zero in his pro- -I and + I; similarly those parts of the imaginary axis not be-
gram wherever he must cope with a discontinuity at zero. On the tween -i and +i serve as slits for arctan and arcsinh. The
other hand, if the standards' rules happen to produce the desired slit for arccosh, the only slit with a finite branch-point (-\)
results without such tests, the tests may be omitted leaving the inside it, must be drawn along the real axis where z ~ + I. None
programs simpler in appearance though perhaps more subtle. This of this is controversial, although a few other writers have at
is just what happens to programs that implement or use the times drawn the slits elsewhere either for a special purpose or
elementary functions named above, as will become evident below. by mistake; other tastes can be accommodated by substitutions
sometimes so simple as writing, say, £n(-l)-£n(-I/z) in place
2. WHERE TO PUT THE SLITS of £n(z) to draw its slit along (and just under) the positive
Each of our nine elementary complex functions f(z) has a real axis instead of the negative real axis.
slit or slits that bound a region, called the principal domain,
inside which f(z) has a principal value that is single valued 3. WHY DO SL ITSMATTER ?
and analytic (representable locally by power series), though it A computer program that includes complex arithmetic opera-
must be discontinuous across the slit(s). That principal value tions must be a product of a deductive process. One stage in
is an extension, with maximal principal domain, of a real elemen- that process might have been a model formulated in terms of ana-
tary function f(x) analytic at every interior point of its lytic expressions that constrain physically meaningful variables
domain, which is a segment of the real x-axis. To conserve the without telling explicitly how to compute them. From those
power series' validity, points strictly inside that segment must expressions somebody had to deduce other complex analytic expres-
also lie strictly inside the principal domain; therefore the sions that the computer will evaluate to solve the given physical
slit(s) cannot intersect the segment's interior. Let z* =x- iy problem. The deductive process entails transformations among
denote the complex conjugate of z =x + iy; the power series for which some may resemble algebraic manipulations of real expres-
f(x) satisfy the identity f(z*) = f(z)* within some complex sions, but with a crucial difference:
neighbourhood of the segment's interior, so the identity should Certain transformations, generally val id for real
persevere throughout the principal domain' s interior too. expressions, are valid for complex expressions only
while their variables remain within suitable regions
Consequently complex conjugation must map the slit(s) to itself/ in the complex plane.
themselves. The slit(s) of an odd function f(z) == - f(-z) Moreover, those regions of validity can depend disconcertingly
regions of convergence, etc. In general, singularities can be
upon the computer that will be used to evaluate the expres-
sions in question. For example, simplifying the expression hard to find; in our examples the singularities are obviously
the pole at 2'" I, the branch-point 2 = 0, and respective slits
";(21 (4 I») ,/( II (4 - I») to ";(4) I (4 I) seems legitimate in so
0< 2 < I, 2 < I and 2 < 0 whereon the quanti ties under square
far as they both describe the same complex function, one that is
continuous everywhere except for a pole at 4 = I and a jump- root signs are negative real.
2. Taken together, the singularities partition the complex
discontinuity along the negative real axis 2 < O. And when those plane into a collection of disjoint connected components.
two expressions are evaluated upon a variety of computers includ- Inside each such component locate a sma?? aontinuum
upon which the equivalence of the given two expressions
ing the ELXSI 6400, the Sun III, the IBM PC/RT, the IBM pcl AT, can be decided; that decision is valid throughout the
PCIXT and PC using i80287 or" i8087, and the hp-71B, they component's interior.
agree everywhere within a rounding error or two. But when the The "small continuum" might be a small disk inside which
same expressions are evaluated upon a different collection of both expressions are represented by the same Taylor series; or
computers including CRAYs, the IBM 370 family, the DEC VAX it could be a curvilinear arc within which both expressions take
line, and the hp-15C, those expressions take opposite signs values that can be proved equal by the laws of real algebra.
along the negative real axis! An experience like this could Other possibilities exist; some will be suggested by whatever
undermine one's faith in some computers. motivated the attempt to prove that the given expressions are
What deserves to be undermined is blind faith in the power equivalent. In our example, the two expressions are easily
of Algebra. We should not believe that the equivalence class of on that part of the real axis where 2 > 1 , which
proven equal
expressions that all describe the same complex analytic function happens to lie inside the one connected component into which the
can be recognized by algebraic means alone, not even if rela- slits along the rest of the real axis divide the complex plane.
tively uncomplicated expressions are the only ones considered. Therefore the two expressions must be equivalent everywhere in
To locate the domain upon which two analytic expressions take the complex plane except possibly for real 2 < 1•
equal values generally requires a combination of algebraic, 3. The singularities cons ti tute loci in the plane upon
which the processes in steps 1 and 2 above can be
analytical and topological techniques. The paradigm is familiar
repeated, finally leaving isolated singular points to
to complex analysts, but it will be summarized here for the sake be handled individually. End of paradigm.
of other readers, using the two expressions given above for In our example, the slit along 2 < 1 is partitioned into
concrete illustration. the branch-point at Z = O. Each
two connected components by
How to decide where two analytic expressions describe Whether the two expres-
component has to be handled separately.
the same function. sions are equivalent on a component must depend upon the defini-
I. Locate the singularities of each constituent subexpression tion of complex ";2 on its slit where Z < 0; there diverse
of the given expressions. That is what this paper is about.
computers appear to disagree.
The singularities of an analytic function are the boundary More generally, programmers who compose complex analytic
points of its domain of analyticity. These will consist of poles, expressions out of the nine elementary functions listed at this
branch-points and slits in this paper; but more generally they paper's beginning will have to verify whether their expressions
would include certain contours of integration, boundaries of
deliver the functions that they intend to compute. In principle, 4. PRINCIPAL VALUES ON THE SLITS, IEEE STYLE
that verification could proceed without prior agreements about Since all the slits in question lie on either the real or
the functions' values on their slits if instead analysts and pro- the imaginary axis, every point z on a slit is represented in
grammers were obliged to supply an explicit expression to handle at least two ways, at least once with a +0 and at least once
every boundary situation as they intend. Such a policy seems with a -0 for whichever of the real and imaginary parts of z
inconsiderate (not to say unconscionable) considering how hard vanishes. Benignly, ambiguity in z at a discontinuity of f(z)
some singu~arities are to find, and how easy to overlook; but permits fez) to be defined formally continuously, except possi-
that policy is not entirely heartless since verifying correctness bly at the ends of some slits, by continuation from inside the
along a boundary costs the intellect nearly as much as writing principal domain. This continuity goes beyond mere formality.
down a statement of intent about that boundary. The trouble with By analytic continuation, the domain of each of our nine elemen-
those statements is that they generally contain inequalities and tary functions fez) extends until it fills out a Riemann
tests and diverse cases, and as they accumulate they burden Surface; think of this surface as a multiple covering wrapped
proofs and programs with a dangerously enlarged capture cross- like a bandage around the Riemann Sphere and mapped onto it
section for errors. And almost all of those statements become continuously by f. To construct f's principal domain, cut the
superfluous in programs after we agree upon reasonable defini- bandage along the slit(s) and discard all but one layer covering
tions for the functions in question on their slits. the sphere. That layer is a closed surface mapped by f con-
For instance, in our examp Ie above we had to discover tinuously onto a subset of the sphere. The shadow of that layer
whether the two expressions agreed on an interval 0 < z < 1 that projected down upon the sphere is the principal domain; it con-
lies strictly inside the dom~in of the desired function's analy- sists of the whole sphere, but with slit(s) covered twice. That
ticity, not on its boundary. That interval turns out to be a is why we wish to represent slits ambiguously.
removable singularity, and it does remove itself from all the Here are some illustrative examples, the first of a real
computers mentioned above because they evaluate both expressions function that is recommended for any implementation of IEEE
correctly on that interval; diverse computers disagree only on standard 754 or p854.
the boundary where the desired function is discontinuous. Per- copysign(x, y) := ± x where the sign bit is that of y, so }
haps that's just luck. (Unlucky examples do exist and one will copysign(1,+O) =+1 = lim copysign(l, y) at y= 0+, and (4.1)
be presented later.) Let us accept good luck with gratitude copysign(l,-O) -I = lim copysign(l, y) at y = 0-.
whenever it simplifies our programs. v(-I+iO) =+O+i=lim,/(-I +iy) at y= 0+; } (4.2)
Complex analytic expressions that involve slits and other v(-I-iO) =+0 - i = lim,j(-I +iy) at y = c- .
singularities are intrinsically complicated, and they get more Consequently, v(z*) =v(z)* for every z, and v(llz) = I/v(z) too.
compl icated when rounding errors are taken into account. Our These identities persist within roundoff provided the programs
objective cannot be to make complicated things simple but rather, used for square root and reciprocal are those, supplied in this
by choosing reasonable values for our nine elementary functions paper, that would have been chosen anyway for their efficiency
on their slits, to make them no worse than necessary.
and accuracy.
174 W. KAHAN BRANCH CUTS 175

arccos (2 + iO) == +0 - i arccosh(2) directly, not by first coercing the real to complex, lest the
= lim arccos(2 + iy)
sign of zero be rendered uninformative; the same goes for com-
at y 0+;)
(4.3)
binations of pure imaginary quantities with complex variables.
arccos(2 - iO) == +0 + i arccosh(2)
And doing arithmetic directly this way saves execution time that
lim arccos(2+iy) at y == 0- •
would otherwise be squandered manipulating zeros.) When z is
An implementation of arccos that preserves full accuracy in the
near ± I the expression a(z) nearly vanishes and loses its rela-
imaginary part of arccos (2 + i y) when Iy I is very tiny can be
tive accuracy to roundoff. Although this loss could be avoided
expected to get its sign right when y = ± 0 too without extra
by rewriting a (z) := v' (z - I) (z + I»), doing so would obscure
tests in the code; such a program is supplied later in this
the discontinuity on the imaginary axis in a cloud of roundoff
paper.
which obliterates Re (z) whenever it is very tiny compared wi th
But the foregoing examples make it all seem too simple.
1 as well as when it is ±O.
The next example presents a more balanced picture.
Also obscure is what happens at the ends of some slits.
Let function a(x) := V(x 2 - \ ) for real x with x 2 ;> I,
Take for example £n(z)=£n(p)+ ie, where p= Izi and e=arg(z)
and let b(x):= a(x) for real x;> \ note that b(x) is not
j
are the polar coordinates of z =x + iy and satisfy
yet defined when x ~ \. The principal values of the complex
x = p cos e, y == p sin e, p;> 0 and -11" ~ e ~ 1f
extensions of a and b following the principles enunciated
Evidently p:= +v(x 2 + y2), and when 0 < p < +co then
above turn out to be
e := 2 arctan (y/(p+x») if x;> 0, or
a(z) = v'(z2- I) = a(-z}, and :=2arctan(p-x)/y) if x~O.
b(z) v'(z-I)v(z+ I) =-b(-z) . At the end of the slit where z = x = y p == 0 (and tn = -co)
Both a and b are defined throughout the complex plane and both the value of e may seem arbitrary, but in fact it must cohere
have a slit on the real axis running from I to + I, but a has with other almost arbitrary choices concerning division by zero
another slit that runs along the entire imaginary axis separat- and arithmetic with infinity. A reasonable choice is to inter-
ing the right half-plane where a b from the left half-plane pose the reassignment
where a=-b. The functions are different because generally if p == 0 then x := copysign (\, x)
v'(~) v'(n) v'(~ n) when largO;) + arg(n) I < 1f between the computations of p and e above. More about that
v( ~ n) when larg(O + arg(n) I> 11" later.

v'( ~ n) (hard to say which) when i; n ~ O. The foregoing examples provide an unsettling glimpse of
Both functions a and b are continuous up to and onto ambiguous the complexities that have daunted implementers of compilers and
boundary points in IEEE style arithmetic, as described above, run-time libraries who would otherwise extend to complex arith-
only if that arithmetic is implemented carefully; in particular, metic the facilities they have supplied for real floating-point
the expression z + I should not be replaced by the ostensibly computation. These complexities are attributable to failures,
equivalent z + (I + iO) lest the sign of zero in the imaginary in complex floating-point arithmetic, of familiar relationships
part of z be reversed wrongly. (Generally, mixed-roode arith- like algebraic identities that we have come to take for granted
metic combining real and complex variables should be performed in the arena of real variables. Three classes of failures can
be discerned:
investigation of an analytic function f(z) whose domain is slit
(i)
The domain of an analytic expression can enclose singu-
along some segment of the real or imaginary axis; say the real
larities that have no counterparts inside the domain
of its real restriction. That is why. for example. axis. When 2 =X + iy crosses the slit, f(z) jumps discontin-
'/( z2 - I) '# '/(2 I) -Ie2 + I) •
uously as y reverses sign although f(z) is continuous as z
(ii) Rounding errors can obscure the singularities. That is
2 approaches one side of the slit or the other. Consequently the
why, for example, -1(2 --,1) =-1(2 1)(z+I») fails so
badly when either z2 = I very nearly or when z2 < 0 two limits
very nearly. To avoid this problem, the programmer may
f(x+iO):= limf(x+iy) as y-+O+ and
have to decompose complex arithmetic expressions into
separate computations of real and imaginary parts. f(x - iO):= limf(x + iy) as y -+ 0-
thereby forgoing Some of the advantages of a compact
notation. both exist, but they are different when x has a real value
inside the slit. Ideally. a subroutine P(z) programmed to
(iii) Careless handling can turn infinity or the sign of zero
into misinformation that subsequently disappears leaving compute f(z) should match these values; P(x±iO)=f(x± iO)
behind only a plausible but incorrect result. That is
respectively should be satisfied within a small tolerance for
why compilers must not transform z - I into z - (I + iO) •
as we have seen above, nor - (-x x 2) into x + x 2 • as roundoff. This normally happens in IEEE style arithmetic as a
we shall see below, lest a subsequent logarithm or square
by-product of whatever steps have been taken to ensure that
root produce a nonzero imaginary part whose sign is oppo-
site to what was intended. P(x + iy) = f(x + iy), within a similarly small tolerance, for
The first two classes are hazards to all kinds of arith- all sufficiently small but nonzero Iyl. To generate a discon-
metic; only the third kind of failure is peculiar to IEEE style tinuity, the subroutine P must contain constructions similar to
arithmetic with its signed zero. Yet all three kinds, must be copysign ( ••• ,y) or arctan(1/y) possibly with "y" replaced by
linked together esoterically because the third kind is not some other expression that either vanishes or tends to infinity
usually found in an applications program unless that program as y -+ O. That expression cannot normally be a sum or difference
suffers also from the second kind. The link is fragile, easily like arctan(y-l) +'IT/4 or exp(y) 1 that vanishes by cancella-
broken if the rational operations or elementary functions, from tion, because roundoff can give such expressions values (typic-
which applications programs are composed. contain either of the ally 0) that have the wrong sign when iyl is tiny enough.
last two kinds of failures. Therefore. implementers of compilers Instead, to preserve accuracy when Iyl is tiny, that expression
and run-time libraries bear a heavy burden of attention to detail must normally be a real product or quotient involving a power of
if applications programmers are to realize the full benefit of the y or sin (y) or some other bui It-in function that vanishes with
IEEE style of complex arithmetic. That benefit deserves Some y and therefore should inherit its sign at y = ± O. Thus does
discussion here if only to reassure implementers that their careful implementation of compiler and library combine with care-
assiduity will be appreciated. ful applications programming to yield correct behaviour on and
The first benefit that users of IEEE style complex arith- near the slit. And if two such carefully programmed subroutines
metic notice is that familiar identities tend to be preserved P(z), though based upon different formulas, agree within roundoff
more often than when other styles of arithmetic are used. everywhere near the slit, then the foregoing reasoning implies
The mechanism that preserves identities can be revealed by an that normally they have to agree on the slit too; this is the
way IEEE style arithmetic preserves identities like -I(z*) = (-12)*
andv'(IIZ)=lh/z that would have to fail on slits if zero lower free boundary of the jet, then from left to right along
no sign.
the jet's,upper free boundary and back along the upper wall.
Of course, applications programmers generally have things This is just what happens when fez) is plotted from a one-line
more important than the preservation of identi ties on their program on the hp-71 B calculator, which imp lements the proposed
minds. Figure I shows a more typical and realistic example. IEEE standard p854. But when fez) is programmed onto the hp-
2
Here I(z) :=I+z +zv'(I+z 2 )+R-n(z2+ z v'(I+z 2 )), and we con- 15C, whose zero is unsigned, the lower wall disappears. Its pre-
strue the, equation 1;;:== fez) as a conformal map, from the plane image, the lower part of the imaginary axis where ali < -I, is
of z = x + iy to the plane of I;; = I;; + in, that maps the right half- mapped during the computation of fez) into the slit that belongs
plane x;;' + 0 onto the space occupied by a liquid that is forced to V and R-n; the upper part zli > 1 gets mapped onto the same
by high preSSure to Jet into a slot. The walls of the slot, slit. For lack of a signed zero, that slit gets attached to a side
where I;; < 0 and n == ±'TT, should be the images of those parts of that is right for the upper wan but wrong for the lower wall,
the imaginary axi s z2 < - 1 lying beyond ± i. The free surf aces thereby throwing the pre-image of the lower wall away into a tiny
of the jet, curving forward from I;; = ±i'TT and then back to segment of the upper wall. To put the lower wall back, x must be
<: = - 00 ±i'TT/2, should be the image of that segment of the increased from 0 to a tiny positive value while y runs from-oo
imaginary axis -1 < < 0 between ±i.
to-I. (How tiny should x be? That's a nontrivial question.)
The misbehaviour revealed in the foregoing example fez)

----Wall
liquid flow

-------------------- ;'" ""


air
I
in
~
)
.i, I
II
may appear to be deserved because fez) has slits on the imagin-
ary axis z2 < -I beyond ± i. Should mapping a slit to the wrong
place be blamed upon the discontinuity there rather than upon
I liquid arithmetic with an unsigned zero? No. Arithmetic with an un-
I
- liquid jet _ signed zero can also cause other programs to misbehave similarly
- liquid flow o~ +-­
I at places where the functions being implemented are otherwise
I liquid
----------------------, I well behaved. For example consider a(z) := z -iv'(iz + 1 )V( iz - I),
. "­ whose slit lies in the imaginary axis l<z2<0 between ±i. Now

1-'
Wail air 'I

J
'-in air I;; := a(z) maps the slit z plane onto the I;; plane outside the
• liquid flow circle 1<:1;;. I; vertical lines in the z plane map to stream
';-plane z-planc
lines in the vertical flow of a fluid around the circle. Imple-
FIG. 1 Conformal map I;; ;=f(z) of half-plane menting a(z), the programmer notices that he can reduce two
to jet with free boundary expensive square roots to one by rewriting
The picture of fez) should be symmetrical about the real a(z) := z + v(z:i.+ I) copysign(l, Re(z»).
axis because f(z*) = fez) *. As z runs up the imaginary axis, The two expressions for a(z) match everywhere in IEEE style
wi th x == +0 and y running from -GO through -I toward -0 and arithmetic; but when zero has only one sign, say +, the second
then from + 0 through + I toward +00, its image I;; = fez) should
expression maps the lower part of the imaginary axis, where
run from left to right along the lower wall and back along the zli < -I, into the inside instead of the outside of the circle,
although a(z) should be continuous there.
dispatched properly; and then familiar identities will persist,
The ease with which IEEE style arithmetic handled the
despite roundoff, more often than in other styles of arithmetic.
important singularities near z = ±i in the examples above should
This thought would comfort us more if the aberrations were
not be allowed to persuade the reader that all singularities can
easier to uncover. Locating potential aberrations remains an
be dispatched so easily. The singularities f(O) and f(oo) and
onerous task for an applications programmer, regardless of the
the overflows near z = 00 would have to be handled in the usual
style of arithmetic; however that style can affect the locus of
ways if they did not lie so far off the left-hand side of the
aberration fundamentally. In IEEE style arithmetic, a program-
picture that nobody cares. Another kind of singularity that did
med implementation of a complex analytic function can take
not matter here, but might matter elsewhere, insinuated weasel
aberrant boundary values, different from what would be produced
words like "not usually", "tends to be" and "normally" into the
by continuation from the interior, because of roundoff or similar
earlier discussion of Sums and differences that normally vanish
phenomena. In arithmetic without a signed zero, such an aberra-
by cancellation. Sums and differences can vanish without cancel~ .
tion can be caused as well by an unfortunate choice of analytic
lation if they combine terms that have already vanished; an
expression, though the programmer has implemented it faithfully.
example is h(x) ;=x+x 2 when x=O. Evaluating h(±O) in IEEE
The fact that an analytic expression determines the values of an
style real arithemetic yields +0 instead of ± 0 respectively,
analytic function correctly inside its domain is no reason to
losing the sign of zero. h(x) has other troubles: it signals
expect the boundary values to be determined correctly too when
Underflow when x is very tiny, suffers inaccuracy when x is
zero is unsigned.
very near - I , and becomes Invalid at x=-oo. Simply rewriting
h(x) :=x(l +x) dispels all these troubles, but is slightly less
5. PRINCIPAL VALUES ON THE SLITS, hp-J5C STYLE
accurate for very tiny Ixl than is h(x) :=-(-x - x 2). which
Of course, the hp-15C is not the only machine with an
preserves accuracy and the sign of zero for all tiny real x.

unsigned zero; a DEC VAX 1J model is similar but lacks so far a


Complex arithmetic complicates this situation. Both expressions
careful software implementation of some of the functions under
z+z2 and z(l+z) produce zeros with the wrong sign for Im(h(z»)
discussion - in time that lack will be remedied. Many other
on various segments of the real z-axis; to get the correct sign
machines, the IBM 370 series among them, have a signed zero in
and better accuracy requires an expression like
their hardware but no provision for propagating its sign in a
h(x+iy) := x(l+x)_y2+ 2iy(x+0.5) coherent and useful way, so they are customarily programmed as
regardless of arithmetic style. For similar reasons. the if zero were unsigned. All these machines discourage attempts
expression for f(z) used above for the conformal map would to distinguish one side of a slit from the other on the slit
have to be rewritten if the interesting part of its domain were itself •
the left instead of right half-plane. What we have to do is attach each slit to one of its sides
IEEE style complex arithmetic appears to burden the imp le- in accordance with some reasonable rule, thereby obtaining a
menters of compilers and run-time libraries with a host of principal value which is continuous up to the slit from that
complicated details that need rarely bother the user if they are side but not from the other. In other words, we have to assign
a sign to zero on each slit and then compute the same principal
value as would have been computed using IEEE-style arithmetic.
a.rcsin(z) 'Ir/2 (power series in l-z)y( I-z) for z near I,
The assignment cannot be arbitrary; for instance we cannot
arccosh(z~ = 9,n(2z) - (power series in J /z) when z I is huge,
change sides in the middle of the slit lest a gratuitous singu-
arctanh(z) =-0.5 9,n(l-z) + (power series in I-z) for z near I.
larity be insinuated by the change. On the other hand, some
degree of arbitrariness is obligatory. For instance, the two In each case the power series is determined uniquely. In general,
functi~ns if S is a finite branch-point at the end of a slit belonging to
b(z) := Y(z-I) y(z+ I) and -b(-z) one of our nine functions I(z), and if the function is analytic
are indistinguishable everywhere except in the slit _I < z < 1 inside some circular disk Iz- 61 < p except on the slit, then
across which they are discontinuous, but in hp-15C style arith- I(z) can be represented inside that slit disk by one of the for-

metic one function must be continuous onto the top of the slit mulas
and the other onto the bottom. Evidently no general rule attach- I(z) = P(z-S)+p(z-S)y«z-6)/e) , or
ing a slit to one of its sides can depend solely upon the slit's I(z) P(z-S)+p(z-S)R.n «z-6)/e) , or
shape nOr solely upon the function's values off the slit. And I(z) = P (some nonintegral power of y( (z - 6) /e») ,
yet, paradoxically, the hp-15C appears to follow just such a where e=lim(S-z)/!S-z! as z-+6 along the slit, so 101=1
rule, namely and (z-S)/e < 0 in the slit, and P(t) and p(t) are represent-
Counter>-CloakUJiBe Continuity (CCC) : able by power series around t= O. Given 13 and 1 and its slit,
Attach each slit to whichever side is approached when o and P and pare oanonioal (determined uniquely). Formulas
the finite branch-point at its end is circled counter- slightly more general than these, but still essentially unique,
clockwise.
cope with more general elementary functions or with isolated
Thus when z is real and negative CCC defines YZ = iY!z!
branch-points at 00.
and R.n (z) = R.n Iz I + in. Actually CCC is merely a mnemonic summary
The dominant terms of these canonical formulas provide
of the implications, for the nine functions that are the subject
approximations useful near branch-points, and are therefore pre-
of this note, of the following more general convention applica-
cious to analysts and programmers who have to exploit or compen-
ble also to b(z) above, as CCC is not.
sate for singularities, so these formulas should not be violated
The Pr>ineipal Expr>eBBion:

unnecessarily on the slits. Programs that handle singularities


Assign to each elementary function in question not
merely a Principal Value but also a ~ineipal Expr>eB­are complicated enough without the additional burden of treating
Bion in terms of 9;n(z) and YZ, using the simplest specially those slits that need no special care so long as pro-
formula that manifests its behaviour at finite
branch-points without gratuitous singularities grams remain as valid on the slits as off them near their ends.
elsewhere. Then programmers can predict from Principal Expressions how their
What makes this convention effective is a canonical asso- programs will behave on slits. The Principal Expressions for all
ciation between the archetypal branch-points of 9,n(z) and YZ nine of our elementary functions are determined by convention
on the one hand, and on the other any isolated branch-point at and tabulated nearby. For other functions the choice of Principal
the end of a slit belonging to any other elementary function. Expression is forced by the choice of slits except when a slit
For example, contains just two singularities, both finite branch points at its
ends'. In the exceptional case the Principal Expression tells In general the definitions of Principal Expressions can
which side of that slit is attached to it. For instance, the and should be honoured in all styles of arithmetic, though they
Fortran programmer can define the
must be implemented carefully if they are to survive roundoff.
COMPLEX FUNCTION B(Z) '= CSQRT(Z -1.0)"'CSQRT(Z + 1.0) Careful implementations of our nine elementary functions will be
when he wishes to attach its slit to its upper side, and invoke presented later in this paper. But some familiar identi ties
-B (-Z) when he wishes to attach the slit to its lower side. satisfied in IEEE style arithmetic must be violated when 0 is
Another e~ample has two definitions
unsigned no matter how the slits be attached. For instance, no
arccot(z) := arctan(I/z) and arccot(z):= 1T/2-arctan(z) elementary function f in the table except arctan and arcsinh
that are both widely used though they differ by 1T in the left can satisfy f(z"') = f(z)'" when z lies in a slit in the real
half-plane. The first has one slit on the imaginary axis axis. Similarly,
-I < z2 < 0 between z '= ±i. The second has two slits on the R.n(l/z) = -inez) and v(l/z) = I/v(z)
imaginary axis z2 <-I beyond z = ±i. But arctan(l/z) is not
must be violated at z = I and therefore everywhere in the slit
a Principal Expression for arccot(z) because it has a gratui- z < O. Other familiar identities violated only in a slit include
tous singularity at z= 0 where its slit changes sides. A cor- violated when z > 1,
arctanh(z) = R.n( (I + z) / (1- z) )/2 ,
rec t Principal Expression for the first defini tion of arccot (z) arctan(z)=itn«i+z)/(i-z»)/2, violated when iz <-I, and
is either iR.n (z-i)/(z+i»)/2 or R.n«z+i)/(z-i»)/(2i) arccos(z)==2arctan(V«I-z)/(J+z»)), violated when z <-I.
according to whether its slit be attached respectively to the Other writers have put forward different formulas as defi-
left half-plane or to the right; except on the slit, these Prin- nitions for our nine elementary functions. Comparing various
cipal Expressions are equal and satisfy arc cot (-z) = -arccot (z). definitions, and choosing among them, is a tedious business
Whichever one be chosen, the other is -arccot (-z). Similarly prone to error. Some ostensibly different definitions, like
for ±arccoth(±z) :=R.n(z+ 1)/(z-I))/2.
arccosh(z) = R.n(z+V(z-I)V(z+I») ,
Table 1
give the same results as ours. Some are quite wrong, as are
Conventional Principal Expressions for Elementary Functions:
arccosh(z) = tn(z +V(z2 -I») and arccos(z) = in(z+v(z2_1»/i,
because their slits are in the wrong places. Some are different
-1T";; arg(z) ";;1T; and -1T < arg(z) if 0 has just one sign.
on only part of a slit, as is
inez) := R.n( Iz I) + i arg(z)
arccosh(z) = -tn(z - V (z - I) V (z + I»)
zW::exp(wR.n(z») (and zO= I , OW=O if Re(w»O)
V(z) := zl/2 which is continuous from below that part of the slit where z <-I
and therefore violates the canonical formula around infinity.
arctanh(z) :=(R.n(l+z)-R.n(l-z»)/2 =-arctanh(-z)
Some are very close to ours; for instance, a proposal to intro-
arctan(z) := arc tanh (iz) /i = -arctan(- z)
duce complex functions into APL recommended the formula
arcsinh(z) := In(z +v (I + ») = -arcsinh(-z)
arccosh(z) = in(z+ (z+ J)v«z-I)/(z+I»)
arcsin(z) := arcsinh(iz)/i = -arcsin(-z)
which yields the same principal value as our formula except for
arccos(z) :=2 "R.n(V(I+z)/2)+iv(I-z)/2))li = 1T/2-arcsin(z)
a gratuitous removable singularity at z = -I. The same proposal
arccosh(z) :=2 in(v(z+ 1)/2) + V«Z-I)/2))
advocated
arctan(z)", -iR.n«1 +iz)v'(I/(z2+ I))
an agreement would be analysts. who would suffer less confusion
because its range matches that of arcsin(z), though no reason
when reading each other's results. More importantly, programmers
was given why the ranges should match (but see below), and
would make fewer mistakes, and find them sooner, when implement-
because it was alleged that the CCC rule should be reversed
ing conformal maps from complex analytic expressions. Although
around a branch point at which the function is infinite, though those benefits might follow from any kind of agreement, Principal
doing so would introduce anomalies in the relation between tn
Expressions offer the further advantage that they introduce no
and v', thereby vitiating the formula being advocated. Another unnecessary singularities. That advantage goes beyond mere parsi-
well-known formula
mony, because control of singularities is the essence of the
arctan(z) = i tn,(v'«i+z)/(i-z») subject.
is continuous one way around one branch-point and the opposite Programs that involve singularities are especially diffi-
way around the other, thereby violating arctan(-z) =-arctan(z) cult to debug because so many programmers tend to think more like
on the slits. Our formula given earlier, which is equivalent to algebraists than like analysts or geometer.s. Unaccustomed to
arctan(z) = i(tn(l-iz)-tn(J +iz»/2,
manipulating inequalities, they have trouble locating the slits
follows the CCC rule and seems simplest, but it does violat~
that are implicit in complex expressions that contain any of our
two cherished formulas
nine elementary functions. Instead, too many programmers are
arcsin(z) = arctan(z/v'(I_ z 2» and
inclined to test complex expressions in the same way as they
arccos(z) =2 arctan(v'«I-z)/(1 +Z»)
often test real expressions, by evaluating them at a handful of
on the slit. These formulas are satisfied almost everywhere by trial arguments to see whether the results agree wi th prior
the APL proposal's definition of arctan mentioned above, the expectations. Because this test strategy usually works for real
except ions arccos (-I) and arcsin (± I) arising because, like
analytic expressions, programmers mostly ignore warnings that it
zero, I/O has no sign and therefore arctan(1/0) has to be is unreliable; what else should we expect in a society where
either undefined or chosen arbitrarily from {±n/2}. Rather drunk driving is still regarded widely as a mere peaaadillo? But
than debate the merits of cherished formulas satisfied every- this strategy is truly a dangerous way to test complex analytic
where except at Some finite branch-points versus canonical formu- expressions of conformal maps with corners because those maps are
las satisfied around every finite branch-point, we choose what notoroious for mapping tiny regions into huge ones. When a tiny
seem to be the more perspicuous definitions. For similar reasons, region like that is missed by a scattering of trial arguments,
our formula above for arctanh seems preferable to the APL the test can be quite deceptive. The next example illustrates
proposal's
the point.
arctanh(z) = tn«1 +z)v'(I/(1 2 2 »),
Let g(z) :=2arccosh(1 +2z/3)-arccosh(5/3-(8/3)/(z+4»,
Regardless of whether our Principal Expressions really are and construe the equation l;:= g(z) as a conformal map of the
preferable to someone else I s. and regardless of the style of .II-plane. slit along the negative real axis .II < 0, onto a slotted
arithmetic, good reasons exist to seek universal agreement upon strip in the plane of l;=t;+in. The strip lies where Inl <: 2n,
a set of Principal Expressions to define Principal Values for and the slot within it lies where t; < 0 and Inl < 'IT. The bound-
familiar elementary functions. The first to benefit from such ary of the slotted strip is the image of both sides of the slit
in IEEE style arithmetic; with an unsigned zero the slit maps
boundary is the locus in the plane of 03 = x + iy whereon the
onto only that part of the boundary in the upper half-plane.
argumen~ of arccosh in q(03) takes values on the slit between
o and -1; the boundaryts equation is
d ~e y2 + (x+3)2 (2x+9)!(2x+5) = 0 for -4.5 <;x<;-3.
c <f-­ Whereas I; = g (z) maps the tear-drop onto two half-strips in the
Tear-drop
left-half of the I;-plane, I; =q(z) maps the tear-drop into two
1

I'
...... half-strips in the right half-plane. Indeed, q(03) = -g(03) in

------11
• a
~a e<f:-d: C '. b --. the tear-drop except. if zero is unsigned, q(03) = -g(03)* for
(I
-4.5 '. -4
:1
", -3
I
0
-1.
••• 4 -4.5 < 03 < -4. Is it likely that a few trial evaluations will
reveal the difference between q(03) and g(z)?
c·-+-­
The examples presented in this paper may give the impres-
I d· ---,lIoe·
sion that an analyst will benefit far less than a programmer
(-plane z -plane from Principal Expressions because their benefits seem meagre
unless slits run along straight lines. Moreover a signed Zero
Seems useless. except when slits lie in the real and imaginary
FIG. 2 Conformal map I; :=g(z) of slit plane to slotted strip
axes. True; but not the whole truth. Despite that applications
The cost of computing g(z) comes mostly from two loga-
of elementary functions frequently relocate their slits to non-
ri thms entai led by two calls upon arccosh. Two logarithms can
standard places, the functions so constructed have to be communi-
be reduced to one by means of a page or so of algebraic manipu-
cated to humans and to computers in terms of combinations of the
lation starting from the Principal Expression tabulated for
standard elementary functions with which we are all acquainted.
arccosh above; the result is a ppoof that
For instance, let e(z) be an analytic extension of arcsin(03)
g(z) ==2R-n(v'«z+4)/3)h/(z+3) + v'o3)2/(2\1'(o3+3) +\I'z)) from the upper half-plane across its slits z2 > I into the lower
Without Principal Expressions, one might resort instead to for- half-plane, where we relocate the slits to run down from ± I
mulas like
along some paths to -ioo. Can e(03) be expressed in terms of
Arccosh(03) Q,n(03 ±,I (z2 - I») + 2ik'TT for k = 0, ± I, ±2, ••• arcsin (z)? Yes. In the upper half-plane or between the new

or to identities like slits, e(03):= arcsin(z). Elsewhere we define 8:= copysign(l,


Im(03)) and calculate
Arccosh (03) ± Arccosh (I;) = Arccosh(z I; ± v'( (03 2 - 1) (1;2 _ I) )) •
e(03) := s arcsin(z) + copysign( (I-s)'TT/2, Re(03)) •
wi th resul ts that are hard· to predict. A pos sib Ie outcome is
the expression which is continuous across the old slits in IEEE style arithme-
tic. If 0 is unsigned, the last expression must be replaced by
q(03) := 2arccosh(2(z+3)'!«z+3)/(27(z+4»)))
something somewhat more complicated.
which matches the desired g(z) everywhere in the o3-plane except
Readers who recoil from tedious labour may rather acquiesce
in a small tear-drop shaped region situated symmetrically about
to all the foregoing assertions th,i'm verify any of them per-
the segment -4.5 < z < -3 on the real axis. The tear-drop f s
sonally, despite that such assertions are notoriously rife with
mistakes. Yet, lest the pleasures of analysis be eschewn alto- to one side of a slit but not to both. Consequently, two expres-
gether, the writer tenders some simple exercises for the reader's sions thflt represent the same function everywhere inside its
amusement; in each group the object is to discover the whole domain often take different values on the boundary. Choosing
domain, including boundary. wherein one expression equals another. among such expressions is tantamount to choosing among boundary
Exereises: Where are TWo Expressions in the Same Group Equal? values for what is otherwise the same function. Our nine elemen-
Group I:, 'I/(z'2.- I ), 'I/(z-I)'I/(Z+I), -v' (I - z) '1/(- I - z ) ,
tary functions are among those defined by Principal Expressions
i'l/(I-z) '1/( 1+ z).
determined along with their Principal Values by convention.
Group 2: 'I/(Z-I)/'l/z, 'I/(I-I/z), 'I/(z2- z )/z,
Other complex functions have to be defined on and inside bounda-
'I/(x(x -I) - y2 + Ziy (x - 1/2»)/2. ries by apt compositions of Principal Expressions, or else by
Group 3: 'I/(z)/'I/(Z-I), 'I/(Z/(z-I)). ad hoe assi-gnments on boundaries.
Group 4: 2arctanh(z), R.n((l+Z)/(I-z»), arcsinh(2z/(I-z2»). Regardless of the style of arithmetic, analytic expressions
provide at best a statement of intent, at worst wishful thinking
Group 5: cos(narccos(z»), cosh(narccosh(z»), for integers n.
about complex analytic functions. Implementations faithful to
Group 6: arctan(z) + arctan (I /z), rr/2, -1T/2. the expressions despite roundoff and over/underflow must overcome
Group 7: arccosh(z), arccosh(2z2-1)/2,2arcsinh('I/(z_I)/2l" nontrivial technical challenges.

i arccos(z).
7. IMPLEMENTATION NOTES
Group 8: arccosh(z) -arccosh (-z), i1T, -i1T.
Six inverse trigonometric and hyperbolic functions are de-
The answers may depend upon whether arithmetic is per- fined in terms of R.n and '1/ by Principal Expressions tabulated
formed in hp-15C style or in IEEE style, the difference appear- above in such a way as might appear to provide one-line programs
ing only when a slit lies in the real or the imaginary axis. to compute those functions in, say, Fortran. Unfortunately, round-
off can cause such programs to lose their relative accuracy near
6. SUMMARY their zeros or poles; and overflow can occur for large arguments
Two different styles of ari thmetic induce two different even though the desired function has an unexceptionable value.
mental attitudes towards the connection between analytic expres- Programs to compute complex elementary functions robustly and
sions and analytic functions. fairly accurately are surprisingly complicated, so much so as to
IEEE style arithmetic encourages the extension by contin- justify supplying them in this paper. Actually, we supply algo-
uity of every complex analytic function from the interior of its rithms that can be converted into programs on various machines
domain to the boundary, including both sides of slits that are by being adapted to the peculiarities of diverse programming
distinguishable with the aid of a signed ±O, Consequently, two languages and computing environments.
expressions that represent the same function everywhere inside Certain Environmental Constants that characterize impor-
its domain are likely to match everywhere on the boundary too; tant attributes of computer arithmetic may be specified precisely
most exceptions are correlated with roundoff problems. when that arithmetic conforms to IEEE 754 or p854; otherwise
Arithmetic with an unsigned 0 permits continuous extension they might be slightly vague:
n := Overflow threshold Nextafter(+co, 0) Algebraic operations upon a NaN reproduce it. Both infinities
E := Roundoff threshold 1.0- Nextafter (1.0,0) and NaN~ can be produced by our algorithms, and both wi 11 be
A := Underflow threshold = 4(I-E)/n in IEEE 754
accepted as inputs to them.
Smallest possible no. = Nextafter(O.O, J) 2EA The IEEE standards prescribe responses to five kinds of
in IEEE 754.
exceptions:
Here N"extafter is a function specified in the appendix to IEEE
Invalid Operation, ();;erflo'W. Divide-by-Zero.
754; it perturbs its first argument by one ulp (one Unit in
Underflo'W. Inexact.
its Last 'Place) towards the second. That appendix also includes
Each kind has its flag. to be raised to signal that its kind of
copysign, which was described early in this paper, and two func-
exception has occurred; each kind produces a defauU resuZt.
tions scalb and logb that will be used later. Let 6 be the
respectively
arithmetic's radix, 2 for IEEE 754, or 2 or 10 for p854. For
NaN, +00, +00, gradual underflow, rounded result.
any floating-point x and integer N, scalb (x • N) := 6N x compu-
Gradual underfZo'W approximates any value between ±A with an
ted without first computing so Over/Underflow is signalled
error smaller than €A instead of flushing it to zero. Neither
only if the final value deserves it. Logb(NaN) is NaN. which
this feature nor flags figure as much as they could and should
stands for "Not a Number" and is produced by invalid operations
in our algorithms. In environments that conform fully to IEEE
like 0/0, 0"". ""/co and 00_00; 10gb (±oo) := +00; logb(O):=-oo
754, as does the Standard Apple Numerical Environment (SANE) on
with Divide-by-Zero signalled; and if A <: Ixl < 00 then logb(x)
Apple computers, robust exception-handling complicates programs
is an integer such that 1 <: Iscalb(x. -logb(x)}1 < 6. The same
much less than ours have been complicated by our desire to pro-
may be true when 0 < Ixl < A. but early implementations may in-
vide algorithms adaptable also to machines that do not conform
stead yield logb(x):= logb(A) in that case. Like the proce-
to the Si.:andards. Most of our algorithms can be adapted to such
dures I dexp and frexp in the C library. scalb and togb are
machines by merely excising references to features that those
practically indispensible for scaling and for computing loga-
machines do not support. For instance. a statement like "If
rithms and exponentials.
x = 00 then ••• " will be deleted for machines that have no infi-
Certain detail s, particularly those that pertain to 00
nity; however, some obvious precaution against division by zero
and NaN, are peculiar to IEEE style arithmetic. Otherwise the
may have to be inserted elsewhere instead. Machines that flush
algorithms presented here for various complex elementary trans-
underflows to zero instead of underflowing gradually may produce
cendental functions. though designed for IEEE style arithmetic,
less accurate results when they approach the underflow thres-
can be used with other reasonably rounded binary floating-point
holds ±A.
arithmetics to get comparable results. Our algorithms assume
Our algorithms would be simpler, some much simpler. if every
either that zero always has a + sign, or else that its sign
arithmetic operation accepted and produced intermediate results
obeys the rules specified by IEEE 754 and p854. Those stan-
of wider range and precision than our algorithms are normally
dards also specify rules for +(10 and -co and for NaN. Predi-
expected to accept or produce. Such a situation arises when the
cates like x=y. x<y and x < y are all false; but x""'"y
transcendental functions are intended for a higher-level language
and x'/> yare true when either or both of x and yare NaN.
like Fortran that supports only Single- and Doub1e- precision
variables, but the implementer has access to another wider should be accomplished not by actual multiplication but rather
format like IEEE 754's Extended format. That is implemented in by swaps and sign reversal; iz :=-y+ix. In a similar way, an
floating-point coprocessor chips such as the Intel i8087 and expression that is syntactically pure imaginary with an unsigned
i80287 used in the IBM PC, PC/XT and PC/AT, the Motorola fl888 I zero for its real part should be handled in a way that avoids
used in a host of 68000-based workstations, the Western Electric both unnecessary arithmetic and unnecessary hazards. For instance,
32106, ,and also in Apple's SANE. But no such Extended format is+z := x+i(S+y), (i8)z := i(8z),
is provided by the National Semiconductor 32081 used in the IBM z/(i8) := -i(z/S) , (is)/z := i(S/z).
PC/RT, nor by the Weitek 1164/1165 chips used in the Sun III In languages where a construction 1 ike CMPLX (x , y) is used to
among others, nor by the NCUBE multiprocessor array. nor by create the complex value z :=x+ iy, the expression CMPLX (0,8)
Fairchild's Clipper; for their sakes we use devious formulas should be treated as is, whereas CMPLX(+O,S) and CMPLX(-O,8)
to preserve accuracy and avoid spurious overflows. should be treated as intentional attempts by the programmer to
In the programs below. e,p,e,s, t, 14 v,x,y, t; and n introduce an appropriately signed zero into the calculation. Of
denote real variables; w :=u+iv, z :=x+iy and t,; :=t;+in de- course, both attempts will produce the same CMPLX(+ 0,8) on a
note complex variables; and a star denotes not multiplication machine whose only zero is + O.
but complex conjugation: z*=x-iy. Mixed-mode arithmetic upon
one real and one complex variable is presumed N(J! to be per- 8. COMPLEX ZEROS AND INFINITIES
formed by coercing the real to complex, but rather in a way that All four zeros ±O ± iO are arithmetically equal. Whether
avoids unnecessary hazards like Oco or co- <0 by avoiding unneces- all complex infinities should be arithmetically equal is a topo-
sary real operations: logical question. When dealing' with complex algebraic (not
S+z := (S+x) +iy, Sz :=Sx+iSy, z/S :=x/S+iy/S; but transcendental) functions, the most convenient topology is that
S/z:=S/(x+(y/x)y)-i<Y/x)(S/(x+(y/x)y)) if Iyl <; lxi,
of the Riemann sphere with its unique point at infinity. A
:=(x/y)(S/(y+(x/y)x))-iS/(Y+(x/y)x) if Ixl '" Iyl,
metria (distance function) that induces that topology is the
with due attention to spurious over/underflows and zeros and Chordal Metria :
infinities.
Chord (z , l;) := Iz - r,; I / v' « I+ Iz 12) ( I + Ir,; 12) )
Ideally, the operators Re and 1m, that select the Real if I z I < co and It,; I < co,
and Imaginary parts respectively, should be interpreted in a way := Chord (I / z , I / r,;) if z =P 0 and l; =P 0 ;
that avoids unnecessary computation of the unwanted part when- ..;; Chord (0, co):= Chord(co, 0) := I .
ever possible. For instance, Re (wz) should be evaluated by In this topology, every algebraic function is a continuous
computing only ux-vy, without evaluating Im(wz) too. Besides (though perhaps multi-valued) map of the sphere to itself. So
saving time, this policy avoids spur.ious exceptions like overt are our nine elementary functions f(z). Only a function discon-
underflow that might afflict only the unwanted part. tinuous at infinity can be affected by its multiplicity of
Note too, to conserve ±O, that -z is not O-z though representations there; an important instance is the equality
they be equal arithmetically; and similarly w-z is the same as case f(z) z. To combat ambiguity at infinity a programmer
-z+w but not -(z-w). Multiplication or division by i ="'-1 can map all its representations upon one of them, namely real
+co, by invoking the function the Riemann sphere, can approximate arbitrary asymptotic direc-
PROJ (x + iy) := x + iy if Ix I *' co and Iy I *' co , tions at best crudely,
:= + co + i copysign (0, y) otherwise, Crudely, but not quite arbitrarily. The approximations
before performing any operation discontinuous at infinity. Of should be predictable and consistent with reasonable expecta-
course, PROJ is just the identity function on machines that tions; in particular, it seems reasonable to expect
lack a way to represent co. wz exp(~n(W)+~n(Z» and w/z=exp(~n(W)-,tn(Z»
The topology of the Riemann sphere is inappropriate for to hold within an allowance for roundoff even for infinite or
Z
functions like e that have an essential singularity at infi- zero products and quotients. These relations imply Iwzl = Iwllzl
nity. Instead, different representations of infinity are custo- and Iw/zl = Iwi/izi at 0 and 00, equations that can be satisfied
marily associated with different paths that tend to infinity in exactly; another implication is that
some asymptotic way, justifying assertions like arg(wz) arg(w) + arg(z) mod 2rr and
exp(-co+iy)=O and lexp(+co+iy)1 co for all finite y. arg(w/z) arg(w) -arg(z) mod 2rr
For example, "00 + i2" could represent a path asymptotically have to be approximated within the set of ten values available
parallel to the positive real axis and 2 units above it; for arg(1;;) when I::; is zero or infinite. Those values turn out
"00+ ioo" would have to represent a path parallel to that traced to be:
by exp(S+ i8) as 13-++ 00 for some fixed but unknown 8 strictly arg(+O±iO) arg(+""± is) = ±O for all finite 13 ,
between 0 and rr/2. Unfortunately, programming languages like arg (+"" ± ioo) ±rr/4,
Fortran represent complex variables by pairs of reals in such a arg(S ± ioo) = ±1f/2 for all finite 13 ,
way as allows at most nine asymptotic directions (8) to be repre- arg(-co± ioo) = ±31f/4,
sented by two real variables of which at least one is ± 00. Those arg(- 0 ± iO) = arg(--<x>± is) = ±1f for all finite e;
directions are arg(NaN + i Anything) and arg (Anything + i NaN) are both NaN.
8: ±rr -3rr/4 -'rr/2 -rr/4 ±O Thus, any coherent scheme for computing complex products,
z: -00 ±is -oo-ioo S-ico 4co ±i"" +00 ±is quotients and logarithms at zero and infinity can be regarded
8: rr/4 rr /2 h/4 NaN as a scheme that rounds arg(l::;) into one of the ten values above
Z: +oo+ioo S+i"" -oo+i"" NaN±i"" or ± ""± i NaN. when I::; is zero or infinite. To be acceptable, such a scheme
(Here e stands for any finite real number.) should not add much to the cost of complex multiplication and
These complex infinities z are the only ones available. By division. The procedure Box that follows seems tolerable.
default, in the absence of some contrivance programmed explicit-
ly to cope with other asymptotic directions, every infinite 9. THE PROCEDURES
complex result, especially of multiplication and division, has Box supplants the explicit calculation of arg during
to be approximated by something chosen from the available com- multiplication and division. It is followed by procedures and
plex infinities z in a fashion resembling the way real numbers auxiliary procedures that calculate the Principal Expressions
are rounded to the ones representable in floating-point. That of the Elementary Functions of Table 1, and algorithms for CTANH
default rounding, while fully satisfactory in the topology of and CTAN are given too. Several real special functions are
usen by these procedures; indeed the only complex auxiliary func- If Y =co then x:= y ;

tion that occurs during the computation of the inverse trigono- t:=x-y;

Metric and hyperbolic functions is CSQRT. It is assumed that If x *" co


and t x then *"
the radix of the computer arithmetic is 2.
{ ••• executed if x co, y *" *" 00 and y is not negligible.
Save Underflow flag;
If t> Y

••• To compute x + iy = 21 := Box( l;;) = Box (~+ in).


then" 0 when 2 < x/y < 2/£,
CBox(~+in): 0'. Defined onty for zero and infinite arguments.
{ 8:= x/y; 8 :=8+ V(I +8 2 )
If ~=O and n""O then 21:= copysign(1 ;~) +
else 0.0 when I '" x/y '" 2 ,
else if I~ I = 00
8:"" tty; t:=(2+8)8;
then { if Inl = co
8 :=«t2pl +t/(1'2+ v(2+t»))+8)+1'2pl };
then 21:= copysign t I ; ~) + i copysign (I ,n)
8:= y/8 00' Harmless Gradual Underflow can occur here.
else z:= copysign (I ;~) + in/~ }
Restore Underflow flag;
else if Inl=oothen z:""~/n+icopysign(l.n)
};
else 21:= (0 + iO)/O; 0 •• Invalid use.
Restore Invalid flag; 0 •• Only if deserved can Overflow
Return z; end CBOX.
happen now.
Return x + 8; end ABS.

···To compute p:= 1211 Ix+iyl =v(x 2 +l).


ABS (x+iy): ••• Fortran's CABS(Z)=C's hypot(x,y). "'To compute a:= arg(z) arg(x+iy).
The obvious formula can produce errors bigger than one ARG(x+iy): "'=Fortran's ATAN2(y,x).
ulp, and could over/underflow spuriously. Not so for If x =0 and y=O then x :=copysign(1 ,x)
what follows. If Ixl =co or Iyl 00 then 21:= CBOX(z);
Constants 1'2:=V2, 1'2pl:= I+V2, t2pl :=1 +v2-r2pl; ••• leaves signs unchanged.
These constants must be correctly rounded to work- If Iyl
> Ixl then a:= copysign(n/2, y) -arctan(x/y)
ing precision; consequently 1'2pl +t2pl = 1 + V2 else if x < 0 then a:= copysign(n, y) + arctan(y/x)
to double that precision. else a:= arctan(y/x) ;
Save invalid flag; ••• This suppresses spurious Invalid Suppress any Underflow signal unless lal < 0.125, say;
Operation signals from NaN comparison or co-co; ••• Better accuracy may be obtained by further case
but spurious inexact signals can be generated by reduction and use of identities like
this program. ... arctan (y/x) = n/4 + arctan( (y -x) / (y + x») •

x:=!xl y:=lyl; 8:=0.0;


Return a; end ARG.
If x <y then swap x and y; ••• so x ;;I> y ;;I> 0 if not NaN.
"'To compute x+ z:=~2= (~+in)2. "'To compute t;+in=~ :=yz =Y(x+iy).
CSQUARE (~+ in) : CSQRT (x + iy):
x!= (~-n)(~+n) ; ••• Not ~2_n2. Real p; Integer k;

yO:= ~n +- ~n ; ••• ONE multiply, one add. p + ik:= CSSQS(x + iy) ;

If a spurious NaN is created by overflow it gets • •• Sum-of-Squares Scaled: see above.


• o. removed thus: If x =x then p:= scalb( Ix I , -k) + yp ;
If x:#;c then If k is odd then k:= (k-I)/2

if Iyl =CIO then x:= copysign(O,c,J else {k:= k/2-1; p:=p+p};


else if Inl =CIO then X:=-CIO p:= scalb(yp,k) ;
else if I~I =CIO then x:= <X> } • •• = y( ( Ix + iy I + Ix 1)/2) without over/underflow.
else if y:#y and Ixl CIO then y:= copysign(O,y) E;,:=p; n:=y;
Return (x + iy); end CSQUARE. If p:# 0 then
if Inl:# 00 then { n:= (n/p)/2 ;
if n underflowed, signal it } ;
if x <0 then { ~: = nI
n := copysign(p, y) }

} ;

Return (E;, + in) ;

k 2
·..
'0' To compute p:= l(x+iy)/2 I scaled to avoid Over/Underflow. • •• This program seems to handle all cases correctly:
CSSQS(x+iy): =p+ik, with an integer k. "'y(-S±iO)=+O ± iy(S) for all 13;;.0.
Integer k; ••• ..,I (x ± iClO) = +00 ± iCIO for aU x, finite,
k :=0 ; • • 0
infinite or NaN, and if x is NaN then
Save and reset the Over/Underflow flags;
p := x 2 + y2 ; ••• Multiply twice and add.
·.. "Invalid Comparison" is signalled too.
• •• For all finite S,
U (p:#p or p=CIO) and (Ixl =CIO or Iyl =(0) then P:=CIO ••• y(NaN + is) , .J(S + and .J(NaN+
else if the Overflow flag was just raised, or are all NaN + i NaN;
the Underflow flag was just raised and p < '}.J'2. } y(+CIO± is) =+CIO ± iO ;

then 1 k:=logb(max(lxl,lyi)); Y(+CIO± iNaN) =+CIO+ iNaN;


p := scalb (x, 2 + scalb (y, _k)2 } ;
Y(-CIO±il3) =+O±i ClO ;

Restore the Over/Underflow flags: V(-CIO ± i NaN) = NaN ± ioo •


Return (p + i k); end CSSQS.
End CSQRT
00 oTo compute ';+in = r;. :=in(2J z) .. in(2 J (x+iy») (integer J). • • • To compute .; + 1;; := arccosh(z) arccosh(x +iy) •

CLOGS(x+ iy,J): O"For use with J"*O only when Ix+iyl CACOSH(z) : • • • Based upon formulas:
••• is huge. This program is particularly helpful for ••• I; := arcsinh(Re( ../(z - 1) * ../ (z + I»)) ;
••• inverse trigonometric and hyperbolic functions that • •• n : .. 2 arc t an ( Im ( ../(z - 1) ) / Re ( ../ (z + J ) )) ;

• •• behave like 11,n (2z) for huge Iz I. This program uses ••• Suppress any Divide-by-Zero signal when z <:: -I •
• •• ' a subprogram 11,n 1 p (x) := in( I + x) presumed .to be Return (I; + in); end CACOSH.
avpilable with full relative accuracy for all tiny
• •• real x. Such a program exists in various math. ••• To compute I;+in = r;. := arcsin(z) = arcsin{x+ iy) •.

••• libraries, included that for 4.3 BSD Unix, Intel's CASIN(x+iy): "'Based upon formulas:
• •• CEL and Apple's SANE. The accuracy of 11,n I p ••• 1;:= arctan(x/Re("/(I-z)"/{1 +z»));

••• influences the choice of thresholds TO, TI and T2. ••• Suppress any Divide-by-Zero signal when z <:: -I •

Constants TO := 1/../2 ; TI := 5/4; T2:= 3; 11,n 2 := 11,n(2) ; • •• n:= arcsinh(Im(../(I-z)*../(1 +z»));

Real p; Integer k; Return (I; + in); end CASIN •


p+ik:=CSSQS(x+iy); ••• = l(x+iy)/2 k I 2 +ik; see above.
S : = max ( Ix I , Iy I ) ; 8: = mi n ( Ix I • Iy I ) ; ••• To compute I; + r;. := arcsinh(z) arcsinh(x + iy) •

If k=O and TO < 13 and (13 <::TI or p<T2) CASINH(z) := -i CASIN(iz).


then p:= 11,nlp(S-J)(S+ I) +8 2 )/2

else p:= 11,n(p)/2 + (k+J) 11,n2; ••• To compute I; + r;. := arctanh(z) = arctanh(x + iy)

8 :=ARG(x+iy) ;
CATANH(x + iy):
Return (p+i8); end CLOGS. Constants a:= ../W)/4, p:= I/a ;
13:= copysign(1 ,x) ; z:= Sz*;'" Copes with unsigned O.
If x> a or Iyl > a ••• To avoid overflow.
then { n := copysign('lr/2. y); 1;:= Re( II (x + iy) )
"'To compute 1;+ in = r;.:= 11,n(z)=11,n(x+iy).
CLOG(Z) :=CLOGS(z,O). else if x 1
then { 1;:= 11,n(../(../(4+y2»)/../(lyl +p));
n := copysign('IT/2 + arctan( (ly I + p)/2), y)/2}
else'" Normal case. Using 11,n I p (u) := in{1 + u)

O"To compute I;+in = r;.:= arccos(z) = arccos(x+iy). ••• accurately even if u is tiny.

CACOS (z) : ••• Based upon formulas :


• 2 2
{ I; :=!1,nJp(4xl(I-x) +(Iy +p) ))/4;
I
1;: 2 arctan(Re("/(J -z»)/Re(4(1 + z»)) ; n := arg( (I -x) (I + x) - (lyl + p)2 +2iy)/2 }

••• Suppress any Divide-by-Zero signal when z <:: -I • • •• All cases appear to be handled correctly.

n :=arcsinh(Im (../(1 +z)*../ (I-z»)); Return (13 r;.*) ; end CATANH.


Return (I; +in); end CACOS.
••• To compute E:+ in = 1; := arctan(z) arctan(x+iy) • 10. THE EXPONENTIAL FUNCTION zW, AND 00
CATAN(z) := -iCATANH(iz). The function zW has two very different definitions. One
is recursive and applicable only when W is an integer:
z °= I and z (W+ 1) = zW z whenever zW exists.
"'To compute x+iy = z :=t:anh(S;) tanh(';+ The second definition is analytic:
CTANH(~ +
lim exp(w 9.n(O) ,
1.;1> arcsinh(n)/4
ZW:=
If ••• Avoid overflow. 1;;"'z
then z:= copysign( I , .;) + i copysign(O, n) provided the limit exists using the principal value and domain
else { of 9.n(1;;). The limit process is necessary to cope smoothly with
t := tan(n) ; ••• Suppress any Divide-by-Zero z = O. Since the recursive definition makes sense when z is a
• •• signal here. number or a square matrix or a nonlinear map of some domain into
6 := I +t2 ; ••• = I/cos 2 n.
itself, regardless of whether 9.n(Z) exists, the fact that both
8 := sinh (.;) ; definitions coincide when W is an integer and inez) exists
P :=y'(1 +B2); "'= cosh';. must be a nontrivial theorem. The fact that both definitions
if Itl=co agree that zO = I for every z is doubly significant because pro-
then z:= p/B + ilt ••• May signal if 8= O. grammers who have implemented zW on computers have so often
else z:= (6P8+ it) I (I +6B2) decreed 0° to be a capital offence.
}; I can only speculate on why 0° might be feared. Perhaps
Return z; end CTANH. fear is induced by the singularity that zW possesses at z = W = 0;
if both z and ware compelled to approach 0 but allowed to do
so independently along any paths, then paths may be chosen on
••• To compute x+ iy = z := tan(1;;) tan('; + which zW holds fast to any preassigned value whatsoever. Assum-
CTAN(1;;) := - i CTANH(i 1;;). ing for the sake of argument (because it is generally not so)
that neither z nor W could be exactly zero but must instead be
approximately zero because of roundoff or underflow, the expres-
sion 0° would have to be treated as if it really ought to have
been (roundoff) roundoff, which generally defies estimation.
To draw conclusions based upon something better than fear
or speculation, we need estimates for certain costs and benefits.
Setting zO:= I without exception confers the benefit of adher-
ence to simply stated rules; but it introduces some risk that we
might unwittingly accept for 0° instead of an unknown but
preferred value with tiny 1;; and v. That added risk should
be judged in the light of the greater and unavoidable risk that
W
<i might unwittingly be accepted when z and Ware both non- C; -+ 13 regardless of the branch chosen for Q,n. Since this pheno-
zero but tiny and quite wrong because of roundoff. In other menon occurs for al.l. pairs of analytic expressions z and w, it
words, only on those extremely rare occasions when a program of is very common.
unknown reliability betrays its inaccuracy by a chance encounter In the light of the foregoing considerations, 0,0°. 0 = 00 = I
with 0° will we benefit from outlawing 00. But outlawing 00 seems to be the only reasonable choice; similar considerations
incurs ,the cost of departing from a simple rule; it imposes upon imply 00°. 0 =00° = I too, Some other exponential expressions in-
those pro~rammers who prefer to take z ° for granted, regard- volving infinite operands require further thought. For instance,
less of whether z = 0, the extra burden of remembering to insert 1.0"" is clearly an invalid operation, but I"" I might be
extra code to cope with a rare eventuality. acceptable. Somewhat less clear are the signs of results like
There are two situations in which programmers are fully (±O.S)"" = 0
00
(±2f"" = 00,-00 = 0 , and
entitled to take 0° = I for granted. The first arises in lan- (±o.sf"", 0-
00
(± 2)"", (±oo)oo, all ±oo.
guages like Fortran and Pascal that distinguish variables of It is possible to argue that all these results should be assigned
type INTEGER from floating-point variables of type REAL and + signs in real arithmetic on any North American computer; since
COMPLEX. Suppose that M is of type INTEGEl't but nl' has a all sufficiently big floating-point numbers on such machines are
floatlng-polnt
" type; t h en z M can b e d'lstlngU1S
. . h e d f rom z W
, even integers, taking the limi t makes co an even integer too.
ana particularly zO from zO'O, because they call upon different Whether equally fulgent reaaoning Can be applied to complex
subroutines from a library of intrinsic functions. Since round- arithmetic remains to be seen. And whether 0""" = co should
off cannot possibly obscure the value of an exponent M of type 1
signal "Division by Zero", as 0- and I/O must, ~eems to be a
INTEGER in the way it might obscure the value of a floating- matter of taste until we realize that no signal is needed for
point variable w that happens to vanish, there is no reason to 0-"" because "Division by Zero" is a misnomer imposed for histori-
doubt that zO =I for every z regardless of one's fears about cal reasons in place of the more appropriate phrase
0.0°.°, Therefore, in every language in which M can be declared "an infinite result produced exactly from finite operands".
of INTEGER type, the exponential function zM must be consistent When z is neither zero nor infinite, and when W is not
with its recursive definition even if computed, at least when IMI an integer, the complex function could be assigned a multi-
is huge, with the aid of logarithms; in short, plicity of values; they are arranged around a circle if W is
M
when M 0 then z regardless of z. real, or otherwise along an Archimedean spiral in the complex
A second situation in which programmers might presume that plane. What distinguishes the principal Value defined above
0
0.0°. = I arises frequently. Consider two expressions z :=z(O from all others is that its logarithm has minimum magnitude;
and w:= w(C;) that depend upon some variable C;, and suppose that this definition is conventional. Respectable accuracy can be
z (B) = w(B) = 0 and that
z and Ware analytic functions of t;, difficult to achieve when either Iwi or Iw 9,n (z) I is big,
in some open neighbourhood of C; B. This means that z (C;) and requiring extraordinarily careful calculation of tn(z), but
w(C;) can be expanded in Taylor series in powers of t;,-i3 valid that is a story to unfold elsewhere.
near C; = 13, and both series begin with positive powers of t;,- S.
Then we find that z-+O and w-+O and zW = exp(w9,n(z))-+1 as
Acknowledgements The ANSI/IEEE standard 754-1985 for Binary Floating-
I am indebted to Prof. Paul Penfield Jr. of M. I. T. for a Point Arithmetic is available as stock number SHI0116 from the
conversati on that illuminated some of the reasons behind the IEEE Service Center, 445 Hoes Lane, Piscataway, NJ 08854: tele-
differences between his APL proposal and the complex arithmetic phone (201) 981-0060. A more readable exposition of 754 and the
implemented on the hp-15C by Dr J. Tanzini:, then at Hewlett- proposed Binary and Decimal Standard p854 was published in pp.86-
Packard. The author's own work has been supported in part also 100 of the Aug. 1984 issue of the IEEE magazine MICRO: to obtain
by grants from the U.S. Department of Energy, the Office of Naval a reprint from the IEEE, cite document number 0272-1732/84/0800-
Research, and the Air Force Office of Scientific Research. 0086. Early versions of 754, now superseded, plus some support-
This paper is an extension of, and completely supersedes, ing materials have appeared in the March 1981 and January 1980
an earlier version that appeared in September 1982 as report issues of the IEEE magazine Computer, and in a special issue,
PAM-lOS of the Center for Pure and Applied Mathematics at the Oc tober 1979, of the ACM SIGNUM Newsletter. Implementations of
University of California at Berkeley. That version was prepared IEEE 754 abound, ranging in size and speed from the ELXSI 6400
as an exercise on an APPLE text formatter slightly modified to the Apple II and Macintosh. The Standard Apple Numerical
using the PASCAL editor and Colin McMaster's SCRIPT. The author Environment (SANE) is now the most thorough implementation, and
thanks his friends at APPLE for that opportunity. is documented in the Apple Numerics Manual published in 1986 by
Addison-Wesley, Reading, Mass.
BIBLIOGRAPHIC NOTES The Intel i8087 and i80287 floating-point coprocessor chips
Penfield's proposal "Principal Values and Branch Cuts in were designed to conform to an early draft of IEEE 754; they
Complex APL" appeared in APL Quote Quad vol. 12, no. I, Sept. very nearly conform to the present standard. Though widely used
1981. in the IBM PC, PC/XT and PC/AT, they are not yet well supported
The complex functions implemented in the hp-15C are des- by software in that realm. A fine library of elementary func-
cribed in Section 3 of the Hewlett-Packard HP-15C Advanced tions for them, real ones coded by Steve Baumel, complex by Dr
Functions Handbook, Aug. 1982, part no. 00015-90011. The formu- Phil Faillace, comes with Intel's Fortran for its 286/310 and
las that tell where that calculator puts the branch cuts were 286/330 computers running under both Xenix and RMX86 operating
first published in an article "Scientific Pocket Calculator systems. That library's algorithms are much like ours above.
Extends Range of Built-In Functions" by Eric Evett, Paul The real functions are documented in Intel's 80287 Support
McClellan and Joe Tanzini in the Hewlett-Packard Journal of Library Reference Manual (1983), order no. 122129. Real functions
May 1983, vol. 34, no. 5, pp.25-35. More about that calculator, similar to those, and almost as accurate, are implemented on the
plus a formula for computing arccosh accurately, may be found Motorola 68881 and documented in the MC68881 Floating-Point
in my paper "Mathematics Written in Sand", pp.12-26 in the Coprocessor User's Manual (1985, preliminary edition), order no.
Statistical Computing Section of the Proceedings of the Joint MC68881UM/AD. I do not yet have public documentation for analo-
Statistical Meetings of the American Statistical Association gous libraries running on the ELXSI 6400 (programmed by Peter
etc. held in Toronto in August 1983. The conformal map onto a Tang), on the National Semiconductor 32081 floating-point slave
slotted strip is adapted from that paper. processor chip, and on the IBM PC/RT. The latter two machines'
libraries are very much like the C Math Library for IEEE 754- from 'rr/2-arctan(z) to arctan(l/z). Finally, H. Kober's
conforming machines programmed mostly by Dr Kwok-Choi Ng and now Dictionary of ConformaZ Representations contains pictures of
distributed with 4.3 BSD UNIX by the University of California at many useful conformal maps; this too was reprinted by Dover,
Berkeley; that library is intended ultimately to be distributed in 1957.
independently of Berkeley UNIX.
The hp-71 B is currently the only implementation in Decimal
arithmeti~ of p854; that hand-held computer is the subject of
the July 1984 issue of the He~lett-Packard Journal, vol. 35, no.
17. Many of the complex elementary functions, plus PROJ, have
W. Kahan
been implemented in the hp-71B's Math Pac, HP 82480A; but its Elect. Eng. and Computer Science
implementers were compelled by limitations upon time and space and Mathematics Departments
University of California
to acquiesce to a few compromises that I wish they could have
Berkeley
avoided. For instance, users of that machine have to write z*z California 94720
instead of ZA2 to compute z2, and (-IMPT(Z), REPT(Z») instead U.S.A.

of (0, 1) * Z to compute iz, if they wish to conserve the sign


of zero.
Some of the ideas that lead to canonical formulas around
branch-points are explained in pp.276-286 of volume III of A.I.
Markushevich's Theory of Functions of a Complex Variable trans-
lated by R.I. Silverman, 1967, Prentice-Hall, N.J. The confor-
mal map from the right half-plane to a liquid jet was adapted,
with corrections, from pp. 122-5 of Theory of Functions as
AppUed to Engineering Problems, edited by Rothe, Ollendorf and
Pohlhausen, translated by Herzenberg in 1933, reprinted in 1961
by Dover, N.Y. Another Dover reprint is the Handbook of Mathe­
matical Functions with Formulas, Graphs, and Mathematical
Tables, edited by M. Abramowitz and Irene Stegun. issued origin-
ally in 1964 as no. 55 in the U.S. National Bureau of Standards
Applied Math. Series. Its Chapter 4 locates the slits for all
nine elementary functions considered here, but its formulas
4.4.37-9 for complex Arcsin, Arccos, and Arctan are non-
committal on the slits and generally vulnerable to roundoff;
and it lacks a formula for complex Arccosh. During the Hand-
book's ninth reprinting its definition of arccot(z) changed

You might also like