Ask Your Question

the `assume` function not working?

asked 2022-07-04 07:56:19 +0100

dz gravatar image

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

f(x) = (1+x*x/(sigma*sigma))**(l-1/2) 

g= integrate(f, x, -infinity, infinity)

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?


edit retag flag offensive close merge delete


Welcome to Ask Sage! Thank you for your question.

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

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

FrédéricC gravatar imageFrédéricC ( 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?

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

2 Answers

Sort by » oldest newest most voted

answered 2022-07-04 09:41:44 +0100

achrzesz gravatar image

updated 2022-07-04 09:48:13 +0100

The function is even, so try





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

edit flag offensive delete link more

answered 2022-07-04 11:23:02 +0100

Emmanuel Charpentier gravatar image


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...).

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: 2022-07-04 07:56:19 +0100

Seen: 164 times

Last updated: Jul 04 '22