From 36681281f33139af227ad654e550045d0393f7e0 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 15 Sep 2024 16:51:07 -0400 Subject: [PATCH 1/3] src/sage/calculus/calculus.py: add "abs tol" to a numeric integral test Various implementations get it a little (1e-10) different. --- src/sage/calculus/calculus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py index 6d765144e23..65a075a2e1f 100644 --- a/src/sage/calculus/calculus.py +++ b/src/sage/calculus/calculus.py @@ -407,7 +407,7 @@ 0.6321205588285577 sage: result = integral(exp(-300.0/(-0.064*x+14.0)),x,0.0,120.0) ... - sage: result + sage: result # abs tol 1e-10 4.62770039817000e-9 To check that :issue:`27092` is fixed:: From 103715310f5e345b564e90ac04f66701ffcaf715 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 15 Sep 2024 17:36:23 -0400 Subject: [PATCH 2/3] src/sage/symbolic/integration/integral.py: accept both giac/sympy answers We have an integration test in this file that is looking for the giac result, but sympy gives an equivalent one. We should accept that, too. --- src/sage/symbolic/integration/integral.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sage/symbolic/integration/integral.py b/src/sage/symbolic/integration/integral.py index 70bb877e5a1..5c7e5db192f 100644 --- a/src/sage/symbolic/integration/integral.py +++ b/src/sage/symbolic/integration/integral.py @@ -71,12 +71,13 @@ def __init__(self): sage: (f*f).integrate(x, algorithm='mathematica_free') # optional -- internet -b*log(e^(a/b) + e^(x/b)) + x + b/(e^(-(a - x)/b) + 1) - Check for :issue:`25119`:: + After :issue:`25119` we can integrate the following function, + although giac and sympy give different-looking answers:: sage: result = integrate(sqrt(x^2)/x,x) ... - sage: result - x*sgn(x) + sage: result in [x*sgn(x), sqrt(x^2)] + True """ # The automatic evaluation routine will try these integrators # in the given order. This is an attribute of the class instead of From df6d309b17c1ad34f2eff91a1daa16ec31f0e5de Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 16 Sep 2024 08:14:32 -0400 Subject: [PATCH 3/3] src/sage/functions/piecewise.py: switch one test from giac to sympy There's one piecewise test that uses algorithm='giac', but it will soon be possible to install sage without giac. We could make the test conditional on giac's presence, but the same thing works with sympy, so let's just use that. --- src/sage/functions/piecewise.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/functions/piecewise.py b/src/sage/functions/piecewise.py index 8a8cbcb62b2..469ce0fbef5 100644 --- a/src/sage/functions/piecewise.py +++ b/src/sage/functions/piecewise.py @@ -828,9 +828,9 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, Check that the algorithm keyword can be used:: sage: ex = piecewise([([0, 1], 1), ((1, oo), 1/x**2)]) - sage: integral(ex, x, 0, 100, algorithm='giac') + sage: integral(ex, x, 0, 100, algorithm='sympy') 199/100 - sage: integral(ex, x, algorithm='giac') + sage: integral(ex, x, algorithm='sympy') piecewise(x|-->x on [0, 1], x|-->-1/x + 2 on (1, +oo); x) """ if a is not None and b is not None: