Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
Compute the inverse of a square matrix (when it exists) using basic linear algebra operations, which is a common building block in solving linear systems. The inverse (A^{-1}) is defined such that:
Implement the function
Rules:
A as a NumPy array.Output:
| Argument | Type |
|---|---|
| A | np.ndarray |
| Return Name | Type |
|---|---|
| value | np.ndarray |
Input is np.ndarray
Return inverse as np.ndarray
Use np.linalg.inv; no manual elimination
Use NumPy’s built-in linear algebra inversion (np.linalg.inv) to compute the inverse.
The function should accept and return a np.ndarray directly.