$ \def \J {\Delta} \def \half {\frac{1}{2}} \def \kwart {\frac{1}{4}} \def \hieruit {\quad \Longrightarrow \quad} \def \slechts {\quad \Longleftrightarrow \quad} \def \norm {\frac{1}{\sigma \sqrt{2\pi}} \; } \def \EN {\quad \mbox{and} \quad} \def \OF {\quad \mbox{or} \quad} \def \wit {\quad \mbox{;} \quad} \def \spekhaken {\iint} \newcommand{\dq}[2]{\displaystyle \frac{\partial #1}{\partial #2}} \newcommand{\oq}[2]{\partial #1 / \partial #2} \newcommand{\qq}[3]{\frac{\partial^2 #1}{{\partial #2}{\partial #3}}} \def \erf {\operatorname{Erf}} $

Drawing an Ellipse

The following general expression will be proposed for the ellipse of inertia: $$ \frac{\sigma_{yy} (x-\mu_x)^2 - 2 \sigma_{xy} (x-\mu_x) (y-\mu_y) + \sigma_{xx} (y-\mu_y)^2}{ \sigma_{xx} \sigma_{yy} - \sigma_{xy}^2 } = 1 $$ When making a drawing of such an ellipse, it would be more handsome to have it in parametrized form. That is, we seek an equivalent like this: \begin{cases} x = \mu_x + a_x\cos(t) + a_y\sin(t) \\ y = \mu_y + b_x\cos(t) + b_y\sin(t) \end{cases} Multiply the first equation with $b_x$, the second with $a_x$ and substract: $$ b_x (x-\mu_x) - a_x (y-\mu_y) = (a_y b_x - a_x b_y)\,\sin(t) \hieruit $$ $$ \sin(t) = \frac{b_x (x-\mu_x) - a_x (y-\mu_y)}{a_y b_x - a_x b_y} $$ Multiply the first equation with $b_y$, the second with $a_y$ and substract: $$ b_y (x-\mu_x) - a_y (y-\mu_y) = (b_y a_x - b_x a_y)\,\cos(t) \hieruit $$ $$ \cos(t) = \frac{b_y (x-\mu_x) - a_y (y-\mu_y)}{b_y a_x - b_x a_y} $$ Now use the well known identity: $$ \cos^2(t) + \sin^2(t) = 1 $$ Giving: $$ \left(\frac{b_x x' - a_x y'}{b_y a_x - b_x a_y}\right)^2 + \left(\frac{b_y x' - a_y y'}{a_y b_x - a_x b_y}\right)^2 = 1 $$ Where $x'= x-\mu_x$ and $y'= y-\mu_y$ . This result must be comparable with: $$ \frac{\sigma_{yy} (x')^2 - 2 \sigma_{xy} x'y' + \sigma_{xx} (y')^2}{ \sigma_{xx} \sigma_{yy} - \sigma_{xy}^2 } = 1 $$ Drop the primes $'$ in both equations for the sake of simplicity. Look after: $$ \left(\frac{b_x x - a_x y}{b_y a_x - b_x a_y}\right)^2 + \left(\frac{b_y x - a_y y}{a_y b_x - a_x b_y}\right)^2 = 1 $$ And work out: $$ \frac{(b_x^2 + b_y^2) \; x^2 - 2 (a_x b_x + a_y b_y) \; x y + (a_x^2 + a_y^2) \; y^2 }{ (b_y a_x - b_x a_y)^2 } = 1 $$ As compared with: $$ \frac{\sigma_{yy} x^2 - 2 \sigma_{xy} x y + \sigma_{xx} y^2}{ \sigma_{xx} \sigma_{yy} - \sigma_{xy}^2 } = 1 $$ We thus find: $$ a_x^2 + a_y^2 = \sigma_{xx} \EN b_x^2 + b_y^2 = \sigma_{yy} \EN a_x b_x + a_y b_y = \sigma_{xy} $$ It also follows that the following must hold: $$ \sigma_{xx} \sigma_{yy} - \sigma_{xy}^2 = (a_x b_y - b_x a_y)^2 $$ Check this: $$ (a_x^2 + a_y^2)(b_x^2 + b_y^2) - (a_x b_x + a_y b_y)^2 = $$ $$ a_x^2 b_x^2 + a_x^2 b_y^2 + a_y^2 b_x^2 + a_y^2 b_y^2 - (a_x^2 b_x^2 + a_y^2 b_y^2 + 2 a_x b_x a_y b_y) = $$ $$ (a_x b_y)^2 + (b_x a_y)^2 - 2 (a_x b_y) (b_x a_y) = (a_x b_y - b_x a_y)^2 $$ Happy maybe that this is consistent, we are nevertheless faced with a little problem: there are four unknowns $(a_x,a_y,b_x,b_y)$, but only three equations to solve for them. This problem is readily tackled by the meaning of the equations, though. The first equation means that the length of the vector $\vec{a}$ is equal to $\sqrt{\sigma_{xx}}$. The second equation means that the length of the vector $\vec{b}$ is equal to $\sqrt{\sigma_{yy}}$. The third equation means that the cosine of the angle between $\vec{a}$ and $\vec{b}$ is given by the inner product divided by these lengths: $ \cos(\theta) = \sigma_{xy}/(\sqrt{\sigma_{xx}\sigma_{yy}}) $. Now it is clear that these three facts are quite independent of an eventual rotation of the coordinate system: \begin{cases} a'_x = + \cos(\tau) a_x + \sin(\tau) a_y \\ a'_y = - \sin(\tau) a_x + \cos(\tau) a_y \end{cases} When applied to the parametrized equations, for example the first of the two: $$ x-\mu_x = a'_x\cos(t) + a'_y\sin(t) = $$ $$ \left[\cos(\tau)\; a_x + \sin(\tau)\; a_y\right] \cos(t) + \left[- \sin(\tau)\; a_x + \cos(\tau)\; a_y\right] \sin(t) = $$ $$ \left[\cos(\tau) cos(t) - \sin(\tau) \sin(t)\right] a_x + \left[\sin(\tau) cos(t) + \cos(\tau) \sin(t)\right] a_y = $$ $$ \cos(t + \tau)\; a_x + \sin(t + \tau)\; a_y $$ We conclude that a change of coordinate system is just the same as a different offset for the running parameter. Nothing interesting actually. This the reason why we are free to replace the four unknowns by only three. For example, choose $\vec{a}$ in the same direction as the x-axis, meaning that $a_y = 0$. Then the solution of our problem becomes: $$ a_x^2 = \sigma_{xx} \hieruit a_x = \sqrt{\sigma_{xx}} \EN a_x b_x = \sigma_{xy} \hieruit b_x = \sigma_{xy}/\sqrt{\sigma_{xx}} $$ $$ b_x^2 + b_y^2 = \sigma_{yy} \hieruit b_y = \sqrt{\sigma_{yy} - \sigma_{xy}^2/\sigma_{xx}} = \sqrt{\frac{\sigma_{xx}\sigma_{yy} - \sigma_{xy}^2}{\sigma_{xx}}} $$ \begin{cases} x = \mu_x + a_x\cos(t) + a_y\sin(t) \\ y = \mu_y + b_x\cos(t) + b_y\sin(t) \end{cases}