0% found this document useful (0 votes)
46 views2 pages

Python Math Library Functions

The document provides a comprehensive reference for the Python math library, detailing constants, number-theoretic functions, power and logarithmic functions, trigonometric functions, hyperbolic functions, and special functions. Each section includes a list of functions along with their descriptions. This serves as a useful guide for developers working with mathematical operations in Python.

Uploaded by

rofiafcb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

Python Math Library Functions

The document provides a comprehensive reference for the Python math library, detailing constants, number-theoretic functions, power and logarithmic functions, trigonometric functions, hyperbolic functions, and special functions. Each section includes a list of functions along with their descriptions. This serves as a useful guide for developers working with mathematical operations in Python.

Uploaded by

rofiafcb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Complete Python math Library Reference

■ Constants
Constant Description
[Link] π = 3.14159… (circle constant)
math.e Euler’s number, base of natural logarithms
[Link] Tau = 2π
[Link] Infinity
[Link] Not a number

■ Number-Theoretic and Representation Functions


Function Description
ceil(x) Smallest integer ≥ x
floor(x) Largest integer ≤ x
fabs(x) Absolute value (float)
factorial(x) x! (integer factorial)
fmod(x, y) Remainder of x/y (C style)
frexp(x) Decomposes x into mantissa and exponent
ldexp(x, i) Computes x × (2**i)
isfinite(x) True if x is finite
isinf(x) True if x is infinite
isnan(x) True if x is NaN
isclose(a, b) Check if a and b are close within tolerance
modf(x) Returns fractional and integer parts of x
trunc(x) Truncates x to integer

■ Power, Exponential and Logarithmic Functions


Function Description
exp(x) e**x (exponential)
expm1(x) e**x − 1 (accurate for small x)
log(x, [base]) Natural log or log base
log10(x) Base 10 logarithm
log2(x) Base 2 logarithm
log1p(x) ln(1 + x), accurate for small x
pow(x, y) x raised to power y
sqrt(x) Square root of x
prod(iterable) Product of all items in iterable

■ Trigonometric Functions
Function Description
sin(x) Sine of x (radians)
cos(x) Cosine of x
tan(x) Tangent of x
asin(x) Inverse sine
acos(x) Inverse cosine
atan(x) Inverse tangent
atan2(y, x) atan(y/x) with correct quadrant
hypot(x, y) √(x² + y²)
degrees(x) Radians → Degrees
radians(x) Degrees → Radians

■■ Hyperbolic Functions
Function Description
sinh(x) Hyperbolic sine
cosh(x) Hyperbolic cosine
tanh(x) Hyperbolic tangent
asinh(x) Inverse hyperbolic sine
acosh(x) Inverse hyperbolic cosine
atanh(x) Inverse hyperbolic tangent

■ Special Functions
Function Description
erf(x) Error function
erfc(x) Complementary error function
gamma(x) Gamma function (factorial extension)
lgamma(x) Natural log of Gamma function
dist(p, q) Euclidean distance between points p and q
comb(n, k) Number of combinations
perm(n, k) Number of permutations

You might also like