Question 1

Which of the following is true for any two similar matrices \(A\) and \(B\)?

Note: We will use the matrices below for this problem.

\[A = \begin{pmatrix} 1 & 0 \\ 0 & 2 \end{pmatrix} \\ B = \begin{pmatrix} 0 & -2 \\ 1 & 3 \end{pmatrix}\]

  1. \(A\) and \(B\) have the same eigenvectors.
A <- matrix(data = c(1,0,0,2),nrow = 2,ncol = 2,byrow = T)
B <- matrix(data = c(0,-2,1,3),nrow = 2,ncol = 2,byrow = T)
cat("Eigenvectors of A: \n")
## Eigenvectors of A:
print(eigen(A)$vectors)
##      [,1] [,2]
## [1,]    0   -1
## [2,]    1    0
cat("Eigenvalues of B: \n")
## Eigenvalues of B:
print(eigen(B)$vectors)
##            [,1]       [,2]
## [1,]  0.7071068 -0.8944272
## [2,] -0.7071068  0.4472136

We find that answer choice A is incorrect becuase the eigenvectors are all different.

  1. The null space of \(A\) is the same as the null space of \(B\).
# install.packages("pracma")
library(pracma)
A <- matrix(data = c(1,0,0,2),nrow = 2,ncol = 2,byrow = T)
B <- matrix(data = c(0,-2,1,3),nrow = 2,ncol = 2,byrow = T)
cat("Null space of A: \n")
## Null space of A:
print(nullspace(A))
## NULL
cat("Null space of B: \n")
## Null space of B:
print(nullspace(B))
## NULL

We find that answer choice B is correct because both null spaces produce nothing at all.

  1. \(A + I\) and \(B - I\) are similar.
A <- matrix(data = c(1,0,0,2),nrow = 2,ncol = 2,byrow = T)
B <- matrix(data = c(0,-2,1,3),nrow = 2,ncol = 2,byrow = T)
cat("A + I: \n")
## A + I:
print(A + diag(2))
##      [,1] [,2]
## [1,]    2    0
## [2,]    0    3
cat("B - I: \n")
## B - I:
print(B - diag(2))
##      [,1] [,2]
## [1,]   -1   -2
## [2,]    1    2

We find that answer choice C is incorrect due to them not being similar matrices. The determinants of each matrix are not equal.

  1. \(A^k\) and \(B^k\) are similar for any positive integer \(k\).
# install.packages("matrixcalc")
library(matrixcalc)
## Warning: package 'matrixcalc' was built under R version 4.5.2
A <- matrix(data = c(1,0,0,2),nrow = 2,ncol = 2,byrow = T)
B <- matrix(data = c(0,-2,1,3),nrow = 2,ncol = 2,byrow = T)
cat("A^2 (k = 2): \n")
## A^2 (k = 2):
print(matrix.power(x = A,k = 2))
##      [,1] [,2]
## [1,]    1    0
## [2,]    0    4
cat("B^2 (k = 2): \n")
## B^2 (k = 2):
print(matrix.power(x = B,k = 2))
##      [,1] [,2]
## [1,]   -2   -6
## [2,]    3    7

We find that answer choice D is incorrect because the two matrices are not the same at all.

In the end, answer choice B is correct!

Question 2

How many prime numbers are there between 10 and 19 inclusive?

# install.packages(c("pracma","comprehenr"))
library(pracma)
library(comprehenr)
## Warning: package 'comprehenr' was built under R version 4.5.2
prime_nums <- to_vec(for (x in 10:19) if (isprime(x)) x)
cat("There are",length(prime_nums),"prime numbers between 10 and 19 inclusive.","\n")
## There are 4 prime numbers between 10 and 19 inclusive.

Question 3

Two fair cubical dice, one red and one blue, are thrown at the same time and their scores are multiplied together. What is the probability that the product of the scores is divisible by 5?

red_die <- 1:6
blue_die <- 1:6
N <- 1e5
counter <- 0
for (i in 1:N) {
  roll1 <- sample(x = red_die,size = 1,replace = T)
  roll2 <- sample(x = blue_die,size = 1,replace = T)
  if ((roll1 * roll2) %% 5 == 0) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability that the product of the scores is divisible by 5 is:",probability,"\n")
## The probability that the product of the scores is divisible by 5 is: 0.30673