Indexed symbols in simultaneous equation

32 views
Skip to first unread message

TIANJIAO SUN

unread,
Jun 8, 2015, 11:36:34 AM6/8/15
to sy...@googlegroups.com
Hi,
For expressive reasons, in some applications I name my symbols as IndexedBased, but really I want to consider U[x,y] and U[x,y-1] etc to be unrelated.
I got equations of relations between bunch of such symbols, and I want to express some of them with the others, but somehow solve() doesn't work for simultaneous equations.
In this example:

U = IndexedBase('U')
x,y = symbols('x y')
eq1 = Eq(U[x,y]+5*U[x,y-1]-2,0)
eq2 = Eq(-4*U[x,y-1]+5*U[x-1,y],0)

solve(eq1,U[x,y])  # this works and give -5*U[x,y-1]+2 as expected
solve([eq1,eq2],U[x,y])  # but this gives errors

tracing down the errors message and it seems to related to testing if the equations are constant
/home/anaconda/lib/python2.7/site-packages/sympy/solvers/solvers.pyc in solve(f, *symbols, **flags)
    844                 ok = True
    845             else:
--> 846                 if fi.is_constant():
    847                     ok = True
    848         if ok:

And I tried swapping symbols with Idx which gives same result.

I figure it's probably due to sympy trying to remove equations from the list that are constant. But I don't have a good explanation as to 1) why Indexed symbols are different and 2) why it works in the previous case?

Thanks,
-TS

Aaron Meurer

unread,
Oct 19, 2015, 4:02:56 PM10/19/15
to sy...@googlegroups.com
I think this is an instance of this bug
https://github.com/sympy/sympy/issues/9791.

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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/ff10d4df-dbf9-427a-a61f-7efeb8031a24%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages