title: Solve nonlinear equations with sympy, but i got results with a small imaginary part
body: <p>I am trying to solve a system of nonlinear equations with Sympy and Python. </p>
  
  <p>The result is almost right, but always with a extremly small imaginary part, and the process is time consuming. </p>
  
  <p>I also try the same computation under Matlab, the result is pretty good and fast.</p>
  
  <p>I know that small imaginary part can be ignored. But I think there must be something wrong in my code which result in slowly and imaginary part. Can any one help me with this?</p>
  
  <pre><code>Python:3.6
  Sympy:1.1.1
  </code></pre>
  
  <pre><code>import sympy
  A1, B1, C1, D1, E1, F1 = (0.0019047619047619048,
                            -1.7494954273533616e-19,
                            0.0004761904761904762,
                            -8.747477136766808e-18,
                            0.047619047619047616,
                            1.0)
  A2, B2, C2, D2, E2, F2 = (8.264462809917356e-05,
                            -0.0,
                            0.00033057851239669424,
                            -0.008264462809917356,
                            -0.03305785123966942,
                            1.0)
  k, b = sympy.symbols('k b')
  eq1 = B1 ** 2 * b ** 2 + 2 * B1 * D1 * b - 2 * B1 * E1 * b * k - 4 * F1 * B1 * k + D1 ** 2 + 2 * D1 * E1 * k + \
        4 * C1 * D1 * b * k + E1 ** 2 * k ** 2 - 4 * A1 * E1 * b - 4 * A1 * C1 * b ** 2 - 4 * C1 * F1 * k ** 2 - 4 * A1 * F1
  eq2 = B2 ** 2 * b ** 2 + 2 * B2 * D2 * b - 2 * B2 * E2 * b * k - 4 * F2 * B2 * k + D2 ** 2 + 2 * D2 * E2 * k + \
        4 * C2 * D2 * b * k + E2 ** 2 * k ** 2 - 4 * A2 * E2 * b - 4 * A2 * C2 * b ** 2 - 4 * C2 * F2 * k ** 2 - 4 * A2 * F2
  s=sympy.solve([eq1,eq2],[k,b])
  print(s)
  </code></pre>
  
  <p>That's what I got under Python and Sympy, with an extremely small imaginary  part. And it almost takes 10 seconds. That is not acceptable for my whole project.</p>
  
  <pre class="lang-none prettyprint-override"><code>[(1.07269682322063 + 2.8315655624133e-28*I, -27.3048937553762 + 0.e-27*I), 
  (1.79271658724978 - 2.83156477591471e-28*I, -76.8585791921325 - 0.e-27*I), 
  (2.34194482854222 + 2.83156702952074e-28*I, -19.2027508047623 - 0.e-26*I),
   (5.20930842765403 - 2.83156580622397e-28*I, -105.800442914396 - 7.59430998293648e-28*I)]
  </code></pre>
  
  <p>That's what I got under MATLAB with 'solve'. It's pretty fast. That's what I wanted.</p>
  
  <pre class="lang-none prettyprint-override"><code>k =
         5.2093
         1.7927
         1.0727
         2.3419
  b =
         -105.8
        -76.859
        -27.305
        -19.203
  </code></pre>