Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / module-cmath.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-random.html" />
<link rel="prev" href="module-math.html" />
<link rel="parent" href="misc.html" />
<link rel="next" href="module-random.html" />
<meta name='aesop' content='information' />
<title>5.8 cmath -- Mathematical functions for complex numbers</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.7 math "
href="module-math.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
href="misc.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.9 random "
href="module-random.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-math.html">5.7 math </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-random.html">5.9 random </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION007800000000000000000">
5.8 <tt class="module">cmath</tt> --
Mathematical functions for complex numbers</A>
</H1>
<P>
<A NAME="module-cmath"></A>
<P>
This module is always available. It provides access to mathematical
functions for complex numbers. The functions are:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1278' xml:id='l2h-1278' class="function">acos</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the arc cosine of <var>x</var>.
There are two branch cuts:
One extends right from 1 along the real axis to &infin;, continuous
from below.
The other extends left from -1 along the real axis to -&infin;,
continuous from above.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1279' xml:id='l2h-1279' class="function">acosh</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the hyperbolic arc cosine of <var>x</var>.
There is one branch cut, extending left from 1 along the real axis
to -&infin;, continuous from above.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1280' xml:id='l2h-1280' class="function">asin</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the arc sine of <var>x</var>.
This has the same branch cuts as <tt class="function">acos()</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1281' xml:id='l2h-1281' class="function">asinh</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the hyperbolic arc sine of <var>x</var>.
There are two branch cuts, extending left from &plusmn;<code>1j</code> to
&plusmn;-&infin;<code>j</code>, both continuous from above.
These branch cuts should be considered a bug to be corrected in a
future release.
The correct branch cuts should extend along the imaginary axis,
one from <code>1j</code> up to &infin;<code>j</code> and continuous from the
right, and one from -<code>1j</code> down to -&infin;<code>j</code> and
continuous from the left.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1282' xml:id='l2h-1282' class="function">atan</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the arc tangent of <var>x</var>.
There are two branch cuts:
One extends from <code>1j</code> along the imaginary axis to
&infin;<code>j</code>, continuous from the left.
The other extends from -<code>1j</code> along the imaginary axis to
-&infin;<code>j</code>, continuous from the left.
(This should probably be changed so the upper cut becomes continuous
from the other side.)
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1283' xml:id='l2h-1283' class="function">atanh</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the hyperbolic arc tangent of <var>x</var>.
There are two branch cuts:
One extends from 1 along the real axis to &infin;, continuous
from above.
The other extends from -1 along the real axis to -&infin;,
continuous from above.
(This should probably be changed so the right cut becomes continuous from
the other side.)
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1284' xml:id='l2h-1284' class="function">cos</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the cosine of <var>x</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1285' xml:id='l2h-1285' class="function">cosh</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the hyperbolic cosine of <var>x</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1286' xml:id='l2h-1286' class="function">exp</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the exponential value <code>e**<var>x</var></code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1287' xml:id='l2h-1287' class="function">log</tt></b>(</nobr></td>
<td><var>x</var><big>[</big><var>, base</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Returns the logarithm of <var>x</var> to the given <var>base</var>.
If the <var>base</var> is not specified, returns the natural logarithm of <var>x</var>.
There is one branch cut, from 0 along the negative real axis to
-&infin;, continuous from above.
<span class="versionnote">Changed in version 2.4:
<var>base</var> argument added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1288' xml:id='l2h-1288' class="function">log10</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the base-10 logarithm of <var>x</var>.
This has the same branch cut as <tt class="function">log()</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1289' xml:id='l2h-1289' class="function">sin</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the sine of <var>x</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1290' xml:id='l2h-1290' class="function">sinh</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the hyperbolic sine of <var>x</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1291' xml:id='l2h-1291' class="function">sqrt</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the square root of <var>x</var>.
This has the same branch cut as <tt class="function">log()</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1292' xml:id='l2h-1292' class="function">tan</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the tangent of <var>x</var>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1293' xml:id='l2h-1293' class="function">tanh</tt></b>(</nobr></td>
<td><var>x</var>)</td></tr></table></dt>
<dd>
Return the hyperbolic tangent of <var>x</var>.
</dl>
<P>
The module also defines two mathematical constants:
<P>
<dl><dt><b><tt id='l2h-1294' xml:id='l2h-1294'>pi</tt></b></dt>
<dd>
The mathematical constant <em>pi</em>, as a real.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-1295' xml:id='l2h-1295'>e</tt></b></dt>
<dd>
The mathematical constant <em>e</em>, as a real.
</dd></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 id='l2h-1296' xml:id='l2h-1296'></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
<code>math.sqrt(-1)</code> 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>
A note on branch cuts: They are curves along which the given function
fails to be continuous. They are a necessary feature of many complex
functions. It is assumed that if you need to compute with complex
functions, you will understand about branch cuts. Consult almost any
(not too elementary) book on complex variables for enlightenment. For
information of the proper choice of branch cuts for numerical
purposes, a good reference should be the following:
<P>
<div class="seealso">
<p class="heading">See Also:</p>
<div class="seetext"><p>Kahan, W: Branch cuts for complex elementary functions;
or, Much ado about nothing's sign bit. In Iserles, A.,
and Powell, M. (eds.), <em class="citetitle"
>The state of the art in
numerical analysis</em>. Clarendon Press (1987) pp165-211.</p></div>
</div>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.7 math "
href="module-math.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
href="misc.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.9 random "
href="module-random.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-math.html">5.7 math </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-random.html">5.9 random </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>