On Monday, May 25, 2015 at 12:07:22 AM UTC-5, dori...@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?
>
>
>
Instead of defining a Python symbol, e.g. f = m*a, define an equation 
containing the symbols of interest, e.g. e1 = Eq(f, ma). Then, when 
solving, tell solve what you *don't* want to solve for and it will attempt 
to solve for the remaining symbols:

>>> e1=Eq(f,m*a)
>>> e2=Eq(rho,m*v)
>>> solve((e1,e2),exclude=[f,rho,v])  # i.e. solve for m and a
[{m: rho/v, a: f*v/rho}]
>>> 


/c

-- 
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/752770ef-51c4-426f-a264-e652a0717d2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to