## Thursday, July 9, 2009

### Eigenvalues, part 2

Continuing with the previous post, let's do a bigger problem. Suppose we have a 3 x 3 matrix A:

 `A = [ 2 1 0 ] [ 1 4 0 ] [ 2 5 2 ]`

The characteristic polynomial of A is given by:

 `det|A - kI|kI = [ k 0 0 ] [ 0 k 0 ] [ 0 0 k ]A - kI = [ 2-k 1 0 ] [ 1 4-k 0 ] [ 2 5 2-k ]`

Remembering that for a 3 x 3 matrix

 `M = [ a1 a2 a3 ] [ b1 b2 b3 ] [ c1 c2 c3 ]`

the determinant det|M| is the sum of three terms. The first is:

 ` a1 * det | [ b2 b3 ] | [ c2 c3 ]`

The other two are similar, except that second term, starting with a2 * ..., is multiplied by - 1. So, going back to our problem:

 `A - kI = [ 2-k 1 0 ] [ 1 4-k 0 ] [ 2 5 2-k ]`

det|A = kI| is:

 `[ (2 - k) * ((4 - k)(2 - k) - 0) ] - 1 * ( (1)(2 - k) - 0 ) + 0= (2 - k)(8 - 6k + k^2) - (2 - k)= (2 - k)(k^2 - 6k + 7)`

Setting this equal to zero, one solution is

 `k = 2`

We use the quadratic formula to obtain the
other two roots:

 `( -b +/- sqrt(b^2 - 4ac) ) / 2a( 6 +/- sqrt (36 - 28) ) / 2( 6 +/- sqrt(8) ) / 2 3 +/- sqrt(2)`

The solutions are: 4.414, 2, 1.586

To find the first eigenvector (for k = 3 + sqrt(2) ),
we have:

 `Av = kv`

where v is a vector with values x,y,z:

 `v = [ x ] [ y ] [ z ]`

For the first eigenvalue we have:

 `A v1 = k1 v1[ 2 1 0 ] [ x ] = (3 + sqrt(2)) [ x ][ 1 4 0 ] [ y ] = (3 + sqrt(2)) [ y ][ 2 5 2 ] [ z ] = (3 + sqrt(2)) [ z ]`

That is:

 `2x + y = (3 + sqrt(2)) xx + 4y = (3 + sqrt(2)) y2x + 5y + 2z = (3 + sqrt(2)) z`

From the first equation:

 `y = (1 + sqrt(2)) x`

If we choose

 `x = 1y = 1 + 1.414 = 2.414`

 `2x + 5y + 2z = 4.414zz = (2 + 5 * 2.414) / 2.414 z = 5.82`

To normalize, we divide each by:

 `sqrt(1 + 2.414^2 + 5.82^2) = 6.38x = 0.157y = 0.378z = 0.912`

Check this is a unit vector:

 `0.157^2 + 0.378^2 + 0.912^2 = 0.9993`

In R:

 `v = c(2,1,0,1,4,0,2,5,2)A = matrix(v,nrow=3,byrow=T)A [,1] [,2] [,3][1,] 2 1 0[2,] 1 4 0[3,] 2 5 2eigen(A)\$values[1] 4.414214 2.000000 1.585786\$vectors [,1] [,2] [,3][1,] 0.1565580 0 0.9124870[2,] 0.3779645 0 -0.3779645[3,] 0.9124870 1 0.1565580`

#### 1 comment:

Thomas Olson said...

Umm, this is tedious. How bout instead I put a u in front of another letter for the unit vector. I'm leaving out the square root and other mess.

uv=[1, 1+sqrt(2), (1+sqrt(2))^2]

vw= [(1/2-(1/2)*sqrt(5))^2, -(1/2-(1/2)*sqrt(5)), 1]
uv=vw

Basically it's [1, a, a^2] for a quadratic solution. You can get the other value with [a^2, -a, 1]

Notice I reversed the order and snuck in a negative sign? Btw, I found this by doing three consecutive Pell numbers. This works with Fibonacci number and any of the recursive number things.