Mathematical functions#

Trigonometric functions#

sin(*args[, out, where, casting, order, dtype])

Trigonometric sine, element-wise.

cos(*args[, out, where, casting, order, dtype])

Cosine element-wise.

tan(*args[, out, where, casting, order, dtype])

Compute tangent element-wise.

arcsin(*args[, out, where, casting, order, ...])

Inverse sine, element-wise.

arccos(*args[, out, where, casting, order, ...])

Trigonometric inverse cosine, element-wise.

arctan(*args[, out, where, casting, order, ...])

Trigonometric inverse tangent, element-wise.

hypot(*args[, out, where, casting, order, dtype])

Given the “legs” of a right triangle, return its hypotenuse.

arctan2(*args[, out, where, casting, order, ...])

Element-wise arc tangent of x1/x2 choosing the quadrant correctly.

degrees(*args[, out, where, casting, order, ...])

Convert angles from radians to degrees.

radians(*args[, out, where, casting, order, ...])

Convert angles from degrees to radians.

deg2rad(*args[, out, where, casting, order, ...])

Convert angles from degrees to radians.

rad2deg(*args[, out, where, casting, order, ...])

Convert angles from radians to degrees.

Hyperbolic functions#

sinh(*args[, out, where, casting, order, dtype])

Hyperbolic sine, element-wise.

cosh(*args[, out, where, casting, order, dtype])

Hyperbolic cosine, element-wise.

tanh(*args[, out, where, casting, order, dtype])

Compute hyperbolic tangent element-wise.

arcsinh(*args[, out, where, casting, order, ...])

Inverse hyperbolic sine element-wise.

arccosh(*args[, out, where, casting, order, ...])

Inverse hyperbolic cosine, element-wise.

arctanh(*args[, out, where, casting, order, ...])

Inverse hyperbolic tangent element-wise.

Rounding#

rint(*args[, out, where, casting, order, dtype])

Round elements of the array to the nearest integer.

floor(*args[, out, where, casting, order, dtype])

Return the floor of the input, element-wise.

ceil(*args[, out, where, casting, order, dtype])

Return the ceiling of the input, element-wise.

trunc(*args[, out, where, casting, order, dtype])

Return the truncated value of the input, element-wise.

Sums, products, differences#

prod(a[, axis, dtype, out, keepdims, ...])

Return the product of array elements over a given axis.

sum(a[, axis, dtype, out, keepdims, ...])

Sum of array elements over a given axis.

cumprod(a[, axis, dtype, out])

Return the cumulative product of the elements along a given axis.

cumsum(a[, axis, dtype, out])

Return the cumulative sum of the elements along a given axis.

diff(a[, n, axis, prepend, append])

Calculate the n-th discrete difference along the given axis.

nancumprod(a[, axis, dtype, out])

Return the cumulative product of the elements along a given axis treating Not a Numbers (NaNs) as one.

nancumsum(a[, axis, dtype, out])

Return the cumulative sum of the elements along a given axis treating Not a Numbers (NaNs) as zero.

nanprod(a[, axis, dtype, out, keepdims, ...])

Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.

nansum(a[, axis, dtype, out, keepdims, ...])

Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as ones.

Exponents and logarithms#

exp(*args[, out, where, casting, order, dtype])

Calculate the exponential of all elements in the input array.

expm1(*args[, out, where, casting, order, dtype])

Calculate exp(x) - 1 for all elements in the array.

exp2(*args[, out, where, casting, order, dtype])

Calculate 2**p for all p in the input array.

log(*args[, out, where, casting, order, dtype])

Natural logarithm, element-wise.

log10(*args[, out, where, casting, order, dtype])

Return the base 10 logarithm of the input array, element-wise.

log2(*args[, out, where, casting, order, dtype])

Base-2 logarithm of x.

log1p(*args[, out, where, casting, order, dtype])

Return the natural logarithm of one plus the input array, element-wise.

logaddexp(*args[, out, where, casting, ...])

Logarithm of the sum of exponentiations of the inputs.

logaddexp2(*args[, out, where, casting, ...])

Logarithm of the sum of exponentiations of the inputs in base-2.

Floating point routines#

signbit(*args[, out, where, casting, order, ...])

Returns element-wise True where signbit is set (less than zero).

copysign(*args[, out, where, casting, ...])

Change the sign of x1 to that of x2, element-wise.

frexp(*args[, out, where, casting, order, dtype])

Decompose the elements of x into mantissa and twos exponent.

ldexp(*args[, out, where, casting, order, dtype])

Returns x1 * 2**x2, element-wise.

nextafter(*args[, out, where, casting, ...])

Return the next floating-point value after x1 towards x2, element-wise.

Rational routines#

lcm(*args[, out, where, casting, order, dtype])

Returns the lowest common multiple of |x1| and |x2|

gcd(*args[, out, where, casting, order, dtype])

Returns the greatest common divisor of |x1| and |x2|

Arithmetic operations#

add(*args[, out, where, casting, order, dtype])

Add arguments element-wise.

reciprocal(*args[, out, where, casting, ...])

Return the reciprocal of the argument, element-wise.

positive(*args[, out, where, casting, ...])

Numerical positive, element-wise.

negative(*args[, out, where, casting, ...])

Numerical negative, element-wise.

multiply(*args[, out, where, casting, ...])

Multiply arguments element-wise.

divide(*args[, out, where, casting, order, ...])

Returns a true division of the inputs, element-wise.

power(*args[, out, where, casting, order, dtype])

First array elements raised to powers from second array, element-wise.

subtract(*args[, out, where, casting, ...])

Subtract arguments, element-wise.

true_divide(*args[, out, where, casting, ...])

Returns a true division of the inputs, element-wise.

floor_divide(*args[, out, where, casting, ...])

Return the largest integer smaller or equal to the division of the inputs.

float_power(*args[, out, where, casting, ...])

First array elements raised to powers from second array, element-wise.

fmod(*args[, out, where, casting, order, dtype])

Returns the element-wise remainder of division.

mod(*args[, out, where, casting, order, dtype])

Return element-wise remainder of division.

modf(*args[, out, where, casting, order, dtype])

Return the fractional and integral parts of an array, element-wise.

remainder(*args[, out, where, casting, ...])

Return element-wise remainder of division.

Handling complex numbers#

real(val)

Return the real part of the complex argument.

imag(val)

Return the imaginary part of the complex argument.

conj(*args[, out, where, casting, order, dtype])

Return the complex conjugate, element-wise.

conjugate(*args[, out, where, casting, ...])

Return the complex conjugate, element-wise.

Extrema Finding#

maximum(*args[, out, where, casting, order, ...])

Element-wise maximum of array elements.

fmax(*args[, out, where, casting, order, dtype])

Element-wise maximum of array elements.

amax(a[, axis, dtype, out, keepdims, ...])

Return the maximum of an array or maximum along an axis.

minimum(*args[, out, where, casting, order, ...])

Element-wise minimum of array elements.

fmin(*args[, out, where, casting, order, dtype])

Element-wise minimum of array elements.

amin(a[, axis, dtype, out, keepdims, ...])

Return the minimum of an array or minimum along an axis.

nanmin(a[, axis, out, keepdims, initial, where])

Return minimum of an array or minimum along an axis, ignoring any NaNs.

nanmax(a[, axis, out, keepdims, initial, where])

Return the maximum of an array or maximum along an axis, ignoring any NaNs.

Miscellaneous#

convolve(a, v[, mode])

Returns the discrete, linear convolution of two ndarrays.

clip(a, a_min, a_max[, out])

Clip (limit) the values in an array.

sqrt(*args[, out, where, casting, order, dtype])

Return the non-negative square-root of an array, element-wise.

cbrt(*args[, out, where, casting, order, dtype])

Return the cube-root of an array, element-wise.

square(*args[, out, where, casting, order, ...])

Return the element-wise square of the input.

absolute(*args[, out, where, casting, ...])

Calculate the absolute value element-wise.

fabs(*args[, out, where, casting, order, dtype])

Compute the absolute values element-wise.

sign(*args[, out, where, casting, order, dtype])

Returns an element-wise indication of the sign of a number.

inner(a, b[, out])

Inner product of two arrays.

outer(a, b[, out])

Compute the outer product of two vectors.

vdot(a, b[, out])

Return the dot product of two vectors.