library(pracma)
## Warning: package 'pracma' was built under R version 4.2.3

ASSIGNMENT 3

1. Problem set 1

  1. What is the rank of the matrix A?
#Defining the matrix A
A <- matrix(c(1, -1, 0, 5, 2, 0, 1, 4, 3, 1, -2, -2, 4, 3, 1, -3), nrow = 4, byrow = TRUE)

#Performing QR decomposition
qr_result <- qr(A)

#Calculating the rank of matrix A
rank_A <- qr_result$rank

#Printing the rank
cat("Rank of Matrix A:", rank_A, "\n")
## Rank of Matrix A: 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? For an m×n matrix where m>n, the maximum rank it can have is
  1. This is because the rank of a matrix cannot exceed the number of columns it has.

As for the minimum rank, assuming the matrix is non-zero, the minimum rank is always 1. This is because a non-zero matrix always has at least one non-zero row or column, and the rank of a matrix is defined as the maximum number of linearly independent rows or columns. Therefore, the rank cannot be zero for a non-zero matrix.

  1. What is the rank of matrix B?
#Lets define matrix B
B <- matrix(c(1, 2, 1, 3, 6, 3, 2, 4, 2), nrow = 3, ncol = 3, byrow = TRUE)

#Printing matrix B
print("Matrix B:")
## [1] "Matrix B:"
print(B)
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2
#Lets find the rank of matrix B
rank_B <- qr(B)$rank
print(paste("Rank of Matrix B:", rank_B))
## [1] "Rank of Matrix B: 1"

We can observe that the second row is a multiple of the first row, and the third row is also a multiple of the first row. In other words, the rows are not linearly independent. Therefore, the rank of matrix B is 1.

2. 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.

#Lets define the matrix A
A <- matrix(c(1, 2, 3, 0, 4, 5, 0, 0, 6), nrow = 3, byrow = TRUE)

#Computing eigenvalues and eigenvectors
eig_A <- eigen(A)

#Printing the results
cat("Eigenvalues:\n", eig_A$values, "\n")
## Eigenvalues:
##  6 4 1
cat("Eigenvectors:\n", eig_A$vectors, "\n")
## Eigenvectors:
##  0.5108407 0.7981886 0.3192754 0.5547002 0.8320503 0 1 0 0