Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / lib / module-cmath.html
CommitLineData
86530b38
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-random.html" />
13<link rel="prev" href="module-math.html" />
14<link rel="parent" href="misc.html" />
15<link rel="next" href="module-random.html" />
16<meta name='aesop' content='information' />
17<title>5.8 cmath -- Mathematical functions for complex numbers</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="5.7 math "
25 href="module-math.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
28 href="misc.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="5.9 random "
31 href="module-random.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-math.html">5.7 math </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-random.html">5.9 random </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION007800000000000000000">
565.8 <tt class="module">cmath</tt> --
57 Mathematical functions for complex numbers</A>
58</H1>
59
60<P>
61<A NAME="module-cmath"></A>
62
63<P>
64This module is always available. It provides access to mathematical
65functions for complex numbers. The functions are:
66
67<P>
68<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
69 <td><nobr><b><tt id='l2h-1278' xml:id='l2h-1278' class="function">acos</tt></b>(</nobr></td>
70 <td><var>x</var>)</td></tr></table></dt>
71<dd>
72Return the arc cosine of <var>x</var>.
73There are two branch cuts:
74One extends right from 1 along the real axis to &infin;, continuous
75from below.
76The other extends left from -1 along the real axis to -&infin;,
77continuous from above.
78</dl>
79
80<P>
81<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
82 <td><nobr><b><tt id='l2h-1279' xml:id='l2h-1279' class="function">acosh</tt></b>(</nobr></td>
83 <td><var>x</var>)</td></tr></table></dt>
84<dd>
85Return the hyperbolic arc cosine of <var>x</var>.
86There is one branch cut, extending left from 1 along the real axis
87to -&infin;, continuous from above.
88</dl>
89
90<P>
91<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
92 <td><nobr><b><tt id='l2h-1280' xml:id='l2h-1280' class="function">asin</tt></b>(</nobr></td>
93 <td><var>x</var>)</td></tr></table></dt>
94<dd>
95Return the arc sine of <var>x</var>.
96This has the same branch cuts as <tt class="function">acos()</tt>.
97</dl>
98
99<P>
100<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
101 <td><nobr><b><tt id='l2h-1281' xml:id='l2h-1281' class="function">asinh</tt></b>(</nobr></td>
102 <td><var>x</var>)</td></tr></table></dt>
103<dd>
104Return the hyperbolic arc sine of <var>x</var>.
105There are two branch cuts, extending left from &plusmn;<code>1j</code> to
106&plusmn;-&infin;<code>j</code>, both continuous from above.
107These branch cuts should be considered a bug to be corrected in a
108future release.
109The correct branch cuts should extend along the imaginary axis,
110one from <code>1j</code> up to &infin;<code>j</code> and continuous from the
111right, and one from -<code>1j</code> down to -&infin;<code>j</code> and
112continuous from the left.
113</dl>
114
115<P>
116<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
117 <td><nobr><b><tt id='l2h-1282' xml:id='l2h-1282' class="function">atan</tt></b>(</nobr></td>
118 <td><var>x</var>)</td></tr></table></dt>
119<dd>
120Return the arc tangent of <var>x</var>.
121There are two branch cuts:
122One extends from <code>1j</code> along the imaginary axis to
123&infin;<code>j</code>, continuous from the left.
124The other extends from -<code>1j</code> along the imaginary axis to
125-&infin;<code>j</code>, continuous from the left.
126(This should probably be changed so the upper cut becomes continuous
127from the other side.)
128</dl>
129
130<P>
131<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
132 <td><nobr><b><tt id='l2h-1283' xml:id='l2h-1283' class="function">atanh</tt></b>(</nobr></td>
133 <td><var>x</var>)</td></tr></table></dt>
134<dd>
135Return the hyperbolic arc tangent of <var>x</var>.
136There are two branch cuts:
137One extends from 1 along the real axis to &infin;, continuous
138from above.
139The other extends from -1 along the real axis to -&infin;,
140continuous from above.
141(This should probably be changed so the right cut becomes continuous from
142the other side.)
143</dl>
144
145<P>
146<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
147 <td><nobr><b><tt id='l2h-1284' xml:id='l2h-1284' class="function">cos</tt></b>(</nobr></td>
148 <td><var>x</var>)</td></tr></table></dt>
149<dd>
150Return the cosine of <var>x</var>.
151</dl>
152
153<P>
154<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
155 <td><nobr><b><tt id='l2h-1285' xml:id='l2h-1285' class="function">cosh</tt></b>(</nobr></td>
156 <td><var>x</var>)</td></tr></table></dt>
157<dd>
158Return the hyperbolic cosine of <var>x</var>.
159</dl>
160
161<P>
162<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
163 <td><nobr><b><tt id='l2h-1286' xml:id='l2h-1286' class="function">exp</tt></b>(</nobr></td>
164 <td><var>x</var>)</td></tr></table></dt>
165<dd>
166Return the exponential value <code>e**<var>x</var></code>.
167</dl>
168
169<P>
170<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
171 <td><nobr><b><tt id='l2h-1287' xml:id='l2h-1287' class="function">log</tt></b>(</nobr></td>
172 <td><var>x</var><big>[</big><var>, base</var><big>]</big><var></var>)</td></tr></table></dt>
173<dd>
174Returns the logarithm of <var>x</var> to the given <var>base</var>.
175If the <var>base</var> is not specified, returns the natural logarithm of <var>x</var>.
176There is one branch cut, from 0 along the negative real axis to
177-&infin;, continuous from above.
178
179<span class="versionnote">Changed in version 2.4:
180<var>base</var> argument added.</span>
181
182</dl>
183
184<P>
185<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
186 <td><nobr><b><tt id='l2h-1288' xml:id='l2h-1288' class="function">log10</tt></b>(</nobr></td>
187 <td><var>x</var>)</td></tr></table></dt>
188<dd>
189Return the base-10 logarithm of <var>x</var>.
190This has the same branch cut as <tt class="function">log()</tt>.
191</dl>
192
193<P>
194<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
195 <td><nobr><b><tt id='l2h-1289' xml:id='l2h-1289' class="function">sin</tt></b>(</nobr></td>
196 <td><var>x</var>)</td></tr></table></dt>
197<dd>
198Return the sine of <var>x</var>.
199</dl>
200
201<P>
202<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
203 <td><nobr><b><tt id='l2h-1290' xml:id='l2h-1290' class="function">sinh</tt></b>(</nobr></td>
204 <td><var>x</var>)</td></tr></table></dt>
205<dd>
206Return the hyperbolic sine of <var>x</var>.
207</dl>
208
209<P>
210<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
211 <td><nobr><b><tt id='l2h-1291' xml:id='l2h-1291' class="function">sqrt</tt></b>(</nobr></td>
212 <td><var>x</var>)</td></tr></table></dt>
213<dd>
214Return the square root of <var>x</var>.
215This has the same branch cut as <tt class="function">log()</tt>.
216</dl>
217
218<P>
219<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
220 <td><nobr><b><tt id='l2h-1292' xml:id='l2h-1292' class="function">tan</tt></b>(</nobr></td>
221 <td><var>x</var>)</td></tr></table></dt>
222<dd>
223Return the tangent of <var>x</var>.
224</dl>
225
226<P>
227<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
228 <td><nobr><b><tt id='l2h-1293' xml:id='l2h-1293' class="function">tanh</tt></b>(</nobr></td>
229 <td><var>x</var>)</td></tr></table></dt>
230<dd>
231Return the hyperbolic tangent of <var>x</var>.
232</dl>
233
234<P>
235The module also defines two mathematical constants:
236
237<P>
238<dl><dt><b><tt id='l2h-1294' xml:id='l2h-1294'>pi</tt></b></dt>
239<dd>
240The mathematical constant <em>pi</em>, as a real.
241</dd></dl>
242
243<P>
244<dl><dt><b><tt id='l2h-1295' xml:id='l2h-1295'>e</tt></b></dt>
245<dd>
246The mathematical constant <em>e</em>, as a real.
247</dd></dl>
248
249<P>
250Note that the selection of functions is similar, but not identical, to
251that 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
252two modules is that some users aren't interested in complex numbers,
253and perhaps don't even know what they are. They would rather have
254<code>math.sqrt(-1)</code> raise an exception than return a complex number.
255Also note that the functions defined in <tt class="module">cmath</tt> always return a
256complex number, even if the answer can be expressed as a real number
257(in which case the complex number has an imaginary part of zero).
258
259<P>
260A note on branch cuts: They are curves along which the given function
261fails to be continuous. They are a necessary feature of many complex
262functions. It is assumed that if you need to compute with complex
263functions, you will understand about branch cuts. Consult almost any
264(not too elementary) book on complex variables for enlightenment. For
265information of the proper choice of branch cuts for numerical
266purposes, a good reference should be the following:
267
268<P>
269<div class="seealso">
270 <p class="heading">See Also:</p>
271
272 <div class="seetext"><p>Kahan, W: Branch cuts for complex elementary functions;
273 or, Much ado about nothing's sign bit. In Iserles, A.,
274 and Powell, M. (eds.), <em class="citetitle"
275 >The state of the art in
276 numerical analysis</em>. Clarendon Press (1987) pp165-211.</p></div>
277</div>
278
279<DIV CLASS="navigation">
280<div class='online-navigation'>
281<p></p><hr />
282<table align="center" width="100%" cellpadding="0" cellspacing="2">
283<tr>
284<td class='online-navigation'><a rel="prev" title="5.7 math "
285 href="module-math.html"><img src='../icons/previous.png'
286 border='0' height='32' alt='Previous Page' width='32' /></A></td>
287<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
288 href="misc.html"><img src='../icons/up.png'
289 border='0' height='32' alt='Up One Level' width='32' /></A></td>
290<td class='online-navigation'><a rel="next" title="5.9 random "
291 href="module-random.html"><img src='../icons/next.png'
292 border='0' height='32' alt='Next Page' width='32' /></A></td>
293<td align="center" width="100%">Python Library Reference</td>
294<td class='online-navigation'><a rel="contents" title="Table of Contents"
295 href="contents.html"><img src='../icons/contents.png'
296 border='0' height='32' alt='Contents' width='32' /></A></td>
297<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
298 border='0' height='32' alt='Module Index' width='32' /></a></td>
299<td class='online-navigation'><a rel="index" title="Index"
300 href="genindex.html"><img src='../icons/index.png'
301 border='0' height='32' alt='Index' width='32' /></A></td>
302</tr></table>
303<div class='online-navigation'>
304<b class="navlabel">Previous:</b>
305<a class="sectref" rel="prev" href="module-math.html">5.7 math </A>
306<b class="navlabel">Up:</b>
307<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
308<b class="navlabel">Next:</b>
309<a class="sectref" rel="next" href="module-random.html">5.9 random </A>
310</div>
311</div>
312<hr />
313<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
314</DIV>
315<!--End of Navigation Panel-->
316<ADDRESS>
317See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
318</ADDRESS>
319</BODY>
320</HTML>