top of page

R Programming Journal Module 5 - Wesley Huang

  • Writer: Wesley Huang
    Wesley Huang
  • Feb 16
  • 1 min read

In this assignment, I explored how to work with matrices in R by calculating the determinant and inverse of two matrices. The matrices were created using sequences of numbers and reshaped into matrix form using the matrix() function.

First, I created matrix A using the values from 1 to 100 arranged into 10 rows. I also created matrix B using the values from 1 to 1000 arranged into 10 rows. After creating the matrices, I checked their dimensions to understand their structure.

Matrix A was a 10 by 10 square matrix, while matrix B was a 10 by 100 rectangular matrix. This difference is important because only square matrices can have determinants and inverses.


I then calculated the determinant of matrix A using the det() function. The result was 0. A determinant of zero means the matrix is singular, which means it does not have an inverse. When I attempted to compute the inverse using solve(A), R returned an error indicating that the matrix is exactly singular. This confirmed that matrix A cannot be inverted.


Next, I examined matrix B. Since B is not a square matrix, R returned an error when I attempted to compute its determinant and inverse. The error messages explained that the matrix must be square. This demonstrates an important rule in linear algebra: determinants and inverses are only defined for square matrices.

Overall, this assignment helped reinforce key concepts about matrices in R, including how matrix dimensions affect what operations are possible. It also showed how R

provides clear error messages when mathematical conditions are not satisfied.


Below is a screenshot showing my input and output from R.


 
 
 

Comments


bottom of page