Mathematical functions#

Trigonometric functions#

sin

Trigonometric sine, element-wise.

cos

Cosine element-wise.

tan

Compute tangent element-wise.

arcsin

Inverse sine, element-wise.

arccos

Trigonometric inverse cosine, element-wise.

arctan

Trigonometric inverse tangent, element-wise.

hypot

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

arctan2

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

degrees

Convert angles from radians to degrees.

radians

Convert angles from degrees to radians.

deg2rad

Convert angles from degrees to radians.

rad2deg

Convert angles from radians to degrees.

Hyperbolic functions#

sinh

Hyperbolic sine, element-wise.

cosh

Hyperbolic cosine, element-wise.

tanh

Compute hyperbolic tangent element-wise.

arcsinh

Inverse hyperbolic sine element-wise.

arccosh

Inverse hyperbolic cosine, element-wise.

arctanh

Inverse hyperbolic tangent element-wise.

Rounding#

round(a[, decimals, out])

Evenly round to the given number of decimals.

rint

Round elements of the array to the nearest integer.

floor

Return the floor of the input, element-wise.

ceil

Return the ceiling of the input, element-wise.

trunc

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.

gradient(f, *varargs[, axis, edge_order])

Return the gradient of an N-dimensional array.

cross(a, b[, axisa, axisb, axisc, axis])

Return the cross product of two (arrays of) vectors.

Exponents and logarithms#

exp

Calculate the exponential of all elements in the input array.

expm1

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

exp2

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

log

Natural logarithm, element-wise.

log10

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

log2

Base-2 logarithm of x.

log1p

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

logaddexp

Logarithm of the sum of exponentiations of the inputs.

logaddexp2

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

Floating point routines#

signbit

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

copysign

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

frexp

Decompose the elements of x into mantissa and twos exponent.

ldexp

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

nextafter

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

Rational routines#

lcm

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

gcd

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

Arithmetic operations#

add

Add arguments element-wise.

reciprocal

Return the reciprocal of the argument, element-wise.

positive

Numerical positive, element-wise.

negative

Numerical negative, element-wise.

multiply

Multiply arguments element-wise.

divide

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

power

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

subtract

Subtract arguments, element-wise.

true_divide

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

floor_divide

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

float_power

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

fmod

Returns the element-wise remainder of division.

mod

Return element-wise remainder of division.

modf

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

remainder

Return element-wise remainder of division.

Handling complex numbers#

real(val)

Return the real part of the complex argument.

real_if_close(a[, tol])

If input is complex with all imaginary parts close to zero, return real parts.

imag(val)

Return the imaginary part of the complex argument.

angle(z[, deg])

Return the angle of the complex argument.

conj

Return the complex conjugate, element-wise.

conjugate

Return the complex conjugate, element-wise.

Extrema Finding#

maximum

Element-wise maximum of array elements.

fmax

Element-wise maximum of array elements.

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

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

minimum

Element-wise minimum of array elements.

fmin

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, method])

Returns the discrete, linear convolution of two ndarrays.

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

Clip (limit) the values in an array.

nan_to_num(a[, copy, nan, posinf, neginf])

Replace NaN with zero and infinity with large finite numbers.

sqrt

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

cbrt

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

square

Return the element-wise square of the input.

roots(p)

Return the roots of a polynomial with coefficients given in p.

absolute

Calculate the absolute value element-wise.

fabs

Compute the absolute values element-wise.

sign

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.