Saturday, February 7, 2026
HomeLanguagessympy.log() method in Python

sympy.log() method in Python

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
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32493 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6864 POSTS0 COMMENTS
Nicole Veronica
11990 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12083 POSTS0 COMMENTS
Shaida Kate Naidoo
7000 POSTS0 COMMENTS
Ted Musemwa
7241 POSTS0 COMMENTS
Thapelo Manthata
6951 POSTS0 COMMENTS
Umr Jansen
6936 POSTS0 COMMENTS