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

Return the reciprocal of the argument, element-wise. Calculates 1/x.

  • x (ndarray or scalar) – The values whose reciprocals are required.

  • out (ndarray or None, optional) – A location into which the result is stored. If provided, it must have the same shape as the input. If not provided or None, a freshly-allocated array is returned.


y – Output array is same shape and type as x. This is a scalar if x is a scalar.

Return type

ndarray or scalar


>>> np.reciprocal(2.)
>>> x = np.array([1, 2., 3.33])
>>> np.reciprocal(x)
array([1.       , 0.5      , 0.3003003])


This function is not designed to work with integers. For integer arguments with absolute value larger than 1 the result is always zero because of the way Python handles integer division. For integer zero the result is an overflow. The output ndarray has the same device as the input ndarray. This function differs from the original numpy.reciprocal in the following aspects:

  • Only support ndarray and scalar now.

  • where argument is not supported.