How to get element-wise true division of an array using Numpy? Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report See More True Division in Python3 returns a floating result containing the remainder of the division. To get the true division of an array, NumPy library has a function numpy.true_divide(x1, x2). This function gives us the value of true division done on the arrays passed in the function. To get the element-wise division we need to enter the first parameter as an array and the second parameter as a single element. Syntax: np.true_divide(x1,x2) Parameters: x1: The dividend arrayx2: divisor (can be an array or an element) Return: If inputs are scalar then scalar; otherwise array with arr1 / arr2(element- wise) i.e. true division Now, let's see an example: Example 1: Python3 # import library import numpy as np # create 1d-array x = np.arange(5) print("Original array:", x) # apply true division # on each array element rslt = np.true_divide(x, 4) print("After the element-wise division:", rslt) Output : Original array: [0 1 2 3 4] After the element-wise division: [0. 0.25 0.5 0.75 1. ] The time complexity of applying true division on each array element using NumPy's true_divide() function is also O(n), since we're applying a single operation to each element in the array. In this case, since the size of the array is 5, the time complexity of this operation is O(5) = O(1). The auxiliary space complexity of this code is O(n), since we're creating a new array rslt with the same number of elements as the original array x. However, since the size of the array is fixed at 5, the space complexity of this code is O(5) = O(1). Example 2: Python3 # import library import numpy as np # create a 1d-array x = np.arange(10) print("Original array:", x) # apply true division # on each array element rslt = np.true_divide(x, 3) print("After the element-wise division:", rslt) Output: Original array: [0 1 2 3 4 5 6 7 8 9] After the element-wise division: [0. 0.33333333 0.66666667 1. 1.33333333 1.66666667 2. 2.33333333 2.66666667 3. ] Time complexity: O(n), where n is the length of the array x. Auxiliary space: O(n), as a new array of size n is created to store the result of the element-wise division. Create Quiz Comment A aakashsaxena14 Follow 0 Improve A aakashsaxena14 Follow 0 Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 3 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 3 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 3 min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 6 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Build a REST API using Flask - Python 3 min read Building a Simple API with Django REST Framework 3 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like