# Math Help - Sketching an Ellipsoid using a matrix

1. ## Sketching an Ellipsoid using a matrix

How would I sketch the ellipsoids $x^t \Sigma^{-1} x <= 1$ for

$\Sigma =\begin{bmatrix}5 &4\\ 4 &5\end{bmatrix}$ and $\Sigma=\begin{bmatrix}3 & 0\\ 0 &3\end{bmatrix}$

clearly indicating the principal axes of the ellipsoid and the intersection of the ellipoids with the axes.

I know that the equation for an ellipsoid $\frac{x^2}{a} + \frac{y^2}{b} + \frac{z^2}{c} = 1$ but not sure how or if it even applies in this problem.

Any help would be greatly appreciated.

2. Are you after the confidence ellipsoid for $\mu$

$\displaystyle n(\bar{x}-\mu)^TS^{-1}(\bar{x}-\mu) \leq \frac{p(n-1)}{n-p}\times F_{p,n-p,\alpha}$

?

3. The matrix $\Sigma= \begin{bmatrix}5 & 4 \\ 4 & 5 \end{bmatrix}$ has eigenvalues 9 and 1 with corresponding eigenvectors $\begin{bmatrix}1 \\ 1\end{bmatrix}$ and $\begin{bmatrix}1 \\ -1\end{bmatrix}$ respectively. If we let $P= \begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix}$, the matrix having those eigenvalues as columns, then $P^{-1}=\begin{bmatrix}\frac{1}{2} & \frac{1}{2} \\ \frac{1}{2} & -\frac{1}{2}\end{bmatrix}$ and $P^{-1}\Sigma P= \begin{bmatrix}\frac{1}{2} & \frac{1}{2} \\ \frac{1}{2} & -\frac{1}{2}\end{bmatrix}\begin{bmatrix}5 & 4 \\ 4 & 5 \end{bmatrix}\begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix}= \begin{bmatrix}9 & 0 \\ 0 & 1\end{bmatrix}$, a diagonal matrix having the eigenvalues of $\Sigma$ on its diagonal.

Blast! I did this whole thing without realizing it was $\Sigma^{-1}$ you wanted rather than $Sigma$! Fortunately, we can still use all of that. If $P^{-1}\Sigma P= \begin{bmatrix}9 & 0 \\ 0 & 1\end{bmatrix}$, then taking the inverse of both sides, $P^{-1}\Sigma^{-1}P= D^{-1}= \begin{bmatrix}\frac{1}{9} & 0 \\ 0 & 1\end{bmatrix}$. And so $P\begin{bmatrix}\frac{1}{9} & 0 \\ 0 & 1\end{bmatrix}P^{-1}= \Sigma^{-1}$

The original equation was $x^T\Sigma^{-1}x= 1$. Which is the same as $x^T(P\begin{bmatrix}\frac{1}{9} & 0 \\ 0 & 1\end{matrix}P^{-1}x= 1$. Let $x'= P^{-1}x$ so that $x'^T= (P^{-1}x)^T= x^TP$ and the equation becomes $x'^T\begin{bmatrix}\frac{1}{9} & 0 \\ 0 & 1\end{bmatrix}x'= 1$.

If $x'= \begin{bmatrix}x' \\ y'\end{bmatrix}$ then that equation is $\frac{x'^2}{9}+ y'^2= 1$. That is an ellipse with axis of length 1/3 along the x'-axis and matrix of length 1 along the y' axis. That choice for x' means that the x'-axis is the same as the y= x line and the y' axis is the same as the y= -x line.

Summarizing, since the original ellipse, $\Sigma^{-1}$, has eigenvalues 1/3 and 1, with eigenvectors <1,1> (along the y= 1 line) and <1, -1> (along the y= -x line), respectively, the ellipse has semi-minor axis of length 1/3 along the line y= x and semi-major axis of length 1 along the y= -x line. The center is still at (0, 0), of course.

By the way, since this is in two dimensions, this is an ellipse, not an ellips[b]oid[b]. An "ellipsoid" is the three dimensional analog of the ellipse.

$\Sigma= \begin{bmatrix}3 & 0 \\ 0 & 3\end{bmatrix}$ has determinant 0 and so does NOT have an inverse.

4. Thanks for your help HallsofIvy. Just got a quick question. What's the different between semi-minor axis and semi-major axis? Is the major bigger than the minor?

$\Sigma= \begin{bmatrix}3 & 0 \\ 0 & 3\end{bmatrix}$ should have determinant 9 (not 0) and the inverse should exist. So would I apply the same process as the first matrix (even though this matrix only has 1 eigenvalue)?

5. Originally Posted by statmajor
Thanks for your help HallsofIvy. Just got a quick question. What's the different between semi-minor axis and semi-major axis? Is the major bigger than the minor?
Yes, that's the only difference.

$\Sigma= \begin{bmatrix}3 & 0 \\ 0 & 3\end{bmatrix}$ should have determinant 9 (not 0) and the inverse should exist. So would I apply the same process as the first matrix (even though this matrix only has 1 eigenvalue)?
For some reason, I was seeing $\Sigma= \begin{bmatrix}3 & 0 \\ 3 & 0\end{bmatrix}$.

Actually, you don't need to go through that process- basically, I was "diagonalizing" the matrix and this matrix is already diagonal. Not every 2 by 2 matrix having only one eigenvalue can be diagonalized- it depends on the number of independent eigenvectors. (Every symmetric matrix can be diagonalized.)

Here, 3 is the eigenvalue and independent eigenvectors are given by <1, 0> and <0, 1>, along the x and y axes. $\Sigma^{-1}= \begin{bmatrix}\frac{1}{3} & 0 \\ 0 & \frac{1}{3}\end{bmatrix}$ and if we write $= x= \begin{bmatrix}x \\ y \end{bmatrix}$, then $x^T\Sigma^{-1}x= \begin{bmatrix}x & y\end{bmatrix}\begin{bmatrix} \frac{1}{3} & 0 \\ 0 & \frac{1}{3}\end{bmatrix}\begin{bmatrix}x \\ y\end{bmatrix}$ $= \frac{x^2}{3}+ \frac{y^2}{3}= 1$ or $x^2+ y^2= 3$. That "ellipse" is actually a circle with center at (0, 0) and radius $\sqrt{3}$.

6. Just wondering what the point of diagonilzing the matrix is. Couldnt I just find the inverse of the matrix, let x = (y x) and just plug it back into the equation $x^t \Sigma^{-1} x <= 1$?

7. Originally Posted by statmajor
Just wondering what the point of diagonilzing the matrix is. Couldnt I just find the inverse of the matrix, let x = (y x) and just plug it back into the equation $x^t \Sigma^{-1} x <= 1$?
The point is to get the equation in "standard form" for an ellipse:
$\frac{x^2}{a^2}+ \frac{y^2}{b^2}=$ is an ellipse with sem-axis of length a along the x- axis and semi-axis of length b along the y axis.

With $\Sigma= \begin{bmatrix}5 & 4 \\ 4 & 5\end{bmatrix}$, $Sigma^{-1}= \begin{bmatrix}\frac{5}{9} & -\frac{4}{9} \\ -\frac{4}{9} & \frac{5}{9}\end{bmatrix}$ so that, taking $x= \begin{bmatrix}x\\ y\end{bmatrix}$, $x^t\Sigma^{-1}x<= 1$ becomes
$\begin{bmatrix}x & y\end{bmatrix}\begin{bmatrix}\frac{5}{9} & -\frac{4}{9} \\ -\frac{4}{9} & \frac{5}{9}\end{bmatrix}\begin{bmatrix}x \\ y \end{bmatrix}= \frac{5}{9}x^2- \frac{8}{9}xy+ \frac{5}{9}y^2\le 1$.

That "xy" term signals an ellipse whose axes are NOT along the x and y axes.

By determining the eigenvectors for the matrix, as I did before, you see that the axes are the lines y= x and y= -x.

A more tedious, less sophisticated, way of doing the same thing would be to let $x= x'cos(\theta)- y sin(\theta)$ and $y= x' sin(\theta)+ y' cos(\theta)$ in the equation of the ellipse, $\frac{5}{9}x^2- \frac{8}{9}xy+ \frac{5}{9}y^2= 1$, then determine $\theta$ to make the coefficient of x'y' equal to 0. You should get $\theta= \pi/4$.