Open In App

Python | sympy.doit() method

Last Updated : 01 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Using the doit() method in sympy module, we can evaluate objects that are not evaluated by default like limits, integrals, sums and products. Note that all objects of this kind will be evaluated recursively.

Syntax : sympy.doit(x)

Return : evaluated object 

Code #1: With the help of the below examples, we can clearly understand that using sympy.doit() method we can evaluate objects that are not evaluated by default. 

Python3




# importing sympy library
from sympy import *
from sympy.abc import x
 
# calling doit() method on expression
geek = (2 * Integral(x, x)).doit()
 
print(geek)


Output: 

x**2

  Code #2: 

Python3




# importing sympy library
from sympy import *
 
# taking symbols
a, b = symbols('a b')
 
# calling doit() method on expression
geek = (3 * a + b * log(a) + log(b) + log(a)*log(1 / b)).doit()
print(geek)


Output: 

3*a + b*log(a) + log(a)*log(1/b) + log(b)

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads