title: Rearrange equations for solver
body: <p>I am looking for a generic python way to manipulate text into solvable equations.</p>
  
  <p>For example:</p>
  
  <p>there may be some constants to initialize</p>
  
  <pre><code>e1,e2=0.58,0.62
  ma1,ma2=0.85,1.15
  mw=0.8
  Cpa,Cpw=1.023,4.193
  dba,dbr=0.0,25.0
  </code></pre>
  
  <p>and a set of equations (written here for readability rather than the solver)</p>
  
  <pre><code>Q=e1*ma1*Cpa*(tw1-dba)
  Q=ma1*Cpa*(dbs-dba)
  Q=mw*Cpw*(tw1-tw2)
  Q=e2*ma2*Cpa*(dbr-tw2)
  Q=ma2*Cpa*(dbr-dbo)
  </code></pre>
  
  <p>This leaves 5 unknowns, so presumably the system can be solved.</p>
  
  <pre><code>Q, dbo, dbr, tw1, tw2
  </code></pre>
  
  <p>Actual systems are non-linear and much more complicated.</p>
  
  <p>I have already solved this easy example with scipy, Delphi, Sage...  so I'm not looking for the solve part.</p>
  
  <p>The equations are typed directly into a text editor and I want a Python program to give me an array of unknowns and an array of error functions.</p>
  
  <pre><code>y = mysolver.fsolve(f, x)
  </code></pre>
  
  <p>So, for the above example</p>
  
  <pre><code>x=[Q,dbo,dbr,tw1,tw2]
  
  f=[Q-e1*ma1*Cpa*(tw1-dba), Q-ma1*Cpa*(dbs-dba), Q-mw*Cpw*(tw1-tw2),
     Q-e2*ma2*Cpa*(dbr-tw2), Q-ma2*Cpa*(dbr-dbo)]
  </code></pre>
  
  <p>I just don't know how to extract the unknowns and create the error functions.</p>
  
  <p>I tried the compile.parse() function and it seems to give a structured breakdown.</p>
  
  <p>Can anyone give some ideas on the best approach.</p>