Assignment #5: Matrix Algebra in R
R code for creating A and B, and for computing
invA
, detA
, invB
, and detB
:
Why solve(A)
and det(A)
behave this way:
Since Matrix A is 10x10 and therefore a square, it could technically have an inverse. However, since the determinant of A is 0, it is considered a singular matrix, meaning it does not have full rank and therefore cannot be inverted. Due to this, solve(A) returns an error even though the matrix is a square, yet it is still able to run and confirm the singularity.
Why operations on B fail (non‑square matrix):
Since Matrix B is 10x100, it is not square. Inverses and determinants can only be defined for square matrices, meaning both solve(B) and det(B) return errors. Though it is expected, it highlights how important it is to check matrix dimensions before attempting further operations.
Notes on numeric stability or performance:
There are important considerations when dealing with matrices, even when they are square and invertible. If the determinant is extremely close to zero, the matrix is called ill-conditioned and could result in much larger errors in the inverse. Because of this, it is more stable to solve for a system of equations rather than compute the full inverse. Likewise, as matrices grow, these operations can also become computationally expensive, another instance to watch out for.
Reference: https://deepai.org/machine-learning-glossary-and-terms/ill-conditioned-matrix
Comments
Post a Comment