library (pracma)

Problem set 1

library (pracma)
## Warning: package 'pracma' was built under R version 3.5.2
knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3set1.jpg")

A: (1)The set of pivot columns of any reduced row echelon form matrix is known as Rank.

#Create a matrix
A = matrix(c(1,-1,0,5, 2,0,1,4, 3,1,-2,-2, 4,3,1,-3),ncol = 4)

A
##      [,1] [,2] [,3] [,4]
## [1,]    1    2    3    4
## [2,]   -1    0    1    3
## [3,]    0    1   -2    1
## [4,]    5    4   -2   -3
#Using qr function calculate rank
rankA <- qr(A)
rankA$rank
## [1] 4

Rank of the matrix A: 4

#reduced row echelon form matrix
rrefA = rref(A)
rrefA
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    0    0
## [2,]    0    1    0    0
## [3,]    0    0    1    0
## [4,]    0    0    0    1

Reduced row echelon form of matrix A shows each column is linearly indepentent, hence rank is 4.

A: (2)

According to theorem Computing Rank and Nullity(CRN), suppose that A is an m x n matrix and B is a row-equivalent matrix in reduced row-echelon form. Let r denote the number of pivot columns (or the number of nonzero rows). Then r(A)=r and \(\quad n(A) = n-r\)

According to theorem Rank Plus Nullity(RPNC) is Columns, suppose that A is an m x n matrix. \(Then\quad r(A) +(A)=n\).

Using both theorems, it can be concluded that an m x n matrix can only have single rank and it is defined as minimum(m,n). If rank is equal to n (number of columns) \(r(A)= n\), then it is called as full rank. A matrix is said to be rank deficient if it does not have full rank, \(r(A) < n\)

Using given conditions of the problem, m > n, hence \(r(A)\le n\)

A: (3)

#Create a matrix
B = matrix(c(1,3,2, 2,6,4, 1,3,2),ncol = 3)

B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
#Using qr function calculate rank
rankB <- qr(B)
rankB$rank
## [1] 1

Rank of the matrix B: 1

#reduced row echelon form matrix
rrefB = rref(B)
rrefB
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    0    0    0
## [3,]    0    0    0

Reduced row echelon form of matrix B shows only one non-zero row, hence rank is 1

Problem set 2

knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3set2.jpg")

A: Characteristic polynomial

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

cp = charpoly(A)

#Characteristic polynomial
cp
## [1]   1 -11  34 -24

Characteristic polynomial equation for given matrix is \(1x^{ 3 } -11{ x }^{ 2 } + 34x - 24 = 0\)

Eigenvalues

According to theorem EMRCP, Eigenvalues of a Matrix are Roots of Characteristic Polynomials Suppose A is a square matrix. Then \(\lambda\) is an eigenvalue of A if and only if \(pA(\lambda )=0\)

By setting the characteristic polynomial equation equal to zero, \({ p }_{ A }(x)=1{ x }^{ 3 }-11{ x }^{ 2 }+34x-24=0\)

ev = eigen(A)
ev$values
## [1] 6 4 1

Roots are x=6,x=4 and x=1.

Eigenvalues of given matrix are \(\lambda= 6\),\(\lambda=4\) and \(\lambda=1\)

Eigenvectors are \(\lambda=6\),\(A-\lambda { I }_{ 3 }\)

lambda = ev$values[1]
lambdaI = lambda * diag(3)

result = A - lambdaI

#using pracma library get reduced row echelon form for result
rrefMx = rref(result)
rrefMx
##      [,1] [,2] [,3]
## [1,]    1    0 -1.6
## [2,]    0    1 -2.5
## [3,]    0    0  0.0

Null space, \({ \varepsilon }_{ A }(6)=\ N (A-(6{ I }_{ 3 }))\)

.\(N(A-(6{ I }_{ 3 }))=\begin{bmatrix} 1 & 0 & -1.6 \\ 0 & 1 & -2.5 \\ 0 & 0 & 0 \end{bmatrix}\begin{bmatrix} { v }_{ 1 } \\ { v }_{ 2 } \\ { v }_{ 3 } \end{bmatrix}=\begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}\)

.Solving the equations, \({ v }_{ 1 }-1.6{ v }_{ 3 }=0,\quad { v }_{ 2 }-2.5{ v }_{ 3 }=0\)

.if \({ v }_{ 3 }=t,then\quad { v }_{ 1 }=1.6t,\quad { v }_{ 2 }=2.5t\)


knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3eq1.png")

knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3eq2.png")

lambda = ev$values[2]
lambdaI = lambda * diag(3)

result = A - lambdaI

#using pracma library get reduced row echelon form for result
rrefMx = rref(result)
rrefMx
##      [,1]       [,2] [,3]
## [1,]    1 -0.6666667    0
## [2,]    0  0.0000000    1
## [3,]    0  0.0000000    0
knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3eq3.png")

lambda = ev$values[3]
lambdaI = lambda * diag(3)

result = A - lambdaI

#using pracma library get reduced row echelon form for result
rrefMx = rref(result)
rrefMx
##      [,1] [,2] [,3]
## [1,]    0    1    0
## [2,]    0    0    1
## [3,]    0    0    0
knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3eq5.png")

Solving using eigen function from R

#eigenvectors values from eigen function
ev$vectors
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0

Eigenspace for lambda=6

#for lambda to 6
ev$values[1]
## [1] 6
es = ev$vectors[,1]
es
## [1] 0.5108407 0.7981886 0.3192754
#let minT be min value of vector
minT = min(es)
knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3eq6.png")

#for lambda to 4
ev$values[2]
## [1] 4
es = ev$vectors[,2]
es
## [1] 0.5547002 0.8320503 0.0000000
#let minT be min value of vector
minT = min(es[es > 0])
knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3eq7.png")

#for lambda to 1
ev$values[3]
## [1] 1
es = ev$vectors[,3]
es
## [1] 1 0 0
#let minT be min value of vector
minT = min(es[es > 0])
knitr::include_graphics("C:\\Users\\sergioor\\Desktop\\Old PC\\CUNY\\DATA605\\hw3eq8.png")