There are two square roots. In this (classic) integration example/bug, a choice has to be made. You know that 4 has two square roots, -2 and 2. The integrand, which also can be rewritten as sqrt ( 4-4*cos(x/2)^2) , has 2 square roots. Therefore there are two potential different values for the integral. Any answer that supplies only one answer is wrong.
On Tuesday, August 4, 2020 at 1:56:16 AM UTC-7, Emmanuel Charpentier wrote: > > BTW : > > sage: integrate(sqrt(2-2*cos(x)),x, algorithm="fricas") > -2*(cos(x) + 1)*sqrt(-2*cos(x) + 2)/sin(x) > sage: integrate(sqrt(2-2*cos(x)),x, algorithm="mathematica_free") > -2*sqrt(-2*cos(x) + 2)*cot(1/2*x) > > Both are visually (on plot) and numerically correct ; both differentiate > to expressions very hard to show equal to the original function. > > HTH, > > Le lundi 3 août 2020 10:50:12 UTC+2, Dima Pasechnik a écrit : > > This is a well-known bug in Sage. A workaround is to set the domain to >> "real": >> >> sage: maxima_calculus.eval('domain: real'); >> sage: integrate(sqrt(2-2*cos(x)),x,0,2*pi) # correct answer >> 8 >> >> sage: maxima_calculus.eval('domain: complex'); # restore the state back >> sage: integrate(sqrt(2-2*cos(x)),x,0,2*pi) # now here the result is again >> wrong, of course >> 0 >> >> >> On Sun, Aug 2, 2020 at 5:26 PM Nico Guth <nico.j...@gmail.com> wrote: >> >>> Hi, >>> >>> I discovered a bug, where a definite integral is calculated wrong! >>> WolframAlpha result for comparison. >>> >>> Code: >>> integrate(sqrt(2-2*cos(x)),x,0,2*pi) >>> >>> Also if I type show() instead of print() SageMathCell just doesn't show >>> anything. >>> >>> Also the form in which the indefinite integral is given is not very >>> pretty. >>> WolframAlpha does a much better job simplifying. >>> >>> [image: sage_wrong_integral.png][image: sage_wrong_integral_wolfram.png] >>> [image: sage_wrong_integral_wolfram_2.png] >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "sage-devel" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to sage-...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/sage-devel/487d0db8-5711-41a8-a7d4-1548286b5573n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/sage-devel/487d0db8-5711-41a8-a7d4-1548286b5573n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/74e290bf-d169-4f9a-b999-6196c078b693o%40googlegroups.com.