Eigenvalues in octave with eig()
Asked Answered
A

3

5

Consider the real, symmetric matrix

S = (2, 1; 1, 2)

From the characteristic equation |S - λ I|, we have the quadratic (2-λ)^2 - 1 = 0, whose solutions yield the eigenvalues 3 and 1. The corresponding eigenvectors are (1;-1) and (1;1).

octave:4> [V,lambda] = eig([2, 1; 1,2])
V =

  -0.70711   0.70711
   0.70711   0.70711

lambda =

Diagonal Matrix

   1   0
   0   3

Why are the eigenvectors in octave [-0.70711; 0.70711] and [0.70711; 0.70711]?

Arrowy answered 7/4, 2014 at 9:32 Comment(0)
D
8

Given λ1 = 3 the corresponding eigenvector is:

| 2 1 |   |x|     |x|
|     | * | | = 3 | |   =>   x = y
| 1 2 |   |y|     |y|

I.e. any vector of the form [x, x]', for any non-zero real number x, is an eigenvector. So [0.70711, 0.70711]' is an eigenvector as valid as [1, 1]'.

Octave (but also Matlab) chooses the values such that the sum of the squares of the elements of each eigenvector equals unity (eigenvectors are normalized to have a norm of 1 and are chosen to be orthogonal, to be precise).

Of course the same is valid for λ2 = 1.

Debutante answered 7/4, 2014 at 10:28 Comment(0)
C
1

In other words, V is one of the qr of [1 1; -1 1]

So you can check like this.

a = [1 1; -1 1]
[q,r] = qr(a)

q = 
   -0.70711  0.70711
    0.70711  0.70711

The result is the same as eig.

Cispadane answered 5/9, 2017 at 4:18 Comment(0)
T
1

Manlio is correct, and here is why:

Any eigenvalue problem has an infinite number of eigenvectors. When you find an eigenvector by hand, what you actually calculate is a parameterized vector representing that infinite family of solutions. The elements of a specific eigenvector Octave (and most computer software) returns for a given eigenvalue can be used to form the orthonormal basis vectors of the eigenspace associated with that eigenvalue. Any linear combination of those basis vectors will be an eigenvector.

So, if you were expecting a different eigenvector, just check to make sure that it is linearly dependent on the basis vectors Octave computed.

Tripe answered 25/3, 2018 at 1:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.