⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module-math.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>5.1 math -- Mathematical functions</title>
<META NAME="description" CONTENT="5.1 math -- Mathematical functions">
<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" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html">
<LINK REL="previous" href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html">
<LINK REL="up" href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html">
<LINK REL="next" href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Up:</b> <a class="sectref" href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html">5.2 cmath  </A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION007100000000000000000">
5.1 <tt class="module">math</tt> --
         Mathematical functions</A>
</H1>

<P>


<P>
This module is always available.  It provides access to the
mathematical functions defined by the C standard.

<P>
These functions cannot be used with complex numbers; use the functions
of the same name from the <tt class='module'><a href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html">cmath</a></tt> module if you require
support for complex numbers.  The distinction between functions which
support complex numbers and those which don't is made since most users
do not want to learn quite as much mathematics as required to
understand complex numbers.  Receiving an exception instead of a
complex result allows earlier detection of the unexpected complex
number used as a parameter, so that the programmer can determine how
and why it was generated in the first place.

<P>
The following functions provided by this module:

<P>
<dl><dt><b><a name='l2h-685'><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-686'><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-687'><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-688'><tt class='function'>atan2</tt></a></b> (<var>y, x</var>)
<dd>
Return <code>atan(<var>y</var> / <var>x</var>)</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-689'><tt class='function'>ceil</tt></a></b> (<var>x</var>)
<dd>
Return the ceiling of <var>x</var> as a real.
</dl>

<P>
<dl><dt><b><a name='l2h-690'><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-691'><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-692'><tt class='function'>exp</tt></a></b> (<var>x</var>)
<dd>
Return <code>e**<var>x</var></code>.
</dl>

<P>
<dl><dt><b><a name='l2h-693'><tt class='function'>fabs</tt></a></b> (<var>x</var>)
<dd>
Return the absolute value of the real <var>x</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-694'><tt class='function'>floor</tt></a></b> (<var>x</var>)
<dd>
Return the floor of <var>x</var> as a real.
</dl>

<P>
<dl><dt><b><a name='l2h-695'><tt class='function'>fmod</tt></a></b> (<var>x, y</var>)
<dd>
Return <code>fmod(<var>x</var>, <var>y</var>)</code>, as defined by the platform C library.
Note that the Python expression <code><var>x</var> % <var>y</var></code> may not return
the same result.
</dl>

<P>
<dl><dt><b><a name='l2h-696'><tt class='function'>frexp</tt></a></b> (<var>x</var>)
<dd>
Return the mantissa and exponent of <var>x</var> as the pair
<code>(<var>m</var>, <var>e</var>)</code>.  <var>m</var> is a float and <var>e</var> is an
integer such that <code><var>x</var> == <var>m</var> * 2**<var>e</var></code>.
If <var>x</var> is zero, returns <code>(0.0, 0)</code>, otherwise
<code>0.5 &lt;= abs(<var>m</var>) &lt; 1</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-697'><tt class='function'>hypot</tt></a></b> (<var>x, y</var>)
<dd>
Return the Euclidean distance, <code>sqrt(<var>x</var>*<var>x</var> + <var>y</var>*<var>y</var>)</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-698'><tt class='function'>ldexp</tt></a></b> (<var>x, i</var>)
<dd>
Return <code><var>x</var> * (2**<var>i</var>)</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-699'><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-700'><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-701'><tt class='function'>modf</tt></a></b> (<var>x</var>)
<dd>
Return the fractional and integer parts of <var>x</var>.  Both results
carry the sign of <var>x</var>.  The integer part is returned as a real.
</dl>

<P>
<dl><dt><b><a name='l2h-702'><tt class='function'>pow</tt></a></b> (<var>x, y</var>)
<dd>
Return <code><var>x</var>**<var>y</var></code>.
</dl>

<P>
<dl><dt><b><a name='l2h-703'><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-704'><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-705'><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-706'><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-707'><tt class='function'>tanh</tt></a></b> (<var>x</var>)
<dd>
Return the hyperbolic tangent of <var>x</var>.
</dl>

<P>
Note that <tt class="function">frexp()</tt> and <tt class="function">modf()</tt> have a different
call/return pattern than their C equivalents: they take a single
argument and return a pair of values, rather than returning their
second return value through an `output parameter' (there is no such
thing in Python).

<P>
The module also defines two mathematical constants:

<P>
<dl><dt><b><a name='l2h-708'><tt>pi</tt></a></b>
<dd>
The mathematical constant <i>pi</i>.
</dl>

<P>
<dl><dt><b><a name='l2h-709'><tt>e</tt></a></b>
<dd>
The mathematical constant <i>e</i>.
</dl>

<P>
<div class='seealso'>
  <p class='heading'><b>See Also:</b></p>

  <dl compact class="seemodule">
    <dt>Module <b><tt class='module'><a href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html">cmath</a></tt>:</b>
    <dd>Complex number versions of many of these functions.
  </dl>
</div>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Up:</b> <a class="sectref" href="misc.html" tppabs="http://www.python.org/doc/current/lib/misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-cmath.html" tppabs="http://www.python.org/doc/current/lib/module-cmath.html">5.2 cmath  </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -