Printing exponential value of vector/matrix elements using numpy.exp() | Linear Algebra using Python

Linear Algebra using Python | numpy.exp(x) Function: Here, we are going to learn how to print the exponential value of vector/matrix elements?
Submitted by Anuj Singh, on May 25, 2020

Prerequisite:

Numpy is the library of function that helps to construct or manipulate matrices and vectors. The function numpy.exp(x) is a function used for generating a matrix /vector /variable with the e value of b x (as ex). This is an element-wise operation where each element in numpy.exp(x) corresponds ex to that element in x.

Syntax:

    numpy.exp(x)

Input parameter(s):

  • x – could be a matrix or vector or a variable.

Return value:

A Matrix or vector or a variable of the same dimensions as input x with ex values at each entry.

Applications:

  1. Machine Learning
  2. Neural Network
  3. General Mathematics

Python code to print the exponential value of vector/matrix elements

# Linear Algebra Learning Sequence
# Element wise exponential

import numpy as np

# Use of np.array() to define an Vector
V = np.array([3,6,8])
print("The Vector A : ",V)

VV = np.array([[3,63,78],[315,32,42]])
print("\nThe Vector B : \n",VV)
    
print("\nexp(A) : ", np.exp(V))
print("\nexp(B) : ", np.exp(VV))
print("\ne^3 : ", np.exp(3))

Output:

The Vector A :  [3 6 8]

The Vector B : 
 [[  3  63  78]
 [315  32  42]]

exp(A) :  [  20.08553692  403.42879349 2980.95798704]

exp(B) :  [[2.00855369e+001 2.29378316e+027 7.49841700e+033]
 [6.34982563e+136 7.89629602e+013 1.73927494e+018]]

e^3 :  20.085536923187668


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.