Computing e^x element-wise in a NumPy array Last Updated : 19 Aug, 2020 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss how to compute e^x for each element of a NumPy array. Example : Input : [1, 3, 5, 7] Output : [2.7182817, 20.085537, 148.41316, 1096.6332] Explanation : e^1 = 2.7182817 e^3 = 20.085537 e^5 = 148.41316 e^7 = 1096.6332 We will be using the numpy.exp() method to calculate the exponential value. Example 1 : Python3 1== # importing the module import numpy as np # creating an array arr = np.array([1, 3, 5, 7]) print("Original array: ") print(arr) # converting array elements into e ^ x res = np.exp(arr) print("\nPrinting e ^ x, element-wise of the said:") print(res) Output : Original array: [1 3 5 7] Printing e ^ x, element-wise of the said: [ 2.71828183 20.08553692 148.4131591 1096.63315843] Example 2 : We can also find the exponential using the math.exp() method. Although it won't take the whole NumPy array at once, we have to pass one element at a time. Python3 # importing the module import numpy as np import math # creating an array arr = np.array([1, 3, 5, 7]) print("Original array: ") print(arr) # converting array elements into e ^ x res = [] for element in arr: res.append(math.exp(element)) print("\nPrinting e ^ x, element-wise of the said:") print(res) Output : Original array: [1 3 5 7] Printing e ^ x, element-wise of the said: [2.718281828459045, 20.085536923187668, 148.4131591025766, 1096.6331584284585] Comment More infoAdvertise with us Next Article Computing e^x element-wise in a NumPy array H hupphurr Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads Creating a one-dimensional NumPy array One-dimensional array contains elements only in one dimension. In other words, the shape of the NumPy array should contain only one value in the tuple. We can create a 1-D array in NumPy using the array() function, which converts a Python list or iterable object. Pythonimport numpy as np # Create a 2 min read Averaging over every N elements of a Numpy Array In this article, we will learn how to find the average over every n element of a NumPy array. For doing our task, we will some inbuilt methods provided by NumPy module which are as follows: numpy.average() to calculate the average i.e the sum of all the numbers divided by the number of elementsnumpy 3 min read Calculate exp(x) - 1 for all elements in a given NumPy array Exponential Function (e^x) is a mathematical function that calculates e raised to the power x where e is an irrational number, approximately 2.71828183. It can be calculated using the numpy.exp() method. This mathematical function helps user to calculate exponential of all the elements in the input 2 min read How to calculate the element-wise absolute value of NumPy array? Let's see the program for finding the element-wise absolute value of NumPy array. For doing this task we are using numpy.absolute() function of NumPy library. This mathematical function helps to calculate the absolute value of each element in the array. Syntax: numpy.absolute(arr, out = None, ufunc 2 min read How to Change a Single Value in a NumPy Array NumPy arrays are a fundamental data structure in Python, widely used for scientific computing and data analysis. They offer a powerful way to perform operations on large datasets efficiently. One common task when working with NumPy arrays is changing a single value within the array. This article wil 6 min read Select an element or sub array by index from a Numpy Array The elements of a NumPy array are indexed just like normal arrays. The index of the first element will be 0 and the last element will be indexed n-1, where n is the total number of elements. Selecting a single element from a NumPy array Each element of these ndarrays can be accessed using its index 2 min read How to get element-wise true division of an array using Numpy? 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-w 2 min read Different Ways to Create Numpy Arrays in Python Creating NumPy arrays is a fundamental aspect of working with numerical data in Python. NumPy provides various methods to create arrays efficiently, catering to different needs and scenarios. In this article, we will see how we can create NumPy arrays using different ways and methods. Ways to Create 3 min read Find the sum and product of a NumPy array elements In this article, let's discuss how to find the sum and product of NumPy arrays. Sum of the NumPy array Sum of NumPy array elements can be achieved in the following ways Method #1:  Using numpy.sum() Syntax: numpy.sum(array_name, axis=None, dtype=None, out=None, keepdims=<no value>, initial= 5 min read Find the memory size of a NumPy array In this post, we will see how to find the memory size of a NumPy array. So for finding the memory size of a NumPy array we are using following methods: Using size and itemsize attributes of NumPy array size: This attribute gives the number of elements present in the NumPy array. itemsize: This attri 2 min read Like