Question 1

Let \(A\) and \(B\) be \(n \times n\) matrices. If matrix \(A\) is invertible and matrix \(B\) is non-invertible, which of the following matrices is guaranteed to be non-invertible?

Step 1: Define matrices \(A\) and \(B\).

A <- matrix(data = c(1,2,3,4),nrow = 2,ncol = 2,byrow = T)
B <- matrix(data = c(5,7,5,7),nrow = 2,ncol = 2,byrow = T)
cat("Matrix A: \n")
## Matrix A:
print(A)
##      [,1] [,2]
## [1,]    1    2
## [2,]    3    4
cat("Matrix B: \n")
## Matrix B:
print(B)
##      [,1] [,2]
## [1,]    5    7
## [2,]    5    7

A. \(A + B\)

if (det(A + B) == 0) {
  cat("A + B is guaranteed to be non-invertible.")
} else {
  cat("A + B is not correct.")
}
## A + B is not correct.

B. \(A - B\)

if (det(A - B) == 0) {
  cat("A - B is guaranteed to be non-invertible.")
} else {
  cat("A - B is not correct.")
}
## A - B is not correct.

C. \(A^2 B\)

# install.packages("matrixcalc")
library(matrixcalc)
## Warning: package 'matrixcalc' was built under R version 4.5.2
if (det(matrix.power(x = A,k = 2) %*% B) == 0) {
  cat("A^2 B is guaranteed to be non-invertible.")
} else {
  cat("A^2 B is not correct.")
}
## A^2 B is guaranteed to be non-invertible.

D. \(A + A^{-1}\)

# install.packages("matrixcalc")
library(matrixcalc)
if (det(A + matrix.inverse(A)) == 0) {
  cat("A + A^{-1} is guaranteed to be non-invertible.")
} else {
  cat("A + A^{-1} is not correct.")
}
## A + A^{-1} is not correct.

Question 2

Write 98 in words.

# install.packages("english")
library(english)
## Warning: package 'english' was built under R version 4.5.2
words(98)
## [1] "ninety-eight"

Question 3

Which one of the following four decimal numbers is the third least?

A. 39.103

B. 398.29

C. 309.13

D. 391.083

# install.packages("tidyverse")
library(tidyverse)
## Warning: package 'lubridate' was built under R version 4.5.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.1     ✔ stringr   1.5.2
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
q3_data <- data.frame(Choice = LETTERS[1:4],
                      Number = c(39.103,398.29,309.13,391.083))
correct_answer <- q3_data %>%
  arrange(Number) %>%
  slice(2) %>%
  pull(Choice)
cat("The correct answer is:",correct_answer,"\n")
## The correct answer is: C

Question 4

A box contains 6 green tokens and 4 orange tokens. Two tokens are drawn at random with replacement. If the first token drawn is green, what is the probability the second token is not green?

box <- c(rep("Green",6),rep("Orange",4))
counter <- 0
N <- 1e5
for (i in 1:N) {
  picks <- sample(x = box,size = 2,replace = T)
  if ((picks[1] == "Green") & (picks[2] != "Green")) {
    counter <- counter + 1
  }
}
probability <- counter / N
cat("The probability is:",probability,"\n")
## The probability is: 0.23755