I was showing my students a famous calculus example of an integral that can be computed in one order of the variables but not in the other. Knowing that SageMath can compute anything, the students suggested trying the integral the "wrong" way.
The "right" way is
sage: integrate(integrate(sin(x^2),y,0,x),x,0,1)
-1/2*cos(1) + 1/2
The "wrong" way is
sage: integrate(integrate(sin(x^2),x,y,1),y,0,1) -1/16*(-1)^(3/4)*((sqrt(2) + 4*(-1)^(1/4))*e^I - sqrt(-I)*((I + 1)*sqrt(2)*(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2)*(-1)^(1/4)*e^I) + I*sqrt(2)*e^I - 2*(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2) - 2*(-1)^(1/4))*e^(-I)
Is there any way to get Sage to check that these are equal?
The obvious thing does not seem to work:
sage: -1/16*(-1)^(3/4)*((sqrt(2) + 4*(-1)^(1/4))*e^I - sqrt(-I)*((I + 1)*sqrt(2) ....: *(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2)*(-1)^(1/4)*e^I) + I*sqrt(2)*e^I - 2* ....: (-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2) - 2*(-1)^(1/4))*e^(-I) == -1/2*cos(1) ....: +1/2 -1/16*(-1)^(3/4)*((sqrt(2) + 4*(-1)^(1/4))*e^I - sqrt(-I)*((I + 1)*sqrt(2)*(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2)*(-1)^(1/4)*e^I) + I*sqrt(2)*e^I - 2*(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2) - 2*(-1)^(1/4))*e^(-I) == -1/2*cos(1) + 1/2
Thanks,
Fernando
-- ================================================================== Fernando Q. Gouvea Carter Professor of Mathematics Colby College Mayflower Hill 5836 Waterville, ME 04901 fqgo...@colby.edu http://www.colby.edu/~fqgouvea I have had a perfectly wonderful evening, but this wasn't it. --Groucho Marx
--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/9557c1a9-bd1c-69e1-358f-4ab02a058c3a%40colby.edu.
Thank you, that works. What is strange is that this does not:
sage: right=integrate(integrate(sin(x^2),y,0,x),x,0,1) sage: wrong=integrate(integrate(sin(x^2),x,y,1),y,0,1) sage: real(wrong)==right -1/2*cos(1) + 1/2 == -1/2*cos(1) + 1/2
Is Sage seeing a difference there that I don't?
I think I don't understand the difference between real(wrong)==right and bool(real(wrong)==right).
Fernando
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CACLE5GC6SNZuSsJ13iRFbO72Udn80Yy5OavR1SFwv03gjaQxvw%40mail.gmail.com.
-- ================================================================== Fernando Q. Gouvea Carter Professor of Mathematics Colby College Mayflower Hill 5836 Waterville, ME 04901 fqgo...@colby.edu http://www.colby.edu/~fqgouvea
What is socialism? The painful transition from capitalism to capitalism.
Thank you, that works. What is strange is that this does not:
sage: right=integrate(integrate(sin(x^2),y,0,x),x,0,1) sage: wrong=integrate(integrate(sin(x^2),x,y,1),y,0,1) sage: real(wrong)==right -1/2*cos(1) + 1/2 == -1/2*cos(1) + 1/2Is Sage seeing a difference there that I don't?
I think I don't understand the difference between real(wrong)==right and bool(real(wrong)==right).
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/5ea4d847-d5a5-1053-cc98-e071382cf49f%40colby.edu.
I see. So the difference between this and, say, 1+1==2 (which returns True) is that 1+1 and 2 are numbers, not symbolic things.
Fernando
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CACLE5GCjm_qE-ufEiOWQ%3DxLsFVsV_Nm6hKdygv121Ss2Tf_iGg%40mail.gmail.com.
-- ================================================================== Fernando Q. Gouvea Carter Professor of Mathematics Colby College Mayflower Hill 5836 Waterville, ME 04901 fqgo...@colby.edu http://www.colby.edu/~fqgouvea
Being powerful is like being a lady. If you have to tell people you are, you aren't. -- Margaret Thatcher
In Sage, this can be written wrong.maxima_methods().trigrat().expand()
.
HTH,