Skip to content

Commit 1a69eea

Browse files
committed
src/sage/interfaces/maxima_lib.py: re-enable abs_integrate
All of the issues we encountered (and reported) with abs_integrate have been fixed. We re-enable it with doctests to, 1. Ensure that none of those errors have returned 2. Test that we can solve some new integrals The list of problems comes from, #12731 With the upstream fixes from, https://sourceforge.net/p/maxima/code/ci/3ca4235b
1 parent 4d02f7f commit 1a69eea

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

src/sage/interfaces/maxima_lib.py

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218

219219
init_code = ['besselexpand : true', 'display2d : false', 'domain : complex', 'keepfloat : true',
220220
'load(to_poly_solve)', 'load(simplify_sum)',
221-
'load(diag)']
221+
'load(diag)', 'load(abs_integrate)']
222222

223223

224224
# Turn off the prompt labels, since computing them *very
@@ -759,19 +759,43 @@ def sr_integral(self, *args):
759759
sage: a.imag().abs() < 3e-17
760760
True
761761
762-
The following examples (at least for now) require Maxima's
763-
``abs_integrate`` package. Enabling ``abs_integrate`` globally
764-
caused several bugs catalogued in :issue:`12731`, so we no
765-
longer load it by default, but you can load it manually by
766-
running ``maxima_calculus.eval("load(abs_integrate)")``.
767-
Afterwards, these integrals should produce a meaningful
768-
result; but be warned, there is no way to unload the
769-
``abs_integrate`` package once it is loaded::
770-
771-
sage: integrate(1/(abs(x) + 1), x)
772-
integrate(1/(abs(x) + 1), x)
773-
sage: integrate(cos(x + abs(x)), x)
774-
integrate(cos(x + abs(x)), x)
762+
The following examples require Maxima's ``abs_integrate``
763+
package. Enabling ``abs_integrate`` globally caused several
764+
bugs (catalogued in :issue:`12731`) but most of these have
765+
been fixed, and ``abs_integrate`` has been re-enabled::
766+
767+
sage: integrate(1/(abs(x) + 1), x, algorithm="maxima")
768+
1/2*(log(x + 1) + log(-x + 1))*sgn(x) + 1/2*log(x + 1) - 1/2*log(-x + 1)
769+
sage: integrate(cos(x + abs(x)), x, algorithm="maxima")
770+
-1/4*(2*x - sin(2*x))*sgn(x) + 1/2*x + 1/4*sin(2*x)
771+
772+
Several examples where ``abs_integrate`` previously lead to
773+
incorrect results. This was once reported to be divergent in
774+
:issue:`13733`::
775+
776+
sage: # long time
777+
sage: integral(log(cot(x)-1), x, 0, pi/4, algorithm="maxima")
778+
catalan + 1/2*I*dilog(1/2*I + 1/2) - 1/2*I*dilog(-1/2*I + 1/2)
779+
780+
This used to return ``1/2`` in :issue:`11590`::
781+
782+
sage: integrate(x * sgn(x^2 - 1/4), x, -1, 0, algorithm="maxima")
783+
-1/4
784+
785+
In :issue:`14591`, this incorrectly simplified to ``cosh(x)``::
786+
787+
sage: integrate(sqrt(1-1/4*cosh(x)^2), x, algorithm="maxima")
788+
integrate(sqrt(-1/4*cosh(x)^2 + 1), x)
789+
790+
In :issue:`17468`, this integral hangs::
791+
792+
sage: integral(log(abs(2*sin(x))), x, 0, pi/3, algorithm="maxima")
793+
1/36*I*pi^2 + I*dilog(1/2*I*sqrt(3) + 1/2) + I*dilog(-1/2*I*sqrt(3) - 1/2)
794+
795+
This used to return a *negative* answer in :issue:`17511`::
796+
797+
sage: integrate(abs(cos(x)), x, 0, pi, algorithm="maxima")
798+
2
775799
776800
"""
777801
try:

0 commit comments

Comments
 (0)