Open In App

sympy.log() method in Python

Improve
Improve
Like Article
Like
Save
Share
Report

With the help of sympy.log() function, we can simplify the principal branch of the natural logarithm. Logarithms are taken with the natural base, e. To get a logarithm of a different base b, use log(x, y), which is essentially short-hand for log(x) / log(y). 

Syntax : sympy.log() 

Return : Return the simplified mathematical expression.  

Example #1 :  

Python3




# import sympy 
from sympy import *
    
# Use sympy.log() method 
gfg = log(16, 2)
      
print(gfg)


Output :  

4

Example #2 : 

Python3




# import sympy 
from sympy import *
    
# Use sympy.log() method 
gfg = log(S(8) / 3, 2)
      
print(gfg)


Output : 

- log(3)/log(2) + 3

Last Updated : 29 Jul, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads