# Maxima needs a change of variable to succeed in an integral

Hi

maxima is not able to integrate this below:

#solExt_0(y)=(((R^2-y^2)*asin(x/(sqrt(R-y)*sqrt(y+R)))+x*sqrt((-y^2)-x^2+R^2))/2 ).subs(x==-sqrt(2*R*y - 2*y^2))
#solExt_1(y)=(((R^2-y^2)*asin(x/(sqrt(R-y)*sqrt(y+R)))+x*sqrt((-y^2)-x^2+R^2))/2 ).subs(x==sqrt(2*R*y - 2*y^2))
#solExt=solExt_1-solExt_0
#show('must give : ',solExt )
var('x,y,R,T',domain='real')
Rnum=1
numL=[R==Rnum]
assume(T>0)
assume(T<=R)
#assume((y-R)*(y+R)<=0)
Iz=sqrt(R^2-y^2 - x^2)

xLow=-sqrt(2*R*y - 2*y^2)
xUp=sqrt(2*R*y - 2*y^2)
show(LatexExpr(r"\int_{"+"}^{"+"} "+latex(Iz))+"dx")
IxT=integrate(Iz(x),x,xLow,xUp)


but succeed with a variable change :

var('x,y,R,T',domain='real')
Rnum=1
numL=[R==Rnum]
assume(T>0)

assume(T<=R)
Iz(x)=sqrt(T - x^2)
xLow=-sqrt(2*R*y - 2*y^2)
xUp=sqrt(2*R*y - 2*y^2)
IxT=integrate(Iz(x),x)

Ix=(IxT.subs(T==R^2-y^2))
show(LatexExpr(r"\int_{"+latex(xLow)+"}^{"+latex(xUp)+"} "+latex(Iz.subs(T==R^2-y^2))+" = "+latex(Ix)))


but may be I need to add some assumes command for the 1st code?

edit retag close merge delete

And your question is ?

( 2020-11-22 11:44:37 +0100 )edit

do I need to add some assumes command for the 1st code?

( 2020-11-22 12:19:01 +0100 )edit

I forgot to precise OS W10 Sagemath 9.1 notebook

( 2020-11-22 14:04:48 +0100 )edit

Sort by ยป oldest newest most voted

Your first code snippet, whatever it means, WorksForMe(TM) in 9.3.beta1 :

sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:#solExt_0(y)=(((R^2-y^2)*asin(x/(sqrt(R-y)*sqrt(y+R)))+x*sqrt((-y^2)-x^2+R^2))/2 ).subs(x==-sqrt(2*R*y - 2*y^2))
:#solExt_1(y)=(((R^2-y^2)*asin(x/(sqrt(R-y)*sqrt(y+R)))+x*sqrt((-y^2)-x^2+R^2))/2 ).subs(x==sqrt(2*R*y - 2*y^2))
:#solExt=solExt_1-solExt_0
:#show('must give : ',solExt )
:var('x,y,R,T',domain='real')
:Rnum=1
:numL=[R==Rnum]
:assume(T>0)
:assume(T<=R)
:#assume((y-R)*(y+R)<=0)
:Iz=sqrt(R^2-y^2 - x^2)
:
:xLow=-sqrt(2*R*y - 2*y^2)
:xUp=sqrt(2*R*y - 2*y^2)
:show(LatexExpr(r"\int_{"+"}^{"+"} "+latex(Iz))+"dx")
:IxT=integrate(Iz(x),x,xLow,xUp)
:--
(x, y, R, T)
\newcommand{\Bold}[1]{\mathbf{#1}}\int_{}^{} \sqrt{R^{2} - x^{2} - y^{2}} dx
sage: IxT
2*sqrt(2*R*y - 2*y^2)*sqrt(-y^2)


Suggestion : try algorithm="giac" or algorithm="fricas" to see other possible primitives...

I'm afraid that your second code snippet does something different:

sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:var('x,y,R,T',domain='real')
:Rnum=1
:numL=[R==Rnum]
:assume(T>0)
:
:assume(T<=R)
:Iz(x)=sqrt(T - x^2)
:xLow=-sqrt(2*R*y - 2*y^2)
:xUp=sqrt(2*R*y - 2*y^2)
:IxT=integrate(Iz(x),x)
:
:
:Ix=(IxT.subs(T==R^2-y^2))
:show(LatexExpr(r"\int_{"+latex(xLow)+"}^{"+latex(xUp)+"} "+latex(Iz.subs(T==R^2-y^2))+" = "+latex(Ix)))
:--
(x, y, R, T)
\newcommand{\Bold}[1]{\mathbf{#1}}\int_{ -\sqrt{2 \, R y - 2 \, y^{2}} }^{ \sqrt{2 \, R y - 2 \, y^{2}} } x \ {\mapsto}\ \sqrt{R^{2} - x^{2} - y^{2}} = \frac{1}{2} \, {\left(R^{2} - y^{2}\right)} \arcsin\left(\frac{x}{\sqrt{R^{2} - y^{2}}}\right) + \frac{1}{2} \, \sqrt{R^{2} - x^{2} - y^{2}} x
sage: IxT
1/2*T*arcsin(x/sqrt(T)) + 1/2*sqrt(-x^2 + T)*x
sage: integrate(Iz(x),x, algorithm="giac")
1/2*T*arcsin(x/sqrt(T)) + 1/2*sqrt(-x^2 + T)*x
sage: integrate(Iz(x),x, algorithm="fricas")
-1/2*T*arctan(sqrt(-x^2 + T)/x) + 1/2*sqrt(-x^2 + T)*x
sage: integrate(Iz(x),x, algorithm="sympy")
cases(((x^2/T > 1, 1/2*I*x^3/(sqrt(T)*sqrt(x^2/T - 1)) - 1/2*I*T*arccosh(x/sqrt(T)) - 1/2*I*sqrt(T)*x/sqrt(x^2/T - 1)), (1, 1/2*sqrt(T)*x*sqrt(-x^2/T + 1) + 1/2*T*arcsin(x/sqrt(T)))))

more

thank you Emmanuel Charpentier

( 2020-11-22 14:02:39 +0100 )edit

Will SageMath 9.2 be available soon for W10? (it has been available for some time for Linux Ubuntu)

( 2020-11-22 14:10:20 +0100 )edit