Learning Scientific Programming with Python (2nd edition)

P6.5.6: Conic sections

Question P6.5.6

The implicit formula for a conic section may be written as the second-degree polynomial, $$ Q = Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0, $$ or in matrix form using the homogeneous coordinate vector,: $$ \mathbf{x} = \begin{pmatrix}x \\ y \\ 1\end{pmatrix}, $$

as $\mathbf{x}^T\mathbf{Q}\mathbf{x} = 0$, where

$$ \mathbf{Q} = \begin{pmatrix} A & B/2 & D/2 \\ B/2 & C & E/2\\ D/2 & E/2 & F \end{pmatrix}. $$

Conic sections may be classified according to the following properties of $\mathbf{Q}$, where the submatrix $\mathbf{Q}_{33}$ is $$ \mathbf{Q}_{33} = \begin{pmatrix}A & B/2\\B/2 & C\end{pmatrix}. $$

Write a program to classify the conic section represented by the 6 coefficients $A, B, C, D, E$ and $F$.

Some test-cases (coefficients not given are zero):