# Python Mathematical Functions

## Python Mathematical Functions

In this section we will learn the functions defined in the Python math module and how to use these functions. The math module can be used in your program by importing the module using the following query:

import math

The math module is considered to be the standard module in Python that can be used any time. The complex data types are not supported by the math module rather for complex numbers we use cmath module that is also built in module in Python.

Consider the following table which is a list of functions defined in the math module that is supported by Python:

 Function Description ceil(x) This function is used to return the smallest integer that will be greater than or equal to x. copysign (x, y) It is used to return the value of x but with the sign of y. fabs (x) It is used to return the absolute value of x. factorial (x) This function is used to return the factorial of the variable x. floor (x) This function is used to return the largest integer that will be smaller than or equal to x. fmode (x, y) This function is used to return the remainder hen x is divide by the variable y. frexp (x) This function is used to return the mantissa and exponent of the variable x in the form of (m, e). fsum (iterable) This function is used to return the accurate floating point sum of the values in the iterables. isinfinite (x) This function is used to return True if the variable x is neither infinity nor a Nan. Nan stands for not a number. isinf (x) This function returns true if x is a positive or x is a negative infinity. isnan (x) This function returns a true if the variable x is not a number or nan. idexp (x, i) This function evaluates the function x * (2**1). modf (x) This function is used to return the integer as well as the fractional parts in x. trunk (x) This function returns the value of x after truncating it to integer nearest to 0. exp (x) This function is used to return the evaluated expression e**x. expm1 (x) This function is used to return the evaluated expression e**x-1. log(x[, base]) This function is used to return the log of x to the base. log1p (x) This function is used to return the natural logarithm of 1 +x. log2 (x) This function is used to return the log of x to the base 2. log10 (x) This function is used to return the log of x to the base 10. pow (x, y) This function is used to return x raised to the power y. sqrt (x) This function returns the square root of variable x. acos (x) This function is used to return the arc cos of the variable x. asin (x) This function is used to return the arc sin of the variable x. atan (x) This function is used to return the arc tan of the variable x. atan2 (y, x) This function is used to return atan (y / x) cos (x) This function is used to return the cosine of variable x. hypot (x, y) This function is used to return the Euclidean norm, that is sqrt (x*x + y*y). sin (x) This function is used to return the sine of variable x. tan (x) This function is used to return the tangent of variable x. degrees (x) This function is used to convert the given angle x from radians to degrees. radians (x) This function is used to convert the given angle x from degrees to radians. acosh (x) This function is used to return the inverse of hyperbolic cosine of x. asinh (x) This function is used to return the inverse of hyperbolic sine of x. atanh (x) This function is used to return the inverse of hyperbolic tangent of x. erf (x) This function is used to return the error function occurring at x. erfc (x) This function is used to return the complimentary error function occurring at x. gamma (x) This function is used to return the gamma function at x. lgamma (x) This function is used to return the natural logarithm of the absolute value of gamma function at x. pi This is the mathematical constant pi that has a value of 3.14159… e This is the mathematical constant e that has a value of 2.71828.