Ask Your Question

what instance is integral from?

asked 2018-08-03 05:26:05 +0200

Nasser gravatar image

updated 2018-08-03 22:40:11 +0200

eric_g gravatar image

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)

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()
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)

I looked at but still do not know how to check for intergal vs. integrate

Any suggestions? thanks --Nasser

edit retag flag offensive close merge delete



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

eric_g gravatar imageeric_g ( 2018-08-03 09:25:23 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-03 22:37:56 +0200

eric_g gravatar image

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()
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
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-08-03 05:26:05 +0200

Seen: 318 times

Last updated: Aug 03 '18