Opened 2 years ago

Closed 2 years ago

#22997 closed enhancement (fixed)

Parse unevaluated integral from giac

Reported by: mforets Owned by:
Priority: major Milestone: sage-8.0
Component: calculus Keywords: integrate, interfaces, giac
Cc: Merged in:
Authors: Marcelo Forets Reviewers: Steven Trogdon
Report Upstream: N/A Work issues:
Branch: 0e5bdf0 (Commits) Commit: 0e5bdf047579f58f169429ea00f8519d4bdb80b4
Dependencies: Stopgaps:

Description

If integrate(..., algorithm='giac') does not find a solution, Sage should return an unevaluated expression.

For example, consider integrate(exp(-x^2)*log(x), x, algorithm='giac').

It returns either

Traceback (most recent call last):
...
NotImplementedError: Unable to parse Giac output: integrate(ln(x)*exp(-x^2),x)

or

integration(e^(-x^2)*ln(x), x)

depending on the user's locale settings (EN and FR respectively).

OTOH, both Maxima and SymPy? return integrate(e^(-x^2)*log(x), x).

Change History (15)

comment:1 Changed 2 years ago by mforets

  • Branch set to u/mforets/22997
  • Commit set to f3c9d15f97ebe44a4fa6fe83f3b56d62a34689ef

does it correspond at the level or giac_integrator (see symbolic/integration/external.py)? or at the level of the giac interface? (see def _sage_(self, locals={})).

in the former case, is this correct?

...
if 'integrate' in format(result) or 'integration' in format(result):
    return integrate(expr, v, a, b, hold=True) # ???
else:
    return result._sage_()

New commits:

f3c9d15add one doctest

comment:2 Changed 2 years ago by git

  • Commit changed from f3c9d15f97ebe44a4fa6fe83f3b56d62a34689ef to 2bba41df3121f7c1b14f9bc072aae8893e8494c9

Branch pushed to git repo; I updated commit sha1. New commits:

2bba41dparse result in giac_integrator

comment:3 Changed 2 years ago by mforets

  • Status changed from new to needs_review

comment:4 Changed 2 years ago by strogdon

  • Status changed from needs_review to needs_work

Perhaps this exposes a bug in sympy_integrator. These work

sage: integrate(e^(-x^2)*log(x), x, algorithm='giac')
integrate(e^(-x^2)*log(x), x)
sage: integrate(e^(-x^2)*log(x), x, algorithm='maxima')
integrate(e^(-x^2)*log(x), x)

although algorithm='maxima' was not doctested, but

integrate(e^(-x^2)*log(x), x, algorithm='sympy')

just hangs.

comment:5 Changed 2 years ago by mforets

here it works only after a looong time:

sage: integrate(e^(-x^2)*log(x), x, algorithm='sympy') # 15-20 minutes, processor intensive
integrate(e^(-x^2)*log(x), x)

comment:6 follow-up: Changed 2 years ago by strogdon

  • Authors set to Marcelo Forets
  • Reviewers set to Steven Trogdon
  • Status changed from needs_work to positive_review

OK, I was impatient. It took 30+ minutes here.

comment:7 in reply to: ↑ 6 Changed 2 years ago by mforets

Replying to strogdon:

OK, I was impatient. It took 30+ minutes here.

Thanks for the review!

comment:8 Changed 2 years ago by vbraun

  • Status changed from positive_review to needs_work

Merge conflict

comment:9 follow-up: Changed 2 years ago by strogdon

This really should have depended on #22833 since src/sage/symbolic/integration/external.py was touched there. I though I had that ticket merged when I tested things here, but apparently not, or else I would have noticed the conflict. #22833 is now in 8.0.beta7 and so this will have to be rebased. Just change it back to positive_review when that is done.

comment:10 in reply to: ↑ 9 Changed 2 years ago by mforets

Replying to strogdon:

This really should have depended on #22833 since src/sage/symbolic/integration/external.py was touched there.

my fault, thanks for pointing it out.

I though I had that ticket merged when I tested things here, but apparently not, or else I would have noticed the conflict. #22833 is now in 8.0.beta7 and so this will have to be rebased.

there's something that i don't understand. i do:

(in t/mforets/22997) $ git rebase develop
(... solve the merge conflict manually ...)
(in t/mforets/22997) $ git add src/sage/symbolic/integration/external.py
(in t/mforets/22997) $ git status
rebase in progress; onto 7a36941
You are currently rebasing branch 't/22997/22997' on '7a36941'.
  (all conflicts fixed: run "git rebase --continue")

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   src/sage/symbolic/integration/external.py
(in t/mforets/22997) $ git rebase --continue
Applying: parse result in giac_integrator

up to now everything seems to work fine, locally. however i try to push to the remote branch and it breaks:

(in t/mforets/22997) $ git push trac HEAD:u/mforets/22997
To trac.sagemath.org:sage.git
 ! [rejected]        HEAD -> u/mforets/22997 (non-fast-forward)
error: failed to push some refs to 'git@trac.sagemath.org:sage.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

it also breaks if i use the automatic command:

(in t/mforets/22997) $ git trac push
Pushing to Trac #22997...
Guessed remote branch: u/mforets/22997
Traceback (most recent call last):
  File "/usr/local/bin/git-trac", line 18, in <module>
    cmdline.launch()
  File "/Users/forets/sage-src/sage/git-trac-command/git_trac/cmdline.py", line 223, in launch
    app.push(ticket_number, remote=args.remote, force=args.force)
  File "/Users/forets/sage-src/sage/git-trac-command/git_trac/app.py", line 216, in push
    self.repo.push(remote, force)
  File "/Users/forets/sage-src/sage/git-trac-command/git_trac/git_repository.py", line 197, in push
    self.git.echo.push('trac', refspec)
  File "/Users/forets/sage-src/sage/git-trac-command/git_trac/git_interface.py", line 341, in meth
    return self.execute(git_cmd, *args, **kwds)
  File "/Users/forets/sage-src/sage/git-trac-command/git_trac/git_interface.py", line 98, in execute
    popen_stderr=subprocess.PIPE)
  File "/Users/forets/sage-src/sage/git-trac-command/git_trac/git_interface.py", line 263, in _run
    raise GitError(result)
git_trac.git_error.GitError: git returned with non-zero exit code (1) when executing "git push trac HEAD:refs/heads/u/mforets/22997"
    STDERR: To trac.sagemath.org:sage.git
    STDERR:  ! [rejected]        HEAD -> u/mforets/22997 (non-fast-forward)
    STDERR: error: failed to push some refs to 'git@trac.sagemath.org:sage.git'
    STDERR: hint: Updates were rejected because a pushed branch tip is behind its remote
    STDERR: hint: counterpart. Check out this branch and integrate the remote changes
    STDERR: hint: (e.g. 'git pull ...') before pushing again.
    STDERR: hint: See the 'Note about fast-forwards' in 'git push --help' for details.

comment:11 Changed 2 years ago by git

  • Commit changed from 2bba41df3121f7c1b14f9bc072aae8893e8494c9 to 0e5bdf047579f58f169429ea00f8519d4bdb80b4

Branch pushed to git repo; I updated commit sha1. New commits:

0e5bdf0Merge branch 'develop' into t/mforets/22997

comment:12 Changed 2 years ago by mforets

  • Status changed from needs_work to positive_review

(merged into v.8.0.beta7)

comment:13 Changed 2 years ago by chapoton

  • Status changed from positive_review to needs_work

The doctest is going to fail with the French locale:

sage: from sage.symbolic.integration.external import *
sage:  giac_integrator(e^(-x^2)*log(x), x)
integration(e^(-x^2)*ln(x), x)

comment:14 Changed 2 years ago by chapoton

  • Status changed from needs_work to positive_review

oops, sorry.

comment:15 Changed 2 years ago by vbraun

  • Branch changed from u/mforets/22997 to 0e5bdf047579f58f169429ea00f8519d4bdb80b4
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.