The transpose flips a matrix over its diagonal, turning rows into columns and columns into rows.
Click to reveal answer
beginner
How do you find the transpose of a matrix in R?
Use the function t(). For example, t(matrix) returns the transpose of matrix.
Click to reveal answer
beginner
What is the inverse of a matrix?
The inverse of a matrix is another matrix that, when multiplied with the original, gives the identity matrix. It 'undoes' the effect of the original matrix.
Click to reveal answer
beginner
How do you calculate the inverse of a matrix in R?
Use the function solve(). For example, solve(matrix) returns the inverse of matrix if it exists.
Click to reveal answer
intermediate
What happens if you try to invert a matrix that is not invertible?
R will give an error because the inverse does not exist. Such matrices are called singular or non-invertible.
Click to reveal answer
Which R function is used to get the transpose of a matrix?
Ainv()
Btranspose()
Csolve()
Dt()
✗ Incorrect
The function t() returns the transpose of a matrix in R.
What does the inverse of a matrix multiplied by the original matrix produce?
AZero matrix
BDiagonal matrix
CIdentity matrix
DTranspose matrix
✗ Incorrect
Multiplying a matrix by its inverse results in the identity matrix.
Which function in R calculates the inverse of a matrix?
At()
Bsolve()
Cinv()
Dinverse()
✗ Incorrect
The solve() function computes the inverse of a matrix in R.
If a matrix is singular, what happens when you try to invert it in R?
AGives an error
BReturns zero matrix
CReturns the original matrix
DReturns identity matrix
✗ Incorrect
Trying to invert a singular matrix causes an error because the inverse does not exist.
What is the result of transposing a 3x2 matrix?
A2x3 matrix
B3x2 matrix
C2x2 matrix
D3x3 matrix
✗ Incorrect
Transposing swaps rows and columns, so a 3x2 matrix becomes 2x3.
Explain how to find the transpose and inverse of a matrix in R, including what functions to use and what the results mean.
Think about flipping rows and columns for transpose, and undoing matrix multiplication for inverse.
You got /6 concepts.
Describe what happens when you try to invert a matrix that is not invertible in R and why.
Consider what it means for a matrix to have no inverse.
You got /4 concepts.
Practice
(1/5)
1.
What does the t() function do when applied to a matrix in R?
easy
A. It sums all elements of the matrix.
B. It calculates the inverse of the matrix.
C. It multiplies the matrix by itself.
D. It flips the matrix over its diagonal (transpose).
Solution
Step 1: Understand the function t()
The t() function in R is used to transpose a matrix, which means flipping it over its diagonal.
Step 2: Identify the effect on the matrix
Transposing swaps rows and columns, so the element at row i, column j moves to row j, column i.
Final Answer:
It flips the matrix over its diagonal (transpose). -> Option D
Quick Check:
t() = transpose [OK]
Hint: Transpose flips rows and columns across the diagonal [OK]
Common Mistakes:
Confusing transpose with inverse
Thinking it sums matrix elements
Assuming it multiplies matrix by itself
2.
Which of the following is the correct syntax to find the inverse of a square matrix A in R?
easy
A. inv(A)
B. inverse(A)
C. solve(A)
D. t(A)
Solution
Step 1: Recall the function for matrix inverse in R
In R, the function solve() is used to compute the inverse of a square matrix.
Step 2: Check the options
Only solve(A) correctly computes the inverse. t(A) transposes, others are invalid.
Final Answer:
solve(A) -> Option C
Quick Check:
solve() = inverse [OK]
Hint: Use solve() to invert matrices in R [OK]
Common Mistakes:
Using t() instead of solve() for inverse
Assuming inverse() or inv() exist in base R
Confusing transpose with inverse
3.
What is the output of the following R code?
A <- matrix(c(1, 2, 3, 4), nrow=2, byrow=TRUE)
B <- t(A)
B
medium
A. [1, 3]
[2, 4]
B. [1, 2]
[3, 4]
C. [4, 3]
[2, 1]
D. [2, 1]
[4, 3]
Solution
Step 1: Create matrix A
Matrix A is 2x2 with rows: [1, 2] and [3, 4].
Step 2: Transpose matrix A to get B
Transposing swaps rows and columns, so B's first row is [1, 3], second row is [2, 4].
Final Answer:
[1, 3]
[2, 4] -> Option A
Quick Check:
Transpose swaps rows and columns [OK]
Hint: Transpose swaps rows and columns [OK]
Common Mistakes:
Confusing original matrix with transpose
Mixing row-wise and column-wise order
Reading matrix elements incorrectly
4.
Consider the code below. What is the error and how to fix it?
B. Error: matrix is not square; fix by making it square (e.g., 2x2).
C. Error: solve() requires a vector; fix by passing a vector.
D. Error: matrix contains non-numeric values; fix data type.
Solution
Step 1: Check matrix dimensions
Matrix A has 2 rows and 3 columns, so it is not square.
Step 2: Understand solve() requirements
The solve() function requires a square matrix to compute its inverse.
Step 3: Fix the error
Make A square by changing number of elements or rows/columns, e.g., 2x2 matrix.
Final Answer:
Error: matrix is not square; fix by making it square (e.g., 2x2). -> Option B
Quick Check:
Inverse needs square matrix [OK]
Hint: Inverse requires square matrix; check dimensions first [OK]
Common Mistakes:
Trying to invert non-square matrix
Ignoring error messages from solve()
Assuming solve() works on any matrix shape
5.
You have a 3x3 matrix M. You want to check if multiplying M by its inverse returns the identity matrix. Which R code correctly performs this check?
hard
A. identity_check <- M %*% solve(M); all(identity_check == diag(3))
B. identity_check <- t(M) %*% solve(M); all(identity_check == diag(3))
C. identity_check <- solve(M) %*% M; all(identity_check == matrix(1,3,3))
D. identity_check <- M %*% M; all(identity_check == diag(3))
Solution
Step 1: Multiply matrix by its inverse
Multiplying M by solve(M) should give the identity matrix.
Step 2: Check equality with identity matrix
Use diag(3) to create 3x3 identity matrix and compare with result using all().
Step 3: Analyze options
identity_check <- M %*% solve(M); all(identity_check == diag(3)) correctly multiplies M %*% solve(M) and compares to identity. identity_check <- t(M) %*% solve(M); all(identity_check == diag(3)) uses transpose incorrectly. identity_check <- solve(M) %*% M; all(identity_check == matrix(1,3,3)) compares to a matrix of ones, which is wrong. identity_check <- M %*% M; all(identity_check == diag(3)) multiplies M by itself, not inverse.
Final Answer:
identity_check <- M %*% solve(M); all(identity_check == diag(3)) -> Option A
Quick Check:
Matrix times inverse = identity [OK]
Hint: Multiply matrix by solve(matrix) to get identity [OK]
Common Mistakes:
Using transpose instead of inverse
Comparing to matrix of ones instead of identity
Multiplying matrix by itself instead of inverse
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.