I do not know of a direct way, however you can extract the information from Y_indef
in order to create a definite integral:
>>> indef = Integral(x)
>>> to_be_integrated, (free_var,) = indef.args
>>> definite = Integral(to_be_integrated, (free_var, 1, 2))
.args
is a general attribute containing anything needed to construct most SymPy objects.
Edit: To address the comments to the questions.
SymPy may succeed evaluating definite integral and at the same time fail to solve their indefinite version. This is due to the existence of additional algorithms to be applied to definite integrals.
Both definite and indefinite integrals are instances of the same class. The only difference is what they contain in their .args
. The need for different classes is not yet felt, given that SymPy mostly uses Integral
as a flag to say that it can not solve the integral (i.e. the integrate
function returns Integral
when all of the implemented algorithms fail).