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