problem in simply with matrix value and multiplication

51 views
Skip to first unread message

Kenneth Frankel

unread,
Jul 8, 2016, 6:47:30 PM7/8/16
to sympy
I downloaded python and simply (etc) from anaconda, and installed anaconda2 and anaconda3.
I upgraded to the latest simply (1.0) and have this problem

When I run

import sympy

from sympy import *

sympy.__version__


x=Symbol('x')

y=Symbol('y')

M=IndexedBase('M')


integrate(cos(M[0] + x*y),x)

integrate(cos(M[0] + x),x)

integrate(cos(M[0] * x),x)


They all work except integrate(cos(M[0] * x),x) throws an error (see output below).

All I can find in the documentation is that there can be 'problems'.

Any idea if I am missing something or is there a bug in simply?

In the meantime my problem is so complex, I can only use variables 2 at a time,

so I can hardcode a fix in my formulas.


Thanks for any advice.

Regards,

Ken Frankel


output:

(same in python 3.5.1 and 2.7.11


python

Python 2.7.11 |Anaconda 4.0.0 (32-bit)| (default, Dec  6 2015, 18:08:45) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

Anaconda is brought to you by Continuum Analytics.

Please check out: http://continuum.io/thanks and https://anaconda.org

>>> import sympy

>>> from sympy import *

>>> sympy.__version__

'1.0'

>>> 

>>> x=Symbol('x')

>>> y=Symbol('y')

>>> M=IndexedBase('M')

>>> 

>>> integrate(cos(M[0] + x*y),x)

Piecewise((x*cos(M[0]), Eq(y, 0)), (sin(x*y + M[0])/y, True))


>>> integrate(cos(M[0] + x),x)

sin(x + M[0])


>>> integrate(cos(M[0] * x),x)

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 1280, in integrate

    risch=risch, manual=manual)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 486, in doit

    conds=conds)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/integrals/integrals.py", line 860, in _eval_integral

    h = trigintegrate(g, x, conds=conds)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/integrals/trigonometry.py", line 100, in trigintegrate

    return Piecewise((zz, Eq(a, 0)), (fx / a, True))

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/functions/elementary/piecewise.py", line 110, in __new__

    r = cls.eval(*newargs)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/functions/elementary/piecewise.py", line 146, in eval

    cond_eval = cls.__eval_cond(cond)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/functions/elementary/piecewise.py", line 507, in __eval_cond

    if checksol(cond, {}, minimal=True):

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/solvers/solvers.py", line 227, in checksol

    if not val.is_constant(*list(sol.keys()), simplify=not minimal):

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/core/expr.py", line 535, in is_constant

    simultaneous=True)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/core/basic.py", line 893, in subs

    rv = rv._subs(old, d*m, **kwargs)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/core/basic.py", line 1016, in _subs

    rv = fallback(self, old, new)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/core/basic.py", line 988, in fallback

    arg = arg._subs(old, new, **hints)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/core/basic.py", line 1016, in _subs

    rv = fallback(self, old, new)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/core/basic.py", line 993, in fallback

    rv = self.func(*args)

  File "/home/Users/frankel/anaconda2/lib/python2.7/site-packages/sympy/tensor/indexed.py", line 334, in __new__

    raise TypeError("Base label should be a string or Symbol.")

TypeError: Base label should be a string or Symbol.

Aaron Meurer

unread,
Jul 8, 2016, 7:10:16 PM7/8/16
to sy...@googlegroups.com
This looks like a bug in SymPy.

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/9fdd6809-e4da-4ff1-a3be-d206f02cb169%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kenneth Frankel

unread,
Jul 10, 2016, 5:17:40 PM7/10/16
to sympy
Aaron
Thanks, that was our guess. I've been trying to follow the error in the python debugger but it's pretty tedious.
I'll run it through gdb and post it to github unless I here from anyone else about a fix.
Regards
Ken Frnakel

Aaron Meurer

unread,
Jul 10, 2016, 5:46:40 PM7/10/16
to sy...@googlegroups.com
Here's an issue for the problem. https://github.com/sympy/sympy/issues/7423. It doesn't look like anyone has figured out the source of the problem yet. 

Aaron Meurer 

Kenneth Frankel

unread,
Jul 13, 2016, 2:45:17 PM7/13/16
to sympy
Aaron
Thanks, I see. My code worked fine in Mathematica (which I have adapted to python). In Mathematica it  was also easier to insert the numerical values when I needed to get the numerical values of the integrals.
However python is free and I have easy access to lots of cpus!. Rewriting the formulas explicitly with Symbols instead of IndexedBased gave me the correct solutions, if albeit with messy lookng code.
Regards
Ken
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages