119 lines
7 KiB
HTML
119 lines
7 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 EXPT-RATIO 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/iss152_w.htm">
|
||
|
<LINK REL=UP HREF="../Issues/iss153.htm">
|
||
|
<LINK REL=NEXT HREF="../Issues/iss154_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/iss152_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss153.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss154_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
|
||
|
<H2>Issue EXPT-RATIO Writeup</H2>
|
||
|
|
||
|
<PRE><B>Forum:</B> Cleanup<P>
|
||
|
<B>Issue:</B> <A HREF="iss153.htm">EXPT-RATIO</A><P>
|
||
|
<P>
|
||
|
<B>References:</B> CLtL pages 204 and 211<P>
|
||
|
<P>
|
||
|
<B>Category:</B> CLARIFICATION<P>
|
||
|
<P>
|
||
|
<B>Edit history:</B> Version 1, 4-Oct-88, by Aspinall and Moon<P>
|
||
|
Version 2, 6-Oct-88, Masinter (very minor discussion)<P>
|
||
|
Version 3, 31-Oct-88, Masinter (fix typo)<P>
|
||
|
<P>
|
||
|
<B>Problem description:<P>
|
||
|
</B><P>
|
||
|
The comment (page 204, 2nd para) that "... an implementation [of expt]<P>
|
||
|
might choose to compute (<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3/2) as if it had been written<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A> (<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3))" disagrees with the principal value definition on<P>
|
||
|
page 211. See the example below for a case where the two disagree. We<P>
|
||
|
believe the principal value definitions are consistent and reasonable,<P>
|
||
|
therefore the implementation comment is wrong.<P>
|
||
|
<P>
|
||
|
<B>Proposal (EXPT-RATIO:P.211):<P>
|
||
|
</B><P>
|
||
|
Clarify that (<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A> (<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3)) is not equivalent to (<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3/2)<P>
|
||
|
and that page 211 rules.<P>
|
||
|
<P>
|
||
|
<B>Examples:<P>
|
||
|
</B><P>
|
||
|
(<A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>defvar</B></A> x (<A REL=DEFINITION HREF="../Body/f_exp_e.htm#exp"><B>exp</B></A> (/ (* 2 <A REL=DEFINITION HREF="../Body/v_pi.htm#pi"><B>pi</B></A> #c(0 1)) 3))) ;exp(2.<A REL=DEFINITION HREF="../Body/v_pi.htm#pi"><B>pi</B></A>.i/3)<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3) => 1 (except for round-off error)<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A> (<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3)) => 1 (except for round-off error)<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3/2) => -1 (except for round-off error)<P>
|
||
|
<P>
|
||
|
There can be no question that <P>
|
||
|
(<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3) ==> 1<P>
|
||
|
because <A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> is single-valued with an integer second argument, and<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A> 1) ==> 1<P>
|
||
|
definitely follows the principal branch of the square root function.<P>
|
||
|
<P>
|
||
|
But (<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> x 3/2) is defined as (exp (* (log x) 3/2)) (page 211).<P>
|
||
|
(log x) ==> 2.pi.i/3<P>
|
||
|
according to the definition of the logarithm's branch cuts on page 211<P>
|
||
|
(which really comes down to the branch cuts of phase - page 210), so<P>
|
||
|
(* (log x) 3/2) ==> pi.i<P>
|
||
|
and<P>
|
||
|
exp(pi.i) is -1.<P>
|
||
|
<P>
|
||
|
<B>Rationale:<P>
|
||
|
</B><P>
|
||
|
We believe the principal value definitions are consistent and<P>
|
||
|
reasonable, therefore the implementation comment is wrong.<P>
|
||
|
<P>
|
||
|
<B>Current practice:<P>
|
||
|
</B><P>
|
||
|
Symbolics Genera 7.3 currently returns the wrong answer, following page<P>
|
||
|
204 rather than page 211. Lucid Common Lisp, and <P>
|
||
|
Envos Medley implement the proposal.<P>
|
||
|
<P>
|
||
|
<B>Cost to Implementors:<P>
|
||
|
</B><P>
|
||
|
The obvious code changes in complex <A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A>.<P>
|
||
|
<P>
|
||
|
<B>Cost to Users:<P>
|
||
|
</B><P>
|
||
|
None.<P>
|
||
|
<P>
|
||
|
<B>Cost of non-adoption:<P>
|
||
|
</B><P>
|
||
|
Self-contradictory language specification.<P>
|
||
|
<P>
|
||
|
<B>Benefits:<P>
|
||
|
</B><P>
|
||
|
Users can better predict the branch cuts in <A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A>.<P>
|
||
|
<P>
|
||
|
<B>Discussion:<P>
|
||
|
</B><P>
|
||
|
Mathematical Explanation: When the <A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> function returns a complex result<P>
|
||
|
in CL (Cartesian) form, the phase of the complex number is effectively<P>
|
||
|
canonicalized. Information is lost, and that information is necessary to<P>
|
||
|
specify upon which branch of the <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A> function the final result should lie.<P>
|
||
|
<P>
|
||
|
Another way to put it would be that although<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A>(<A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A>(x,3)) = <A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A>(x,3/2)<P>
|
||
|
where <A REL=DEFINITION HREF="../Body/f_exp_e.htm#expt"><B>expt</B></A> and <A REL=DEFINITION HREF="../Body/f_sqrt_.htm#sqrt"><B>sqrt</B></A> are the mathematical multi-valued functions, it is not<P>
|
||
|
true that:<P>
|
||
|
pvsqrt(pvexpt(x,3)) = pvexpt(x,3/2)<P>
|
||
|
where pvexpt and pvsqrt denote the principal value versions of those functions.<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>
|