# the assume function not working?

Hi, I'm trying to run this math in SagemathCell,

x,l,sigma=var("x,l,sigma")
f(x) = (1+x*x/(sigma*sigma))**(l-1/2)
unicode_art(f)

assume(-(2*l-1)/2>0)
assume(sigma>0)
g= integrate(f, x, -infinity, infinity)
unicode_art(g)


but I got the error complaining

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation may help (example of legal syntax is 'assume(-(2l-1)/2>0)', see assume? for more details) Is -(2l-1)/2 an integer?

As you can see from my script that I already have assume(-(2*l-1)/2>0). How to fix?

Thanks!

edit retag close merge delete

( 2022-07-04 08:08:45 +0100 )edit

You assumed that it is positive. Now maxima asks you whether this is an integer..

( 2022-07-04 09:47:19 +0100 )edit

Oh...thanks a lot! I got another error "TypeError: self (=-l + 1/2) must be a relational expression" if I add this line assume(-(2*l-1)/2,'integer'). Do you happen to know what the correct syntax is? I searched the "Computational Mathematics with SageMath" book but didn't find an example...

Actually, I want to tell sage that -(2*l-1)/2 is not an integer. Is there a way?

( 2022-07-04 10:09:24 +0100 )edit

Sort by » oldest newest most voted

The function is even, so try

forget()

l,sigma=var("l,sigma")

assume(l<0)

assume(sigma>0)

2 * integrate((1+x * x/sigma^2)**(l-1/2) , x, 0, oo)

more

FWIW :

sage: mathematica.Integrate(f, (x, -infinity, infinity))
ConditionalExpression[(Sqrt[Pi]*Gamma[-l])/(Sqrt[sigma^(-2)]*Gamma[1/2 - l]),
Re[l] < 0 && (Re[sigma^2] >= 0 || NotElement[sigma^2, Reals])]


which does not (yet) translate automatically to Sage for lack of symbolic logical functions (one can whip up a cases equivalent manually..).

sage: import sympy
sage: sympy.integrate(*map(sympy.sympify, (f(x), (x, -oo, oo))))
Piecewise((sqrt(pi)*sigma*gamma(-l)/gamma(1/2 - l), ((re(l) < 0) & (Abs(arg(sigma)) < pi/2)) | ((re(l) < 0) & Ne(sigma**(-2), 0) & (Abs(arg(sigma)) < pi/2) & Ne(Abs(arg(sigma)), pi/2))), (Integral((1 + x**2/sigma**2)**(l - 1/2), (x, -oo, oo)), True))


which does not (yet) translate to Sage (ditto...).

more