Mathematical functions

Trigonometric functions

methoddescription
sinopen in new window(x, /[, out, where, casting, order, …])Trigonometric sine, element-wise.
cosopen in new window(x, /[, out, where, casting, order, …])Cosine element-wise.
tanopen in new window(x, /[, out, where, casting, order, …])Compute tangent element-wise.
arcsinopen in new window(x, /[, out, where, casting, order, …])Inverse sine, element-wise.
arccosopen in new window(x, /[, out, where, casting, order, …])Trigonometric inverse cosine, element-wise.
arctanopen in new window(x, /[, out, where, casting, order, …])Trigonometric inverse tangent, element-wise.
hypotopen in new window(x1, x2, /[, out, where, casting, …])Given the “legs” of a right triangle, return its hypotenuse.
arctan2open in new window(x1, x2, /[, out, where, casting, …])Element-wise arc tangent of x1/x2 choosing the quadrant correctly.
degreesopen in new window(x, /[, out, where, casting, order, …])Convert angles from radiansopen in new window to degrees.
radians(x, /[, out, where, casting, order, …])Convert angles from degrees to radians.
unwrapopen in new window(p[, discont, axis])Unwrap by changing deltas between values to 2*pi complement.
deg2radopen in new window(x, /[, out, where, casting, order, …])Convert angles from degrees to radians.
rad2degopen in new window(x, /[, out, where, casting, order, …])Convert angles from radians to degrees.

Hyperbolic functions

methoddescription
sinhopen in new window(x, /[, out, where, casting, order, …])Hyperbolic sine, element-wise.
coshopen in new window(x, /[, out, where, casting, order, …])Hyperbolic cosine, element-wise.
tanhopen in new window(x, /[, out, where, casting, order, …])Compute hyperbolic tangent element-wise.
arcsinhopen in new window(x, /[, out, where, casting, order, …])Inverse hyperbolic sine element-wise.
arccoshopen in new window(x, /[, out, where, casting, order, …])Inverse hyperbolic cosine, element-wise.
arctanhopen in new window(x, /[, out, where, casting, order, …])Inverse hyperbolic tangent element-wise.

Rounding

methoddescription
aroundopen in new window(a[, decimals, out])Evenly round to the given number of decimals.
round_open in new window(a[, decimals, out])Round an array to the given number of decimals.
rintopen in new window(x, /[, out, where, casting, order, …])Round elements of the array to the nearest integer.
fixopen in new window(x[, out])Round to nearest integer towards zero.
flooropen in new window(x, /[, out, where, casting, order, …])Return the floor of the input, element-wise.
ceilopen in new window(x, /[, out, where, casting, order, …])Return the ceiling of the input, element-wise.
truncopen in new window(x, /[, out, where, casting, order, …])Return the truncated value of the input, element-wise.

Sums, products, differences

methoddescription
prodopen in new window(a[, axis, dtype, out, keepdims, …])Return the product of array elements over a given axis.
sumopen in new window(a[, axis, dtype, out, keepdims, …])Sum of array elements over a given axis.
nanprodopen in new window(a[, axis, dtype, out, keepdims])Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.
nansumopen in new window(a[, axis, dtype, out, keepdims])Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.
cumprodopen in new window(a[, axis, dtype, out])Return the cumulative product of elements along a given axis.
cumsumopen in new window(a[, axis, dtype, out])Return the cumulative sum of the elements along a given axis.
nancumprodopen in new window(a[, axis, dtype, out])Return the cumulative product of array elements over a given axis treating Not a Numbers (NaNs) as one.
nancumsumopen in new window(a[, axis, dtype, out])Return the cumulative sum of array elements over a given axis treating Not a Numbers (NaNs) as zero.
diffopen in new window(a[, n, axis, prepend, append])Calculate the n-th discrete difference along the given axis.
ediff1dopen in new window(ary[, to_end, to_begin])The differences between consecutive elements of an array.
gradientopen in new window(f, *varargs, **kwargs)Return the gradient of an N-dimensional array.
crossopen in new window(a, b[, axisa, axisb, axisc, axis])Return the cross product of two (arrays of) vectors.
trapzopen in new window(y[, x, dx, axis])Integrate along the given axis using the composite trapezoidal rule.

Exponents and logarithms

methoddescription
expopen in new window(x, /[, out, where, casting, order, …])Calculate the exponential of all elements in the input array.
expm1open in new window(x, /[, out, where, casting, order, …])Calculate exp(x) - 1 for all elements in the array.
exp2open in new window(x, /[, out, where, casting, order, …])Calculate 2**p for all p in the input array.
logopen in new window(x, /[, out, where, casting, order, …])Natural logarithm, element-wise.
log10open in new window(x, /[, out, where, casting, order, …])Return the base 10 logarithm of the input array, element-wise.
log2open in new window(x, /[, out, where, casting, order, …])Base-2 logarithm of x.
log1popen in new window(x, /[, out, where, casting, order, …])Return the natural logarithm of one plus the input array, element-wise.
logaddexpopen in new window(x1, x2, /[, out, where, casting, …])Logarithm of the sum of exponentiations of the inputs.
logaddexp2open in new window(x1, x2, /[, out, where, casting, …])Logarithm of the sum of exponentiations of the inputs in base-2.

Other special functions

methoddescription
i0open in new window(x)Modified Bessel function of the first kind, order 0.
sincopen in new window(x)Return the sinc function.

Floating point routines

methoddescription
signbitopen in new window(x, /[, out, where, casting, order, …])Returns element-wise True where signbit is set (less than zero).
copysignopen in new window(x1, x2, /[, out, where, casting, …])Change the sign of x1 to that of x2, element-wise.
frexpopen in new window(x[, out1, out2], / [[, out, where, …])Decompose the elements of x into mantissa and twos exponent.
ldexpopen in new window(x1, x2, /[, out, where, casting, …])Returns x1 * 2**x2, element-wise.
nextafteropen in new window(x1, x2, /[, out, where, casting, …])Return the next floating-point value after x1 towards x2, element-wise.
spacingopen in new window(x, /[, out, where, casting, order, …])Return the distance between x and the nearest adjacent number.

Rational routines

methoddescription
lcmopen in new window(x1, x2, /[, out, where, casting, order, …])Returns the lowest common multiple of 1 and x2
gcdopen in new window(x1, x2, /[, out, where, casting, order, …])Returns the greatest common divisor of x1 and x2

Arithmetic operations

methoddescription
addopen in new window(x1, x2, /[, out, where, casting, order, …])Add arguments element-wise.
reciprocalopen in new window(x, /[, out, where, casting, …])Return the reciprocal of the argument, element-wise.
positiveopen in new window(x, /[, out, where, casting, order, …])Numerical positive, element-wise.
negativeopen in new window(x, /[, out, where, casting, order, …])Numerical negative, element-wise.
multiplyopen in new window(x1, x2, /[, out, where, casting, …])Multiply arguments element-wise.
divideopen in new window(x1, x2, /[, out, where, casting, …])Returns a true division of the inputs, element-wise.
poweropen in new window(x1, x2, /[, out, where, casting, …])First array elements raised to powers from second array, element-wise.
subtractopen in new window(x1, x2, /[, out, where, casting, …])Subtract arguments, element-wise.
true_divideopen in new window(x1, x2, /[, out, where, …])Returns a true division of the inputs, element-wise.
floor_divideopen in new window(x1, x2, /[, out, where, …])Return the largest integer smaller or equal to the division of the inputs.
float_poweropen in new window(x1, x2, /[, out, where, …])First array elements raised to powers from second array, element-wise.
fmodopen in new window(x1, x2, /[, out, where, casting, …])Return the element-wise remainderopen in new window of division.
modopen in new window(x1, x2, /[, out, where, casting, order, …])Return element-wise remainder of division.
modfopen in new window(x[, out1, out2], / [[, out, where, …])Return the fractional and integral parts of an array, element-wise.
remainder(x1, x2, /[, out, where, casting, …])Return element-wise remainder of division.
divmodopen in new window(x1, x2[, out1, out2], / [[, out, …])Return element-wise quotient and remainder simultaneously.

Handling complex numbers

methoddescription
angleopen in new window(z[, deg])Return the angle of the complex argument.
realopen in new window(val)Return the real part of the complex argument.
imagopen in new window(val)Return the imaginary part of the complex argument.
conjopen in new window(x, /[, out, where, casting, order, …])Return the complex conjugateopen in new window, element-wise.
conjugateopen in new window(x, /[, out, where, casting, …])Return the complex conjugate, element-wise.

Miscellaneous

methoddescription
convolveopen in new window(a, v[, mode])Returns the discrete, linear convolution of two one-dimensional sequences.
clipopen in new window(a, a_min, a_max[, out])Clip (limit) the values in an array.
sqrtopen in new window(x, /[, out, where, casting, order, …])Return the non-negative squareopen in new window-root of an array, element-wise.
cbrtopen in new window(x, /[, out, where, casting, order, …])Return the cube-root of an array, element-wise.
squareopen in new window(x, /[, out, where, casting, order, …])Return the element-wise square of the input.
absoluteopen in new window(x, /[, out, where, casting, order, …])Calculate the absolute value element-wise.
fabsopen in new window(x, /[, out, where, casting, order, …])Compute the absolute values element-wise.
signopen in new window(x, /[, out, where, casting, order, …])Returns an element-wise indication of the sign of a number.
heavisideopen in new window(x1, x2, /[, out, where, casting, …])Compute the Heaviside step function.
maximumopen in new window(x1, x2, /[, out, where, casting, …])Element-wise maximum of array elements.
minimumopen in new window(x1, x2, /[, out, where, casting, …])Element-wise minimum of array elements.
fmaxopen in new window(x1, x2, /[, out, where, casting, …])Element-wise maximum of array elements.
fminopen in new window(x1, x2, /[, out, where, casting, …])Element-wise minimum of array elements.
nan_to_numopen in new window(x[, copy, nan, posinf, neginf])Replace NaN with zero and infinity with large finite numbers (default behaviour) or with the numbers defined by the user using the nan, posinf and/or neginf keywords.
real_if_closeopen in new window(a[, tol])If complex input returns a real array if complex parts are close to zero.
interpopen in new window(x, xp, fp[, left, right, period])One-dimensional linear interpolation.