Module 5: Determinant and Inverse of Matrices in R

 This assignment practiced creating matrices in R and computing a determinant and inverse (when possible).

 

Step 1: Creating Matrices A and B 

I created the matrices using matrix()

 


Matrix A contains the numbers 1 to 100 arranged into 10 rows.
Matrix B contains the numbers 1 to 1000 arranged into 10 rows.

 

 Step 2: Checking the Dimensions

To check the size of each matrix, I used:


Step 3: Finding the Determinant of A

I used the det() function to find the determinant of A:

This result shows that matrix A is singular, which means it does not have an inverse. 

 

Step 4: Finding the Inverse of A

I attempted to find the inverse of A using:

 

Result:
R returned an error saying that the system is computationally singular.

This confirms that A does not have an inverse because its determinant is zero.

 

Step 5: Testing Matrix B

Since B is not a square matrix, I tested:

 

 

Result:
Both commands returned errors.

This happens because determinants and inverses are only defined for square matrices.

  

Conclusion

From this assignment, I learned that a matrix must be square and have a non-zero determinant in order to have an inverse. Even though matrix A is square, it does not have an inverse because its determinant is zero. Matrix B does not have a determinant or inverse because it is not square. This exercise helped me understand the conditions needed for matrix inversion in R.

 

 

 

 

 

 

 

Comments

Popular posts from this blog

Creating and Analyzing Data Frames in R

Module 10: Friedman R Package Proposal