Skip to content
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

Add giac interface to integrate #22891

Closed
mforets mannequin opened this issue Apr 27, 2017 · 12 comments
Closed

Add giac interface to integrate #22891

mforets mannequin opened this issue Apr 27, 2017 · 12 comments

Comments

@mforets
Copy link
Mannequin

mforets mannequin commented Apr 27, 2017

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'.

Component: calculus

Keywords: giac, integrate, symbolics

Author: Marcelo Forets

Branch/Commit: 8e1af6d

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/22891

@mforets mforets mannequin added this to the sage-8.0 milestone Apr 27, 2017
@mforets mforets mannequin added c: calculus labels Apr 27, 2017
@mforets
Copy link
Mannequin Author

mforets mannequin commented Apr 27, 2017

comment:1

(minor, documentation): in symbolic/integration/integral.py, the word EXAMPLES appears two times, first in the usual place, then just after the ALIASES. this is a bit strange. shall we remove the second one?

@mforets
Copy link
Mannequin Author

mforets mannequin commented Apr 27, 2017

Branch: u/mforets/t/mforets/giac_integrator

@mforets
Copy link
Mannequin Author

mforets mannequin commented Apr 27, 2017

comment:3

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:

8e1af6dadd giac external integrator

@mforets
Copy link
Mannequin Author

mforets mannequin commented Apr 27, 2017

Commit: 8e1af6d

@mforets mforets mannequin added the s: needs review label Apr 27, 2017
@kcrisman
Copy link
Member

comment:4

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).

@mforets
Copy link
Mannequin Author

mforets mannequin commented Apr 27, 2017

comment:5

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)

@mforets
Copy link
Mannequin Author

mforets mannequin commented Apr 27, 2017

comment:6

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

@tscrim
Copy link
Collaborator

tscrim commented May 2, 2017

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented May 2, 2017

comment:7

I think this is something that we should get into the next Sage, but we should discuss on another ticket, and possibly sage-devel, switching the default integrator.

@mforets
Copy link
Mannequin Author

mforets mannequin commented May 2, 2017

comment:8

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 sage-devel, 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. abs-trig 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.

@kcrisman
Copy link
Member

kcrisman commented May 2, 2017

comment:9

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 sage-devel, for sure.

@vbraun
Copy link
Member

vbraun commented May 4, 2017

Changed branch from u/mforets/t/mforets/giac_integrator to 8e1af6d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants