<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>5.2 cmath --
Mathematical functions for complex numbers</TITLE>
<META NAME="description" CONTENT="5.2 cmath --
Mathematical functions for complex numbers">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="lib.css">
<LINK REL="next" HREF="module-whrandom.html">
<LINK REL="previous" HREF="module-math.html">
<LINK REL="up" HREF="misc.html">
<LINK REL="next" HREF="module-whrandom.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-whrandom.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="misc.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-math.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-whrandom.html">5.3 whrandom  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="misc.html">5. Miscellaneous Services</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-math.html">5.1 math  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION007200000000000000000">
5.2 <tt class=module>cmath</tt> --
         Mathematical functions for complex numbers</A>
</H1>

<P>


<P>
This module is always available.  It provides access to mathematical
functions for complex numbers.  The functions are:

<P>
<dl><dt><b><a name="l2h-737"><tt class=function>acos</tt></a></b> (<var>x</var>)
<dd>
Return the arc cosine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-738"><tt class=function>acosh</tt></a></b> (<var>x</var>)
<dd>
Return the hyperbolic arc cosine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-739"><tt class=function>asin</tt></a></b> (<var>x</var>)
<dd>
Return the arc sine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-740"><tt class=function>asinh</tt></a></b> (<var>x</var>)
<dd>
Return the hyperbolic arc sine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-741"><tt class=function>atan</tt></a></b> (<var>x</var>)
<dd>
Return the arc tangent of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-742"><tt class=function>atanh</tt></a></b> (<var>x</var>)
<dd>
Return the hyperbolic arc tangent of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-743"><tt class=function>cos</tt></a></b> (<var>x</var>)
<dd>
Return the cosine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-744"><tt class=function>cosh</tt></a></b> (<var>x</var>)
<dd>
Return the hyperbolic cosine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-745"><tt class=function>exp</tt></a></b> (<var>x</var>)
<dd>
Return the exponential value <tt>e**<var>x</var></tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-746"><tt class=function>log</tt></a></b> (<var>x</var>)
<dd>
Return the natural logarithm of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-747"><tt class=function>log10</tt></a></b> (<var>x</var>)
<dd>
Return the base-10 logarithm of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-748"><tt class=function>sin</tt></a></b> (<var>x</var>)
<dd>
Return the sine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-749"><tt class=function>sinh</tt></a></b> (<var>x</var>)
<dd>
Return the hyperbolic sine of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-750"><tt class=function>sqrt</tt></a></b> (<var>x</var>)
<dd>
Return the square root of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-751"><tt class=function>tan</tt></a></b> (<var>x</var>)
<dd>
Return the tangent of <var>x</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-752"><tt class=function>tanh</tt></a></b> (<var>x</var>)
<dd>
Return the hyperbolic tangent of <var>x</var>.
</dl>

<P>
The module also defines two mathematical constants:

<P>
<dl><dt><b><a name="l2h-753"><tt>pi</tt></a></b>
<dd>
The mathematical constant <i>pi</i>, as a real.
</dl>

<P>
<dl><dt><b><a name="l2h-754"><tt>e</tt></a></b>
<dd>
The mathematical constant <i>e</i>, as a real.
</dl>

<P>
Note that the selection of functions is similar, but not identical, to
that in module <tt class=module><a href="module-math.html">math</a></tt><a name="l2h-755"></a>.  The reason for having
two modules is, that some users aren't interested in complex numbers,
and perhaps don't even know what they are.  They would rather have
<tt>math.sqrt(-1)</tt> raise an exception than return a complex number.
Also note that the functions defined in <tt class=module>cmath</tt> always return a
complex number, even if the answer can be expressed as a real number
(in which case the complex number has an imaginary part of zero).
<p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-whrandom.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="misc.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-math.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-whrandom.html">5.3 whrandom  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="misc.html">5. Miscellaneous Services</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-math.html">5.1 math  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
