Skip to content

Python math functions list

  • by

Python math functions list available as standard in the Math module. You have to import the module using import math to use mathematical functions in Python.

Here is a List of Functions in the Python Math Module.

ceil(x)Returns the smallest integer greater than or equal to x.
copysign(x, y)Returns x with the sign of y
fabs(x)Returns the absolute value of x
factorial(x)Returns the factorial of x
floor(x)Returns the largest integer less than or equal to x
fmod(x, y)Returns the remainder when x is divided by y
frexp(x)Returns the mantissa and exponent of x as the pair (m, e)
fsum(iterable)Returns an accurate floating point sum of values in the iterable
isfinite(x)Returns True if x is neither an infinity nor a NaN (Not a Number)
isinf(x)Returns True if x is a positive or negative infinity
isnan(x)Returns True if x is a NaN
ldexp(x, i)Returns x * (2**i)
modf(x)Returns the fractional and integer parts of x
trunc(x)Returns the truncated integer value of x
exp(x)Returns e**x
expm1(x)Returns e**x – 1
log(x[, b])Returns the logarithm of x to the base b (defaults to e)
log1p(x)Returns the natural logarithm of 1+x
log2(x)Returns the base-2 logarithm of x
log10(x)Returns the base-10 logarithm of x
pow(x, y)Returns x raised to the power y
sqrt(x)Returns the square root of x
acos(x)Returns the arc cosine of x
asin(x)Returns the arc sine of x
atan(x)Returns the arc tangent of x
atan2(y, x)Returns atan(y / x)
cos(x)Returns the cosine of x
hypot(x, y)Returns the Euclidean norm, sqrt(x*x + y*y)
sin(x)Returns the sine of x
tan(x)Returns the tangent of x
degrees(x)Converts angle x from radians to degrees
radians(x)Converts angle x from degrees to radians
acosh(x)Returns the inverse hyperbolic cosine of x
asinh(x)Returns the inverse hyperbolic sine of x
atanh(x)Returns the inverse hyperbolic tangent of x
cosh(x)Returns the hyperbolic cosine of x
sinh(x)Returns the hyperbolic cosine of x
tanh(x)Returns the hyperbolic tangent of x
erf(x)Returns the error function at x
erfc(x)Returns the complementary error function at x
gamma(x)Returns the Gamma function at x
lgamma(x)Returns the natural logarithm of the absolute value of the Gamma function at x
piMathematical constant, the ratio of the circumference of a circle to its diameter (3.14159…)
emathematical constant e (2.71828…)

Python math functions list examples

Simple example code of some math methods.

import math

x = 10.346
print("ceil", math.ceil(x))
print("floor", math.floor(x))

print("factorial", math.factorial(9))
print("absolute value: ", math.fabs(-10))

print("exponenetial value", math.exp(9))
print("power ", math.pow(2, 3))

angle = math.pi / 4
print("sine", math.sin(angle))
print("cosine", math.cos(angle))
print("tangent", math.tan(angle))

functions = dir(math)
# print(functions)


Python math functions list

Do comment if you have any doubts or suggestions on this Python math module topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.