90 lines
5.5 KiB
HTML
90 lines
5.5 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 LOG</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_lcm.htm">
|
|
<LINK REL=UP HREF="c_number.htm">
|
|
<LINK REL=NEXT HREF="f_mod_r.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_lcm.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="f_mod_r.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="log"><I>Function</I> <B>LOG</B></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>log</B> <I>number <TT>&optional</TT> base</I> => <I>logarithm</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>number</I>---a non-zero <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A>. <P>
|
|
<I>base</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A>. <P>
|
|
<I>logarithm</I>---a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#log"><B>log</B></A> returns the logarithm of <I>number</I> in base <I>base</I>. If <I>base</I> is not supplied its value is <I>e</I>, the base of the natural logarithms. <P>
|
|
<A REL=DEFINITION HREF="#log"><B>log</B></A> may return a <A REL=DEFINITION HREF="26_glo_c.htm#complex"><I>complex</I></A> when given a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A> negative <I>number</I>. <P>
|
|
<PRE>
|
|
(log -1.0) == (complex 0.0 (float pi 0.0))
|
|
</PRE>
|
|
</TT> <P>
|
|
If <I>base</I> is zero, <A REL=DEFINITION HREF="#log"><B>log</B></A> returns zero. <P>
|
|
The result of <TT>(log 8 2)</TT> may be either <TT>3</TT> or <TT>3.0</TT>, depending on the implementation. An implementation can use floating-point calculations even if an exact integer result is possible. <P>
|
|
The branch cut for the logarithm function of one argument (natural logarithm) lies along the negative real axis, continuous with quadrant II. The domain excludes the origin. <P>
|
|
The mathematical definition of a complex logarithm is as follows, whether or not minus zero is supported by the implementation: <P>
|
|
<PRE>
|
|
(log x) == (complex (log (abs x)) (phase x))
|
|
</PRE>
|
|
</TT> <P>
|
|
Therefore the range of the one-argument logarithm function is that strip of the complex plane containing numbers with imaginary parts between -<PI> (exclusive) and <PI> (inclusive) if minus zero is not supported, or -<PI> (inclusive) and <PI> (inclusive) if minus zero is supported. <P>
|
|
The two-argument logarithm function is defined as <P>
|
|
<PRE>
|
|
(log base number)
|
|
== (/ (log number) (log base))
|
|
</PRE>
|
|
</TT> <P>
|
|
This defines the <A REL=DEFINITION HREF="26_glo_p.htm#principal"><I>principal</I></A> <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>values</I></A> precisely. The range of the two-argument logarithm function is the entire complex plane. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(log 100 10)
|
|
=> 2.0
|
|
=> 2
|
|
(log 100.0 10) => 2.0
|
|
(log #c(0 1) #c(0 -1))
|
|
=> #C(-1.0 0.0)
|
|
OR=> #C(-1 0)
|
|
(log 8.0 2) => 3.0
|
|
</PRE>
|
|
</TT> <P>
|
|
|
|
<PRE>
|
|
(log #c(-16 16) #c(2 2)) => 3 or approximately #c(3.0 0.0)
|
|
or approximately 3.0 (unlikely)
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
The implementation. <P>
|
|
<P><B>Exceptional Situations:</B> None.
|
|
<P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_exp_e.htm#exp"><B>exp</B></A>, <A REL=DEFINITION HREF="f_exp_e.htm#expt"><B>expt</B></A>, <A REL=CHILD HREF="12_acc.htm">Section 12.1.3.3 (Rule of Float Substitutability)</A> <P>
|
|
<P><B>Notes:</B> None.
|
|
<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/iss071.htm">COMPLEX-RATIONAL-RESULT:EXTEND</A><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><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>
|