Mathematical functions

Trigonometric functions

sin

Elementwise sine function.

cos

Elementwise cosine function.

tan

Elementwise tangent function.

arcsin

Elementwise inverse-sine function (a.k.a.

arccos

Elementwise inverse-cosine function (a.k.a.

arctan

Elementwise inverse-tangent function (a.k.a.

hypot

Computes the hypoteneous of orthogonal vectors of given length.

arctan2

Elementwise inverse-tangent of the ratio of two arrays.

degrees

Converts angles from radians to degrees elementwise.

radians

Converts angles from degrees to radians elementwise.

unwrap(p[, discont, axis, period])

Unwrap by taking the complement of large deltas w.r.t.

deg2rad

Converts angles from degrees to radians elementwise.

rad2deg

Converts angles from radians to degrees elementwise.

Hyperbolic functions

sinh

Elementwise hyperbolic sine function.

cosh

Elementwise hyperbolic cosine function.

tanh

Elementwise hyperbolic tangent function.

arcsinh

Elementwise inverse of hyperbolic sine function.

arccosh

Elementwise inverse of hyperbolic cosine function.

arctanh

Elementwise inverse of hyperbolic tangent function.

Rounding

around(a[, decimals, out])

Rounds to the given number of decimals.

round_(a[, decimals, out])

rint

Rounds each element of an array to the nearest integer.

fix

If given value x is positive, it return floor(x).

floor

Rounds each element of an array to its floor integer.

ceil

Rounds each element of an array to its ceiling integer.

trunc

Rounds each element of an array towards zero.

Sums, products, differences

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

Returns the product of an array along given axes.

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

Returns the sum of an array along given axes.

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

Returns the product of an array along given axes treating Not a Numbers (NaNs) as zero.

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

Returns the sum of an array along given axes treating Not a Numbers (NaNs) as zero.

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

Returns the cumulative product of an array along a given axis.

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

Returns the cumulative sum of an array along a given axis.

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

Returns the cumulative product of an array along a given axis treating Not a Numbers (NaNs) as one.

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

Returns the cumulative sum of an array along a given axis treating Not a Numbers (NaNs) as zero.

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

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

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

Return the gradient of an N-dimensional array.

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

Returns the cross product of two vectors.

Exponents and logarithms

exp

Elementwise exponential function.

expm1

Computes exp(x) - 1 elementwise.

exp2

Elementwise exponentiation with base 2.

log

Elementwise natural logarithm function.

log10

Elementwise common logarithm function.

log2

Elementwise binary logarithm function.

log1p

Computes log(1 + x) elementwise.

logaddexp

Computes log(exp(x1) + exp(x2)) elementwise.

logaddexp2

Computes log2(exp2(x1) + exp2(x2)) elementwise.

Other special functions

i0

Modified Bessel function of the first kind, order 0.

sinc

Elementwise sinc function.

Floating point routines

signbit

Tests elementwise if the sign bit is set (i.e.

copysign

Returns the first argument with the sign bit of the second elementwise.

frexp

Decomposes each element to mantissa and two’s exponent.

ldexp

Computes x1 * 2 ** x2 elementwise.

nextafter

Computes the nearest neighbor float values towards the second argument.

Rational routines

lcm

Computes lcm of x1 and x2 elementwise.

gcd

Computes gcd of x1 and x2 elementwise.

Arithmetic operations

add

Adds two arrays elementwise.

reciprocal

Computes 1 / x elementwise.

negative

Takes numerical negative elementwise.

multiply

Multiplies two arrays elementwise.

divide

Elementwise true division (i.e.

power

Computes x1 ** x2 elementwise.

subtract

Subtracts arguments elementwise.

true_divide

Elementwise true division (i.e.

floor_divide

Elementwise floor division (i.e.

fmod

Computes the remainder of C division elementwise.

mod

Computes the remainder of Python division elementwise.

modf

Extracts the fractional and integral parts of an array elementwise.

remainder

Computes the remainder of Python division elementwise.

divmod

Handling complex numbers

angle

Returns the angle of the complex argument.

real(val)

Returns the real part of the elements of the array.

imag(val)

Returns the imaginary part of the elements of the array.

conj

Returns the complex conjugate, element-wise.

conjugate

Returns the complex conjugate, element-wise.

Miscellaneous

convolve(a, v[, mode])

Returns the discrete, linear convolution of two one-dimensional sequences.

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

Clips the values of an array to a given interval.

sqrt

Elementwise square root function.

cbrt

Elementwise cube root function.

square

Elementwise square function.

absolute

Elementwise absolute value function.

sign

Elementwise sign function.

maximum

Takes the maximum of two arrays elementwise.

minimum

Takes the minimum of two arrays elementwise.

fmax

Takes the maximum of two arrays elementwise.

fmin

Takes the minimum of two arrays elementwise.

nan_to_num(x[, out, nan, posinf, neginf])

Elementwise nan_to_num function.

interp(x, xp, fp[, left, right, period])

One-dimensional linear interpolation.