Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to correctly check that integration evaluated?

What is the correct way in sage to check that the result of integration has evaluated? I.e. the result has no unevaluated integrate remaining in it?

The way I am checking fail in some cases. For example

sage: var('x')
sage: anti=integrate((4*x - sqrt(-x^2 + 1))/(sqrt(-x^2 + 1) + 5), x)

sage: anti
-x - 4*sqrt(-x^2 + 1) + 5*integrate(1/(sqrt(x + 1)*sqrt(-x + 1) + 5), x) + 20*log(sqrt(-x^2 + 1) + 5)

The above did not fully evaluate, since there is an integrate inside the result returned. But when I do

sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
False

I was expecting to get True. It failed the check, because integrate was not the first operator. This one works

sage: anti=integrate(1/(sqrt(x + 1)*sqrt(-x + 1) + 5), x) 
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
True

So what is the correct way to tell sage to scan the whole expression and if there is an instance of integrate any where, to return True

Thank you

--Nasser