NumPy Exponential Function in Python

Hi, guys today we have got a very easy topic i.e exponential function in Numpy – Python.

So let’s start.

The first question comes in our mind that what is the Exponential Function and what it does?

So as we know about the exponents, this Exponential Function in Numpy is used to find the exponents of  ‘e’.

We know that the value of  ‘e’ is ‘2.71828183’.

If we need to find the exponential of a given array or list, the code is mentioned below.

import numpy as np
#create a list

Run this code online

The output of the following code is:-

Numpy Exponential Function in Python

import numpy as np


Run this program online

The output of the following code is:-

numpy.exp() in Python

Now the above things are the basics.

Here is the complete syntax of the numpy.exp

numpy.exp(array, out = None, where = True, casting = ‘same_kind’, order = ‘K’, dtype = None)

numpy.exp() with matplotlib

As we know we can plot the graph of ‘e’. Python gives as a special module matplotlib.pyplot.

By using this module we can plot the graph of the ‘e’

Here is the example code for that.

import numpy as np
import matplotlib.pyplot as plt
x= np.array([1,2,3,4,5])

The output of the code is a graph shown below.

numpy.exp() with matplotlib

Now there is a question arises that what to do if we have to plot two graphs together.

So, no need to worry because we can plot n numbers of the graphs using the module I have mentioned above.

import numpy as np
import matplotlib.pyplot as plt
x= np.array([1,3,5])
plt.xlabel("X Axis--------->")
plt.ylabel("Y Axis--------->")

Here is the output of the following code.

Numpy exp in Python

So, I hope you have understood this topic very well.

Leave a Reply

Your email address will not be published. Required fields are marked *