Quiz: Solving linear equation systems
Short questions to test your understanding of linear systems and solving them by hand. Try each before opening the hint or answer.
Q1. Which of these is not a linear equation in the unknowns \(x\) and \(y\)?
- \(2x + 5y = 3\) (ii) \(x - y = 0\) (iii) \(xy = 4\)
- \(7x = 1\)
“Linear” means each unknown appears only to the first power, on its own — never squared, and never multiplied by another unknown.
(iii). The term \(xy\) is a product of two unknowns, which is not linear. The others are all weighted sums of the unknowns.
Q2. Write the system \[ \begin{aligned} 4x + y &= 9\\ x + 3y &= 6 \end{aligned} \] in the form \(A\mathbf{x} = \mathbf{b}\). What are \(A\) and \(\mathbf{b}\)?
Each equation is a row. The coefficients of \(x\) and \(y\) fill \(A\); the right-hand numbers fill \(\mathbf{b}\).
\[ A = \begin{bmatrix} 4 & 1 \\ 1 & 3 \end{bmatrix}, \qquad \mathbf{b} = \begin{bmatrix} 9 \\ 6 \end{bmatrix}. \]
Q3. In the deconvolution setup \(A\mathbf{x} = \mathbf{b}\), what does each of \(A\), \(\mathbf{x}\), and \(\mathbf{b}\) represent biologically?
One holds known cell-type signatures, one the unknown amounts, one the bulk measurements.
\(A\) = the cell-type signatures (column \(j\) = signature of cell type \(j\)); \(\mathbf{x}\) = the unknown amounts of each cell type; \(\mathbf{b}\) = the measured bulk signals.
Q4. Solve by substitution: \(x + y = 5\) and \(x - y = 1\).
From the first equation, \(x = 5 - y\). Substitute into the second.
\(x = 5 - y\), so \((5 - y) - y = 1 \Rightarrow 5 - 2y = 1 \Rightarrow y = 2\), and \(x = 3\). Check: \(3 + 2 = 5\ \checkmark\), \(3 - 2 = 1\ \checkmark\).
Q5. Which of the following row operations is not allowed during Gaussian elimination (because it would change the solution set)?
- Multiply a row by \(0\). (ii) Multiply a row by \(-2\).
- Add 3 times row 1 to row 2. (iv) Swap row 1 and row 2.
What information is lost if you multiply an entire equation by zero?
(i). Multiplying by zero turns an equation into \(0 = 0\), destroying its information. The allowed scaling is by any non-zero number.
Q6. You have reduced an augmented matrix to \[ \left[\begin{array}{cc|c} 1 & 2 & 5 \\ 0 & 3 & 9 \end{array}\right]. \] What are \(x\) and \(y\)?
Read the bottom row first — it has only one unknown.
Bottom row: \(3y = 9 \Rightarrow y = 3\). Top row: \(x + 2(3) = 5 \Rightarrow x = -1\).
Q7. Is \(x = 2,\ y = 1\) a solution of \(5x - y = 9\) and \(2x + 3y = 8\)? Show how you check.
Substitute both values into both original equations and see if each holds.
Eq 1: \(5(2) - 1 = 9\ \checkmark\). Eq 2: \(2(2) + 3(1) = 7 \ne 8\). The second equation fails, so no, it is not a solution.
Q8. To eliminate the \(x\) term from row 2, you have rows R1: \(2x + 4y = 6\) and R2: \(3x + y = 4\). What multiple of R1 do you subtract from R2?
You want the new \(x\) coefficient in R2 to be zero. The multiplier is the \(x\) coefficient of R2 divided by the \(x\) coefficient of R1.
\(\tfrac{3}{2}\): replace R2 by \(\text{R2} - \tfrac{3}{2}\text{R1}\). The \(x\) coefficient becomes \(3 - \tfrac{3}{2}\cdot 2 = 0\).
Q9. In R, what does solve(A, b) return, and what does A %*% x compute?
solve(A, b) returns the vector \(\mathbf{x}\) solving \(A\mathbf{x} = \mathbf{b}\). A %*% x multiplies \(A\) by \(\mathbf{x}\); if \(\mathbf{x}\) is correct it should reproduce \(\mathbf{b}\).
Q10. When you build a matrix in R with matrix(c(1, 2, 3, 4), nrow = 2), the result has \(1, 2\) in the first column, not the first row. What argument makes it fill by row instead, so the code matches the equations on paper?
See the byrow argument of matrix.
byrow = TRUE. By default matrix fills column by column (byrow = FALSE), which is a common source of mistakes when transcribing a system.
Q11. A bulk sample contains 3 cell types but you measured only 2 marker genes. Have you written enough equations to pin down all three amounts? Why?
Count equations versus unknowns. Each measured gene gives one equation; each cell type is one unknown.
No — 2 equations, 3 unknowns. The system is under-determined, so it generally has infinitely many solutions rather than one. (Linear systems in R makes this precise.)
Q12. Find the inverse of \(A = \begin{bmatrix} 1 & 2 \\ 1 & 3 \end{bmatrix}\) by row-reducing \([\,A \mid I\,]\) to \([\,I \mid A^{-1}\,]\). Which is \(A^{-1}\)?
- \(\begin{bmatrix} 1 & 0 \\ -1 & 1 \end{bmatrix}\) (ii) \(\begin{bmatrix} 3 & -1 \\ -2 & 1 \end{bmatrix}\) (iii) \(\begin{bmatrix} 3 & -2 \\ -1 & 1 \end{bmatrix}\) (iv) \(\begin{bmatrix} 3 & 2 \\ 1 & 1 \end{bmatrix}\)
Start from \(\left[\begin{array}{cc|cc} 1 & 2 & 1 & 0 \\ 1 & 3 & 0 & 1 \end{array}\right]\). First clear the entry below the diagonal, then the one above it, and apply every operation to all four numbers in the row. Stop only when the left side is \(I\).
(iii). \[
\left[\begin{array}{cc|cc} 1 & 2 & 1 & 0 \\ 1 & 3 & 0 & 1 \end{array}\right]
\xrightarrow{\;\text{R2}\,-\,\text{R1}\;}
\left[\begin{array}{cc|cc} 1 & 2 & 1 & 0 \\ 0 & 1 & -1 & 1 \end{array}\right]
\xrightarrow{\;\text{R1}\,-\,2\text{R2}\;}
\left[\begin{array}{cc|cc} 1 & 0 & 3 & -2 \\ 0 & 1 & -1 & 1 \end{array}\right]
\] The pivots are already 1, so no scaling is needed. Check: \[
A A^{-1} =
\begin{bmatrix} 1 & 2 \\ 1 & 3 \end{bmatrix}
\begin{bmatrix} 3 & -2 \\ -1 & 1 \end{bmatrix}
= \begin{bmatrix} 3 - 2 & -2 + 2 \\ 3 - 3 & -2 + 3 \end{bmatrix}
= \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\ \checkmark
\] The wrong options are common slips: (i) stops after the first step, before the left side is \(I\); (ii) is the correct answer transposed (columns written as rows); (iv) drops the minus signs. In R, solve(A) gives the same matrix.