Numpy.log() in python

  • The numpy.log() is a inbulit mathematical function used to solve problems very quickly.
  • It is used to calculate the natural logarithm of the elements in an array.
  • The natural logarithm is log in base e , that is inverse of the exp().
  • Here Numpy is a package used for calculating different mathematical operations.
SYNTAX:

numpy.log(array)

  • numpy : Package which we import to perform logarithms.
  • log: Represents that we are performing logarithm calculations.
  • array: Similar type of data is given.
EXAMPLES:

Let us see 2 programs now:-

Program 1:

import numpy as np   
#importing numpy package and giving alias name as np.
a=1                 
#giving input. 
print(np.log(a))     
#performing calculation and printing it.
Output:  0.0

Program 2:

#Performing same operation but now in array
import numpy as np
arr = np.array([1,1])
print(np.log(arr))
Output: [0.0.]

 

Finally I would like to conclude that I have explained clearly above the need and usage of Numpy.log() .

Leave a Comment

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

Scroll to Top