help-octave
[Top][All Lists]

## Re: eigenvectors

 From: heberf Subject: Re: eigenvectors Date: Wed, 9 Jun 1999 16:09:46 -0500 (CDT)

```Actually neither is correct in general.  In general you have

Q = X*D*inv(X)

but if Q is symmetric inv(X) = X'

Heber

On Wed, 9 Jun 1999, John W. Eaton wrote:

>
> | Ahh, I'd forgotten about the eig function.  I was looking in the help
> | under matrix factorizations and eig wasn't listed.  It's under basic
> | matrix functions.
>
> Oops.  I think I should move it.
>
> | Thanks,
> |
> | On Wed, 9 Jun 1999, Nimrod Mesika wrote:
> |
> | > >
> | > >         Q = inv(X)*D*X
> | > >
> | > use   [X,D] = eig(Q);
> | >
> | > D is a diagonal matrix (the elements are the eigenvalues of Q: lambda1,
> | > lambda2, etc..).
> | > X is a matrix of eigenvectors.
> | >
> | > Actually, since octave returns X as a unitary matrix (a matrix for which
> | > inv(A)=A') you also have the simpler expression:
> | >
> | > Q = X' * D * X;
>
> Except that I think the expression should be
>
>   Q = X * D * X'
>
> For example, a quick check shows
>
>   octave:15> q = hilb (3);
>   octave:16> [x, d] = eig (q)
>   x =
>
>     -0.12766   0.54745   0.82704
>      0.71375  -0.52829   0.45986
>     -0.68867  -0.64901   0.32330
>
>   d =
>
>     0.00269  0.00000  0.00000
>     0.00000  0.12233  0.00000
>     0.00000  0.00000  1.40832
>
>   octave:17> x*d*x' - q
>   ans =
>
>       0.0000e+00    0.0000e+00    5.5511e-17
>       0.0000e+00    0.0000e+00    5.5511e-17
>       5.5511e-17    5.5511e-17   -5.5511e-17
>
>   octave:18> x'*d*x - q
>   ans =
>
>     -0.269717   0.083138  -0.607023
>      0.083138   0.294810  -0.573999
>     -0.607023  -0.573999  -0.025093
>
>
> Also note that this diagonalization can fail if you have repeated
> eigenvalues.  For example, try q = [1, 2, 3; 0, 1, 2; 0, 0, 3].
>
> jwe
>
>
>
> ---------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.  To ensure
> that development continues, see www.che.wisc.edu/octave/giftform.html
> Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
> ---------------------------------------------------------------------
>
>

---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure