what instance is integral from?

When the result has integrate in it, I check for it as follows

sage: anti=integrate(1/(sqrt(x + 1)*sqrt(-x + 1) + 5), x)
integrate(1/(sqrt(x + 1)*sqrt(-x + 1) + 5), x)

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


But the above does not work when the result is integral instead of integrate.

My question is, what instance is integral coming from?

sage: anti=integrate(cos(b*x + a)*cos_integral(d*x + c)/x,x, algorithm="fricas")
integral(cos(b*x + a)*cos_integral(d*x + c)/x, x)
sage: anti.operator()
integral
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
False


I looked at http://doc.sagemath.org/html/en/refer... but still do not know how to check for intergal vs. integrate

Any suggestions? thanks --Nasser

edit retag close merge delete

1

Have you tried type(anti.operator()) for the integral case?

( 2018-08-03 02:25:23 -0500 )edit

Sort by ยป oldest newest most voted

We have

sage: var('a b c d')
(a, b, c, d)
sage: anti = integrate(cos(b*x + a)*cos_integral(d*x + c)/x, x, algorithm="fricas")
sage: anti
integral(cos(b*x + a)*cos_integral(d*x + c)/x, x)
sage: anti.operator()
integral
sage: type(anti.operator())
<class 'sage.symbolic.function_factory.NewSymbolicFunction'>


So, integral in anti is a NewSymbolicFunction. I would say this reflects a bad conversion of the FriCAS integral to a SageMath integral. Indeed, the derivative treats integral as an ordinary (generic) function, not as an antiderivative, as you can see from the D[0](integral) and D[1](integral) below:

sage: diff(anti, x)
-(b*cos_integral(d*x + c)*sin(b*x + a)/x - d*cos(b*x + a)*cos(d*x + c)/((d*x + c)*x) + cos(b*x + a)*cos_integral(d*x + c)/x^2)*D[0](integral)(cos(b*x + a)*cos_integral(d*x + c)/x, x) + D[1](integral)(cos(b*x + a)*cos_integral(d*x + c)/x, x)


As a workaround, you can substitute the fake integral by the true SageMath integral:

sage: anti2 = anti.substitute_function(anti.operator(), integrate)
sage: anti2
integrate(cos(b*x + a)*cos_integral(d*x + c)/x, x)
sage: diff(anti2, x)
cos(b*x + a)*cos_integral(d*x + c)/x

more