On Mon, May 25, 2015 at 5:18 AM, <doris...@berkeley.edu> wrote: > Hi all, > > I am new to SymPy and I am trying to rearrange equations in order to express > one variable in terms of another in SymPy. > For example, I have two physics equations F=ma and rho=m/v which I defined > in the beginning. I want to re-express ``a`` in terms of f,rho, and v. > However, the ``solve`` function sets the right hand side of the equation so > that it is equal to zero so then when I try to get ``a`` in terms of `f` it > returns zero. > Is there a way I could do this SymPy, if so, which function should I be > looking at instead?
Is this what you want? First find m in terms of F and a: >>> m1 = solve(F-m*a, m, dict=True)[0][m] Now, feed in above to the second equation: >>> solve(rho - m1/v, a) [F/(rho*v)] Best, Amit. > > Thank you. > > > > In [6]: > > from sympy import * > > In [11]: > > f = Symbol('f') > > m = Symbol('m') > > a = Symbol('a') > > rho = Symbol('rho') > > v = Symbol('v') > > In [37]: > > f=m*a > > rho=m*v > > In [38]: > > solve(a,[f]) > > Out[38]: > > [] > > In [39]: > > solve(rho,[v]) > > Out[39]: > > [0] > > In [42]: > > solve_linear(f-m*a,f) > > Out[42]: > > (m, 0) > > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to sympy@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/b3475c31-357a-4f59-abe1-a4b43a78892e%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- http://echorand.me -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sympy@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/CANODV3%3DyCNoKRJMxOQUnYvJz4Q0rAk6W9KP10n1bsvt4%3DwtDUg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.