numpy.reciprocal() in Python Last Updated : 04 Dec, 2020 Comments Improve Suggest changes Like Article Like Report The numpy.reciprocal() is a mathematical function that is used to calculate reciprocal of all the elements in the input array. Syntax :numpy.reciprocal(x, /, out=None, *, where=True) Parameters : x[array_like]: Input array or object whose elements needed to test. 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. **kwargs : Allows to pass keyword variable length of argument to a function. Used when we want to handle named argument in a function. where [array_like, optional]: True value means to calculate the universal functions(ufunc) at that position, False value means to leave the value in the output alone. Return : y : ndarray. This is a scalar if x is a scalar. Note: 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. Code #1 : Python3 # Python3 code demonstrate reciprocal() function # importing numpy import numpy as np in_num = 2.0 print ("Input number : ", in_num) out_num = np.reciprocal(in_num) print ("Output number : ", out_num) Output : Input number : 2.0 Output number : 0.5 Code #2 : Python3 # Python3 code demonstrate reciprocal() function # importing numpy import numpy as np in_arr = [2., 3., 8.] print ("Input array : ", in_arr) out_arr = np.reciprocal(in_arr) print ("Output array : ", out_arr) Output : Input array : [2.0, 3.0, 8.0] Output array : [ 0.5 0.33333333 0.125 ] Code #3 : Exception in reciprocal() function. Result is always zero. Python3 # Python3 code demonstrate Exception in reciprocal() function # importing numpy import numpy as np in_arr = [2, 3, 8] print ("Input array : ", in_arr) out_arr = np.reciprocal(in_arr) print ("Output array : ", out_arr) Output : Input array : [2, 3, 8] Output array : [0 0 0] Comment More infoAdvertise with us Next Article numpy.reciprocal() in Python jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads numpy.remainder() in Python numpy.remainder() is another function for doing mathematical operations in numpy.It returns element-wise remainder of division between two array arr1 and arr2 i.e. arr1 % arr2 .It returns 0 when arr2 is 0 and both arr1 and arr2 are (arrays of) integers. Syntax : numpy.remainder(arr1, arr2, /, out=No 2 min read numpy.rint() in Python The numpy.rint() is a mathematical function that rounds elements of the array to the nearest integer. Syntax : numpy.rint(x[, out]) = ufunc ârintâ) Parameters : array : [array_like] Input array. Return : An array with all array elements being rounded off, having same type and shape as input. Code #1 2 min read numpy.trunc() in Python The numpy.trunc() is a mathematical function that returns the truncated value of the elements of array. The trunc of the scalar x is the nearest integer i which, closer to zero than x. This simply means that, the fractional part of the signed number x is discarded by this function. Syntax : numpy.tr 2 min read numpy.sqrt() in Python numpy.sqrt() in Python is a function from the NumPy library used to compute the square root of each element in an array or a single number. It returns a new array of the same shape with the square roots of the input values. The function handles both positive and negative numbers, returning NaN for n 2 min read sympy.stats.Reciprocal() in Python With the help of sympy.stats.Reciprocal() method, we can get the continuous random variable which represents the Reciprocal distribution. Syntax : sympy.stats.Reciprocal(name, a, b) Where, a and b are real number and a, b > 0. Return : Return the continuous random variable. Example #1 : In this e 1 min read numpy.true_divide() in Python (arr1, arr22, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, ufunc 'true_divide') : Array element from first array is divided by the elements from second array(all happens element-wise). Both arr1 and arr2 must have same shape. Returns true division element-wise. Python trad 3 min read numpy.mod() in Python numpy.mod() is another function for doing mathematical operations in numpy.It returns element-wise remainder of division between two array arr1 and arr2 i.e. arr1 % arr2 .It returns 0 when arr2 is 0 and both arr1 and arr2 are (arrays of) integers. Syntax : numpy.mod(arr1, arr2, /, out=None, *, where 2 min read Python | Tensorflow reciprocal() method Tensorflow is an open-source machine learning library developed by Google. One of its applications is to develop deep neural networks. The module tensorflow.math provides support for many basic mathematical operations. Function tf.reciprocal() [alias tf.math.reciprocal ] provides support to calculat 2 min read numpy.divide() in Python numpy.divide(arr1, arr2, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : Array element from first array is divided by elements from second element (all happens element-wise). Both arr1 and arr2 must have same shape and element in arr2 must not be zero; otherwise it will 3 min read numpy.invert() in Python numpy.invert() function is used to Compute the bit-wise Inversion of an array element-wise. It computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. For signed integer inputs, the twoâs complement is returned. In a twoâs-complement system negative num 2 min read Like