The exponential function is e^x where e is a mathematical constant called Euler's number, approximately 2.718281. This value has a close mathematical relationship with pi and the slope of the curve e^x is equal to its value at every point. np.exp() calculates e^x for each value of x in your input array.

Answer from machine yearning on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › constants.html
Constants — NumPy v2.4 Manual
e = 2.71828182845904523536028747135266249775724709369995... ... IEEE 754 floating point representation of (positive) infinity.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.1 Manual
The irrational number e is also known as Euler’s number. It is approximately 2.718281, and is the base of the natural logarithm, ln (this means that, if \(x = \ln y = \log_e y\), then \(e^x = y\). For real input, exp(x) is always positive.
🌐
Reddit
reddit.com › r/learnpython › simulating stock data using numpy.exp (eulers number, e)
r/learnpython on Reddit: Simulating stock data using numpy.exp (Eulers number, e)
February 20, 2023 -

I came across this code example:

import plotly.graph_objects as go
import numpy as np np.random.seed(42) 

# Simulate data 
returns = np.random.normal(0.01, 0.2, 100)
price = 100 * np.exp(returns.cumsum()) 
time = np.arange(100)

I read up on the use of the natural logarithm and Euler's number here: https://lucaslouca.com/Why-Use-Logarithmic-Returns-In-Time-Series-Modelling/

I'm not quite sure why it's good to use Euler's number here.

My thinking so far is this:

multiplying with 100 simply makes the data start at index 100 instead of at index 1.

I see that using the exp function allows a simple summation of the returns. But on the other hand, if we see the returns as percentage based (0.1 meaning 10 %) then using this method will distort the data - since exp(0.1) = 1.10517

Curious if anyone can explain this.

I realize it's as much math and economics as its programming, but I've seen it used before and in this particular example there were no comments in the relevant section of the code.

🌐
GeeksforGeeks
geeksforgeeks.org › python › computing-ex-element-wise-in-a-numpy-array
Computing e^x element-wise in a NumPy array - GeeksforGeeks
July 15, 2025 - 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.
🌐
NumPy
numpy.org › doc › 1.13 › reference › generated › numpy.exp.html
numpy.exp — NumPy v1.13 Manual
The irrational number e is also known as Euler’s number. It is approximately 2.718281, and is the base of the natural logarithm, ln (this means that, if , then . For real input, exp(x) is always positive.
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.3 Manual
The irrational number e is also known as Euler’s number. It is approximately 2.718281, and is the base of the natural logarithm, ln (this means that, if \(x = \ln y = \log_e y\), then \(e^x = y\). For real input, exp(x) is always positive.
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-exp-python
numpy.exp() in Python - GeeksforGeeks
March 29, 2023 - It is 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.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › home › numpy › numpy exponential functions
NumPy Exponential Functions
March 5, 2015 - In NumPy, exponential functions are provided to calculate powers of Euler's number (e), and to perform operations involving exponential growth or decay. NumPy provides the numpy.exp() function to calculate exponentials. In this tutorial, we will explore how to use NumPy's exponential functions to calculate powers of e, and perform other related operations.
🌐
Medium
medium.com › @amit25173 › numpy-exponential-8e099b664794
numpy exponential. I understand that learning data science… | by Amit Yadav | Medium
January 25, 2025 - ... Let’s start small: calculating the exponential of a single number. import numpy as np # Example: Calculate the exponential of a number result = np.exp(1) print(result) # Output: 2.718281828459045 · In this example, we asked Python to ...
🌐
Codecademy
codecademy.com › docs › python:numpy › math methods › .exp()
Python:NumPy | Math Methods | .exp() | Codecademy
April 17, 2025 - where: The condition to be checked. When True, the function is applied and when False, the original values are retained. casting: Controls the type of data casting that may occur. order: Defines the memory layout order of the result: C for C-order, F for Fortran-order, A for automatic, and K for input layout. dtype: Overrides the data type of the resultant array. ... The np.exp() function returns a new array containing the exponential of all elements in the input array.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.4 Manual
The irrational number e is also known as Euler’s number. It is approximately 2.718281, and is the base of the natural logarithm, ln (this means that, if \(x = \ln y = \log_e y\), then \(e^x = y\). For real input, exp(x) is always positive.
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › exp
Python Numpy exp() - Calculate Exponential | Vultr Docs
November 18, 2024 - ... This snippet calculates e raised ... point numbers. Define a NumPy array with several numbers. Use the exp() function to compute the exponential for each element....
🌐
Programiz
programiz.com › python-programming › numpy › constants
Numpy Constants (With Examples)
However, this example makes no sense because that's not how we use the constant e in real life. We usually use the constant e with the function exp(). e is the base of exponential function, exp(x), which is equivalent to e^x.
🌐
Programiz
programiz.com › python-programming › numpy › methods › exp
NumPy exp() (With Examples)
Become a certified Python programmer. Try Programiz PRO! ... The exp() function is used to calculate the exponential values of the elements in an array. import numpy as np array1 = np.array([1, 2, 3, 4, 5])
🌐
AskPython
askpython.com › home › numpy exp – a complete guide
NumPy exp - A Complete Guide - AskPython
February 16, 2023 - The exp method in NumPy is a function that returns the exponential of all the elements of the input array. This means that it calculates e^x for each x in the input array. Here, e is the Euler’s constant and has a value of approximately 2.718281.
🌐
ImportPython
importpython.com › home › exponentially easy: mastering how to write ‘e’ in python
How to Write 'e' in Python: A Beginner's Tutorial
March 14, 2024 - This function is particularly useful for performing element-wise exponential calculations across large datasets; Logarithmic Function: The numpy.log() function calculates the natural logarithm of an array or scalar value, with ‘e’ as the base. It offers enhanced flexibility and performance compared to native Python functions, especially when dealing with large datasets;
🌐
Spark By {Examples}
sparkbyexamples.com › home › numpy › how to use numpy exponential function
How to Use NumPy Exponential Function - Spark By {Examples}
March 27, 2024 - To calculate the exponential of a single value in Python using NumPy, you can use the np.exp() function.
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-math-exercise-31.php
NumPy: Compute e^x, element-wise of a given array - w3resource
The exponential function raises the constant e to the power of each element in x, so the resulting array r will have the values [2.718282 , 7.389056 , 20.085537, 54.598152]. ... Implement a function that computes the exponential of each element ...