Fitting ellipse to 5 given points on the plane
The following is based on the fact that the determinant of a matrix is equal to zero when two rows are the same. Thus, if you plug any of the points in, you get a true statement.
SeedRandom[3];
pts = RandomReal[{-1, 1}, {5, 2}];
row[{x_, y_}] := {1, x, y, x*y, x^2, y^2};
eq = Det[Prepend[row /@ pts, row[{x, y}]]] == 0
(* Out:
0.0426805-0.0293168x-0.155097x^2-0.019868y-0.087933x*y-0.061593y^2 == 0
*)
ContourPlot[Evaluate[eq], {x, -1, 1}, {y, -1, 1},
Epilog -> Point[pts]]
The general equation of an ellipse (here) is given by:
ellipse[x_, y_] = a x^2 + b x y + c y^2 + d x + e y + f == 0;
solving using 5 points results in:
SeedRandom[3];
pts = RandomReal[{-1, 1}, {5, 2}];
sol = Solve[ellipse @@@ pts];
ellipse[x, y] /. sol[[1]] // Simplify
(*a (-0.275185 + 1. x^2 + x (0.189022 + 0.566953 y) + 0.1281 y +
0.397124 y^2) == 0*)
all $a$ values result in the same equation except when $a=0$.
Through 5 points we can pass a conic, an ellipse, hyperbola etc. After Algohi's solution coefficients are obtained we can determine choice of conic by sign of the second evaluated invariant $ (b^2 - 4 a c) $ along with standard calculated expression for values of rotation/translation of central conic.A sign change test for a test point chosen inside or outside can be done,it should vanish on the arc.