113 lines
12 KiB
HTML
113 lines
12 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: Function ASIN, ACOS, ATAN</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="f_sin_c.htm">
|
|
<LINK REL=UP HREF="c_number.htm">
|
|
<LINK REL=NEXT HREF="v_pi.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="f_sin_c.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_number.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="v_pi.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="asin"><A NAME="acos"><A NAME="atan"><I>Function</I> <B>ASIN, ACOS, ATAN</B></A></A></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>asin</B> <I>number</I> => <I>radians</I><P>
|
|
|
|
<B>acos</B> <I>number</I> => <I>radians</I><P>
|
|
|
|
<B>atan</B> <I>number1 <TT>&optional</TT> number2</I> => <I>radians</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>number</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A>. <P>
|
|
<I>number1</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A> if <I>number2</I> is not supplied, or a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A> if <I>number2</I> is supplied. <P>
|
|
<I>number2</I>---a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A>. <P>
|
|
<I>radians</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A> (of radians). <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#asin"><B>asin</B></A>, <A REL=DEFINITION HREF="#acos"><B>acos</B></A>, and <A REL=DEFINITION HREF="#atan"><B>atan</B></A> compute the arc sine, arc cosine, and arc tangent respectively. <P>
|
|
The arc sine, arc cosine, and arc tangent (with only <I>number1</I> supplied) functions can be defined mathematically for <I>number</I> or <I>number1</I> specified as <I>x</I> as in the next figure. <P>
|
|
<PRE>
|
|
Function Definition
|
|
Arc sine -i log (ix+ sqrt(1-x^2) )
|
|
Arc cosine (<PI>/2) - arcsin x
|
|
Arc tangent -i log ((1+ix) sqrt(1/(1+x^2)) )
|
|
</PRE>
|
|
<P><B>Figure 12-14. Mathematical definition of arc sine, arc cosine, and arc tangent</B> <P>
|
|
These formulae are mathematically correct, assuming completely accurate computation. They are not necessarily the simplest ones for real-valued computations. <P>
|
|
If both <I>number1</I> and <I>number2</I> are supplied for <A REL=DEFINITION HREF="#atan"><B>atan</B></A>, the result is the arc tangent of <I>number1</I>/<I>number2</I>. The value of <A REL=DEFINITION HREF="#atan"><B>atan</B></A> is always between -<PI> (exclusive) and <PI> (inclusive) when minus zero is not supported. The range of the two-argument arc tangent when minus zero is supported includes -<PI>. <P>
|
|
For a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A> <I>number1</I>, the result is a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A> and lies between -<PI>/2 and <PI>/2 (both exclusive). <I>number1</I> can be a <A REL=DEFINITION HREF="26_glo_c.htm#complex"><I>complex</I></A> if <I>number2</I> is not supplied. If both are supplied, <I>number2</I> can be zero provided <I>number1</I> is not zero. <P>
|
|
The following definition for arc sine determines the range and branch cuts: <P>
|
|
<P> <TT>arcsin</TT> z = -i <TT>log</TT> (iz+<TT>sqrt</TT>(1-z^2)) <P> <P>
|
|
The branch cut for the arc sine function is in two pieces: one along the negative real axis to the left of -1 (inclusive), continuous with quadrant II, and one along the positive real axis to the right of 1 (inclusive), continuous with quadrant IV. The range is that strip of the complex plane containing numbers whose real part is between -<PI>/2 and <PI>/2. A number with real part equal to -<PI>/2 is in the range if and only if its imaginary part is non-negative; a number with real part equal to <PI>/2 is in the range if and only if its imaginary part is non-positive. <P>
|
|
The following definition for arc cosine determines the range and branch cuts: <P>
|
|
<P>
|
|
<P> <TT>arccos</TT> z = <PI>/2- <TT>arcsin</TT> z<P> <P>
|
|
or, which are equivalent, <P>
|
|
<P> <TT>arccos</TT> z = -i <TT>log</TT> (z+i <TT>sqrt</TT>(1-z^2)) <P> <P>
|
|
<P> <TT>arccos</TT> z = 2 <TT>log</TT> (<TT>sqrt</TT>((1+z)/2) + i <TT>sqrt</TT>((1-z)/2))/i<P> <P>
|
|
The branch cut for the arc cosine function is in two pieces: one along the negative real axis to the left of -1 (inclusive), continuous with quadrant II, and one along the positive real axis to the right of 1 (inclusive), continuous with quadrant IV. This is the same branch cut as for arc sine. The range is that strip of the complex plane containing numbers whose real part is between 0 and <PI>. A number with real part equal to 0 is in the range if and only if its imaginary part is non-negative; a number with real part equal to <PI> is in the range if and only if its imaginary part is non-positive. <P>
|
|
The following definition for (one-argument) arc tangent determines the range and branch cuts: <P>
|
|
<P> <TT>arctan</TT> z = <TT>log</TT> (1+iz) - <TT>log</TT> (1-iz)/(2i) <P> <P>
|
|
Beware of simplifying this formula; ``obvious'' simplifications are likely to alter the branch cuts or the values on the branch cuts incorrectly. The branch cut for the arc tangent function is in two pieces: one along the positive imaginary axis above i (exclusive), continuous with quadrant II, and one along the negative imaginary axis below -i (exclusive), continuous with quadrant IV. The points i and -i are excluded from the domain. The range is that strip of the complex plane containing numbers whose real part is between -<PI>/2 and <PI>/2. A number with real part equal to -<PI>/2 is in the range if and only if its imaginary part is strictly positive; a number with real part equal to <PI>/2 is in the range if and only if its imaginary part is strictly negative. Thus the range of arc tangent is identical to that of arc sine with the points -<PI>/2 and <PI>/2 excluded. <P>
|
|
For <A REL=DEFINITION HREF="#atan"><B>atan</B></A>, the signs of <I>number1</I> (indicated as <I>x</I>) and <I>number2</I> (indicated as <I>y</I>) are used to derive quadrant information. The next figure details various special cases. The asterisk (*) indicates that the entry in the figure applies to implementations that support minus zero. <P>
|
|
<PRE>
|
|
y Condition x Condition Cartesian locus Range of result
|
|
y = 0 x > 0 Positive x-axis 0
|
|
* y = +0 x > 0 Positive x-axis +0
|
|
* y = -0 x > 0 Positive x-axis -0
|
|
y > 0 x > 0 Quadrant I 0 < result< <PI>/2
|
|
y > 0 x = 0 Positive y-axis <PI>/2
|
|
y > 0 x < 0 Quadrant II <PI>/2 < result< <PI>
|
|
y = 0 x < 0 Negative x-axis <PI>
|
|
* y = +0 x < 0 Negative x-axis +<PI>
|
|
* y = -0 x < 0 Negative x-axis -<PI>
|
|
y < 0 x < 0 Quadrant III -<PI>< result< -<PI>/2
|
|
y < 0 x = 0 Negative y-axis -<PI>/2
|
|
y < 0 x > 0 Quadrant IV -<PI>/2 < result< 0
|
|
y = 0 x = 0 Origin undefined consequences
|
|
* y = +0 x = +0 Origin +0
|
|
* y = -0 x = +0 Origin -0
|
|
* y = +0 x = -0 Origin +<PI>
|
|
* y = -0 x = -0 Origin -<PI>
|
|
</PRE>
|
|
<P><B>Figure 12-15. Quadrant information for arc tangent</B> <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
|
|
<PRE>
|
|
(asin 0) => 0.0
|
|
(acos #c(0 1)) => #C(1.5707963267948966 -0.8813735870195432)
|
|
(/ (atan 1 (sqrt 3)) 6) => 0.087266
|
|
(atan #c(0 2)) => #C(-1.5707964 0.54930615)
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Affected By:</B> None.
|
|
<P>
|
|
<P><B>Exceptional Situations:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#acos"><B>acos</B></A> and <A REL=DEFINITION HREF="#asin"><B>asin</B></A> should signal an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> if <I>number</I> is not a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A>. <A REL=DEFINITION HREF="#atan"><B>atan</B></A> should signal <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> if one argument is supplied and that argument is not a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A>, or if two arguments are supplied and both of those arguments are not <I>reals</I>. <P>
|
|
<A REL=DEFINITION HREF="#acos"><B>acos</B></A>, <A REL=DEFINITION HREF="#asin"><B>asin</B></A>, and <A REL=DEFINITION HREF="#atan"><B>atan</B></A> might signal <A REL=DEFINITION HREF="e_arithm.htm#arithmetic-error"><B>arithmetic-error</B></A>. <P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_log.htm#log"><B>log</B></A>, <A REL=DEFINITION HREF="f_sqrt_.htm#sqrt"><B>sqrt</B></A>, <A REL=CHILD HREF="12_acc.htm">Section 12.1.3.3 (Rule of Float Substitutability)</A> <P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
The result of either <A REL=DEFINITION HREF="#asin"><B>asin</B></A> or <A REL=DEFINITION HREF="#acos"><B>acos</B></A> can be a <A REL=DEFINITION HREF="26_glo_c.htm#complex"><I>complex</I></A> even if <I>number</I> is not a <A REL=DEFINITION HREF="26_glo_c.htm#complex"><I>complex</I></A>; this occurs when the absolute value of <I>number</I> is greater than one. <P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss192.htm">IEEE-ATAN-BRANCH-CUT:SPLIT</A><LI> <A REL=CHILD HREF="../Issues/iss290.htm">REAL-NUMBER-TYPE:X3J13-MAR-89</A><LI> <A REL=CHILD HREF="../Issues/iss069.htm">COMPLEX-ATAN-BRANCH-CUT:TWEAK</A><LI> <A REL=CHILD HREF="../Issues/iss070.htm">COMPLEX-ATANH-BOGUS-FORMULA:TWEAK-MORE</A><P></UL><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>
|