Problem with integrating the expression of M

Hi. I have the following code that I want to integrate and differentiate, but I am stuck at the expression of M, where it is unable to integrate. Is my coding wrong?

c,t = var('c t')
Pi = RR.pi()
G=integrate(sqrt(1-t^2)*(t+c),t,-0.9,0.9);G
H=G.diff(c);H
L=integrate(-(t+c)/(sqrt(1-t^2)),t,-0.9,0.9);L
M=integrate(1/(sqrt(1-t^2)*(t-c)),t,-0.9,0.9);M #cannot seem to integrate this wrt to t
I=(c^2-1)*(L+(1-c^2)*M);I #equation I that involves M
P=I.diff(c);P #differentiate I wrt to c to obtain equation P


I have tried integrating M by hand which gives me a closed-form involving log function, but I can't seem to integrate it here using Sage.

edit retag close merge delete

What do you assume about $c$? Try making it explicit, using assume before integrate.

( 2019-07-22 14:29:14 +0200 )edit

Homework ?

Works for me using Sage 8.9.beta3 using Python3. rburning's hint is good, but trying other integrators ("sympy", "giac", "mathematica_free") might give you other ideas... Check your results by rederiving...

( 2019-07-22 23:31:47 +0200 )edit

@rburing c is any value in the interval [-0.9, 0.9], which i plan to vary later at the end after the integration and differentiation.

( 2019-07-23 07:26:45 +0200 )edit

@emmanuel definitely not homework but research paper that I am leading at the moment. my co-author got different results than mine. so we thought of using Sage to verify the results.

( 2019-07-23 07:28:17 +0200 )edit

Sort by ยป oldest newest most voted

Well, in this case, let's look at your expression's antiderivative (Sage is known to have some infelicities in definite integration). Sage's default integrator (i. e. maxima) needs to know if $c^2-1>0$ ; account for that as well as for other Sage's integrators :

(c,t)=var("c, t")
E=sqrt(1-t^2)*(t+c)
Sols={}
with assuming(c>-1,c<1):Sols.update({"Mn":E.integrate(t)})
with assuming(c<-1):Sols.update({"Mp":E.integrate(t)})
Sols.update({"Mf":E.integrate(t, algorithm="fricas")})
Sols.update({"Mg":E.integrate(t, algorithm="giac")})
Sols.update({"Mm":mathematica.Integrate(E,t).sage()}
Sols.update({"Ms":E.integrate(t, algorithm="sympy")}))


We have now six expressions (four pairwise distinct expressions) for a primitive of your expression $E$:

Sols
{'Mn': 1/2*sqrt(-t^2 + 1)*c*t + 1/2*c*arcsin(t) - 1/3*(-t^2 + 1)^(3/2),
'Mp': 1/2*sqrt(-t^2 + 1)*c*t + 1/2*c*arcsin(t) - 1/3*(-t^2 + 1)^(3/2),
'Mf': 1/6*(3*c*t^5 + 2*t^6 - 15*c*t^3 - 12*t^4 + 12*c*t + 12*t^2 - 6*(3*c*t^2 - (c*t^2 - 4*c)*sqrt(-t^2 + 1) - 4*c)*arctan((sqrt(-t^2 + 1) - 1)/t) + 3*(3*c*t^3 + 2*t^4 - 4*c*t - 4*t^2)*sqrt(-t^2 + 1))/(3*t^2 - (t^2 - 4)*sqrt(-t^2 + 1) - 4),
'Mg': 1/2*c*arcsin(t) + 1/6*((3*c + 2*t)*t - 2)*sqrt(-t^2 + 1),
'Mm': 1/2*c*arcsin(t) + 1/6*(3*c*t + 2*t^2 - 2)*sqrt(-t^2 + 1),
'Ms': 1/2*sqrt(-t^2 + 1)*c*t + 1/3*sqrt(-t^2 + 1)*t^2 + 1/2*c*arcsin(t) - 1/3*sqrt(-t^2 + 1)}


More easily seen and understood via \LaTeX:

\begin{align} Mn &: \frac{1}{2} \, \sqrt{-t^{2} + 1} c t + \frac{1}{2} \, c \arcsin\left(t\right) - \frac{1}{3} \, {\left(-t^{2} + 1\right)}^{\frac{3}{2}}\\Mp &: \frac{1}{2} \, \sqrt{-t^{2} + 1} c t + \frac{1}{2} \, c \arcsin\left(t\right) - \frac{1}{3} \, {\left(-t^{2} + 1\right)}^{\frac{3}{2}}\\Mf &: \frac{3 \, c t^{5} + 2 \, t^{6} - 15 \, c t^{3} - 12 \, t^{4} + 12 \, c t + 12 \, t^{2} - 6 \, {\left(3 \, c t^{2} - {\left(c t^{2} - 4 \, c\right)} \sqrt{-t^{2} + 1} - 4 \, c\right)} \arctan\left(\frac{\sqrt{-t^{2} + 1} - 1}{t}\right) + 3 \, {\left(3 \, c t^{3} + 2 \, t^{4} - 4 \, c t - 4 \, t^{2}\right)} \sqrt{-t^{2} + 1}}{6 \, {\left(3 \, t^{2} - {\left(t^{2} - 4\right)} \sqrt{-t^{2} + 1} - 4\right)}}\\Mg &: \frac{1}{2} \, c \arcsin\left(t\right) + \frac{1}{6} \, {\left({\left(3 \, c + 2 \, t\right)} t - 2\right)} \sqrt{-t^{2} + 1}\\Mm &: \frac{1}{2} \, c \arcsin\left(t\right) + \frac{1}{6} \, {\left(3 \, c t + 2 \, t^{2} - 2\right)} \sqrt{-t^{2} + 1}\\Ms &: \frac{1}{2} \, \sqrt{-t^{2} + 1} c t + \frac{1}{3} \, \sqrt{-t^{2} + 1} t^{2} + \frac{1}{2} \, c \arcsin\left(t\right) - \frac{1}{3} \, \sqrt{-t^{2} + 1} \end{align}

(one can ensure that maxima's solution for $c>1$ is identical to the one found for $c<-1$:

with assuming(c>1): bool(E.integrate(t)==Sols.get("Mp"))
True).


But all these expressions turn out to derivate to $E$:

[(Sols.get(u).diff(t)/E).canonicalize_radical() for u in Sols.keys()]
[1, 1, 1, 1, 1, 1]


Different integrators have different strategies for integration, leading to different primitives. Barring discontinuities, these four expressions should differ by a constant.

more

thank you! this is great!

( 2020-02-13 04:54:27 +0200 )edit