Opened 4 years ago
Closed 4 years ago
#22891 closed enhancement (fixed)
Add giac interface to integrate
Reported by:  mforets  Owned by:  

Priority:  major  Milestone:  sage8.0 
Component:  calculus  Keywords:  giac, integrate, symbolics 
Cc:  Merged in:  
Authors:  Marcelo Forets  Reviewers:  Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  8e1af6d (Commits, GitHub, GitLab)  Commit:  8e1af6dd9a52b2c90abe1c170b5a020003612dcb 
Dependencies:  Stopgaps: 
Description
Provide a giac_integrator
function, which relies on the external (but standard) Giac package.
A test could be:
sage: integrate(abs(cos(x)), x, 0, 2*pi, algorithm='giac') 4
This test is chosen because (at the time or writing) Maxima gives a wrong result (0
), SymPy? gives i don't know (unevaluated), and Fricas (optional package) gives 'failed'
.
Change History (10)
comment:1 Changed 4 years ago by
comment:2 Changed 4 years ago by
 Branch set to u/mforets/t/mforets/giac_integrator
comment:3 Changed 4 years ago by
 Commit set to 8e1af6dd9a52b2c90abe1c170b5a020003612dcb
 Status changed from new to needs_review
setting to review; i've added the new optional keyword algorithm='giac'
, and for the moment i wouldn't know if there is something else that needs to be done with respect to this ticket! feedback welcome
New commits:
8e1af6d  add giac external integrator

comment:4 followup: ↓ 6 Changed 4 years ago by
Love this. Don't see any obvious problems with the commit (I haven't tested it, though, just reading through).
On a related note, can you test out the various tickets at https://trac.sagemath.org/wiki/symbolics#Integrationtickets with this? In particular the abs_integrate
ones, see e.g. #12731. If the integrator here is powerful enough, it might be time to replace the Maxima integrator with this one; the Maxima one has many errors (though in my opinion is still way better than not having one, as most of those are on relatively "interesting" functions like your example, abs and other stuff with branch issues).
comment:5 Changed 4 years ago by
we may want to ensure a symbolic integral wrapper, for instance with (cf. #22138):
sage: n = var('n') sage: integral(x^n*sin(x), x, algorithm='giac') ... NotImplementedError: Unable to parse Giac output: integrate(x^n*sin(x),x)
but in other cases it already returns unevaluted:
sage: integrate(log(1+x)/x, x, 0, 1, algorithm='giac') integrate(ln(x + 1)/x, x, 0, 1)
comment:6 in reply to: ↑ 4 Changed 4 years ago by
Replying to kcrisman:
Love this. Don't see any obvious problems with the commit (I haven't tested it, though, just reading through).
On a related note, can you test out the various tickets at https://trac.sagemath.org/wiki/symbolics#Integrationtickets with this? In particular the
abs_integrate
ones, see e.g. #12731. If the integrator here is powerful enough, it might be time to replace the Maxima integrator with this one; the Maxima one has many errors (though in my opinion is still way better than not having one, as most of those are on relatively "interesting" functions like your example, abs and other stuff with branch issues).
:) here are some gist of hard integrals
comment:7 followup: ↓ 8 Changed 4 years ago by
 Reviewers set to Travis Scrimshaw
 Status changed from needs_review to positive_review
I think this is something that we should get into the next Sage, but we should discuss on another ticket, and possibly sagedevel, switching the default integrator.
comment:8 in reply to: ↑ 7 Changed 4 years ago by
Replying to tscrim:
I think this is something that we should get into the next Sage, but we should discuss on another ticket, and possibly sagedevel, switching the default integrator.
thanks for the review!
yes, IMO some action should be taken (for example to double check with numerical integrator and show a warning if nonsense is detected / dispatch another integrator for known issues eg. abstrig or some special functions). i am not a big fan of 'blatantly wrong' answers, because from the user's point of view, it makes you loose a lot of confidence on the software.
comment:9 Changed 4 years ago by
Oh yeah, we would want some super testing if we switched the default. But the problem is that currently Maxima's integration for anything involving branches or abs is weak, at least the way we interface with it.
As a first approximation, perhaps we could have a system where we removed the abs_integrate
option from Maxima and then had Sage use either Sympy or giac as a backup if "integral" was in the returned Maxima output... anyway, that's for sagedevel, for sure.
comment:10 Changed 4 years ago by
 Branch changed from u/mforets/t/mforets/giac_integrator to 8e1af6dd9a52b2c90abe1c170b5a020003612dcb
 Resolution set to fixed
 Status changed from positive_review to closed
(minor, documentation): in
symbolic/integration/integral.py
, the wordEXAMPLES
appears two times, first in the usual place, then just after theALIASES
. this is a bit strange. shall we remove the second one?