title: Trouble solving a system of 6 nonlinear equations in Python
body: <p>I'm trying to solve a system of 6 non linear equations with Python. So far I've got:</p>
  <pre><code>from scipy.optimize import fsolve 
  import math 
  from numpy import log
  
  ka1 = 1.045
  ka2 = 0.1759
  ka3 = 0.3159
  
  def equations(p):
      yh2o, yco2, yh2, ych4, yco = p
  
      return (yh2o + yco2 + yh2 + ych4 + yco - 1,
          ka1 - (yh2o ** 2)/(yco * (yh2 ** 2),
          ka2 - (yco ** 2) / yco2,
          ka3 - ych4 / (yh2 ** 2),
          0.5 - (2.0 * yco2 + yco + yh2o) / (2 * yh2o + 2 * yh2 + 4 * ych4)))
  
  yh2o, yco2, yh2, ych4, yco = fsolve(equations, [0.2, 0.2, 0.2, 0.2, 0.2])
  
  print(f&quot;yh2o = {yh2o}, yco2 = {yco2}, yh2 = {yh2}, ych4 = {ych4}, yco = {yco}&quot;)
  
  </code></pre>
  <p>When I try to run this I get</p>
  <pre><code>TypeError: fsolve: there is a mismatch between the input and output shape of the 'func' argument 'equations'.Shape should be (5,) but it is (2,).
  </code></pre>
  <p>I've tried changing the initial guess but the error is still the same.</p>
  <p>I've also tried changing the equations into polynomials like so:</p>
  <pre><code>    return (yh2o + yco2 + yh2 + ych4 + yco - 1.0,
          ka1 * (yco * (yh2 ** 2.0)) - (yh2o * yh2o),
          ka2 * (yco2) - (yco ** 2.0),
          ka3 * (yh2 ** 2.0) - ych4,
          0.5 * (2.0 * yh2o + 2.0 * yh2 + 4 * ych4) - (2.0 * yco2 + yco + yh2o)) 
  </code></pre>
  <p>But I get an error saying</p>
  <pre><code>TypeError: can't multiply sequence by non-int of type 'float'
  </code></pre>