Open kcrisman opened 9 years ago
Worse,
sage: integrate(abs(cos(x)),x,0,pi)
-1
Changed upstream from Not yet reported upstream; Will do shortly. to Reported upstream. Developers acknowledge bug.
Description changed:
---
+++
@@ -1,6 +1,6 @@
See [this comment](https://github.com/sagemath/sage/issues/11483#comment:12), discussion in #13364, the supposed fix at https://sourceforge.net/p/maxima/bugs/2520/, [this ask.sagemath question](http://ask.sagemath.org/question/25269/i-dont-know-why-sage-return-0-for-integratesin2xabsx0pi-when-its-value-is-2/), and so forth.
-E.g. apparently this is quite wrong
+E.g. this is annoying (but apparently right)
(%i1) load(abs_integrate); @@ -19,4 +19,4 @@ -log(2))) /4)
-and it doesn't do the definite integral at all, even the easy ones where abs does nothing on the interval!
+but it doesn't do the definite integral at all, even the easy ones where abs does nothing on the interval!
Stopgaps: #12731
Reported again at https://groups.google.com/forum/#!topic/sage-support/1Hcv29UyqVo
Changed keywords from none to abs_integrate
Everything works in 8.9.b7 after #27958. Some doctests were added there.
Maybe one could add one doctest for
sage: integrate(abs(sin(x)),x)
-cos(x)*sgn(sin(x)) + sgn(sin(x))
Author: Frédéric Chapoton
Branch: u/chapoton/17511
This answer
sage: integrate(abs(sin(x)),x)
-cos(x)*sgn(sin(x)) + sgn(sin(x))
is very wrong (outside of [-pi, pi])! It takes negative values
sage: f = integrate(abs(sin(x)), x)
sage: (f(5) - f(0)).n()
-0.716337814536774
and the integral is supposed to go to +oo
as x -> +oo/-oo
...
Reviewer: Vincent Delecroix
But this is correct
sage: integrate(abs(sin(x)), x, 0, 10)
cos(10) + 7
And I like very much
sage: %time integrate(abs(sin(x)), x, algorithm='sympy')
CPU times: user 8.09 s, sys: 99 µs, total: 8.09 s
Wall time: 8.1 s
integrate(abs(sin(x)), x)
Indeed. Giac is responsible for the wrong answer. This should be reported upstream.
sage: integrate(abs(sin(x)),x,algorithm='maxima')
integrate(abs(sin(x)), x)
sage: integrate(abs(sin(x)),x,algorithm='sympy')
integrate(abs(sin(x)), x)
sage: integrate(abs(sin(x)),x,algorithm='giac')
-cos(x)*sgn(sin(x)) + sgn(sin(x))
sage: integrate(abs(sin(x)),x,algorithm='fricas')
integral(abs(sin(x)), x)
sage: integrate(abs(sin(x)),x,algorithm='mathematica_free')
-cos(x)*sgn(sin(x))
But giac is also providing the correct answer for the definite integral, where sympy fails to deliver:
sage: integrate(abs(cos(x)),x,0,44,algorithm='maxima')
integrate(abs(cos(x)), x, 0, 44)
sage: integrate(abs(cos(x)),x,0,44,algorithm='sympy')
-sin(44) + 4
sage: integrate(abs(cos(x)),x,0,44,algorithm='giac')
sin(44) + 28
sage: integrate(abs(cos(x)),x,0,44,algorithm='fricas')
integrate(abs(cos(x)), x, 0, 44)
sage: integrate(abs(cos(x)),x,0,44,algorithm='mathematica_free')
sin(44) + 28
Replying to @fchapoton:
But giac is also providing the correct answer for the definite integral, where sympy fails to deliver:
[...]
which should also be reported upstream I guess...
Changed branch from u/chapoton/17511 to none
Samuel, would you please report to giac the failure of comment:12 ?
I emailed Bernard Parisse, here is his reply:
Ce n'est pas une erreur, au sens ou un avertissement est renvoyé
0>> integrate(abs(sin(x))
Warning adding 1 ) at end of input
Attention, l'intégration de abs() ou sign() suppose un signe constant
par intervalles (vérifié si l'argument est réel):
Verifiez [abs(sin(x))]
Discontinuités aux zeros de sin(x) were not checked
sign(sin(x))-cos(x)*sign(sin(x))
// Time 0.04
C'est à l'utilisateur de prendre garde aux discontinuites de la
primitive pour calculer une intégrale définie s'il utilise la primitive
renvoyée. Lorsqu'on demande à giac une intégrale définie, il essaie de
tenir compte des discontinuités, et il fait le calcul numérique en
parallèle pour verifier. En cas de non concordance, les 2 valeurs sont
renvoyées (la plupart du temps c'est la valeur numérique qui est la bonne).
which roughly translates as
This is not an error, in the sense that a warning is issued:
0>> integrate(abs(sin(x))
Warning adding 1 ) at end of input
Caution, integrating abs() or sign() assumes piecewise constant sign
(check if the argument is real):
Check [abs(sin(x))]
Discontinuities at zeros of sin(x) were not checked
sign(sin(x))-cos(x)*sign(sin(x))
// Time 0.04
It is up to the user to check for discontinuities of the antiderivative
to compute an integral using the antiderivative returned by giac.
When asking giac for an integral on an interval, it tries to take
discontinuities into account, and does the numerical integration in parallel
to check. In case of mismatch, both values are returned (most of the time
the numerical value is the one that is correct).
Ticket retargeted after milestone closed
Moving tickets to milestone sage-9.2 based on a review of last modification date, branch status, and severity.
Moving this ticket to 9.4, as it seems unlikely that it will be merged in 9.3, which is in the release candidate stage
Setting a new milestone for this ticket based on a cursory review.
Stalled in needs_review
or needs_info
; likely won't make it into Sage 9.5.
See this comment, discussion in #13364, the supposed fix at https://sourceforge.net/p/maxima/bugs/2520/, this ask.sagemath question, and so forth.
E.g. this is annoying (but apparently right)
but it doesn't do the definite integral at all, even the easy ones where abs does nothing on the interval!
Upstream: Reported upstream. Developers acknowledge bug.
CC: @slel
Component: calculus
Keywords: abs_integrate
Stopgaps: #12731
Author: Frédéric Chapoton
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/17511