194 lines
9.2 KiB
HTML
194 lines
9.2 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Issue COMPLEX-ATANH-BOGUS-FORMULA Writeup</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="../Issues/iss069_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss070.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss071_w.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss069_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss070.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss071_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue COMPLEX-ATANH-BOGUS-FORMULA Writeup</H2>
|
|
|
|
<PRE>Date: Wed, 20 Sep 89 11:24:48 EDT<P>
|
|
From: gls@Think.COM (Guy Steele)<P>
|
|
Message-Id: <8909201524.AA21857@verdi.think.com><P>
|
|
To: x3j13@sail.stanford.edu<P>
|
|
Cc: gls@Think.COM, cl-cleanup@sail.stanford.edu<P>
|
|
Subject: Issue <A HREF="iss070.htm">COMPLEX-ATANH-BOGUS-FORMULA</A><P>
|
|
<P>
|
|
<P>
|
|
I hate to bring *anything* up at this late date, but while working over the<P>
|
|
numbers chapter second edition I have been going over this branch cut stuff<P>
|
|
one more time, with even greater care, and have discovered that the formula<P>
|
|
for <A REL=DEFINITION HREF="../Body/f_sinh_.htm#atanh"><B>ATANH</B></A> on page 209 and again on page 213 is completely bogus. What that<P>
|
|
computes is not anything like a hyperbolic arc tangent. It would seem that<P>
|
|
I must have mistranscribed the APL formula in Penfield's article.<P>
|
|
<P>
|
|
CLtL has: arctanh z = log ((1+z) <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>(1 - (1 / z^2)))<P>
|
|
<P>
|
|
Should be: arctanh z = log ((1+z) <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>(1 / (1 - z^2)))<P>
|
|
<P>
|
|
Note that they differ in the transposition of two operators. (Boy, am I<P>
|
|
embarrassed.)<P>
|
|
<P>
|
|
Clearly this must be corrected. In the meantime I have found a more<P>
|
|
definitive treatment of complex branch cuts by W. Kahan, and I propose to<P>
|
|
follow his recommendations. This involves correcting the formula for<P>
|
|
<A REL=DEFINITION HREF="../Body/f_sinh_.htm#atanh"><B>ATANH</B></A>, and adopting new formulas for <A REL=DEFINITION HREF="../Body/f_asin_.htm#acos"><B>ACOS</B></A> and <A REL=DEFINITION HREF="../Body/f_sinh_.htm#acosh"><B>ACOSH</B></A> that are equivalent to<P>
|
|
the ones we have now but more perspicuous.<P>
|
|
<P>
|
|
I would appreciate knowing very soon on an informal basis whether anyone<P>
|
|
objects to this change, so that I can include some discussion of it in the<P>
|
|
second edition. (Of course I'm not asking for a vote until we have an<P>
|
|
official meeting.)<P>
|
|
<P>
|
|
--Guy<P>
|
|
----------------------------------------------------------------<P>
|
|
<B>Status:</B> New proposal<P>
|
|
<B>Forum:</B> Cleanup<P>
|
|
<B>Issue:</B> <A HREF="iss070.htm">COMPLEX-ATANH-BOGUS-FORMULA</A><P>
|
|
<B>References:</B> CLtL pp. 209, 212, 213<P>
|
|
Penfield, P. "Principal Values and Branch Cuts in<P>
|
|
Complex APL", Proc. APL 81 Conference Proceedings,<P>
|
|
Association for Computing Machinery, 1981<P>
|
|
Kahan, W. "Branch Cuts for Complex Elementary<P>
|
|
Functions, or Much Ado About Nothing's Sign Bit"<P>
|
|
in Iserles and Powell (eds.) "The State of the Art<P>
|
|
in Numerical Analysis", pp. 165-211, Clarendon<P>
|
|
Press, 1987<P>
|
|
Related issues: <A HREF="iss069.htm">COMPLEX-ATAN-BRANCH-CUT</A>, <A HREF="iss192.htm">IEEE-ATAN-BRANCH-CUT</A><P>
|
|
<B>Category:</B> CHANGE<P>
|
|
<P>
|
|
<B>Edit history:</B> Version 1, 20-SEP-89, Steele<P>
|
|
<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
The formula that defines <A REL=DEFINITION HREF="../Body/f_sinh_.htm#atanh"><B>ATANH</B></A> in CLtL is incorrect, apparently<P>
|
|
because of a mistranscription of a formula from Penfield's article.<P>
|
|
<P>
|
|
CLtL has: arctanh z = log ((1+z) <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>(1 - (1 / z^2)))<P>
|
|
<P>
|
|
Should be: arctanh z = log ((1+z) <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>(1 / (1 - z^2)))<P>
|
|
<P>
|
|
However, given the change to <A REL=DEFINITION HREF="../Body/f_asin_.htm#atan"><B>ATAN</B></A> in issue <A HREF="iss069.htm">COMPLEX-ATAN-BRANCH-CUT</A>,<P>
|
|
it seems simpler to follow Kahan's recommendation and define<P>
|
|
<P>
|
|
arctanh z = (log(1+z) - log(1-z))/2<P>
|
|
<P>
|
|
thereby preserving the identity i arctan z = arctanh iz .<P>
|
|
<P>
|
|
Kahan also notes that Penfield's formula for arccosh (CLtL p. 213)<P>
|
|
<P>
|
|
arccosh z = log(z + (z + 1) <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((z-1)/(z+1)))<P>
|
|
<P>
|
|
has a gratuitous removable singularity at z=-1 and recommends<P>
|
|
<P>
|
|
arccosh z = 2 log(<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((z+1)/2) + <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((z-1)/2))<P>
|
|
<P>
|
|
which has the same values and is also well-defined at z=-1.<P>
|
|
<P>
|
|
Finally, Kahan recommends a different defining formula for <A REL=DEFINITION HREF="../Body/f_asin_.htm#acos"><B>acos</B></A><P>
|
|
that is more similar to that of <A REL=DEFINITION HREF="../Body/f_sinh_.htm#acosh"><B>acosh</B></A> (but less similar to that<P>
|
|
of <A REL=DEFINITION HREF="../Body/f_asin_.htm#asin"><B>asin</B></A>).<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal (COMPLEX-ATANH-BRANCH-CUT:TWEAK-MORE):<P>
|
|
</B> <P>
|
|
(1) Replace the erroneous formula<P>
|
|
<P>
|
|
arctanh z = log ((1+z) <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>(1 - (1 / z^2)))<P>
|
|
with<P>
|
|
arctanh z = (log(1+z) - log(1-z))/2<P>
|
|
<P>
|
|
(2) Note that i arctan z = arctanh iz .<P>
|
|
<P>
|
|
(3) Replace the gratuitously singular formula<P>
|
|
<P>
|
|
arccosh z = log(z + (z + 1) <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((z-1)/(z+1)))<P>
|
|
with<P>
|
|
arccosh z = 2 log(<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((z+1)/2) + <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((z-1)/2))<P>
|
|
<P>
|
|
(4) Adopt the formula (already in CLtL)<P>
|
|
<P>
|
|
arccos z = (pi / 2) - arcsin z<P>
|
|
<P>
|
|
as the official definition of arccos, and also note that the<P>
|
|
formulas<P>
|
|
<P>
|
|
arccos z = -i log(z + i <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>(1 - z^2))<P>
|
|
<P>
|
|
(already in CLtL) and<P>
|
|
<P>
|
|
arccos z = 2 log(<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((1+z)/2) + i <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>((1-z)/2)) / i<P>
|
|
<P>
|
|
(recommended by Kahan) are equivalent.<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
Compatibility with what seems to be becoming <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> practice.<P>
|
|
<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
Implementations I have checked have a correct implementation<P>
|
|
of <A REL=DEFINITION HREF="../Body/f_sinh_.htm#atanh"><B>ATANH</B></A> rather than slavishly following the bogus CLtL formula.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
<A REL=DEFINITION HREF="../Body/f_sinh_.htm#atanh"><B>ATANH</B></A> must be rewritten. It is not a very difficult fix.<P>
|
|
<P>
|
|
Possibly <A REL=DEFINITION HREF="../Body/f_sinh_.htm#acosh"><B>ACOSH</B></A> must be rewritten. It is not a very difficult fix.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
The compatibility note on p. 210 of CLtL gave users fair warning that<P>
|
|
a change of this kind might be adopted.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
Possible incorrect implementations of <A REL=DEFINITION HREF="../Body/f_sinh_.htm#atanh"><B>ATANH</B></A>.<P>
|
|
<P>
|
|
Incompatibility with HP calculators.<P>
|
|
<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Numerical analysts may find the new definition easier to use.<P>
|
|
<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
A toss-up, except to those who care.<P>
|
|
<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Kahan's article not only discussed formulas but also gives specific<P>
|
|
implementation techniques for use with IEEE 754 arithmetic.<P>
|
|
<P>
|
|
</PRE>
|
|
<HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|