title: How to rearrange a complicated equation by Python
body: <p>I want to rearrange the below equation for the variable <code>r</code> by using Python.</p>
  
  <pre><code>P = C * ((1-(1+r)**(-n)))/r + fv*(1+r)**(-n)
  to
  r = blabla...
  </code></pre>
  
  <p>I understood that sympy is related to a rearranging task like this. So, I wrote the below codes.</p>
  
  <pre class="lang-py prettyprint-override"><code># Solve the equation for r
  import sympy
  from sympy import symbols
  
  P, C, r, n, fv = sympy.symbols('P C r n fv')
  eq = sympy.Eq(P, C * ((1-1/(1+r)**n))/r + fv/(1+r)**n)
  sympy.solve(eq, r)
  </code></pre>
  
  <p>However, I got the error like this.</p>
  
  <pre><code>NotImplementedError                       Traceback (most recent call last)
  &lt;ipython-input-47-a183add313da&gt; in &lt;module&gt;
        3 P, C, r, n, fv = sympy.symbols('P C r n fv')
        4 eq = sympy.Eq(P, C * ((1-1/(1+r)**n))/r + fv/(1+r)**n)
  ----&gt; 5 sympy.solve(eq, r)
  
  ~\Anaconda3\lib\site-packages\sympy\solvers\solvers.py in solve(f, *symbols, **flags)
     1169     ###########################################################################
     1170     if bare_f:
  -&gt; 1171         solution = _solve(f[0], *symbols, **flags)
     1172     else:
     1173         solution = _solve_system(f, symbols, **flags)
  
  ~\Anaconda3\lib\site-packages\sympy\solvers\solvers.py in _solve(f, *symbols, **flags)
     1740 
     1741     if result is False:
  -&gt; 1742         raise NotImplementedError('\n'.join([msg, not_impl_msg % f]))
     1743 
     1744     if flags.get('simplify', True):
  
  NotImplementedError: multiple generators [r, (r + 1)**n]
  No algorithms are implemented to solve equation -C*(1 - (r + 1)**(-n))/r + P - fv*(r + 1)**(-n)
  </code></pre>
  
  <p>I guess the calculation for power is not available as to sympy. 
  Do you know how to execute this kind of complicated rearrangement for a equation?
  I am using Python==3.7, sympy==1.4.</p>