AppDividend
Latest Code Tutorials

# np.exp: How to Find Exponential Value of an Array

The exp() function is defined under a numpy library that can import numpy as np. We can create multidimensional arrays and derive other mathematical statistics with the help of numpy.

## np.exp

The np.exp() is a mathematical function used to find the exponential values of all the elements present in the input array. The numpy exp() function takes three arguments which are input array, output array, where, and **kwargs, and returns an array containing all the exponential values of the input array.

To find the exponential value of the input array in Python, use the numpy exp() method.

### Syntax

```numpy.exp(input array,output array( to store the results,optional),where,**kwargs)
```

### Parameters

The np.exp() function takes one required parameter, the input array, and all the other parameters are optional.

The first parameter is an input array, for which we have to find the exponential values.

The second parameter is the output array placed with the result.

The third parameter is used to broadcast over the input values.

The fourth and last parameter is the **kwargs, which allows us to pass the keyword of variable length to the argument of a function.

### Return Value

The function returns an array containing all the exponential values of the input array.

### Example programs on exp() method in Python

Write a program to show the working of the exp() function in Python.

```# app.py

import numpy as np

a = [1, 2, 3, 4]
b = [53, 22, 11]
print("Input array: ", a, "\n")
print("Exponential values: ", np.exp(a), "\n")
print("Input array: ", b, "\n")
print("Exponential values: ", np.exp(b), "\n")
```

#### Output

```python3 app.py
Input array:  [1, 2, 3, 4]

Exponential values:  [ 2.71828183  7.3890561  20.08553692 54.59815003]

Input array:  [53, 22, 11]

Exponential values:  [1.04137594e+23 3.58491285e+09 5.98741417e+04]```

In this example, we have seen that by passing an input array, we are getting an output array consisting of the exponential values of the input array elements.

#### Write a program to show the graphical representation of the exp() function using a line graph.

See the following code.

```# app.py

import numpy as np
import matplotlib.pyplot as plt

a = [1, 1.5, 2.0, 2.5, 3, 3.5]
b = np.exp(a)

y = [1, 2, 3, 4, 5, 6]

plt.plot(b, y, color='black', marker="o")
plt.title("numpy.exp()")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
```

#### Output

The above figure shows the curve of exp() values of an input array concerning the axes.

That’s it for the np.exp() function in the Python tutorial.