-
-
Notifications
You must be signed in to change notification settings - Fork 636
src/sage/symbolic/integration/integral.py: better giac errors #40405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Perhaps too much work to implement, but perhaps consider specifying the error message to: "Optional backend for requested integration method not installed". When the error condition arises, the system would recognize that the "algorithm" is not in the recognized list but is in the wider "optional" list, so that a more specific error can be raised. |
If the optional sagemath-giac is not installed, requesting integration via giac "does nothing," i.e. sage: integrate(sin(x), x, algorithm="giac") integrate(sin(x), x) This is due mainly to the fact that, when no algorithm is requested, ALL available integration routines are tried one after the other. Having the giac integrator do nothing so that the problem can be handed to the next integrator makes sense. However, when algorithm="giac" is explicitly requested, this is confusing. This commit adds "giac" and "libgiac" to the list of chain of integration backends only when sagemath-giac is present. The end result is that passing algorithm="giac" to integrate() or integral() will raise an error about the missing feature rather than quietly doing nothing with the input: FeatureNotPresentError: sage.libs.giac is not available. Optional backend for giac integration not installed. No equivalent system packages for gentoo are known to Sage.
First, mention that both algorithm="giac" and algorithm="libgiac" require the optional sagemath-giac package to be installed. Then, clarify that the default algorithm is None, and has special behavior.
b058c0e
to
c6c342a
Compare
That's not too hard to do if we change the giac integrator to throw a I haven't re-run all of the integration tests but hopefully nothing breaks in CI. |
We have a doctest that is testing for an unevaluated integral: sage: A = integral(1/ ((x-4) * (x^4+x+1)), x); A integrate(1/((x^4 + x + 1)*(x - 4)), x) This is now failing because we output the maxima answer, -1/261*integrate((x^3 + 4*x^2 + 16*x + 65)/(x^4 + x + 1), x) + 1/261*log(x - 4) rather than the giac answer, which is completely unevaluated. In an earlier commit, giac was removed from the default list of integration backends whenever giac is not actually installed because this produces better error messages. But, as a side effect, we are no longer skipping over the partial maxima answer to accept the unevaluated giac answer. (This is actually an improvement in the case where giac is not installed and where sympy raises an error.) There is no important result tested by these lines, so I think the least confusing thing to do is re-word the surrounding paragraph a bit and delete this test. There are still other tests nearby for partial evaluation of hard integrals.
Deleted a failing doctest to fix the CI. The situation now is actually slightly improved: to check if an indefinite integral backend worked or not, we are checking for "integral()" or "integrate()" in the resulting expression. We always get a partial answer from maxima in the test I removed, but when giac is not installed, we see the maxima result as a failure and proceed to try giac, which is a no-op, but is the last engine that does not raise an error. So, ultimately, we throw out the partially evaluated answer for a completely unevaluated one. I don't think the test is demonstrating anything terribly important (the very next test shows a partial answer from maxima) so I've simply removed the failing one. |
Remaining CI issues appear unrelated, but beware that I am unable to test with sagemath-giac installed (giac no longer builds on Gentoo, and no one is going to fix it.) I don't know if we have a CI runner with the optional package installed. |
If the optional sagemath-giac is not installed, requesting integration via giac "does nothing," i.e.
This is due mainly to the fact that, when no algorithm is requested, ALL available integration routines are tried one after the other. Having the giac integrator do nothing so that the problem can be handed to the next integrator makes sense.
However, when algorithm="giac" is explicitly requested, this is confusing. This commit adds "giac" and "libgiac" to the list of integrators only when sagemath-giac is present. The end result is that passing algorithm="giac" to
integrate()
orintegral()
will raise an error about the missing algorithm rather than quietly doing nothing with the input: