Tensor of Inertia
$
\def \half {\frac{1}{2}}
\def \kwart {\frac{1}{4}}
\def \slechts {\quad \Longleftrightarrow \quad}
\def \EN {\quad \mbox{and} \quad}
$
In two dimensional space, the first order moments can be conceived as the two
components of a vector:
$$
\vec{\mu} = \left[ \begin{array}{c} \sum_k w_k x_k \\
\sum_k w_k y_k \end{array} \right]
$$
Likewise, the second order moments can be conceived as the three components of
a symmetric matrix, the so-called inertial tensor:
$$
\stackrel{\leftrightarrow}{\sigma} =
\left[ \begin{array}{cc} \sigma_{xx} & \sigma_{xy} \\
\sigma_{xy} & \sigma_{yy} \end{array} \right]
$$
At a more sophisticated level, the problem of finding the main axes of inertia
can then be approached via Linear Algebra, especially the theory of eigenvalues
and eigenvectors. It's a matter of routine to show that the expressions found
for the transformed moments of inertia are equivalent with the following:
find the orthogonal transformation (i.e. rotation over an angle $\theta$) which
reduces the tensor (matrix) of inertia to its diagonal form:
$$
\left[ \begin{array}{cc} \cos(\theta) & \sin(\theta) \\
- \sin(\theta) & \cos(\theta) \end{array} \right]
\left[ \begin{array}{cc} \sigma_{xx} & \sigma_{xy} \\
\sigma_{xy} & \sigma_{yy} \end{array} \right]
\left[ \begin{array}{cc} \cos(\theta) & - \sin(\theta) \\
\sin(\theta) & \cos(\theta) \end{array} \right] =
\left[ \begin{array}{cc} \sigma'_{xx} & 0 \\
0 & \sigma'_{yy} \end{array} \right]
$$
This, in turn, is equivalent with finding the eigenvalues $\lambda$ and the
eigenvectors $(\kappa_x,\kappa_y)$ of the inertial matrix:
$$
\left[ \begin{array}{cc} \sigma_{xx} & \sigma_{xy} \\
\sigma_{xy} & \sigma_{yy} \end{array} \right]
\left[ \begin{array}{c} \kappa_x \\ \kappa_y \end{array} \right] = \lambda
\left[ \begin{array}{c} \kappa_x \\ \kappa_y \end{array} \right]
$$
The corresponding characteristic equations are:
$$
\left| \begin{array}{cc} \sigma_{xx} - \lambda & \sigma_{xy} \\
\sigma_{xy} & \sigma_{yy} - \lambda \end{array}
\right| = 0 \slechts
$$ $$
( \sigma_{xx} - \lambda ) ( \sigma_{yy} - \lambda ) - \sigma_{xy}^2 = 0
\slechts
\lambda^2 - ( \sigma_{xx} + \sigma_{yy} ) \lambda
+ (\sigma_{xx} \sigma_{yy} - \sigma_{xy}^2) = 0
$$
Define trace $Sp$ and determinant $Det$ by:
$$
Sp := \sigma_{xx} + \sigma_{yy} \EN
Det := \sigma_{xx} \sigma_{yy} - \sigma_{xy}^2
$$
We have seen that the trace $(\sigma_{xx} + \sigma_{yy})$ is invariant for a
rotation of the coordinate system.
It is remarked that the determinant $(\sigma_{xx} \sigma_{yy} - \sigma_{xy}^2)$
is also invariant for such a transformation. The latter can be accepted as
a well known fact of Linear Algebra, or proved with help of elementary, though
somewhat laborious goniometry.
Having established trace and determinant, the characteristic equation of the
eigenvalue problem can be written as:
$$
\lambda^2 - (Sp)\lambda + Det = 0
$$
Most of the time, a quadratic equation has two solutions. The greatest of the
two solutions will be called $\lambda_1$ and the smallest one $\lambda_2$.
Sum and product of the solutions are found immediately:
$$
\lambda_1 + \lambda_2 = Sp \EN
\lambda_1 . \lambda_2 = Det
$$
Write the equation as:
$$
\lambda^2 - 2 (Sp/2) \lambda + (Sp/2)^2 = (Sp/2)^2 - Det \slechts
$$ $$
\left[ \lambda - (Sp/2) \right]^2 = (Sp/2)^2 - Det
\slechts \lambda - (Sp/2) = \pm \sqrt{ (Sp/2)^2 - Det }
$$ $$
\slechts \lambda = (Sp/2) \pm \sqrt{ (Sp/2)^2 - Det }
$$
Herewith we find the solutions:
$$
\lambda_1 = (Sp/2) + \sqrt{ (Sp/2)^2 - Det } $$ $$
\lambda_2 = (Sp/2) - \sqrt{ (Sp/2)^2 - Det } = Det / \lambda_1
$$
Provided that de discriminant is positive, indeed:
$$
(Sp/2)^2 - Det =
\kwart ( \sigma_{xx} + \sigma_{yy} )^2
- ( \sigma_{xx} \sigma_{yy} - \sigma_{xy}^2 ) =
$$ $$
\kwart \sigma_{xx}^2 + \kwart \sigma_{yy}^2 + \half \sigma_{xx} \sigma_{yy}
- \sigma_{xx} \sigma_{yy} + \sigma_{xy}^2 =
\kwart \sigma_{xx}^2 + \kwart \sigma_{yy}^2 - \half \sigma_{xx} \sigma_{yy}
+ \sigma_{xy}^2 =
$$ $$
= \kwart (\sigma_{xx} - \sigma_{yy})^2 + \sigma_{xy}^2 > 0
$$
Herewith the eigenvalues can also be expressed as:
$$
\lambda_{12} = \half ( \sigma_{xx} + \sigma_{yy} )
\pm \half ( \sigma_{xx} - \sigma_{yy} ) \sqrt{ 1 +
\left( \frac{2 \sigma_{xy}}{\sigma_{xx}-\sigma_{yy}} \right)^2}
$$
Where the expression between parentheses $(\,)$ is recognized as:
$$
\frac{2 \sigma_{xy}}{\sigma_{xx}-\sigma_{yy}} = \tan(2\theta)
$$
Calculation of the accompanying eigenvectors may be a tricky business, unless
proper measures are taken. Reconsider the formula which expresses the angle
over which the coordinate system must be rotated in order to force the cross
correllation moment to be zero:
$$
\tan(2 \theta) = \frac{2 \sigma_{xy}}{\sigma_{xx} - \sigma_{yy}}
\qquad \mbox{for} \quad \sigma_{xx} \ne \sigma_{yy}
$$
It is quite useful to distinguish the special cases $\sigma_{xy} = 0$ and
$\sigma_{xx} = \sigma_{yy}$ in the first place. But then the formula readily
gives an angle $\theta$ :
$$
\theta = \half \arctan\left(\frac{2 \sigma_{xy}}
{\sigma_{xx} - \sigma_{yy}}\right)
$$
Resulting in two possible eigenvectors, because the angle $\theta$ is ambiguous
up to a multiple of $90^o$ :
$$
\left[ \begin{array}{c} \cos(\theta) \\
\sin(\theta) \end{array} \right]
\EN
\left[ \begin{array}{c} - \sin(\theta) \\
\cos(\theta) \end{array} \right]
$$
It is necessary to decide afterwards which of the two eigenvectors is the one
belonging to the chosen eigenvalue. To that end, multiply both vectors with
the (singular) eigenvalue matrix:
$$
\left[ \begin{array}{cc} \sigma_{xx} - \lambda_1 & \sigma_{xy} \\
\sigma_{xy} & \sigma_{yy} - \lambda_1 \end{array}
\right] \left[ \begin{array}{c} \cos(\theta) \\ \sin(\theta) \end{array}
\right] \left[ \begin{array}{c} - \sin(\theta) \\ \cos(\theta) \end{array}
\right]
$$
The outcome with the smallest vector-length (idealiter = zero) corresponds with
the eigenvector to be selected.