title: How to find the equation for an ellipse
body: <p>I am looking to find the equation for an ellipse given five or six points using the general equation for a conic: 
  A x2 + B xy + C y2 + D x + E y + F = 0. </p>
  
  <p>At first I tried using six points. Here is my python code:</p>
  
  <pre><code>    import numpy as np
      def conic_section(p1, p2, p3, p4, p5, p6):
          def row(point):
              return [point[0]*point[0], point[0]*point[1], point[1]*point[1],                         
              point[0], point[1], 1]
          matrix=np.matrix([row(p1),row(p2),row(p3),row(p4),row(p5), row(p6)])
          b=[0,0,0,0,0,0]
          return np.linalg.solve(matrix,b)
  
      print conic_section(np.array([6,5]), np.array([2,9]), np.array([0,0]),         
      np.array([11, 5.5]), np.array([6, 7]), np.array([-1,-1]))
  </code></pre>
  
  <p>The problem is that this will return the solution [0,0,0,0,0,0] because the right hand side of my equation is the zero vector.</p>
  
  <p>I then attempted to change the conic by subtracting the F and dividing it through:</p>
  
  <p>A x2 + B xy + C y2 + D x + E y + F = 0</p>
  
  <p>A x2 + B xy + C y2 + D x + E y = -F</p>
  
  <p>A' x2 + B xy + C' y2 + D' x + E' y = -1.</p>
  
  <p>The reason that this doesn't work though is that if one of my point is (0,0), then I would end up with a Matrix that has a row of zeros, yet the right hand side of the equation would have a -1 for the entries in the vector. In other words, if one of my points is (0,0) - then "F" should be 0, and so I can't divide it out.</p>
  
  <p>Any help would be appreciated.
  Thank You.</p>