The math
module
The math
module provides various mathematical functions and constants for mathematical operations.
Constants
e: number
The mathematical constant ‘e’ (Euler’s number), approximately equal to 2.71828.
pi: number
The mathematical constant ‘π’ (pi), approximately equal to 3.14159.
Free functions
abs(x: number): number
Returns the absolute value of the given number ‘x’.
acos(x: number): number
Returns the arccosine (inverse cosine) of the given number ‘x’ in radians.
acosh(x: number): number
Returns the hyperbolic arccosine of the given number ‘x’.
asin(x: number): number
Returns the arcsine (inverse sine) of the given number ‘x’ in radians.
asinh(x: number): number
Returns the hyperbolic arcsine of the given number ‘x’.
atan(x: number): number
Returns the arctangent (inverse tangent) of the given number ‘x’ in radians.
atan2(y: number, x: number): number
Returns the arctangent of the quotient of ‘y’ and ‘x’, with the result in radians.
atanh(x: number): number
Returns the hyperbolic arctangent of the given number ‘x’.
cbrt(x: number): number
Returns the cube root of the given number ‘x’.
ceil(x: number): number
Rounds ‘x’ up to the nearest integer and returns the result as a float.
cos(x: number): number
Returns the cosine of the given number ‘x’ in radians.
cosh(x: number): number
Returns the hyperbolic cosine of the given number ‘x’.
exp(x: number): number
Returns ‘e’ raised to the power of ‘x’.
expm1(x: number): number
Returns ‘e’ raised to the power of ‘x’ minus 1.
floor(x: number): number
Rounds ‘x’ down to the nearest integer and returns the result.
hypot(x: number, y: number): number
Returns the square root of the sum of the squares of ‘x’ and ‘y’.
ln(x: number): number
Returns the natural logarithm of ‘x’.
log10(x: number): number
Returns the base−10 logarithm of ‘x’.
log2(x: number): number
Returns the base−2 logarithm of ‘x’.
pow(base: number, exponent: number): number
Returns ‘base’ raised to the power of ‘exponent’.
round(x: number): number
Rounds ‘x’ to the nearest integer and returns the result as a float.
sign(x: number): number
Returns the sign of ‘x’ as −1 for negative numbers, 1 for positive numbers, and 0 for zero.
sin(x: number): number
Returns the sine of the given number ‘x’ in radians.
sinh(x: number): number
Returns the hyperbolic sine of the given number ‘x’.
sqrt(x: number): number
Returns the square root of the given number ‘x’.
tan(x: number): number
Returns the tangent of the given number ‘x’ in radians.
tanh(x: number): number
Returns the hyperbolic tangent of the given number ‘x’.