0
0
NumPydata~5 mins

np.linalg.solve() for linear systems in NumPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does np.linalg.solve() do in NumPy?

np.linalg.solve() finds the solution to a system of linear equations Ax = b, where A is a matrix and b is a vector or matrix of constants.

Click to reveal answer
beginner
What are the required inputs for np.linalg.solve(A, b)?

You need a square matrix A (same number of rows and columns) and a vector or matrix b representing the constants on the right side of the equations.

Click to reveal answer
intermediate
Why must matrix A be square for np.linalg.solve()?

Because only square matrices have a unique inverse, which is needed to find a unique solution to the system Ax = b.

Click to reveal answer
intermediate
What happens if matrix A is singular or not invertible when using np.linalg.solve()?

np.linalg.solve() will raise a LinAlgError because the system does not have a unique solution.

Click to reveal answer
beginner
How can you interpret the output of np.linalg.solve(A, b)?

The output is the vector or matrix x that satisfies the equation Ax = b. It gives the values of the variables that solve the system.

Click to reveal answer
What shape must matrix A have to use np.linalg.solve(A, b)?
ARectangular matrix
BOnly 1D array
CAny shape
DSquare matrix
What does np.linalg.solve() return?
AThe inverse of matrix <code>A</code>
BThe solution vector or matrix <code>x</code>
CThe determinant of <code>A</code>
DThe product of <code>A</code> and <code>b</code>
If A is singular, what will happen when calling np.linalg.solve(A, b)?
AIt returns zero vector
BIt returns a random vector
CIt raises a <code>LinAlgError</code>
DIt returns <code>b</code>
Which equation does np.linalg.solve(A, b) solve?
A<code>Ax = b</code>
B<code>xA = b</code>
C<code>Ab = x</code>
D<code>b = Ax + 1</code>
What type of data can b be in np.linalg.solve(A, b)?
AA vector or matrix
BOnly a vector
COnly a scalar
DOnly a matrix
Explain how np.linalg.solve() is used to solve a system of linear equations.
Think about the equation form and what the function returns.
You got /4 concepts.
    What errors or issues might you encounter when using np.linalg.solve() and how can you handle them?
    Consider what happens if the system has no unique solution.
    You got /4 concepts.