Challenge - 5 Problems
Linear System Solver Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this linear system solution?
Consider the following MATLAB code that solves a system of linear equations using the backslash operator. What is the value of
x after running this code?MATLAB
A = [3 1; 1 2]; b = [9; 8]; x = A\b;
Attempts:
2 left
💡 Hint
Remember that x = A\b solves the system A*x = b.
✗ Incorrect
Solving the system: 3*x1 + 1*x2 = 9 and 1*x1 + 2*x2 = 8 gives x1 = 2 and x2 = 3.
❓ Predict Output
intermediate2:00remaining
What error does this code produce?
What error will MATLAB produce when running this code?
MATLAB
A = [1 2; 2 4]; b = [3; 6]; x = A\b;
Attempts:
2 left
💡 Hint
Check if matrix A is invertible.
✗ Incorrect
Matrix A is singular because the second row is a multiple of the first, so MATLAB warns that the matrix is singular or close to singular when solving.
🔧 Debug
advanced2:00remaining
Why does this code produce a wrong solution?
The code below attempts to solve a system but produces an incorrect solution. What is the main reason?
MATLAB
A = [1 2 3; 4 5 6]; b = [7; 8]; x = A\b;
Attempts:
2 left
💡 Hint
Check the size of matrix A and vector b.
✗ Incorrect
Matrix A is 2x3 (not square), so the system is overdetermined or underdetermined. MATLAB uses least squares solution but it may not be exact.
🧠 Conceptual
advanced2:00remaining
What does the MATLAB expression x = A\b compute?
In MATLAB, what does the expression
x = A\b compute when A is a square, invertible matrix?Attempts:
2 left
💡 Hint
Think about solving linear equations.
✗ Incorrect
The backslash operator solves the linear system A*x = b efficiently without explicitly computing the inverse.
❓ Predict Output
expert2:00remaining
What is the output of this code with a sparse matrix?
Given the code below, what is the output of
x?MATLAB
A = sparse([1 2 3], [1 2 3], [4 5 6], 3, 3); b = [4; 10; 18]; x = A\b;
Attempts:
2 left
💡 Hint
Sparse matrices can be used with backslash just like full matrices.
✗ Incorrect
The sparse matrix A is diagonal with values 4,5,6. Solving A*x = b gives x = [1; 2; 3].