sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.21k stars 421 forks source link

Yet another abs_integrate trig integral problem #17183

Open kcrisman opened 9 years ago

kcrisman commented 9 years ago

See this ask.sagemath question. Original report is

sage: F = sqrt((cos(x) - 1)^2 + sin(x)^2)
sage: F.integrate(x, 0, 2*pi)
0

but the answer should be 8.

EDIT: related

sage: F.integrate(x, 0, pi)
4
sage: F.integrate(x, pi, 2*pi)
-4

and the primitive is wrong:

sage: F.integrate(x)
-4/sqrt(sin(x)^2/(cos(x) + 1)^2 + 1)

Upstream: Fixed upstream, but not in a stable release.

Component: calculus

Keywords: abs_integrate

Stopgaps: #12731

Issue created by migration from https://trac.sagemath.org/ticket/17183

kcrisman commented 9 years ago

Changed upstream from Not yet reported upstream; Will do shortly. to Reported upstream. No feedback yet.

kcrisman commented 9 years ago
comment:1

Upstream https://sourceforge.net/p/maxima/bugs/2823/

kcrisman commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,6 +1,8 @@
 See [this ask.sagemath question](http://ask.sagemath.org/question/24532/).  Original report is 

-F = sqrt((cos(x) - 1)^2 + sin(x)^2) -F.integrate(x, 0, 2pi) +sage: F = sqrt((cos(x) - 1)^2 + sin(x)^2) +sage: F.integrate(x, 0, 2pi) +0

+but the answer should be 8.
kcrisman commented 9 years ago

Changed upstream from Reported upstream. No feedback yet. to Reported upstream. Developers acknowledge bug.

kcrisman commented 9 years ago
comment:3

See also #12731.

ea1d0bf8-c27a-4548-8cb7-de0b1d02441a commented 9 years ago

Stopgaps: todo

ea1d0bf8-c27a-4548-8cb7-de0b1d02441a commented 9 years ago
comment:5

I suppose, this ticket needs a stopgap?

kcrisman commented 9 years ago
comment:6

Maybe all the abs_integrate ones do - see #12731. But I don't think it's appropriate to just raise a warning EVERY TIME someone integrates. So there would have to be some way to limit its applicability. I think that is why I never worked on stopgaps; the stuff I was working on doesn't lend itself to easily pointing that out, other than having Sage itself start with a disclaimer "warning: computer math sometimes has errors".

ea1d0bf8-c27a-4548-8cb7-de0b1d02441a commented 9 years ago
comment:7

Sage itself start with a disclaimer "warning: computer math sometimes has errors"

+1

which in additional links to Mathematically Wrong Answers: http://trac.sagemath.org/query?status=new&status=needs_work&status=needs_review&status=needs_info&type=defect&stopgaps=!&max=0&order=id

I would support that (to warn the greenhorns), or will that have too much opposition? ``

but I don't think it's appropriate to just raise a warning EVERY TIME someone integrates.

Agree, so what about showing a stopgap warning only once per user+computer+sageVersion or similar? ( otherwise the user has explicitly request regular stopgap warnings)

kcrisman commented 9 years ago
comment:8

These are questions above my pay grade, as I did not institute the stopgap system. Again, if there is a way to invoke this when abs_integrate is used, that would be fine - we already have a way to only selectively load packages, but once loaded, I'm not sure we can "unload" it. But continue that discussion at #12731.

ea1d0bf8-c27a-4548-8cb7-de0b1d02441a commented 9 years ago

Changed stopgaps from todo to #12731

fchapoton commented 5 years ago

Changed keywords from none to abs_integrate

fchapoton commented 5 years ago

Description changed:

--- 
+++ 
@@ -6,3 +6,12 @@
 0

but the answer should be 8. + +EDIT: related + + +sage: F.integrate(x, 0, pi) +4 +sage: F.integrate(x, pi, 2*pi) +-4 +

fchapoton commented 5 years ago

Description changed:

--- 
+++ 
@@ -15,3 +15,9 @@
 sage: F.integrate(x, pi, 2*pi)
 -4

+and the primitive is wrong: + + +sage: F.integrate(x) +-4/sqrt(sin(x)^2/(cos(x) + 1)^2 + 1) +

mwageringel commented 5 years ago
comment:13

Possibly related:

sage: integrate(sqrt(1/(2-cos(x))), (x, 0, pi))
0

According to Mathematica, the correct result should be 2*elliptic_kc(-2).

mwageringel commented 3 years ago
comment:14

See also https://groups.google.com/g/sage-devel/c/h50LZVLVQI4.

fchapoton commented 3 years ago
comment:15

The issue with the primitive of F may come from our choice of "domain: complex" in maxima.

Using maxima("domain : real;") gives another answer, that could be better.

EDIT: this seems to give in fact the same wrong primitive.

fricas and giac also gives other wrong primitives, not even continuous ? Sigh :(

kcrisman commented 2 years ago
comment:16

Apparently fixed upstream.

kcrisman commented 2 years ago

Changed upstream from Reported upstream. Developers acknowledge bug. to Fixed upstream, but not in a stable release.