218
218
219
219
init_code = ['besselexpand : true' , 'display2d : false' , 'domain : complex' , 'keepfloat : true' ,
220
220
'load(to_poly_solve)' , 'load(simplify_sum)' ,
221
- 'load(diag)' ]
221
+ 'load(diag)' , 'load(abs_integrate)' ]
222
222
223
223
224
224
# Turn off the prompt labels, since computing them *very
@@ -726,58 +726,21 @@ def sr_integral(self, *args):
726
726
sage: assumptions() # Check the assumptions really were forgotten
727
727
[]
728
728
729
- Make sure the abs_integrate package is being used,
730
- :issue:`11483`. The following are examples from the Maxima
731
- abs_integrate documentation::
729
+ An example from the maxima documentation involving the
730
+ absolute value::
732
731
733
- sage: integrate(abs(x), x)
734
- 1/2*x*abs(x)
735
-
736
- ::
737
-
738
- sage: integrate(sgn(x) - sgn(1-x), x) # known bug
732
+ sage: integrate(sgn(x) - sgn(1-x), x)
739
733
abs(x - 1) + abs(x)
740
734
741
- This is a known bug in Sage symbolic limits code, see
735
+ This is a fixed bug in Sage symbolic limits code, see
742
736
:issue:`17892` and https://sourceforge.net/p/maxima/bugs/3237/ ::
743
737
744
- sage: integrate(1 / (1 + abs(x-5)), x, -5, 6) # not tested -- known bug
738
+ sage: integrate(1 / (1 + abs(x-5)), x, -5, 6)
745
739
log(11) + log(2)
746
740
747
- ::
748
-
749
- sage: integrate(1/(1 + abs(x)), x) # known bug
750
- 1/2*(log(x + 1) + log(-x + 1))*sgn(x) + 1/2*log(x + 1) - 1/2*log(-x + 1)
751
-
752
- ::
753
-
754
- sage: integrate(cos(x + abs(x)), x) # known bug
755
- -1/2*x*sgn(x) + 1/4*(sgn(x) + 1)*sin(2*x) + 1/2*x
756
-
757
- The last example relies on the following simplification::
758
-
759
- sage: maxima("realpart(signum(x))")
760
- signum(x)
761
-
762
- An example from sage-support thread e641001f8b8d1129::
763
-
764
- sage: f = e^(-x^2/2)/sqrt(2*pi) * sgn(x-1)
765
- sage: integrate(f, x, -Infinity, Infinity) # known bug
766
- -erf(1/2*sqrt(2))
767
-
768
- From :issue:`8624`::
769
-
770
- sage: integral(abs(cos(x))*sin(x),(x,pi/2,pi))
771
- 1/2
772
-
773
- ::
774
-
775
- sage: integrate(sqrt(x + sqrt(x)), x).canonicalize_radical() # known bug
776
- 1/12*((8*x - 3)*x^(1/4) + 2*x^(3/4))*sqrt(sqrt(x) + 1) + 1/8*log(sqrt(sqrt(x) + 1) + x^(1/4)) - 1/8*log(sqrt(sqrt(x) + 1) - x^(1/4))
777
-
778
741
And :issue:`11594`::
779
742
780
- sage: integrate(abs(x^2 - 1), x, -2, 2) # known bug
743
+ sage: integrate(abs(x^2 - 1), x, -2, 2)
781
744
4
782
745
783
746
This definite integral returned zero (incorrectly) in at least
@@ -795,6 +758,45 @@ def sr_integral(self, *args):
795
758
0.124756040961038
796
759
sage: a.imag().abs() < 3e-17
797
760
True
761
+
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`, and only in maxima-5.48 does it give the
775
+ correct answer::
776
+
777
+ sage: # long time, not tested until maxima-5.48 is widespread
778
+ sage: integral(log(cot(x)-1), x, 0, pi/4, algorithm="maxima")
779
+ catalan + 1/2*I*dilog(1/2*I + 1/2) - 1/2*I*dilog(-1/2*I + 1/2)
780
+
781
+ This used to return ``1/2`` in :issue:`11590`::
782
+
783
+ sage: integrate(x * sgn(x^2 - 1/4), x, -1, 0, algorithm="maxima")
784
+ -1/4
785
+
786
+ In :issue:`14591`, this incorrectly simplified to ``cosh(x)``::
787
+
788
+ sage: integrate(sqrt(1-1/4*cosh(x)^2), x, algorithm="maxima")
789
+ integrate(sqrt(-1/4*cosh(x)^2 + 1), x)
790
+
791
+ In :issue:`17468`, this integral hangs::
792
+
793
+ sage: integral(log(abs(2*sin(x))), x, 0, pi/3, algorithm="maxima")
794
+ 1/36*I*pi^2 + I*dilog(1/2*I*sqrt(3) + 1/2) + I*dilog(-1/2*I*sqrt(3) - 1/2)
795
+
796
+ This used to return a *negative* answer in :issue:`17511`::
797
+
798
+ sage: integrate(abs(cos(x)), x, 0, pi, algorithm="maxima")
799
+ 2
798
800
"""
799
801
try :
800
802
return max_to_sr (maxima_eval (([max_integrate ],
0 commit comments