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
🌐
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 - 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 ...
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.1 Manual
Calculate 2**x for all elements in the array. ... 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\).
🌐
NumPy
numpy.org › doc › stable › reference › constants.html
Constants — NumPy v2.4 Manual
e = 2.71828182845904523536028747135266249775724709369995... ... IEEE 754 floating point representation of (positive) infinity.
🌐
Medium
medium.com › @amit25173 › numpy-exponential-8e099b664794
numpy exponential. I understand that learning data science… | by Amit Yadav | Medium
January 25, 2025 - Sounds fancy, but let’s see it in action—you’ll understand it much faster with examples. ... 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 compute e¹, which is approximately 2.718.
🌐
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.

🌐
Replit
replit.com › home › discover › how to use 'e' in python
How to use 'e' in Python
While it's a great way to understand the underlying math, you should stick with the built-in math.exp() for practical applications. It's already optimized for performance and precision. Beyond basic calculations, e is fundamental to advanced computing, enabling efficient array operations in NumPy and unlocking the complexities of Euler's identity.
🌐
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 in an array using np.exp. Test the function on arrays with both positive and negative values to verify the exponential behavior.
Find elsewhere
🌐
Codecademy
codecademy.com › docs › python:numpy › math methods › .exp()
Python:NumPy | Math Methods | .exp() | Codecademy
April 17, 2025 - The exponential function, np.exp(x), returns e^x, where e is Euler’s number with an approximate value of 2.71828. As a part of NumPy, a widely used library for numerical computing in Python, this function is particularly useful in scientific computations where exponential functions are common.
🌐
pythontutorials
pythontutorials.net › blog › numpye
Mastering `numpy.e` in Python: A Comprehensive Guide — pythontutorials.net
... The constant e is an irrational ... on infinitely without repeating. It is defined as the limit: [ \lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e ]...
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › exp
Python Numpy exp() - Calculate Exponential | Vultr Docs
November 18, 2024 - Import the NumPy library. Apply the exp() function to a single number. ... This code computes e raised to the power of 2 (e²). The result is approximately 7.389056, showcasing how exp() calculates exponential values.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.4 Manual
Calculate 2**x for all elements in the array. ... 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\).
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.5.dev0 Manual
Calculate 2**x for all elements in the array. ... 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\).
🌐
NumPy
numpy.org › doc › 1.13 › reference › generated › numpy.exp.html
numpy.exp — NumPy v1.13 Manual
It is approximately 2.718281, and ... , then . For real input, exp(x) is always positive. For complex arguments, x = a + ib, we can write . The first term, , is already known (it is the real argument, described above). The second term, , is , a function with magnitude 1 and a periodic ...
🌐
AskPython
askpython.com › home › numpy exp – a complete guide
NumPy exp - A Complete Guide - AskPython
February 16, 2023 - Hello and welcome to this tutorial on Numpy exp. In this tutorial, we will be learning about the NumPy exp() method and also seeing a lot of examples
🌐
datagy
datagy.io › home › numpy › numpy exponential: using the numpy.exp() function
NumPy Exponential: Using the NumPy.exp() Function • datagy
December 30, 2022 - In this tutorial, you’ll learn how to use the NumPy exponential function, np.exp(). The function raises the Euler’s constant, e, to a given power. Because Euler’s constant has many practical applications in science, math, and deep learning, being able to work with this function in meaningful ...
🌐
TutorialsPoint
tutorialspoint.com › home › numpy › numpy exponential functions
NumPy Exponential Functions
March 5, 2015 - In mathematics, the natural logarithm of a number is the exponent to which e must be raised to obtain that number. The numpy.log() function is useful for solving equations that involve exponential growth or decay.
🌐
Programiz
programiz.com › python-programming › numpy › methods › exp
NumPy exp() (With Examples)
The exp() function is used to calculate the exponential values of the elements in an array. The exp() function is used to calculate the exponential values of the elements in an array. Example import numpy as np array1 = np.array([1, 2, 3, 4, 5]) # use of exp() to calculate the exponential values ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-exp-python
numpy.exp() in Python - GeeksforGeeks
March 29, 2023 - It is used when we want to handle ... at that position, False value means to leave the value in the output alone. ... An array with exponential of all elements of input array. ... # Python program explaining # exp() function import numpy as np in_array = [1, 3, 5] print ("Input ...