-
ceil( x) - Return the ceiling of x as a float, the smallest integer value greater than or equal to x.
ceil(3.7) # 4.0
-
fabs( x) - Return the absolute value of x.
fabs(-3) # 3.0
-
floor( x) - Return the floor of x as a float, the largest integer value less than or equal to x.
floor(3.7) # 3.0
-
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 % y returns a result with the sign of y instead, and may not be exactly computable for float arguments. For example, fmod(-1e-100, 1e100) is -1e-100, but the result of 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.
fmod(10,3) # 1.0
fmod(12,5) # 2.0
-
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.
frexp(5) # (0.625, 3)
-
ldexp( x, i) - Return x * (2**i). This is essentially the inverse of function frexp().
ldexp(0.625, 3) # 5.0
-
modf( x) - Return the fractional and integer parts of x. Both results carry the sign of x, and both are floats.
modf(5.25) # (0.25, 5.0)
-
exp( x) - Return e**x.
exp(5) # 148.4131591025766
-
log( x[, base]) - Return the logarithm of x to the given base. If the base is not specified, return the natural logarithm of x (that is, the logarithm to base e). Changed in version 2.3: base argument added.
log(5) # 1.6094379124341003
-
log10( x) - Return the base-10 logarithm of x.
log10(5) # 0.69897000433601886
-
pow( x, y) - Return x**y.
pow(3,3) # 27.0
-
sqrt( x) - Return the square root of x.
sqrt(9) # 3.0
-
acos( x) - Return the arc cosine of x, in radians.
asin( x) - Return the arc sine of x, in radians.
atan( x) - Return the arc tangent of x, in radians.
atan2( y, x) - Return atan(y / x), in radians. The result is between -pi and pi. The vector in the plane from the origin to point (x, y) makes this angle with the positive X axis. The point of atan2() is that the signs of both inputs are known to it, so it can compute the correct quadrant for the angle. For example, atan(1) and atan2(1, 1) are both pi/4, but atan2(-1, -1) is -3*pi/4.
cos( x) - Return the cosine of x radians.
sin( x) - Return the sine of x radians.
tan( x) - Return the tangent of x radians.
-
hypot( x, y) - Return the Euclidean norm, sqrt(x*x + y*y). This is the length of the vector from the origin to point (x, y).
hypot(5,3) # 5.8309518948452999
-
degrees( x) - Converts angle x from radians to degrees.
degrees(1) # 57.295779513082323
-
radians( x) - Converts angle x from degrees to radians.
radians(60) # 1.0471975511965976
-
cosh( x) - Return the hyperbolic cosine of x.
sinh( x) - Return the hyperbolic sine of x.
tanh( x) - Return the hyperbolic tangent of x.
pi - The mathematical constant pi.
e - The mathematical constant e.
index
