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
On 12/8/2021 1:23 PM, William Stein wrote:
You can compare the real and imaginary parts directly.
https://cocalc.com/wstein/support/2021-12-08-gouvea
sage: bool(wrong.real()==right)
True
sage: wrong.imag()
0
On Wed, Dec 8, 2021 at 10:07 AM Fernando Q. Gouvea
<fqgou...@colby.edu> wrote:
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
fqgou...@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+unsubscr...@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
<https://groups.google.com/d/msgid/sage-support/9557c1a9-bd1c-69e1-358f-4ab02a058c3a%40colby.edu?utm_medium=email&utm_source=footer>.
--
William (http://wstein.org)
--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/CACLE5GC6SNZuSsJ13iRFbO72Udn80Yy5OavR1SFwv03gjaQxvw%40mail.gmail.com
<https://groups.google.com/d/msgid/sage-support/CACLE5GC6SNZuSsJ13iRFbO72Udn80Yy5OavR1SFwv03gjaQxvw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
==================================================================
Fernando Q. Gouvea
Carter Professor of Mathematics
Colby College
Mayflower Hill 5836
Waterville, ME 04901
fqgou...@colby.edu http://www.colby.edu/~fqgouvea
What is socialism?
The painful transition from capitalism to capitalism.
--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/5ea4d847-d5a5-1053-cc98-e071382cf49f%40colby.edu.