NumPy - Arithmetic Operations Last Updated : 23 Jul, 2025 Suggest changes Share Like Article Like Report Arithmetic operations are used for numerical computation and we can perform them on arrays using NumPy. With NumPy we can quickly add, subtract, multiply, divide and get power of elements in an array. NumPy performs these operations even with large amounts of data. In this article, we’ll see at the basic arithmetic functions in NumPy and show how to use them for simple calculations.1. Addition of ArraysAddition is an arithmetic operation where the corresponding elements of two arrays are added together. In NumPy the addition of two arrays is done using the np.add() function. Python import numpy as np a = np.array([5, 72, 13, 100]) b = np.array([2, 5, 10, 30]) add_ans = np.add(a, b) print(add_ans) Output:[ 7 77 23 130]2. Subtraction of ArraysWe can subtract two arrays element-wise using the np.subtract() function. This function subtracts each element of the second array from the corresponding element in the first array. Python import numpy as np a = np.array([5, 72, 13, 100]) b = np.array([2, 5, 10, 30]) sub_ans = np.subtract(a, b) print(sub_ans) Output:[ 3 67 3 70]3. Multiplication of ArraysMultiplication in NumPy can be done element-wise using the np.multiply() function. This multiplies corresponding elements of two arrays. Python import numpy as np a = np.array([5, 72, 13, 100]) b = np.array([2, 5, 10, 30]) mul_ans = np.multiply(a, b) print(mul_ans) Output:[ 10 360 130 3000]4. Division of ArraysDivision is another important operation that is performed element-wise using the np.divide() function. This divides each element of the first array by the corresponding element in the second array. Python import numpy as np a = np.array([5, 72, 13, 100]) b = np.array([2, 5, 10, 30]) div_ans = np.divide(a, b) print(div_ans) Output:[ 2.5 14.4 1.3 3.33333333]5. Exponentiation (Power)It allows us to raise each element in an array to a specified power. In NumPy, this can be done using the np.power() function. Python import numpy as np a = np.array([5, 72, 13, 100]) b = np.array([2, 5, 10, 30]) pow_ans = np.power(a, b) print(pow_ans) Output:[25 1934917632 137858491849 1152921504606846976]6. Modulus OperationIt finds the remainder when one number is divided by another. In NumPy, you can use the np.mod() function to calculate the modulus element-wise between two arrays. Python import numpy as np a = np.array([5, 72, 13, 100]) b = np.array([2, 5, 10, 30]) mod_ans = np.mod(a, b) print(mod_ans) Output:[ 1 2 3 10]With these basic arithmetic functions in NumPy we can efficiently perform calculations on arrays. A apurva__007 Follow Article Tags : Numpy Python-numpy Python numpy-Mathematical Function Explore NumPy Tutorial - Python Library 3 min read IntroductionNumPy Introduction 7 min read Python NumPy 6 min read NumPy Array in Python 2 min read Basics of NumPy Arrays 4 min read Numpy - ndarray 3 min read Data type Object (dtype) in NumPy Python 3 min read Creating NumPy ArrayNumpy - Array Creation 5 min read numpy.arange() in Python 2 min read numpy.zeros() in Python 2 min read NumPy - Create array filled with all ones 2 min read NumPy - linspace() Function 2 min read numpy.eye() in Python 2 min read Creating a one-dimensional NumPy array 2 min read How to create an empty and a full NumPy array 2 min read Create a Numpy array filled with all zeros - Python 2 min read How to generate 2-D Gaussian array using NumPy? 2 min read How to create a vector in Python using NumPy 4 min read Python - Numpy fromrecords() method 2 min read NumPy Array ManipulationNumPy Copy and View of Array 4 min read How to Copy NumPy array into another array? 2 min read Appending values at the end of an NumPy array 4 min read How to swap columns of a given NumPy array? 4 min read Insert a new axis within a NumPy array 4 min read numpy.hstack() in Python 2 min read numpy.vstack() in python 2 min read Joining NumPy Array 3 min read Combining a One and a Two-Dimensional NumPy Array 3 min read Numpy np.ma.concatenate() method-Python 2 min read Numpy dstack() method-Python 2 min read Splitting Arrays in NumPy 6 min read How to compare two NumPy arrays? 2 min read Find the union of two NumPy arrays 2 min read Find unique rows in a NumPy array 3 min read Numpy np.unique() method-Python 2 min read numpy.trim_zeros() in Python 2 min read Matrix in NumPyMatrix manipulation in Python 4 min read numpy matrix operations | empty() function 1 min read numpy matrix operations | zeros() function 2 min read numpy matrix operations | ones() function 2 min read numpy matrix operations | eye() function 2 min read numpy matrix operations | identity() function 1 min read Adding and Subtracting Matrices in Python 2 min read Matrix Multiplication in NumPy 2 min read Numpy ndarray.dot() function | Python 2 min read NumPy | Vector Multiplication 4 min read How to calculate dot product of two vectors in Python? 3 min read Multiplication of two Matrices in Single line using Numpy in Python 3 min read Numpy np.eigvals() method - Python 1 min read How to Calculate the Determinant of a Matrix using NumPy 2 min read Python | Numpy matrix.transpose() 3 min read Python | Numpy matrix.var() 1 min read Compute the inverse of a matrix using NumPy 2 min read Operations on NumPy ArrayNumpy | Binary Operations 8 min read Numpy | Mathematical Function 9 min read Numpy - String Functions & Operations 5 min read Reshaping NumPy ArrayReshape NumPy Array 5 min read Python | Numpy matrix.resize() 1 min read Python | Numpy matrix.reshape() 1 min read NumPy Array Shape 2 min read Change the dimension of a NumPy array 3 min read numpy.ndarray.resize() function - Python 1 min read Flatten a Matrix in Python using NumPy 1 min read numpy.moveaxis() function | Python 2 min read numpy.swapaxes() function - Python 2 min read Python | Numpy matrix.swapaxes() 1 min read numpy.vsplit() function | Python 2 min read numpy.hsplit() function | Python 2 min read Numpy MaskedArray.reshape() function | Python 3 min read Python | Numpy matrix.squeeze() 1 min read Indexing NumPy ArrayBasic Slicing and Advanced Indexing in NumPy 5 min read numpy.compress() in Python 2 min read Accessing Data Along Multiple Dimensions Arrays in Python Numpy 3 min read How to Access Different Rows of a Multidimensional NumPy Array 2 min read numpy.tril_indices() function | Python 1 min read Arithmetic operations on NumPyArrayNumPy Array Broadcasting 6 min read Estimation of Variable | set 1 3 min read Python: Operations on Numpy Arrays 3 min read How to use the NumPy sum function? 4 min read numpy.divide() in Python 3 min read numpy.inner() in python 1 min read Absolute Deviation and Absolute Mean Deviation using NumPy | Python 3 min read Calculate standard deviation of a Matrix in Python 2 min read numpy.gcd() in Python 2 min read Linear Algebra in NumPy ArrayNumpy | Linear Algebra 6 min read Get the QR factorization of a given NumPy array 2 min read How to get the magnitude of a vector in NumPy? 3 min read How to compute the eigenvalues and right eigenvectors of a given square array using NumPY? 2 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like