Let $F_1$, $F_2$ be the foci points of an ellipse $\mathcal{E}\colon \mathbf{x}^TA\mathbf{x}=1$, $\mathbf{x}\in\mathbb{R}^2$, $A\in\mathbb{S}_{++}^{2}$. Let also $a$, $b$ be the semi-axes of $\mathcal{E}$. We would like to find the (symmetric positive-definite) matrix $A$.

I tried the following:

I first constructed the diagonal matrix $D=\operatorname{diag}\{a^{-2},b^{-2}\}$. Then I cunstructed the orthogonal matrix $U=[\mathbf{u}_1\:\:\mathbf{u}_2]$, where $\mathbf{u}_1=F_1F_2$ and $\mathbf{u}_2\perp\mathbf{u}_1$, specificaly $\mathbf{u}_2 = (-u_{12},u_{11})^T$.

Finally I got $A=UDU^T$. But when I use Matlab's eig() function to get again the eigenvalues and the eigenvectors, while I get correctly the eigenvalues, I get the opposite of the eigenvectors.

What is the error here? Thanks a lot!

  • 1
    $\begingroup$ Do you mean "opposite sign"? If so, there's no error, since eigenvectors are unique only up to multiplication by scalars. In particular, if $Ax=\lambda x$, then $A(-x) = \lambda (-x)$. $\endgroup$ Aug 7, 2014 at 13:49
  • $\begingroup$ Yes, this is what I mean. So, is there any way of getting the correct eigenvectors? $\endgroup$ Aug 7, 2014 at 13:51
  • 2
    $\begingroup$ Both are correct eigenvectors. If you want to have (say) $u_{11}\geq 0$, just multiply $u_1$ by $\mathsf{sign}(u_{11})$. $\endgroup$ Aug 7, 2014 at 13:53
  • $\begingroup$ Thanks @ChristianClason, but isn't it significant which exactly are the eigenvectors? Since they determine a new basis... $\endgroup$ Aug 7, 2014 at 13:55
  • $\begingroup$ They're not really a new basis; just a rescaling of the same basis; they span exactly the same subspace (which is all eigenvectors care about). $\endgroup$ Aug 7, 2014 at 13:58

1 Answer 1


As indicated in several of the comments, if $\mathbf{v}$ is an eigenvector of $A$, then so is $\alpha\mathbf{v}$ for any $\alpha \ne 0$. Given an eigenvalue $\lambda$, there are thus infinitely many eigenvectors. Whatever solver you are using normalizes the eigenvectors, reducing this set to two possibilities; $\pm \mathbf{v}$ where $|\mathbf{v}|=1$. The solver has no way of knowing which of these two you want.

This raises the question, do you care which you get? In terms of specifying the ellipse, or spanning the relevant space, the answer is no. If $\{\mathbf{v}_i\}$ is the set of eigenvectors, then any combination of sign changes on these vectors, $\{\pm \mathbf{v}_i\}$, spans the same subspace and equivalently defines the same ellipse when you construct your matrix $A$ from them.

There are cases, however, in which it matters which you get. For example, if you wanted to obtain the angular velocity of the ellipse given a time-series of matrices $\{A_i\}$, you would do so using the eigenvectors of each $A_i$. The matrix whose columns are the eigenvectors of $A$ defines a rotation, and in this case taking the opposite eigenvector will give a different rotation (although symmetric with respect to the ellipse).

Does it matter for your problem what the signs are? If so, we can devise a way to get you the "right" ones.

  • $\begingroup$ Thanks, @Eric, yeah, the answer is actually "no", as I have figured out recently. Your answer still helps though! :) $\endgroup$ Aug 9, 2014 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.