Assignment 3

Problem Set 1

  1. What is the rank of the matrix A?

\[A = \begin{bmatrix}1&2&3&4\\-1&0&1&3\\0&1&-2&1\\5&4&-2&-3\end{bmatrix}\] The rank of a mxn matrix A is defined as the dimension of the column space of A, or \(r(A) = dim(C(A))\). Using reduced row echelon form, we can determine the dimensions and null spaces. Using the matlib function, echelon, I calculated the reduced rows of Matrix A below:

# Define Matrix A
A <- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3), ncol = 4)

# Reduce rows
echelon(A, verbose = T)
## 
## Initial matrix:
##      [,1] [,2] [,3] [,4]
## [1,]    1    2    3    4
## [2,]   -1    0    1    3
## [3,]    0    1   -2    1
## [4,]    5    4   -2   -3
## 
## row: 1 
## 
##  exchange rows 1 and 4 
##      [,1] [,2] [,3] [,4]
## [1,]    5    4   -2   -3
## [2,]   -1    0    1    3
## [3,]    0    1   -2    1
## [4,]    1    2    3    4
## 
##  multiply row 1 by 0.2 
##      [,1] [,2] [,3] [,4]
## [1,]    1  0.8 -0.4 -0.6
## [2,]   -1  0.0  1.0  3.0
## [3,]    0  1.0 -2.0  1.0
## [4,]    1  2.0  3.0  4.0
## 
##  multiply row 1 by 1 and add to row 2 
##      [,1] [,2] [,3] [,4]
## [1,]    1  0.8 -0.4 -0.6
## [2,]    0  0.8  0.6  2.4
## [3,]    0  1.0 -2.0  1.0
## [4,]    1  2.0  3.0  4.0
## 
##  subtract row 1 from row 4 
##      [,1] [,2] [,3] [,4]
## [1,]    1  0.8 -0.4 -0.6
## [2,]    0  0.8  0.6  2.4
## [3,]    0  1.0 -2.0  1.0
## [4,]    0  1.2  3.4  4.6
## 
## row: 2 
## 
##  exchange rows 2 and 4 
##      [,1] [,2] [,3] [,4]
## [1,]    1  0.8 -0.4 -0.6
## [2,]    0  1.2  3.4  4.6
## [3,]    0  1.0 -2.0  1.0
## [4,]    0  0.8  0.6  2.4
## 
##  multiply row 2 by 0.8333333 
##      [,1] [,2]      [,3]      [,4]
## [1,]    1  0.8 -0.400000 -0.600000
## [2,]    0  1.0  2.833333  3.833333
## [3,]    0  1.0 -2.000000  1.000000
## [4,]    0  0.8  0.600000  2.400000
## 
##  multiply row 2 by 0.8 and subtract from row 1 
##      [,1] [,2]      [,3]      [,4]
## [1,]    1  0.0 -2.666667 -3.666667
## [2,]    0  1.0  2.833333  3.833333
## [3,]    0  1.0 -2.000000  1.000000
## [4,]    0  0.8  0.600000  2.400000
## 
##  subtract row 2 from row 3 
##      [,1] [,2]      [,3]      [,4]
## [1,]    1  0.0 -2.666667 -3.666667
## [2,]    0  1.0  2.833333  3.833333
## [3,]    0  0.0 -4.833333 -2.833333
## [4,]    0  0.8  0.600000  2.400000
## 
##  multiply row 2 by 0.8 and subtract from row 4 
##      [,1] [,2]      [,3]       [,4]
## [1,]    1    0 -2.666667 -3.6666667
## [2,]    0    1  2.833333  3.8333333
## [3,]    0    0 -4.833333 -2.8333333
## [4,]    0    0 -1.666667 -0.6666667
## 
## row: 3 
## 
##  multiply row 3 by -0.2068966 
##      [,1] [,2]      [,3]       [,4]
## [1,]    1    0 -2.666667 -3.6666667
## [2,]    0    1  2.833333  3.8333333
## [3,]    0    0  1.000000  0.5862069
## [4,]    0    0 -1.666667 -0.6666667
## 
##  multiply row 3 by 2.666667 and add to row 1 
##      [,1] [,2]      [,3]       [,4]
## [1,]    1    0  0.000000 -2.1034483
## [2,]    0    1  2.833333  3.8333333
## [3,]    0    0  1.000000  0.5862069
## [4,]    0    0 -1.666667 -0.6666667
## 
##  multiply row 3 by 2.833333 and subtract from row 2 
##      [,1] [,2]      [,3]       [,4]
## [1,]    1    0  0.000000 -2.1034483
## [2,]    0    1  0.000000  2.1724138
## [3,]    0    0  1.000000  0.5862069
## [4,]    0    0 -1.666667 -0.6666667
## 
##  multiply row 3 by 1.666667 and add to row 4 
##      [,1] [,2] [,3]       [,4]
## [1,]    1    0    0 -2.1034483
## [2,]    0    1    0  2.1724138
## [3,]    0    0    1  0.5862069
## [4,]    0    0    0  0.3103448
## 
## row: 4 
## 
##  multiply row 4 by 3.222222 
##      [,1] [,2] [,3]       [,4]
## [1,]    1    0    0 -2.1034483
## [2,]    0    1    0  2.1724138
## [3,]    0    0    1  0.5862069
## [4,]    0    0    0  1.0000000
## 
##  multiply row 4 by 2.103448 and add to row 1 
##      [,1] [,2] [,3]      [,4]
## [1,]    1    0    0 0.0000000
## [2,]    0    1    0 2.1724138
## [3,]    0    0    1 0.5862069
## [4,]    0    0    0 1.0000000
## 
##  multiply row 4 by 2.172414 and subtract from row 2 
##      [,1] [,2] [,3]      [,4]
## [1,]    1    0    0 0.0000000
## [2,]    0    1    0 0.0000000
## [3,]    0    0    1 0.5862069
## [4,]    0    0    0 1.0000000
## 
##  multiply row 4 by 0.5862069 and subtract from row 3 
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    0    0
## [2,]    0    1    0    0
## [3,]    0    0    1    0
## [4,]    0    0    0    1

The column index dimensions of the reduced Matrix A can be shown as \(D = {1,2,3,4}\). Each index represents an individual vector, meaning that \(r(A) = 4\). This can also be calculated using the R function found in the matlib package:

# Calculate rank of matrix
rankA <- R(A)
rankA
## [1] 4
  1. Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?

The maximum rank of the matrix is n. The minimum rank of all non-zero matrices is 1.

  1. What is the rank of matrix B?

\[B = \begin{bmatrix}1&2&1\\3&6&3\\2&4&2\end{bmatrix} \\\]

# Define Matrix A
B <- matrix(c(1,3,2,2,6,4,1,3,2), ncol = 3)

# Reduce rows
echelon(B, verbose = T)
## 
## Initial matrix:
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
## 
## row: 1 
## 
##  exchange rows 1 and 2 
##      [,1] [,2] [,3]
## [1,]    3    6    3
## [2,]    1    2    1
## [3,]    2    4    2
## 
##  multiply row 1 by 0.3333333 
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    1    2    1
## [3,]    2    4    2
## 
##  subtract row 1 from row 2 
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    2    4    2
## 
##  multiply row 1 by 2 and subtract from row 3 
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    0    0    0
## 
## row: 2

In this example, you can clearly see that matrix B has 1 non-zero row, thus the rank of this Matrix is 1. This is further proved using the R function below:

# Calculate rank
rankB <- R(B)
rankB
## [1] 1

Problem Set 2

Compute the eigenvalues and eigenvectors of the matrix A. You’ll need to show your work. You’ll need to write out the characteristic polynomial and show your solution.

\[A = \begin{bmatrix}1&2&3\\0&4&5\\0&0&6\end{bmatrix} \\\]

Eigenvalues

Because Matrix A is a upper-triangle matrix, we know that the eigenvalues of A are the diagonals. However, we can also calculate the values and vectors from the characteristic polynomial of Matrix A.

The eigenvalues of Matrix A can be solved using the function, \(f(\lambda)=det(\lambda I - A)=0\):

\(= \lambda \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}-\begin{bmatrix}1&2&3\\0&4&5\\0&0&6\end{bmatrix}=0 \\ = \begin{bmatrix}\lambda&0&0\\0&\lambda&0\\0&0&\lambda\end{bmatrix}-\begin{bmatrix}1&2&3\\0&4&5\\0&0&6\end{bmatrix}=0 \\ = \begin{bmatrix}\lambda -1&-2&-3\\0&\lambda-4&-5\\0&0&\lambda-6\end{bmatrix}=0\\= (\lambda-1)(\lambda-4)(\lambda-6)=0\)

We can use R to compute the characteristic polynomial using the charpoly function from the pracma package.

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

# Compute characteristic polynomial 
p <- Poly(A)
p
## [1]   1 -11  34 -24

We can now determine characteristic polynomial is \(\lambda^3-11\lambda ^2+34 \lambda-24 = 0\) and can be solved using the following values:

\[\begin{matrix}\lambda_1=1\\\lambda_2=4\\\lambda_3=6\end{matrix}\] These solutions can be checked in R using the eigen function:

# Check eigenvalues  
lam <- eigen(A)$values
lam
## [1] 6 4 1

Eigenvector

To get the eigenvector, we substitue each \(\lambda\) value into the matrix:

\(det(\lambda I-A)=\begin{bmatrix}\lambda-1&-2&-3\\0&\lambda-4&-5\\0&0&\lambda-6\end{bmatrix}=0\)

Solve for \(\lambda=1\):

\[A-1\lambda =\begin{bmatrix}1-1&-2&-3\\0&1-4&-5\\0&0&1-6\end{bmatrix}=\begin{bmatrix}0&-2&-3\\0&-3&-5\\0&0&-5\end{bmatrix}=0\\\]

# Define Matrix when Lambda = 1
lam=1
lam1 <- matrix(c(lam-1,0,0,-2,lam-4,0,-3,-5,lam-6), ncol= 3)

# Calculate eigen space
lam1 <- echelon(lam1) 
lam1 <- lam1[1:3,2]

# Show vector values for Lambda = 1
as.matrix(lam1)
##      [,1]
## [1,]    1
## [2,]    0
## [3,]    0

Solve for \(\lambda=4\):

\[A-4\lambda =\begin{bmatrix}4-1&-2&-3\\0&4-4&-5\\0&0&4-6\end{bmatrix}=\begin{bmatrix}3&-2&-3\\0&0&-5\\0&0&-2\end{bmatrix}=0\\\]

# Define Matrix when Lambda = 4
lam=4
lam2 <- matrix(c(lam-1,0,0,-2,lam-4,0,-3,-5,lam-6), ncol= 3)
lam2 
##      [,1] [,2] [,3]
## [1,]    3   -2   -3
## [2,]    0    0   -5
## [3,]    0    0   -2
# Calculate eigen space
lam2 <- echelon(lam2)
lam2
##      [,1]       [,2] [,3]
## [1,]    1 -0.6666667    0
## [2,]    0  0.0000000    1
## [3,]    0  0.0000000    0
lam2 <- lam2[1:3,2]

# Show vector values for Lambda = 4
as.matrix(lam2)
##            [,1]
## [1,] -0.6666667
## [2,]  0.0000000
## [3,]  0.0000000

Solve for \(\lambda=6\):

\[A-6\lambda =\begin{bmatrix}6-1&-2&-3\\0&6-4&-5\\0&0&6-6\end{bmatrix}=\begin{bmatrix}5&-2&-3\\0&2&-5\\0&0&0\end{bmatrix}=0\\\]

# Define Matrix when Lambda = 6
lam=6
lam3 <- matrix(c(lam-1,0,0,-2,lam-4,0,-3,-5,lam-6), ncol= 3)
lam3 
##      [,1] [,2] [,3]
## [1,]    5   -2   -3
## [2,]    0    2   -5
## [3,]    0    0    0
# Calculate eigen space
lam3 <- echelon(lam3)
lam3
##      [,1] [,2] [,3]
## [1,]    1    0 -1.6
## [2,]    0    1 -2.5
## [3,]    0    0  0.0
lam3 <- lam3[1:3,3]

# Show vector values for Lambda = 6
as.matrix(lam3)
##      [,1]
## [1,] -1.6
## [2,] -2.5
## [3,]  0.0

Eigenvector:

v <- c(lam3, lam2, lam1)
matrix(v, ncol=3)
##      [,1]       [,2] [,3]
## [1,] -1.6 -0.6666667    1
## [2,] -2.5  0.0000000    0
## [3,]  0.0  0.0000000    0