arccos

arccos(x, out=None, **kwargs)

Trigonometric inverse cosine, element-wise. The inverse of cos so that, if y = cos(x), then x = arccos(y).

Parameters:
x : ndarray

x-coordinate on the unit circle. For real arguments, the domain is [-1, 1].

out : ndarray, optional

A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

Returns:
angle : ndarray

The angle of the ray intersecting the unit circle at the given x-coordinate in radians [0, pi]. This is a scalar if x is a scalar.

Notes

arccos is a multivalued function: for each x there are infinitely many numbers z such that cos(z) = x. The convention is to return the angle z whose real part lies in [0, pi]. For real-valued input data types, arccos always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag. The inverse cos is also known as acos or cos^-1.

Examples

>>> np.arccos([1, -1])
array([ 0.        ,  3.14159265])