MCPcopy Index your code
hub / github.com/numpy/numpy / arccos

Function arccos

numpy/lib/_scimath_impl.py:496–538  ·  view source on GitHub ↗

Compute the inverse cosine of x. Return the "principal value" (for a description of this, see `numpy.arccos`) of the inverse cosine of `x`. For real `x` such that `abs(x) <= 1`, this is a real number in the closed interval :math:`[0, \\pi]`. Otherwise, the complex principle va

(x)

Source from the content-addressed store, hash-verified

494@set_module('numpy.lib.scimath')
495@array_function_dispatch(_unary_dispatcher)
496def arccos(x):
497 """
498 Compute the inverse cosine of x.
499
500 Return the "principal value" (for a description of this, see
501 `numpy.arccos`) of the inverse cosine of `x`. For real `x` such that
502 `abs(x) <= 1`, this is a real number in the closed interval
503 :math:`[0, \\pi]`. Otherwise, the complex principle value is returned.
504
505 Parameters
506 ----------
507 x : array_like or scalar
508 The value(s) whose arccos is (are) required.
509
510 Returns
511 -------
512 out : ndarray or scalar
513 The inverse cosine(s) of the `x` value(s). If `x` was a scalar, so
514 is `out`, otherwise an array object is returned.
515
516 See Also
517 --------
518 numpy.arccos
519
520 Notes
521 -----
522 For an arccos() that returns ``NAN`` when real `x` is not in the
523 interval ``[-1,1]``, use `numpy.arccos`.
524
525 Examples
526 --------
527 >>> import numpy as np
528 >>> np.set_printoptions(precision=4)
529
530 >>> np.emath.arccos(1) # a scalar is returned
531 0.0
532
533 >>> np.emath.arccos([1,2])
534 array([0.-0.j , 0.-1.317j])
535
536 """
537 x = _fix_real_abs_gt_1(x)
538 return nx.arccos(x)
539
540
541@set_module('numpy.lib.scimath')

Callers 3

test_testUfuncs1Method · 0.90
test_basic_ufuncsMethod · 0.85

Calls 1

_fix_real_abs_gt_1Function · 0.85

Tested by 3

test_testUfuncs1Method · 0.72
test_basic_ufuncsMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…