Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
0

Problem with integrating the expression of M

asked 5 years ago

Sha gravatar image

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.

Preview: (hide)

Comments

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

rburing gravatar imagerburing ( 5 years ago )

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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 5 years ago )

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

Sha gravatar imageSha ( 5 years ago )

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

Sha gravatar imageSha ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 5 years ago

Emmanuel Charpentier gravatar image

updated 5 years ago

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 c21>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:

Mn:12t2+1ct+12carcsin(t)13(t2+1)32Mp:12t2+1ct+12carcsin(t)13(t2+1)32Mf:3ct5+2t615ct312t4+12ct+12t26(3ct2(ct24c)t2+14c)arctan(t2+11t)+3(3ct3+2t44ct4t2)t2+16(3t2(t24)t2+14)Mg:12carcsin(t)+16((3c+2t)t2)t2+1Mm:12carcsin(t)+16(3ct+2t22)t2+1Ms:12t2+1ct+13t2+1t2+12carcsin(t)13t2+1

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

Preview: (hide)
link

Comments

thank you! this is great!

Sha gravatar imageSha ( 5 years ago )

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: 5 years ago

Seen: 370 times

Last updated: Jul 24 '19