ΣνΜDr. Sharon's Math PlatformSyvara Learning
Question Bank › 📘 Undergraduate › Numerical Method with Python (Math & Eng) › Q22

Q22 · NumPy: solve Ax = b with linalg.solve and inverse

Solving Linear Systems: RREF and Matrix Inverse 🟡 Intermediate Coding
Question

Solve the linear system $A\mathbf{x} = \mathbf{b}$ using Python, where:
$$A = \begin{bmatrix} 2 & 1 & -1 \\ -3 & -1 & 2 \\ -2 & 1 & 2 \end{bmatrix}, \quad \mathbf{b} = \begin{bmatrix} 8 \\ -11 \\ -3 \end{bmatrix}$$

(a) Use np.linalg.solve(A, b) to find $\mathbf{x}$.
(b) Verify by computing $A \mathbf{x}$ and checking it equals $\mathbf{b}$.
(c) Also find $A^{-1}$ using np.linalg.inv(A) and solve via $\mathbf{x} = A^{-1}\mathbf{b}$. Do both methods agree?

🔒

Log in to see the worked solution

Enter your email to get started. Your first free solutions in every course unlock as soon as you verify.

Log in or sign up with email
← Previous Next →
Working…