Calculating the length of the semi-major axis from the general equation of an ellipse What is the most accurate way of solving the length of the semi-major axis of this ellipse?  
$-0.21957597384315714 x^2 -0.029724573612439117 xy -0.35183249227660496 y^2 -0.9514941664721085 x + 0.1327709804087165 y+1 = 0$  
The answer should be extremely close to the correct value of the length of the semi-major axis which is equal to $3.073400961177073$  
I already tried to rotate the graph so that the major axis will coincide with the x-axis making the xy term equal to zero, then I made it into standard form, in which I was able to calculate the length of semi-major axis. However, the result differs from the true value by about $0.1$ . This difference is not acceptable since this value will be used many times for the orbit propagation formulas and in our final computation, the result has about 5% error. We could not accept this 5% error since our goal is to have an error of at least 2%. Thank you in advance.
 A: In this answer to a related question, it is shown that
$$
Ax^2+Bxy+Cy^2+Dx+Ey+F=0
$$
is simply a rotated and translated version of
$$
\small\left(A{+}C-\sqrt{(A{-}C)^2+B^2}\right)x^2+\left(A{+}C+\sqrt{(A{-}C)^2+B^2}\right)y^2+2\left(F-\frac{AE^2{-}BDE{+}CD^2}{4AC{-}B^2}\right)=0
$$
which says the semi-major axis is
$$
\left[\frac{2\left(\frac{AE^2{-}BDE{+}CD^2}{4AC{-}B^2}-F\right)}{\left(A{+}C-\sqrt{(A{-}C)^2+B^2}\right)}\right]^{1/2}
$$
and the semi-minor axis is
$$
\left[\frac{2\left(\frac{AE^2{-}BDE{+}CD^2}{4AC{-}B^2}-F\right)}{\left(A{+}C+\sqrt{(A{-}C)^2+B^2}\right)}\right]^{1/2}
$$
A: One strategy is to rotate the coordinate system so the semi-major/minor axes are parallel to the coordinate axis.
To do that, write your equation as $ax^2 + 2bxy + cy^2 + dx + ey = 1$. We can rewrite the first three terms as $(x \ y)A(x \ y)^T$ for the symmetric matrix $A = \left( \begin{matrix} a & b \\ b & c \end{matrix} \right)$. That matrix can be diagonalized and in the new coordinates, call them $(x', y')$, we have
$$fx'^2 + gy'^2 + hx' + jy' = 1$$
That equation you can now write in a 'standard form' for an ellipse and hence calculate precisely the length of either the semi-major or -minor axis.

I find that $A = RDR^{-1}$ where $D = diag(0.353482063035, 0.21792640308) = diag(f,g)$. (Using WA,  link, with the rotation matrix $R$.)
