Ask Your Question
1

the `assume` function not working?

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

dz gravatar image

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 flag offensive close merge delete

Comments

Welcome to Ask Sage! Thank you for your question.

slelievre gravatar imageslelievre ( 2022-07-04 08:08:45 +0200 )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 +0200 )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 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

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

achrzesz gravatar image

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

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)

edit flag offensive delete link more
0

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

Emmanuel Charpentier gravatar image

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

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

Stats

Asked: 2022-07-04 07:56:19 +0200

Seen: 172 times

Last updated: Jul 04 '22