Assignment #5

 For Module #5, I practiced matrix operations in R and checked whether two matrices could be inverted. First, I created the matrices using the assignment instructions: A <- matrix(1:100, nrow = 10) and B <- matrix(1:1000, nrow = 10). I used dim(A) and dim(B) to confirm their sizes. Matrix A is a 10×10 square matrix, while matrix B is a 10×100 matrix, which means B is not square.

Next, I calculated the determinant of A using det(A). The determinant came out to be 0, which tells me A is singular. A singular matrix does not have an inverse, so when I attempted solve(A) R returned an error (I used tryCatch() to capture the error message without stopping my code). I also attempted solve(B), but that also produced an error because non-square matrices do not have inverses. So the results were expected: A cannot be inverted because its determinant is 0, and B cannot be inverted because it is not square.

After checking inverses, I explored additional matrix operations to understand how matrices interact. I used t(A) and t(B) to transpose each matrix, which flips rows and columns. I also multiplied A by a vector v <- 1:10 using A %*% v, which produced a 10×1 result. Finally, I multiplied the two matrices using C <- A %*% B. Since A is 10×10 and B is 10×100, the inner dimensions match (10), so the multiplication is valid and produces a new 10×100 matrix C. This helped me see that matrix work is not just about dimensions operations like transpose and multiplication show how matrices combine to create new outputs.

macauleywilson/r-programming-assignments





Comments

Popular posts from this blog

Assignment #4

Assignment 10