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

maxima interface integration problem #13071

Open
sagetrac-dsm mannequin opened this issue May 31, 2012 · 2 comments
Open

maxima interface integration problem #13071

sagetrac-dsm mannequin opened this issue May 31, 2012 · 2 comments

Comments

@sagetrac-dsm
Copy link
Mannequin

sagetrac-dsm mannequin commented May 31, 2012

Something seems to be going wrong in maxima_lib:


sage: integrate(sin(x), x)
-cos(x)
sage: integrate(sin(x)*exp(x), x)
1/2*(sin(x) - cos(x))*e^x
sage: integrate(sin(x)*exp(x)/x, x)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (580, 0))

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/mcneil/sagedev/sage-5.1.beta1/devel/sage-hack/sage/<ipython console> in <module>()

/home/mcneil/sagedev/sage-5.0/local/lib/python2.7/site-packages/sage/misc/functional.pyc in integral(x, *args, **kwds)
    726     """
    727     if hasattr(x, 'integral'):
--> 728         return x.integral(*args, **kwds)
    729     else:
    730         from sage.symbolic.ring import SR

/home/mcneil/sagedev/sage-5.0/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.integral (sage/symbolic/expression.cpp:33707)()

[...]

/home/mcneil/sagedev/sage-5.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.pyc in max_to_sr(expr)
   1536         op=max_op_dict[op_max]
   1537         max_args=cdr(expr)
-> 1538         args=[max_to_sr(a) for a in max_args]
   1539         return op(*args)
   1540     elif expr.symbolp():

/home/mcneil/sagedev/sage-5.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.pyc in max_to_sr(expr)
   1537         max_args=cdr(expr)
   1538         args=[max_to_sr(a) for a in max_args]
-> 1539         return op(*args)
   1540     elif expr.symbolp():
   1541         if not(expr in max_sym_dict):

TypeError: op_mul expected 2 arguments, got 1

This happens in 5.0 and beyond. Unfortunately I don't have a 4.8 at hand so I can't track it down before that.

Strangely enough, if you do it again, you get a different error:


/home/mcneil/sagedev/sage-5.0/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.pyc in sr_integral(self, *args)
    745                 raise ValueError, "Computation failed since Maxima requested additional constraints; using the 'assume' command before integral evaluation *may* help (example of legal syntax is 'assume(" + s[4:k] +">0)', see `assume?` for more details)\n" + s
    746             else:
--> 747                 raise error
    748 
    749     def sr_sum(self,*args):

RuntimeError: ECL says: Error executing code in Maxima: conjugate: wrong number of arguments.

So -- and this might be independent -- something's stateful which probably shouldn't be.

CC: @kcrisman

Component: symbolics

Keywords: integral

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

@sagetrac-dsm sagetrac-dsm mannequin added this to the sage-5.11 milestone May 31, 2012
@sagetrac-dsm sagetrac-dsm mannequin assigned burcin May 31, 2012
@nbruin
Copy link
Contributor

nbruin commented Jun 1, 2012

comment:1

Yep, sage is trying to learn how to translate "conjugate" and gets tripped up. The following does work because it primes the dictionary.

sage: integrate(conjugate(Ei((I+1)*x)),x)
integrate(-conjugate(Ei(-(I + 1)*x)), x)
sage: integrate(sin(x)*exp(x)/x, x)
-1/4*I*conjugate(Ei(-(I - 1)*x)) + 1/4*I*conjugate(Ei((I + 1)*x)) + 1/4*I*Ei(-(I - 1)*x) - 1/4*I*Ei((I + 1)*x)

The problem is that sage tries to learn what conjugate is from this expression:

sage: expr=maxima("conjugate(gamma_incomplete(0,(-%i-1)*x))")
conjugate(gamma_incomplete(0,(-%i-1)*x))

but its conversion to SR pulls out a minus sign:

sage: SR(expr)
-conjugate(Ei((I + 1)*x))

so in max_to_sr line 1530 text-based fallback we find that the corresponding operator is:

sage: SR(expr).operator()
<built-in function mul>

Once conversion of multiplication is broken, we of course get all kinds garbage. A warning for exactly this problem is in the source.

Work-around for this particular issue: Prepopulate sage_op_dict with conjugate

A better solution would be to once and for all solve this problem by initializing sage_op_dict from the same source where the text-based interface gets its knowledge from.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@embray embray removed this from the sage-6.4 milestone Feb 28, 2019
@fchapoton
Copy link
Contributor

Changed keywords from none to integral

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

5 participants