If you work with the current master you won't get the Indexed error:
>>> from sympy import IndexedBase
>>> A=IndexedBase('A')
>>> solve([A[0] + 5*A[1] - 2, -3*A[0]+ 6*A[1] - 15])
[]
But no solution...so let's try the Tuple-atoms trick:
>>> eqs=Tuple(*([A[0] + 5*A[1] - 2, -3*A[0]+ 6*A[1] - 15]))
>>> solve(eqs,eqs.atoms(IndexedBase))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sympy/solvers/solvers.py", line 689, in solve
raise TypeError(msg % type(s))
TypeError: expected Symbol, Function, Power or Derivative but got <class
'sympy.tensor.indexed.IndexedBase'>
(that should be fixed -- solve should be able to solve for other things,
too)
So replace them with dummies:
>>> reps = [(i, Dummy()) for i in eqs.atoms(Indexed)]
>>> solve(eqs.subs(reps),[d for i, d in reps])
{_20: -3, _21: 1}
Make the solution a SymPy object capable of doing replacement:
>>> Dict(_).xreplace(dict([(v,k) for k,v in reps]))
{A[0]: -3, A[1]: 1}
And there we are!
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.