没有合适的资源?快使用搜索试试~ 我知道了~
python数学模块.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 190 浏览量
2021-09-14
12:49:39
上传
评论
收藏 51KB DOCX 举报
温馨提示
试读
11页
。。。
资源推荐
资源详情
资源评论
9.2. math — Mathematical functions¶
This module is always available. It provides access to the mathematical functions
defined by the C standard.
These functions cannot be used with complex numbers; use the functions of the
same name from the cmath 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.
The following functions are provided by this module. Except when explicitly noted
otherwise, all return values are floats.
9.2.1. Number-theoretic and representation functions
math.ceil(x)
Return the ceiling of x, the smallest integer greater than or equal tox. If x is not a float,
delegates to x.__ceil__(), which should return anIntegral value.
math.copysign(x, y)
Return a float with the magnitude (absolute value) ofx but the sign of y. On platforms
that support signed zeros, copysign(1.0, -0.0) returns-1.0.
math.fabs(x)
Return the absolute value of x.
math.factorial(x)
Return x factorial. Raises ValueError if x is not integral or is negative.
math.floor(x)
Return the floor of x, the largest integer less than or equal to x. If x is not a float,
delegates to x.__floor__(), which should return anIntegral value.
math.fmod(x, y)
Return fmod(x, y), as defined by the platform C library. Note that the Python
expression x % y may not return the same result. The intent of the C standard is
that fmod(x, y) be exactly (mathematically; to infinite precision) equal to x - n*y for
some integer n such that the result has the same sign as x and magnitude less
than abs(y). Python’s x % yreturns a result with the sign of y instead, and may not be
exactly
computable
for
float
but
arguments.
the result
For
of
example, fmod(-1e-100, 1e100) is -1e-100,
Python’s -1e-100 % 1e100 is 1e100-1e-100, which cannot be represented exactly as
a float, and rounds to the surprising 1e100. For this reason, function fmod() is
generally preferred when working with floats, while Python’s x % y is preferred when
working with integers.
math.frexp(x)
Return the mantissa and exponent of x as the pair (m, e). m is a float and e is an
integer
such
that x == m * 2**e exactly.
If x is
zero,
returns (0.0, 0),
otherwise 0.5 <= abs(m)< 1. This is used to “pick apart” the internal representation of
a float in a portable way.
math.fsum(iterable)
Return an accurate floating point sum of values in the iterable. Avoids loss of
precision by tracking multiple intermediate partial sums:
>>>
>>>sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
0.9999999999999999
>>>fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
1.0
The algorithm’s accuracy depends on IEEE-754 arithmetic guarantees and the typical
case where the rounding mode is half-even. On some non-Windows builds, the
underlying C library uses extended precision addition and may occasionally
double-round an intermediate sum causing it to be off in its least significant bit.
For further discussion and two alternative approaches, see the ASPN cookbook
recipes for accurate floating point summation.
math.gcd(a, b)
Return the greatest common divisor of the integers a and b. If either a or b is nonzero,
then the value of gcd(a, b) is the largest positive integer that divides
both a and b.gcd(0, 0) returns 0.
New inversion 3.5.
剩余10页未读,继续阅读
资源评论
苦茶子12138
- 粉丝: 1w+
- 资源: 6万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 农村小别墅图纸编号D040-三层-08.30&14.60米-施工图.dwg
- 三层别墅图纸编号D039-三层-16.70&14.70米- 结构图.dwg
- 三层农村小别墅编号D038-三层-11.90&13.50米-施工图.dwg
- 采购组·主管业务原型集与说明(Xmind书写)
- 三层图纸编号D037-三层-10.40&15.10米-施工图.dwg
- 三层别墅图纸编号D036-三层-14.04&15.44米-施工图.dwg
- 三层别墅图纸编号D035-三层-09.30&13.80米- 施工图.dwg
- 三层别墅图纸编号D032-三层-07.20&10.00米- 施工图.dwg
- 三层别墅图纸编号D031-三层-08.00&09.70米- 施工图.dwg
- aaaaaaaaaaa
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功