What is the easiest/most optimal way of finding the exponential of a number, say x, in Python? i.e. how can I implement e^x?
            Asked
            
        
        
            Active
            
        
            Viewed 96 times
        
    -2
            
            
        
        Tomerikoo
        
- 18,379
 - 16
 - 47
 - 61
 
        Marioanzas
        
- 1,663
 - 2
 - 10
 - 33
 
- 
                    2That's just "finding the exponential", not finding the "exponential *of a function*". – khelwood Nov 16 '22 at 15:01
 
2 Answers
1
            
            
        The easiest and most optimal way to do e^x in Python is:
from math import exp
print(exp(4))
Output
>>> 54.598150033144236
        Khaled DELLAL
        
- 871
 - 4
 - 16
 
- 
                    2
 - 
                    1Import only `exp` function instead of import the whole `math` module – Khaled DELLAL Nov 16 '22 at 15:12
 
0
            
            
        You can use the math.exp() function from the math module (read the docs).
>>> import math
>>> x = 4
>>> print(math.exp(x))
54.598150033144236
        Marioanzas
        
- 1,663
 - 2
 - 10
 - 33
 
- 
                    1I'm glad you found an answer, but perhaps this question could be deleted rather than answered. – John Coleman Nov 16 '22 at 14:59