Mathematical functions#

The reference documentation is generated from numpy files, see also API reference on Numpy

Trigonometric functions#

All trigonometric functions use radians when an angle is called for. The ratio of degrees to radians is 180^{\circ}/\pi.

sin

sin(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

cos

cos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

tan

tan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

arcsin

arcsin(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

arccos

arccos(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

arctan

arctan(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

degrees

degrees(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

radians

radians(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

deg2rad

deg2rad(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

rad2deg

rad2deg(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

Hyperbolic functions#

sinh

sinh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

cosh

cosh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

tanh

tanh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

arcsinh

arcsinh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

arccosh

arccosh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

arctanh

arctanh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

Rounding#

rint

rint(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

floor

floor(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

ceil

ceil(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

trunc

trunc(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

Sums, products, differences#

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

Sum of array elements over a given axis.

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

Return the cumulative product of 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.

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

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

Exponents and logarithms#

exp

exp(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

expm1

expm1(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

exp2

exp2(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

log

log(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

log10

log10(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

Arithmetic operations#

add

add(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

multiply

multiply(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

Miscellaneous#

convolve(a, v[, mode])

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

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

Clip (limit) the values in an array.

sqrt

sqrt(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

square

square(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

absolute

absolute(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

fabs

fabs(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

sign

sign(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

maximum

maximum(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

minimum

minimum(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

dtype(dtype[, align, copy])

Create a data type object.

dtype.itemsize

The element size of this data-type object.

Tip

The Python function max() will find the maximum over a one-dimensional array, but it will do so using a slower sequence interface. The reduce method of the maximum ufunc is much faster. Also, the max() method will not give answers you might expect for arrays with greater than one dimension. The reduce method of minimum also allows you to compute a total minimum over an array.

Warning

the behavior of maximum(a, b) is different than that of max(a, b). As a ufunc, maximum(a, b) performs an element-by-element comparison of a and b and chooses each element of the result according to which element in the two arrays is larger. In contrast, max(a, b) treats the objects a and b as a whole, looks at the (total) truth value of a > b and uses it to return either a or b (as a whole). A similar difference exists between minimum(a, b) and min(a, b).

Array operations#

linalg.inv(a)

Compute the inverse of a matrix.

std(a[, axis, dtype, out, ddof, keepdims, ...])

Compute the standard deviation along the specified axis.

dot(a, b[, out])

Dot product of two arrays.

outer(a, b[, out])

Compute the outer product of two vectors.

mean(a[, axis, dtype, out, keepdims, where])

Compute the arithmetic mean along the specified axis.

putmask(a, mask, values)

Changes elements of an array based on conditional and input values.

shape(a)

Return the shape of an array.

ndim(a)

Return the number of dimensions of an array.

size(a[, axis])

Return the number of elements along a given axis.

Random functions#

random.rand(d0, d1, ..., dn)

Random values in a given shape.

random.randn(d0, d1, ..., dn)

Return a sample (or samples) from the "standard normal" distribution.

random.random([size])

Return random floats in the half-open interval [0.0, 1.0).

random.standard_normal([size])

Draw samples from a standard Normal distribution (mean=0, stdev=1).

random.uniform([low, high, size])

Draw samples from a uniform distribution.

Sorting, searching#

searchsorted(a, v[, side, sorter])

Find indices where elements should be inserted to maintain order.

where(condition, [x, y], /)

Return elements chosen from x or y depending on condition.