In Sympy, how do you isolate a generic variable?
I can do this, for instance:
>>> import sympy as sm
>>> P, rho, g, h = sm.symbols("P rho g h")
>>> depth = sm.Eq(P, rho*g*h)
>>> sm.solve(depth, h)
[P/(g*rho)]
But not this:
>>> T, a, mu = sm.symbols("T a mu")
>>> kepler3 = sm.Eq(T, 2*sm.pi*sm.sqrt(a**3 / mu))
>>> solve(kepler3, a)
[2**(1/3)*(T**2*mu)**(1/3)/(2*pi**(2/3)),
2**(1/3)*(T**2*mu)**(1/3)*(-1 + sqrt(3)*I)/(4*pi**(2/3)),
-2**(1/3)*(T**2*mu)**(1/3)*(1 + sqrt(3)*I)/(4*pi**(2/3))]
What I'm looking for is a way to automatically generate: sm.root(mu*T**2/(4*sm.pi**2), 3)
, which is technically the first one of the outputs.
Solve finds the roots, though, as opposed to writing it in terms of a given variable.