---
title: Problem set 2
heading: "Problem set 2: elimination and LU"
eyebrow: A7 · Problem set 2
type: problems
---

::: hook
These problems use lessons 8 and 9: elimination with row exchanges, pivots, the LU factorization and solving with its factors. Work each by hand first; a 3 × 3 elimination takes a few minutes and is worth doing until it's automatic.
:::

::: pool
pick: 12

::: check
kind: parts
given: b1 = 6 | 7; b2 = 11 | 12; b3 = 14 | 16

## Solve $x_1 + x_2 + x_3 = \given{b1}$, $2x_1 + 3x_2 + x_3 = \given{b2}$, $x_1 + 2x_2 + 3x_3 = \given{b3}$.

::: part
answer: (b1 - b2 + b3)/3
tolerance: 0.5%

### What is $x_3$?

::: misses
- [any] Eliminate to $x_1 + x_2 + x_3 = b_1$, $x_2 - x_3 = b_2 - 2b_1$, $3x_3 = b_1 - b_2 + b_3$.
:::
:::

::: part
answer: (7*b1 - b2 - 2*b3)/3
tolerance: 0.5%

### What is $x_1$?

::: misses
- [any] Back-substitute: find $x_2$ from row 2, then $x_1$ from row 1.
:::
:::
:::

::: check
kind: parts
given: p = 2 | 4; q = 3 | 5; c1 = 6 | 8; c2 = 7 | 10

## Solve $\given{p}y = \given{c1}$, $\given{q}x + y = \given{c2}$.

::: part
answer: c1/p
tolerance: 0.5%

### What is $y$?

::: misses
- [any] Exchange the rows; the system is then triangular.
:::
:::

::: part
answer: (c2 - c1/p)/q
tolerance: 0.5%

### What is $x$?

::: misses
- [c2/q] Subtract $y$ first.
- [any] $x = \frac{c_2 - y}{q}$.
:::
:::
:::

::: check
kind: parts
given: k = 8 | 10 | 12

## Eliminate $A = \begin{bmatrix}2 & 1 & 1\\4 & 3 & 3\\8 & 7 & \given{k}\end{bmatrix}$.

::: part
answer: k - 7
tolerance: 0.5%

### What is the third pivot?

::: misses
- [k - 4] After subtracting 4 × row 1, row 3 is $(0, 3, k - 4)$; then subtract 3 × row 2 too.
- [any] The multipliers are 2, 4 and 3.
:::
:::

::: part
answer: 2*(k - 7)
tolerance: 0.5%

### What is $\det A$?

::: misses
- [any] Multiply the pivots: 2, 1 and the third.
:::
:::
:::

::: check
kind: parts
given: a = 2 | 3 | 5; c = 4 | 7

## Consider $\begin{bmatrix}1 & \given{a}\\3 & k\end{bmatrix}\mathbf{x} = \begin{bmatrix}1\\c\end{bmatrix}$ with $c$ = {c}.

::: part
answer: 3*a
tolerance: 0.5%

### For which $k$ is the matrix singular?

::: misses
- [a/3] The second pivot is $k - 3a$.
- [any] Subtract 3 × row 1 from row 2.
:::
:::

::: part
answer: (c - 3)/(5 - 3*a)
tolerance: 0.5%

### With $k$ = 5, what is $x_2$?

::: misses
- [any] Row 2 becomes $(5 - 3a)x_2 = c - 3$.
:::
:::
:::

::: check
kind: parts
given: l21 = 2 | 3; l31 = 1 | 5; l32 = 2 | 5

## Elimination uses multipliers $\ell_{21}$ = {l21}, $\ell_{31}$ = {l31} and $\ell_{32}$ = {l32}.

::: part
answer: l31
tolerance: 0.5%

### What is the (3, 1) entry of $L$?

::: misses
- [any] $L$ stores the multipliers in place.
:::
:::

::: part
answer: l21*l32 - l31
tolerance: 0.5%

### What is the (3, 1) entry of $E = E_{32}E_{31}E_{21}$, the matrix that does the elimination?

::: misses
- [-l31] The steps interact: $E_{32}$ also subtracts $\ell_{32}$ times the new row 2, which contains $-\ell_{21}$ times row 1.
- [any] Multiply the three elimination matrices.
:::
:::
:::

::: check
kind: parts
given: b1 = 1 | 2; b2 = 5 | 7; b3 = 9 | 20

## Forward-substitute $L\mathbf{y} = \mathbf{b}$ with $L = \begin{bmatrix}1 & 0 & 0\\2 & 1 & 0\\4 & 3 & 1\end{bmatrix}$ and $\mathbf{b} = (\given{b1}, \given{b2}, \given{b3})$.

::: part
answer: b2 - 2*b1
tolerance: 0.5%

### What is $y_2$?

::: misses
- [any] $y_2 = b_2 - 2y_1$.
:::
:::

::: part
answer: b3 + 2*b1 - 3*b2
tolerance: 0.5%

### What is $y_3$?

::: misses
- [b3 - 4*b1 - 3*b2] Use $y_2$, not $b_2$, in the last row.
- [any] $y_3 = b_3 - 4y_1 - 3y_2$.
:::
:::
:::

::: check
kind: parts
given: g = 1 | 2 | 4

## Eliminate the ladder $G = \begin{bmatrix}\given{g} + 1 & -1 & 0\\-1 & 2 & -1\\0 & -1 & 2\end{bmatrix}$ mS.

::: part
answer: 2 - 1/(g + 1)
tolerance: 0.5%

### What is the second pivot?

::: misses
- [2] Subtract $\frac{-1}{g + 1}$ times row 1 from row 2.
- [any] $2 - \frac{1}{g + 1}$.
:::
:::

::: part
answer: 2 - 1/(2 - 1/(g + 1))
tolerance: 0.5%

### What is the third pivot?

::: misses
- [any] Each pivot of a tridiagonal matrix is $d_k - \frac{1}{p_{k-1}}$.
:::
:::
:::

::: check
kind: parts
given: a = 2 | 4; b = 1 | 3; c = 5 | 6

## Factor the symmetric $S = \begin{bmatrix}\given{a} & \given{b}\\\given{b} & \given{c}\end{bmatrix} = LDL^T$.

::: part
answer: b/a
tolerance: 0.5%

### What is the multiplier in $L$?

::: misses
- [any] $\ell = b/a$.
:::
:::

::: part
answer: c - b^2/a
tolerance: 0.5%

### What is the second entry of $D$?

::: misses
- [c - b] The multiplier $b/a$ multiplies $b$.
- [any] The second pivot, $c - \frac{b^2}{a}$.
:::
:::
:::

::: check
kind: parts
given: p = 2 | 3; q = 4 | 5; r = 1 | 7

## Take $A = \begin{bmatrix}0 & \given{p}\\\given{q} & \given{r}\end{bmatrix}$.

::: part
answer: -p*q
tolerance: 0.5%

### What is $\det A$?

::: misses
- [p*q] A row exchange flips the sign.
- [any] $PA = \begin{bmatrix}q & r\\0 & p\end{bmatrix}$, and $\det P = -1$.
:::
:::
:::

::: check
kind: parts
given: a = 2 | 3; b = 1 | 5; c = 4 | 6

## Invert $U = \begin{bmatrix}1 & \given{a} & \given{b}\\0 & 1 & \given{c}\\0 & 0 & 1\end{bmatrix}$.

::: part
answer: -a
tolerance: 0.5%

### What is the (1, 2) entry of $U^{-1}$?

::: misses
- [any] Undo the step that added $a$ times row 2.
:::
:::

::: part
answer: a*c - b
tolerance: 0.5%

### What is the (1, 3) entry?

::: misses
- [-b] The steps interact: the corner picks up $ac$.
- [any] Solve $U\mathbf{x} = (0, 0, 1)$ by back substitution.
:::
:::
:::

::: check
kind: parts
given: g1 = 1 | 2; g2 = 0.5 | 3; g3 = 1 | 4

## A two-node circuit has $g_1$ = {g1} mS from node 1 to ground, $g_2$ = {g2} mS between the nodes and $g_3$ = {g3} mS from node 2 to ground. Factor its $G = LU$.

::: part
answer: -g2/(g1 + g2)
tolerance: 0.5%

### What is $\ell_{21}$?

::: misses
- [g2/(g1 + g2)] The off-diagonal entry is $-g_2$.
- [any] $G_{21}/G_{11}$.
:::
:::

::: part
answer: g2 + g3 - g2^2/(g1 + g2)
tolerance: 0.5%

### What is the second pivot?

::: misses
- [g2 + g3] Subtract $\ell_{21}G_{12}$.
- [any] $G_{22} - \frac{g_2^2}{g_1 + g_2}$.
:::
:::
:::

::: check
kind: parts
given: n = 4 | 10 | 100

## Count the work of factoring an {n} × {n} matrix.

::: part
answer: n*(n - 1)/2
tolerance: 0

### How many multipliers does elimination compute (with no row exchanges)?

::: misses
- [n^2/2] Count exactly: one per entry below the diagonal.
- [any] $(n - 1) + (n - 2) + \cdots + 1$.
:::
:::

::: part
answer: n^2
tolerance: 0

### How many numbers does storing $L$ and $U$ together take, with $L$'s diagonal of ones left implicit?

::: misses
- [2*n^2] They share one array: multipliers below the diagonal, $U$ on and above it.
- [any] The multipliers plus $U$'s $\frac{n(n + 1)}{2}$ entries.
:::
:::
:::

::: check
kind: parts
given: n = 100 | 500; k = 10 | 1000

## An {n}-node circuit is solved for {k} source values.

::: part
answer: k*(n^3/3 + n^2)
tolerance: 1%

### About how many multiply-adds does factoring every time take?

::: misses
- [any] Each solve costs $\frac{n^3}{3} + n^2$.
:::
:::

::: part
answer: n^3/3 + k*n^2
tolerance: 1%

### And factoring once?

::: misses
- [k*n^2] Include the one factoring.
- [any] One factoring, then $k$ pairs of triangular solves.
:::
:::
:::

::: check
kind: parts
given: b1 = 4 | 5; b2 = 10 | 11; b3 = 24 | 30

## $A = \begin{bmatrix}2 & 1 & 1\\4 & 3 & 3\\8 & 7 & 9\end{bmatrix} = LU$ with $L = \begin{bmatrix}1 & 0 & 0\\2 & 1 & 0\\4 & 3 & 1\end{bmatrix}$ and $U = \begin{bmatrix}2 & 1 & 1\\0 & 1 & 1\\0 & 0 & 2\end{bmatrix}$. Solve $A\mathbf{x} = (\given{b1}, \given{b2}, \given{b3})$.

::: part
answer: (2*b1 - 3*b2 + b3)/2
tolerance: 0.5%

### What is $x_3$?

::: misses
- [any] Forward: $\mathbf{y} = (b_1, b_2 - 2b_1, b_3 + 2b_1 - 3b_2)$. Back: $x_3 = y_3/2$.
:::
:::

::: part
answer: (3*b1 - b2)/2
tolerance: 0.5%

### What is $x_1$?

::: misses
- [any] $x_2 = y_2 - x_3$, then $x_1 = \frac{y_1 - x_2 - x_3}{2}$.
:::
:::
:::

::: check
kind: parts
given: b1 = 2 | 3; b2 = 4 | 5; b3 = 6 | 9

## Solve $x_2 + x_3 = \given{b1}$, $x_1 + x_3 = \given{b2}$, $x_1 + x_2 = \given{b3}$.

::: part
answer: (-b1 + b2 + b3)/2
tolerance: 0.5%

### What is $x_1$?

::: misses
- [any] The first pivot is 0: exchange rows first. Or add all three equations: $x_1 + x_2 + x_3 = \frac{b_1 + b_2 + b_3}{2}$.
:::
:::

::: part
answer: (b1 - b2 + b3)/2
tolerance: 0.5%

### What is $x_2$?

::: misses
- [any] Subtract the second equation from the sum of all three.
:::
:::
:::
:::
