Universal functions in Numpy are simple mathematical functions. It is just a term that we gave to mathematical functions in the Numpy library. Numpy provides various universal functions that cover a wide variety of operations.
The detailed documentation for each and every function is listed in the official website in the URL(https://numpy.org/doc/stable/reference/ufuncs.html). If want you can learn complete functions.
Here is simple python example which illustrates you how to use these universal functions
import numpy as np arr1 = np.array([10, 11, 12, 13, 14, 15]) arr2 = np.array([20, 21, 22, 23, 24, 25]) addition = np.add(arr1, arr2) print("1.addition is",addition) sub = np.subtract(arr2, arr1) print("2.subtraction is",sub) multi = np.multiply(arr1, arr2) print("3.Multiplication is",multi) Div = np.divide(arr1, arr2) print("4.Division is",Div) arr3 = np.array([2, 2, 3, 4, 5, 6]) arr4 = np.array([3, 5, 6, 8, 2, 3]) pow = np.power(arr3, arr4) print("5.powers of array3 rise array4",pow)
The Output is as follows
1.addition is [30 32 34 36 38 40] 2.subtraction is [10 10 10 10 10 10] 3.Multiplication is [200 231 264 299 336 375] 4.Division is [0.5 0.52380952 0.54545455 0.56521739 0.58333333 0.6 ] 5.powers of array3 rise array4 [ 8 32 729 65536 25 216]
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.