The **numpy.reciprocal()**** function** in NumPy is used to compute the reciprocal of an argument `x`

, which has been passed to it.

The reciprocal of a number is the value obtained when `1`

is divided by that number.

Mathematically, this is represented as follows:

numpy.reciprocal(x) =

numpy.reciprocal(x, /, out=None, *, where=True)

The syntax for the numpy.reciprocal() function

The `numpy.reciprocal()`

function takes the following parameter values.

: This represents input array and is a required parameter.**x**

: This represents the location where the result is stored and is an optional parameter.**out**

: This is the condition over which the input is being broadcast. The resulting array will be set to the**where**`ufunc`

result at a given location where this condition is`True`

. Otherwise, the resulting array will retain its original value. This is an optional parameter.

: This represents other keyword arguments and is an optional parameter.****kwargs**

import numpy as np# creating an arrayx = np.array([0.5, 1, 2])# implementing the numpy.reciprocal() functionmyarray = np.reciprocal(x)print(myarray)

- Line 1: We import the
`numpy`

module. - Line 4: We create an array
`x`

using the`array()`

method. - Line 7: We implement the
`np.reciprocal()`

function on the array. The result is assigned to a variable,`myarray`

. - Line 9: We print the
`myarray`

variable.

TRENDING TOPICS