how to express solution only in terms of some variables in sympy.solve?

150 Views Asked by At

How to express this solution in terms of r, g, and phi?

import sympy as sp
m, N, phi, v, g, r = sp.symbols('m N phi v g r')
sp.solve((-N*sp.sin(phi)+m*v**2/r,N*sp.cos(phi)-m*g),v, dict=True)

yields: $\left[ \left\{ v : - \sqrt{\frac{N r \sin{\left(\phi \right)}}{m}}\right\}, \ \left\{ v : \sqrt{\frac{N r \sin{\left(\phi \right)}}{m}}\right\}\right]$

The result I want is $v:\sqrt{rgtan(\phi)}$

as derived in: https://ocw.mit.edu/courses/8-01sc-classical-mechanics-fall-2016/pages/week-3-circular-motion/11-2-worked-example-car-on-a-banked-turn/

1

There are 1 best solutions below

0
On BEST ANSWER

You can add the variable you want to eliminate to the list of variables you want to solve for.

>>> sp.solve((-N*sp.sin(phi)+m*v**2/r, N*sp.cos(phi)-m*g), v, N, dict=True)

[{N: g*m/cos(phi), v: -sqrt(g*r*tan(phi))}, {N: g*m/cos(phi), v: sqrt(g*r*tan(phi))}]