MCPcopy Create free account
hub / github.com/numpy/numpy / arccos

Function arccos

numpy/lib/scimath.py:487–528  ·  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

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

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