Opened 5 years ago

Closed 23 months ago

#24117 closed defect (fixed)

integrate(sqrt(1-4*sin(x)^2),x) is wrong

Reported by: slabbe Owned by:
Priority: major Milestone: sage-9.2
Component: calculus Keywords: maxima, abs_integrate
Cc: kcrisman, jhpalmieri, slelievre Merged in:
Authors: Frédéric Chapoton Reviewers: Sébastien Labbé
Report Upstream: N/A Work issues:
Branch: 9406e0a (Commits, GitHub, GitLab) Commit: 9406e0adb95727f9036cc7dd0c58f999100bdd04
Dependencies: Stopgaps:

Status badges


I received an email from Pierre Arnoux saying that this is wrong:

sage: integrate (sqrt(1-4*sin(x)^2),x, algorithm='maxima')
-1/12*sin(3*x) + 1/4*sin(x)

Quoting what Pierre says: "Ce qui est visiblement faux: il y a un point d'inflexion horizontal en 0 alors que la fonction à intégrer vaut 1 en 0, ça ne peut pas être une primitive. Est-ce que vous avez une idée de ce qui ne marche pas?"

Other programs in Sage just can't solve this integral:

sage: integrate (sqrt(1-4*sin(x)^2),x, algorithm='fricas')  # installed with "sage -i fricas"
integral(sqrt(4*cos(x)^2 - 3), x)
sage: integrate (sqrt(1-4*sin(x)^2),x, algorithm='giac')
integrate(sqrt(-4*sin(x)^2 + 1), x)
sage: integrate (sqrt(1-4*sin(x)^2),x, algorithm='sympy')
....does not halt...

Change History (11)

comment:1 Changed 5 years ago by rws

See also #18821.

comment:2 Changed 4 years ago by slelievre

Here is how I would describe this bug in the integrate function. (This can be turned into a doctest when this bug is resolved.)

sage: f(x) = sqrt(1-4*sin(x)^2)
sage: F(x) = integrate(f(x), x)
sage: F(x)
-1/12*sin(3*x) + 1/4*sin(x)

Comparing the derivative of F with f shows this is wrong.

sage: g(x) = diff(F(x), x)
sage: g(x)
-1/4*cos(3*x) + 1/4*cos(x)
sage: f(0), g(0)
(1, 0)

Looking at the plots of f and F also reveals an error:

sage: xr = (-0.4, 0.4)
sage: plot(f, xr, color='blue') + plot(F, xr, color='red')

Here, f (blue curve) is 1 at 0, so its primitive F (red curve) should have slope 1 at 0, instead of 0.

comment:3 Changed 4 years ago by rws

There are half a dozen similar tickets to this. The reason is that Sage uses a (now) unmaintained package of Maxima, see #12731 for an overview.

comment:4 Changed 3 years ago by chapoton

  • Keywords abs_integrate added

comment:5 Changed 3 years ago by chapoton

this one is fixed by #27958, that needs review

comment:6 Changed 23 months ago by chapoton

  • Authors set to Frédéric Chapoton
  • Branch set to u/chapoton/24117
  • Cc kcrisman jhpalmieri slelievre added
  • Commit set to 020d526ec76410f32c315eb73ef2d4c180d3a35c
  • Status changed from new to needs_review

easy one

New commits:

0661926add some safety check for numerical integrals up to infinity
020d526add a doctest for 24117

comment:7 Changed 23 months ago by git

  • Commit changed from 020d526ec76410f32c315eb73ef2d4c180d3a35c to 9406e0adb95727f9036cc7dd0c58f999100bdd04

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

9406e0aadd doctest for 24117

comment:8 Changed 23 months ago by chapoton

  • Milestone changed from sage-8.1 to sage-9.2

comment:9 Changed 23 months ago by slabbe

  • Status changed from needs_review to positive_review

comment:10 Changed 23 months ago by slabbe

  • Reviewers set to Sébastien Labbé

comment:11 Changed 23 months ago by vbraun

  • Branch changed from u/chapoton/24117 to 9406e0adb95727f9036cc7dd0c58f999100bdd04
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.