Eigenvalues and eigenvectors for 3 x 3 matrix

For matrix A:

A <- matrix(c(1,-0,0,2,4,0,3,5,6),nrow=3)

(A)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0    4    5
## [3,]    0    0    6

P = def(A-lambda * I) = 0

FindEigenvalues3x3 <- function(x) {
  a <- A[1,1]
  b <- A[1,2]
  c <- A[1,3]
  d <- A[2,1]
  e <- A[2,2]
  f <- A[2,3]
  g <- A[3,1]
  h <- A[3,2]
  k <- A[3,3]
  
  -x^3 + (a+e+k)*x^2 + (-a*e - a*e - e*k + c*g + f*h + b*d)*x + (a*e*k + b*f*g + c*d*h - c*g*e - f*h*a - b*d*k)
  
  
}

for(x in -100:100){
  if (FindEigenvalues3x3(x)==0) {
    print(x)
  }
  
}
## [1] 3

For Lamda = 3, solve A-lamda*y

f3 <- function() {
  I <- matrix(c(1,0,0,0,1,0,0,0,1), nrow=3)
  solve(A - 3*I)
}

y<-f3()

print(y )
##      [,1] [,2]       [,3]
## [1,] -0.5    1 -1.1666667
## [2,]  0.0    1 -1.6666667
## [3,]  0.0    0  0.3333333

multiply all rows by 3 to make it easier to see

print(3*y)
##      [,1] [,2] [,3]
## [1,] -1.5    3 -3.5
## [2,]  0.0    3 -5.0
## [3,]  0.0    0  1.0

x3 = 1

3x2 = 5x3

x2 = (5/3)* x3

(3/2)x1 = 3x2 - (7/2)*x3

(3/2)x1 = 5x3 - (7/2)*x3

x1 = (10/3)* x3 - (7/3)x3 = (3/3)x3 = x3

eigenvector for lamda = 3

x = { x1 = 1, x2 = 5/3, x3 = 1 }