Skip to content

Chapter 3 Exercises and Solutions

Ten exercises, all of them worked. Try each before reading the solution — three of them (3.2, 3.5 and 3.6) are traps for a habit rather than tests of a formula, and they only teach you something if you fall into them first.

The verification code at the end of each solution is the one you should run. Every number on this page came out of it.

3.1 — Show that a formula is an inner product

Section titled “3.1 — Show that a formula is an inner product”

Show that ,\langle\cdot,\cdot\rangle defined for all x=[x1,x2]R2\mathbf{x} = [x_1, x_2]^\top \in \mathbb{R}^2 and y=[y1,y2]R2\mathbf{y} = [y_1, y_2]^\top \in \mathbb{R}^2 by

x,y:=x1y1(x1y2+x2y1)+2(x2y2)\langle\mathbf{x},\mathbf{y}\rangle := x_1y_1 - (x_1y_2 + x_2y_1) + 2(x_2y_2)

is an inner product.

Solution. Read off the matrix. Every term is a product xiyjx_iy_j with a coefficient, and those coefficients are the entries of A\mathbf{A} in x,y=xAy\langle\mathbf{x},\mathbf{y}\rangle = \mathbf{x}^\top\mathbf{A}\mathbf{y}:

termcoefficiententry
x1y1x_1y_111A11=1A_{11} = 1
x1y2x_1y_21-1A12=1A_{12} = -1
x2y1x_2y_11-1A21=1A_{21} = -1
x2y2x_2y_222A22=2A_{22} = 2
A=[1112]\mathbf{A} = \begin{bmatrix}1 & -1\\ -1 & 2\end{bmatrix}

Now check the three conditions of Definition 3.3.

Bilinear. Automatic. Any expression of the form xAy\mathbf{x}^\top\mathbf{A}\mathbf{y} is linear in each argument separately, because matrix multiplication is.

Symmetric. A12=A21=1A_{12} = A_{21} = -1, so A=A\mathbf{A} = \mathbf{A}^\top and x,y=y,x\langle\mathbf{x},\mathbf{y}\rangle = \langle\mathbf{y},\mathbf{x}\rangle.

Positive definite. Complete the square:

xAx=x122x1x2+2x22=(x1x2)2+x22\mathbf{x}^\top\mathbf{A}\mathbf{x} = x_1^2 - 2x_1x_2 + 2x_2^2 = (x_1 - x_2)^2 + x_2^2

A sum of two squares, so it is 0\geq 0 always. It equals zero only when both squares vanish: x2=0x_2 = 0 and x1x2=0x_1 - x_2 = 0, hence x1=x2=0x_1 = x_2 = 0. So it is zero only at the origin. ∎

Completing the square is the argument to give, because it needs no eigenvalue machinery — Chapter 4 has not happened yet. If you want the eigenvalue check anyway, they are 0.3819660.381966 and 2.6180342.618034, both positive.

ex_3_1.py
import numpy as np
 
A = np.array([[1.0, -1.0], [-1.0, 2.0]])
print("symmetric:", np.allclose(A, A.T))
print("eigenvalues:", np.round(np.linalg.eigvalsh(A), 6))
 
x = np.array([3.0, -2.0])
print("form on (3, -2):", float(x @ A @ x))
print("(x1 - x2)^2 + x2^2 =", (3 - (-2)) ** 2 + (-2) ** 2)
output
symmetric: True
eigenvalues: [0.381966 2.618034]
form on (3, -2): 29.0
(x1 - x2)^2 + x2^2 = 29

Consider R2\mathbb{R}^2 with ,\langle\cdot,\cdot\rangle defined for all x\mathbf{x} and y\mathbf{y} in R2\mathbb{R}^2 as

x,y:=x[2012]=:Ay\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\top\underbrace{\begin{bmatrix}2 & 0\\ 1 & 2\end{bmatrix}}_{=:\mathbf{A}}\mathbf{y}

Is ,\langle\cdot,\cdot\rangle an inner product?

Solution. No. A\mathbf{A} is not symmetric: A12=0A_{12} = 0 while A21=1A_{21} = 1.

The one-line witness. Take x=e1\mathbf{x} = \mathbf{e}_1 and y=e2\mathbf{y} = \mathbf{e}_2:

e1,e2=e1Ae2=A12=0,e2,e1=A21=1\langle\mathbf{e}_1, \mathbf{e}_2\rangle = \mathbf{e}_1^\top\mathbf{A}\mathbf{e}_2 = A_{12} = 0, \qquad \langle\mathbf{e}_2, \mathbf{e}_1\rangle = A_{21} = 1

010 \neq 1, so symmetry fails and Definition 3.3 is not satisfied. ∎

Why this exercise is here. The quadratic form is perfectly well behaved:

xAx=2x12+x1x2+2x22\mathbf{x}^\top\mathbf{A}\mathbf{x} = 2x_1^2 + x_1x_2 + 2x_2^2

and only the symmetric part of A\mathbf{A} affects it, 12(A+A)=[20.50.52]\tfrac{1}{2}(\mathbf{A}+\mathbf{A}^\top) = \begin{bmatrix}2 & 0.5\\ 0.5 & 2\end{bmatrix}, whose eigenvalues are 1.51.5 and 2.52.5 — both positive. So x,x>0\langle\mathbf{x},\mathbf{x}\rangle > 0 for every nonzero x\mathbf{x}, and a reader who tests only positive definiteness will pass this matrix.

The failure is entirely in the asymmetry, and its consequence is concrete: “the angle between x\mathbf{x} and y\mathbf{y}” would depend on which one you named first.

ex_3_2.py
import numpy as np
 
A = np.array([[2.0, 0.0], [1.0, 2.0]])
e1, e2 = np.array([1.0, 0.0]), np.array([0.0, 1.0])
 
print("A   =", A.tolist())
print("A^T =", A.T.tolist())
print("symmetric:", bool(np.allclose(A, A.T)))
print("<e1, e2> =", float(e1 @ A @ e2), "  <e2, e1> =", float(e2 @ A @ e1))
 
sym = (A + A.T) / 2
print("symmetric part:", sym.tolist(), " eigenvalues:", np.round(np.linalg.eigvalsh(sym), 6))
output
A   = [[2.0, 0.0], [1.0, 2.0]]
A^T = [[2.0, 1.0], [0.0, 2.0]]
symmetric: False
<e1, e2> = 0.0   <e2, e1> = 1.0
symmetric part: [[2.0, 0.5], [0.5, 2.0]]  eigenvalues: [1.5 2.5]

The last line is the one to notice. The symmetric part has eigenvalues 1.51.5 and 2.52.5, both positive, so x,x>0\langle\mathbf{x},\mathbf{x}\rangle > 0 for every nonzero x\mathbf{x}. A verification routine that checks only positive definiteness — for instance by running Cholesky on 12(A+A)\tfrac12(\mathbf{A}+\mathbf{A}^\top), which is what several libraries silently do — reports this matrix as fine.

Compute the distance between x=[1,2,3]\mathbf{x} = [1, 2, 3]^\top and y=[1,1,0]\mathbf{y} = [-1, -1, 0]^\top using (a) x,y:=xy\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\top\mathbf{y} and (b) x,y:=xAy\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\top\mathbf{A}\mathbf{y} with A:=[210131012]\mathbf{A} := \begin{bmatrix}2&1&0\\1&3&-1\\0&-1&2\end{bmatrix}.

Solution. Distance is the norm of the difference (Definition 3.6), so compute the difference once:

xy=[1(1)2(1)30]=[233]\mathbf{x} - \mathbf{y} = \begin{bmatrix}1-(-1)\\ 2-(-1)\\ 3-0\end{bmatrix} = \begin{bmatrix}2\\3\\3\end{bmatrix}

(a) (2,3,3)2=4+9+9=22\lVert(2,3,3)\rVert^2 = 4 + 9 + 9 = 22, so

d(x,y)=224.690416.d(\mathbf{x},\mathbf{y}) = \sqrt{22} \approx 4.690416 .

(b) First A(xy)\mathbf{A}(\mathbf{x}-\mathbf{y}), row by row:

rowworkingresult
12(2)+1(3)+0(3)2(2) + 1(3) + 0(3)77
21(2)+3(3)+(1)(3)1(2) + 3(3) + (-1)(3)88
30(2)+(1)(3)+2(3)0(2) + (-1)(3) + 2(3)33

Then (2,3,3)(7,8,3)=14+24+9=47(2,3,3)\cdot(7,8,3) = 14 + 24 + 9 = 47, so

d(x,y)=476.855655.d(\mathbf{x},\mathbf{y}) = \sqrt{47} \approx 6.855655 .

A\mathbf{A} really is an inner product: its eigenvalues are exactly 11, 22 and 44. So both answers are correct and they differ by 46%46\% — which is the whole point of asking for both. ∎

ex_3_3.py
import numpy as np
 
x = np.array([1.0, 2.0, 3.0])
y = np.array([-1.0, -1.0, 0.0])
d = x - y
A = np.array([[2.0, 1.0, 0.0], [1.0, 3.0, -1.0], [0.0, -1.0, 2.0]])
 
print("x - y   =", d)
print("A(x-y)  =", A @ d)
print("(a) squared", float(d @ d), " distance", np.sqrt(float(d @ d)))
print("(b) squared", float(d @ A @ d), " distance", np.sqrt(float(d @ A @ d)))
print("A eigenvalues:", np.round(np.linalg.eigvalsh(A), 6))
output
x - y   = [2. 3. 3.]
A(x-y)  = [7. 8. 3.]
(a) squared 22.0  distance 4.69041575982343
(b) squared 47.0  distance 6.855654600401044
A eigenvalues: [1. 2. 4.]

Compute the angle between x=[1,2]\mathbf{x} = [1, 2]^\top and y=[1,1]\mathbf{y} = [-1, -1]^\top using (a) x,y:=xy\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\top\mathbf{y} and (b) x,y:=xBy\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\top\mathbf{B}\mathbf{y} with B:=[2113]\mathbf{B} := \begin{bmatrix}2&1\\1&3\end{bmatrix}.

Solution. Both parts use Equation 3.25, so the only work is three inner products each.

(a) Dot product.

x,y=1(1)+2(1)=3,x=1+4=5,y=1+1=2\langle\mathbf{x},\mathbf{y}\rangle = 1(-1) + 2(-1) = -3, \qquad \lVert\mathbf{x}\rVert = \sqrt{1+4} = \sqrt5, \qquad \lVert\mathbf{y}\rVert = \sqrt{1+1} = \sqrt2 cosω=352=3100.948683ω2.819842 rad=161.565051°\cos\omega = \frac{-3}{\sqrt5\sqrt2} = \frac{-3}{\sqrt{10}} \approx -0.948683 \qquad\Longrightarrow\qquad \omega \approx 2.819842\ \text{rad} = 161.565051°

(b) With B\mathbf{B}. Compute the matrix-vector products first, and reuse them:

Bx=[2(1)+1(2)1(1)+3(2)]=[47],By=[2(1)+1(1)1(1)+3(1)]=[34]\mathbf{B}\mathbf{x} = \begin{bmatrix}2(1)+1(2)\\ 1(1)+3(2)\end{bmatrix} = \begin{bmatrix}4\\7\end{bmatrix}, \qquad \mathbf{B}\mathbf{y} = \begin{bmatrix}2(-1)+1(-1)\\ 1(-1)+3(-1)\end{bmatrix} = \begin{bmatrix}-3\\-4\end{bmatrix}
quantityworkingvalue
x,y\langle\mathbf{x},\mathbf{y}\ranglexBy=1(3)+2(4)\mathbf{x}\cdot\mathbf{B}\mathbf{y} = 1(-3) + 2(-4)11-11
x,x\langle\mathbf{x},\mathbf{x}\ranglexBx=1(4)+2(7)\mathbf{x}\cdot\mathbf{B}\mathbf{x} = 1(4) + 2(7)1818
y,y\langle\mathbf{y},\mathbf{y}\rangleyBy=(1)(3)+(1)(4)\mathbf{y}\cdot\mathbf{B}\mathbf{y} = (-1)(-3) + (-1)(-4)77
cosω=11187=111260.979958ω2.941046 rad=168.509540°\cos\omega = \frac{-11}{\sqrt{18}\sqrt{7}} = \frac{-11}{\sqrt{126}} \approx -0.979958 \qquad\Longrightarrow\qquad \omega \approx 2.941046\ \text{rad} = 168.509540°

B\mathbf{B}‘s eigenvalues are 1.3819661.381966 and 3.6180343.618034, so it is a valid inner product. The two angles differ by nearly 7°, and both are obtuse — these vectors point broadly opposite ways under either geometry, but by different amounts. ∎

ex_3_4.py
import numpy as np
 
x = np.array([1.0, 2.0])
y = np.array([-1.0, -1.0])
B = np.array([[2.0, 1.0], [1.0, 3.0]])
 
for name, M in (("dot", np.eye(2)), ("B  ", B)):
    ip = float(x @ M @ y)
    nx, ny = np.sqrt(float(x @ M @ x)), np.sqrt(float(y @ M @ y))
    c = ip / (nx * ny)
    print(f"({name}) <x,y> {ip:+.4f}  ||x|| {nx:.6f}  ||y|| {ny:.6f}  "
          f"cos {c:.6f}  omega {np.arccos(c):.6f} rad = {np.degrees(np.arccos(c)):.6f} deg")
 
print("-3/sqrt(10)  =", round(-3 / np.sqrt(10), 6))
print("-11/sqrt(126) =", round(-11 / np.sqrt(126), 6))
print("Bx =", B @ x, " By =", B @ y, " B eigenvalues:", np.round(np.linalg.eigvalsh(B), 6))
output
(dot) <x,y> -3.0000  ||x|| 2.236068  ||y|| 1.414214  cos -0.948683  omega 2.819842 rad = 161.565051 deg
(B  ) <x,y> -11.0000  ||x|| 4.242641  ||y|| 2.645751  cos -0.979958  omega 2.941046 rad = 168.509540 deg
-3/sqrt(10)  = -0.948683
-11/sqrt(126) = -0.979958
Bx = [4. 7.]  By = [-3. -4.]  B eigenvalues: [1.381966 3.618034]

Consider the Euclidean vector space R5\mathbb{R}^5 with the dot product. A subspace UR5U \subseteq \mathbb{R}^5 and xR5\mathbf{x} \in \mathbb{R}^5 are given by

\qquad \mathbf{x} = \begin{bmatrix}-1\\-9\\-1\\4\\1\end{bmatrix}$$ **(a)** Determine the orthogonal projection $\pi_U(\mathbf{x})$ of $\mathbf{x}$ onto $U$. **(b)** Determine the distance $d(\mathbf{x}, U)$.

Solution. Read the margin note in §3.8.2 first. The problem gives a spanning set, and the book warns: if UU is given by spanning vectors that are not a basis, determine a basis before proceeding. Here that warning has teeth.

Step 0 — the rank. Four vectors, and

rank=3.\mathrm{rank} = 3 .

One of them is redundant. Solving for it: the fourth vector is 1u1+2u2+1u31\cdot\mathbf{u}_1 + 2\cdot\mathbf{u}_2 + 1\cdot\mathbf{u}_3. Check the first coordinate: 0+2(1)+(3)=10 + 2(1) + (-3) = -1 ✓; the second: 1+2(3)+4=3-1 + 2(-3) + 4 = -3 ✓; the third: 2+2(1)+1=52 + 2(1) + 1 = 5 ✓; the fourth: 0+2(1)+2=00 + 2(-1) + 2 = 0 ✓; the fifth: 2+2(2)+1=72 + 2(2) + 1 = 7 ✓.

So dimU=3\dim U = 3, and B=[u1 u2 u3]\mathbf{B} = [\mathbf{u}_1\ \mathbf{u}_2\ \mathbf{u}_3] is a basis. Using all four columns makes BB\mathbf{B}^\top\mathbf{B} singular and Equation 3.59 undefined — its condition number comes out at 2.0×10172.0\times10^{17}.

Step 1 — the normal equation on the three-column basis gives

λ=[341].\boldsymbol{\lambda} = \begin{bmatrix}-3\\4\\1\end{bmatrix} .

Step 2 — the projection.

πU(x)=Bλ=3u1+4u2+u3=[15123]\pi_U(\mathbf{x}) = \mathbf{B}\boldsymbol{\lambda} = -3\mathbf{u}_1 + 4\mathbf{u}_2 + \mathbf{u}_3 = \begin{bmatrix}1\\-5\\-1\\-2\\3\end{bmatrix}

Spot-check the first coordinate: 3(0)+4(1)+(3)=1-3(0) + 4(1) + (-3) = 1 ✓. The fifth: 3(2)+4(2)+1=6+8+1=3-3(2) + 4(2) + 1 = -6 + 8 + 1 = 3 ✓.

Step 3 — the distance.

xπU(x)=[24062],d(x,U)=4+16+0+36+4=607.745967\mathbf{x} - \pi_U(\mathbf{x}) = \begin{bmatrix}-2\\-4\\0\\6\\-2\end{bmatrix}, \qquad d(\mathbf{x}, U) = \sqrt{4 + 16 + 0 + 36 + 4} = \sqrt{60} \approx 7.745967

And the check: U(xπU(x))=0\mathbf{U}^\top(\mathbf{x} - \pi_U(\mathbf{x})) = \mathbf{0} against all four spanning vectors, not merely the three in the basis — which it must be, since the fourth lies in the span of the others. ∎

ex_3_5.py
import numpy as np
 
U = np.array([[0.0, 1.0, -3.0, -1.0],
              [-1.0, -3.0, 4.0, -3.0],
              [2.0, 1.0, 1.0, 5.0],
              [0.0, -1.0, 2.0, 0.0],
              [2.0, 2.0, 1.0, 7.0]])
x = np.array([-1.0, -9.0, -1.0, 4.0, 1.0])
 
print("rank of the spanning set:", np.linalg.matrix_rank(U))
print("cond(U^T U):", f"{np.linalg.cond(U.T @ U):.3e}", "-> Eq 3.59 is undefined on all four columns")
print("column 4 in terms of the first three:",
      np.round(np.linalg.lstsq(U[:, :3], U[:, 3], rcond=None)[0], 6))
 
B = U[:, :3]                                  # a genuine basis
lam = np.linalg.solve(B.T @ B, B.T @ x)
proj = B @ lam
print("lambda      =", np.round(lam, 10))
print("(a) pi_U(x) =", np.round(proj, 10))
print("residual    =", np.round(x - proj, 10))
print("(b) distance =", round(float(np.linalg.norm(x - proj)), 6), " sqrt(60) =", round(float(np.sqrt(60)), 6))
print("orthogonal to all FOUR spanning vectors:", np.round(U.T @ (x - proj), 10))
output
rank of the spanning set: 3
cond(U^T U): 2.018e+17 -> Eq 3.59 is undefined on all four columns
column 4 in terms of the first three: [1. 2. 1.]
lambda      = [-3.  4.  1.]
(a) pi_U(x) = [ 1. -5. -1. -2.  3.]
residual    = [-2. -4.  0.  6. -2.]
(b) distance = 7.745967  sqrt(60) = 7.745967
orthogonal to all FOUR spanning vectors: [ 0.  0. -0.  0.]

3.6 — Projection under a non-standard inner product

Section titled “3.6 — Projection under a non-standard inner product”

Consider R3\mathbb{R}^3 with the inner product x,y:=x[210121012]y\langle\mathbf{x},\mathbf{y}\rangle := \mathbf{x}^\top\begin{bmatrix}2&1&0\\1&2&-1\\0&-1&2\end{bmatrix}\mathbf{y}. Furthermore, e1,e2,e3\mathbf{e}_1, \mathbf{e}_2, \mathbf{e}_3 are the standard basis in R3\mathbb{R}^3.

(a) Determine the orthogonal projection πU(e2)\pi_U(\mathbf{e}_2) of e2\mathbf{e}_2 onto U=span[e1,e3]U = \mathrm{span}[\mathbf{e}_1, \mathbf{e}_3]. Hint: orthogonality is defined through the inner product. (b) Compute the distance d(e2,U)d(\mathbf{e}_2, U). (c) Draw the scenario: standard basis vectors and πU(e2)\pi_U(\mathbf{e}_2).

Solution. The hint is the whole exercise. Under the dot product, e2\mathbf{e}_2 is already orthogonal to span[e1,e3]\mathrm{span}[\mathbf{e}_1,\mathbf{e}_3], so its projection would be 0\mathbf{0} and the distance would be 11. Under this inner product it is not, because A12=10A_{12} = 1 \neq 0 and A32=10A_{32} = -1 \neq 0: the coordinate axes are not perpendicular in this geometry.

(a) The normal equation with the inner product’s matrix inserted in every slot — see the last pitfall on the Orthogonal Projections page — is

BABλ=BAe2,B=[e1  e3].\mathbf{B}^\top\mathbf{A}\mathbf{B}\,\boldsymbol{\lambda} = \mathbf{B}^\top\mathbf{A}\mathbf{e}_2, \qquad \mathbf{B} = [\mathbf{e}_1\ \ \mathbf{e}_3] .

Because B\mathbf{B} selects rows and columns 11 and 33, both sides read straight off A\mathbf{A}:

BAB=[A11A13A31A33]=[2002],BAe2=[A12A32]=[11]\mathbf{B}^\top\mathbf{A}\mathbf{B} = \begin{bmatrix}A_{11} & A_{13}\\ A_{31} & A_{33}\end{bmatrix} = \begin{bmatrix}2&0\\0&2\end{bmatrix}, \qquad \mathbf{B}^\top\mathbf{A}\mathbf{e}_2 = \begin{bmatrix}A_{12}\\ A_{32}\end{bmatrix} = \begin{bmatrix}1\\-1\end{bmatrix}

The Gram matrix is diagonal, so no solving is needed:

λ=[1/21/2],πU(e2)=12e112e3=[0.500.5]\boldsymbol{\lambda} = \begin{bmatrix}1/2\\ -1/2\end{bmatrix}, \qquad \pi_U(\mathbf{e}_2) = \tfrac12\mathbf{e}_1 - \tfrac12\mathbf{e}_3 = \begin{bmatrix}0.5\\ 0\\ -0.5\end{bmatrix}

Not the zero vector. Under this inner product e2\mathbf{e}_2 has a genuine component along e1\mathbf{e}_1 and along e3\mathbf{e}_3.

(b) The residual is

e2πU(e2)=[0.510.5]\mathbf{e}_2 - \pi_U(\mathbf{e}_2) = \begin{bmatrix}-0.5\\ 1\\ 0.5\end{bmatrix}

and the distance must be measured with the same inner product:

rA2=rAr\lVert\mathbf{r}\rVert^2_{\mathbf{A}} = \mathbf{r}^\top\mathbf{A}\mathbf{r}

Compute Ar\mathbf{A}\mathbf{r} first:

rowworkingresult
12(0.5)+1(1)+0(0.5)2(-0.5) + 1(1) + 0(0.5)00
21(0.5)+2(1)+(1)(0.5)1(-0.5) + 2(1) + (-1)(0.5)11
30(0.5)+(1)(1)+2(0.5)0(-0.5) + (-1)(1) + 2(0.5)00

Then r(0,1,0)=1\mathbf{r}\cdot(0,1,0) = 1, so

d(e2,U)=1=1.d(\mathbf{e}_2, U) = \sqrt{1} = 1 .

Exactly 11. And note the trap closing: the Euclidean length of that same residual is 0.25+1+0.25=1.51.224745\sqrt{0.25 + 1 + 0.25} = \sqrt{1.5} \approx 1.224745. Using the dot product to measure a distance in a non-Euclidean geometry gives 1.2247451.224745; the correct answer is 11. Orthogonality was defined through the inner product, and so is length.

The orthogonality check, in the right inner product: e1Ar=0\mathbf{e}_1^\top\mathbf{A}\mathbf{r} = 0 and e3Ar=0\mathbf{e}_3^\top\mathbf{A}\mathbf{r} = 0, both exactly.

(c) The picture: three unit coordinate arrows, the plane UU spanned by the first and third, and πU(e2)\pi_U(\mathbf{e}_2) sitting in that plane at (0.5,0,0.5)(0.5, 0, -0.5) — pointing along the e1e3\mathbf{e}_1 - \mathbf{e}_3 diagonal, not at the origin. The dashed perpendicular from e2\mathbf{e}_2 down to it looks oblique in Euclidean eyes and is perpendicular in this inner product’s eyes, which is exactly what makes the exercise worth drawing. ∎

ex_3_6.py
import numpy as np
 
A = np.array([[2.0, 1.0, 0.0], [1.0, 2.0, -1.0], [0.0, -1.0, 2.0]])
B = np.array([[1.0, 0.0], [0.0, 0.0], [0.0, 1.0]])      # columns e1 and e3
e2 = np.array([0.0, 1.0, 0.0])
 
G = B.T @ A @ B
c = B.T @ A @ e2
print("B^T A B =", G.tolist(), "  B^T A e2 =", c)
 
lam = np.linalg.solve(G, c)
proj = B @ lam
r = e2 - proj
print("(a) lambda =", lam, " pi_U(e2) =", proj)
print("    A r    =", A @ r)
print("(b) A-squared-norm =", float(r @ A @ r), " distance =", round(float(np.sqrt(r @ A @ r)), 6))
print("    Euclidean norm of the same residual =", round(float(np.linalg.norm(r)), 6),
      "  <- the WRONG answer")
print("orthogonal under A?", float(np.array([1.0, 0, 0]) @ A @ r), float(np.array([0, 0, 1.0]) @ A @ r))
print("A eigenvalues:", np.round(np.linalg.eigvalsh(A), 6))
output
B^T A B = [[2.0, 0.0], [0.0, 2.0]]   B^T A e2 = [ 1. -1.]
(a) lambda = [ 0.5 -0.5]  pi_U(e2) = [ 0.5  0.  -0.5]
    A r    = [0. 1. 0.]
(b) A-squared-norm = 1.0  distance = 1.0
    Euclidean norm of the same residual = 1.224745   <- the WRONG answer
orthogonal under A? 0.0 0.0
A eigenvalues: [0.585786 2.         3.414214]

Let VV be a vector space and π\pi an endomorphism of VV.

(a) Prove that π\pi is a projection if and only if idVπ\mathrm{id}_V - \pi is a projection, where idV\mathrm{id}_V is the identity endomorphism on VV. (b) Assume now that π\pi is a projection. Calculate Im(idVπ)\mathrm{Im}(\mathrm{id}_V - \pi) and ker(idVπ)\ker(\mathrm{id}_V - \pi) as a function of Im(π)\mathrm{Im}(\pi) and ker(π)\ker(\pi).

Solution (a). Write ρ:=idVπ\rho := \mathrm{id}_V - \pi and expand ρ2\rho^2:

ρ2=(idπ)(idπ)=idππ+π2=id2π+π2\rho^2 = (\mathrm{id} - \pi)(\mathrm{id} - \pi) = \mathrm{id} - \pi - \pi + \pi^2 = \mathrm{id} - 2\pi + \pi^2

So

ρ2ρ=(id2π+π2)(idπ)=π2π.\rho^2 - \rho = (\mathrm{id} - 2\pi + \pi^2) - (\mathrm{id} - \pi) = \pi^2 - \pi .

The two differences are the same object. Hence ρ2=ρ\rho^2 = \rho if and only if π2=π\pi^2 = \pi, which is the statement in both directions at once. ∎

The one-line version: idempotence of π\pi and of idπ\mathrm{id}-\pi are literally the same equation π2=π\pi^2 = \pi, rearranged.

Solution (b). Two claims.

Im(idπ)=ker(π)\mathrm{Im}(\mathrm{id}-\pi) = \ker(\pi).

\subseteq: take vπ(v)\mathbf{v} - \pi(\mathbf{v}) in the image. Then π(vπ(v))=π(v)π2(v)=π(v)π(v)=0\pi(\mathbf{v} - \pi(\mathbf{v})) = \pi(\mathbf{v}) - \pi^2(\mathbf{v}) = \pi(\mathbf{v}) - \pi(\mathbf{v}) = \mathbf{0}, so it is in ker(π)\ker(\pi).

\supseteq: take wker(π)\mathbf{w} \in \ker(\pi), so π(w)=0\pi(\mathbf{w}) = \mathbf{0}. Then (idπ)(w)=w0=w(\mathrm{id}-\pi)(\mathbf{w}) = \mathbf{w} - \mathbf{0} = \mathbf{w}, so w\mathbf{w} is in the image. ∎

ker(idπ)=Im(π)\ker(\mathrm{id}-\pi) = \mathrm{Im}(\pi).

\subseteq: if (idπ)(v)=0(\mathrm{id}-\pi)(\mathbf{v}) = \mathbf{0} then v=π(v)\mathbf{v} = \pi(\mathbf{v}), which exhibits v\mathbf{v} as something in the image of π\pi.

\supseteq: take π(u)\pi(\mathbf{u}) in the image. Then (idπ)(π(u))=π(u)π2(u)=0(\mathrm{id}-\pi)(\pi(\mathbf{u})) = \pi(\mathbf{u}) - \pi^2(\mathbf{u}) = \mathbf{0}. ∎

Both directions used π2=π\pi^2 = \pi and nothing else. So the two maps swap image and kernel:

Im(idπ)=ker(π),ker(idπ)=Im(π)\mathrm{Im}(\mathrm{id}-\pi) = \ker(\pi), \qquad \ker(\mathrm{id}-\pi) = \mathrm{Im}(\pi)

which is why IP\mathbf{I} - \mathbf{P} is the residual operator of §3.6: it keeps exactly what P\mathbf{P} throws away, and throws away exactly what P\mathbf{P} keeps. Note that nothing here assumed orthogonality — the result holds for oblique projections too, and in that case the two subspaces are complementary without being orthogonal complements.

ex_3_7.py
import numpy as np
 
def check(P, label):
    n = P.shape[0]
    R = np.eye(n) - P
    print(f"{label}")
    print("  P^2 - P  =", f"{np.linalg.norm(P @ P - P):.2e}",
          "   R^2 - R =", f"{np.linalg.norm(R @ R - R):.2e}")
    print("  rank P =", np.linalg.matrix_rank(P), " rank R =", np.linalg.matrix_rank(R),
          " sum =", np.linalg.matrix_rank(P) + np.linalg.matrix_rank(R), " n =", n)
    # Im(R) = ker(P): R's columns are killed by P, and P's columns are killed by R.
    print("  P @ R  =", f"{np.abs(P @ R).max():.2e}", "  R @ P =", f"{np.abs(R @ P).max():.2e}")
 
rng = np.random.default_rng(3)
B = rng.normal(size=(7, 3))
check(B @ np.linalg.inv(B.T @ B) @ B.T, "orthogonal projection onto a 3-dim subspace of R^7")
check(np.array([[1.0, 1.0], [0.0, 0.0]]), "an OBLIQUE projection (not symmetric)")
output
orthogonal projection onto a 3-dim subspace of R^7
  P^2 - P  = 2.41e-16    R^2 - R = 3.11e-16
  rank P = 3  rank R = 4  sum = 7  n = 7
  P @ R  = 1.83e-16   R @ P = 1.83e-16
an OBLIQUE projection (not symmetric)
  P^2 - P  = 0.00e+00    R^2 - R = 0.00e+00
  rank P = 1  rank R = 1  sum = 2  n = 2
  P @ R  = 0.00e+00   R @ P = 0.00e+00

Read the two idempotence columns together. Part (a) says ρ2ρ\rho^2 - \rho and π2π\pi^2 - \pi are the same expression, so exact arithmetic would give identical numbers — and the exact case, the oblique projection with integer entries, does: both print 0.00e+000.00\mathrm{e}{+}00. In the floating-point case they come out at 2.41×10162.41\times10^{-16} and 3.11×10163.11\times10^{-16}, differing because P\mathbf{P} and IP\mathbf{I}-\mathbf{P} are formed by different sequences of operations even though they are algebraically related. Same order of magnitude, both at machine precision; the algebra is exact and the arithmetic is not.

Part (b) is the last line of each block: PR=RP=0\mathbf{P}\mathbf{R} = \mathbf{R}\mathbf{P} = \mathbf{0}, so each map annihilates the other’s image — which is precisely Im(R)=ker(P)\mathrm{Im}(\mathbf{R}) = \ker(\mathbf{P}) and Im(P)=ker(R)\mathrm{Im}(\mathbf{P}) = \ker(\mathbf{R}). And the ranks add to nn in both cases, including the oblique one.

Using the Gram-Schmidt method, turn the basis B=(b1,b2)B = (\mathbf{b}_1, \mathbf{b}_2) of a two-dimensional subspace UR3U \subseteq \mathbb{R}^3 into an ONB C=(c1,c2)C = (\mathbf{c}_1, \mathbf{c}_2) of UU, where

\qquad \mathbf{b}_2 := \begin{bmatrix}-1\\2\\0\end{bmatrix}.$$

Solution.

Step 1. u1:=b1=(1,1,1)\mathbf{u}_1 := \mathbf{b}_1 = (1,1,1)^\top, kept unchanged.

Step 2. Subtract the projection of b2\mathbf{b}_2 onto u1\mathbf{u}_1. The coefficient is

u1,b2u1,u1=1+2+01+1+1=13\frac{\langle\mathbf{u}_1,\mathbf{b}_2\rangle}{\langle\mathbf{u}_1,\mathbf{u}_1\rangle} = \frac{-1 + 2 + 0}{1 + 1 + 1} = \frac{1}{3} u2=b213u1=[120]13[111]=[4/35/31/3]\mathbf{u}_2 = \mathbf{b}_2 - \tfrac13\mathbf{u}_1 = \begin{bmatrix}-1\\2\\0\end{bmatrix} - \tfrac13\begin{bmatrix}1\\1\\1\end{bmatrix} = \begin{bmatrix}-4/3\\ 5/3\\ -1/3\end{bmatrix}

Check: u1,u2=43+5313=0\langle\mathbf{u}_1,\mathbf{u}_2\rangle = -\tfrac43 + \tfrac53 - \tfrac13 = 0

Step 3. Normalise. u1=3\lVert\mathbf{u}_1\rVert = \sqrt3, and

u2=1316+25+1=4232.160247\lVert\mathbf{u}_2\rVert = \tfrac13\sqrt{16 + 25 + 1} = \frac{\sqrt{42}}{3} \approx 2.160247

so the 13\tfrac13 cancels and

c1=13[111],c2=142[451]\mathbf{c}_1 = \frac{1}{\sqrt3}\begin{bmatrix}1\\1\\1\end{bmatrix}, \qquad \mathbf{c}_2 = \frac{1}{\sqrt{42}}\begin{bmatrix}-4\\5\\-1\end{bmatrix} CC=I2\mathbf{C}^\top\mathbf{C} = \mathbf{I}_2

ex_3_8.py
import numpy as np
 
b1 = np.array([1.0, 1.0, 1.0])
b2 = np.array([-1.0, 2.0, 0.0])
 
u1 = b1.copy()
coeff = float(u1 @ b2) / float(u1 @ u1)
u2 = b2 - coeff * u1
print("coefficient  =", coeff, "  (should be 1/3)")
print("u2           =", u2)
print("<u1, u2>     =", float(u1 @ u2))
 
c1, c2 = u1 / np.linalg.norm(u1), u2 / np.linalg.norm(u2)
print("||u1|| =", np.linalg.norm(u1), " sqrt(3) =", np.sqrt(3))
print("||u2|| =", np.linalg.norm(u2), " sqrt(42)/3 =", np.sqrt(42) / 3)
print("c2 * sqrt(42) =", np.round(c2 * np.sqrt(42), 6))
C = np.stack([c1, c2], axis=1)
print("C^T C =")
print(np.round(C.T @ C, 15))
output
coefficient  = 0.3333333333333333   (should be 1/3)
u2           = [-1.33333333  1.66666667 -0.33333333]
<u1, u2>     = 1.6653345369377348e-16
||u1|| = 1.7320508075688772  sqrt(3) = 1.7320508075688772
||u2|| = 2.1602468994692865  sqrt(42)/3 = 2.160246899469287
c2 * sqrt(42) = [-4.  5. -1.]
C^T C =
[[1. 0.]
 [0. 1.]]

3.9 — Two inequalities from Cauchy-Schwarz

Section titled “3.9 — Two inequalities from Cauchy-Schwarz”

Let nNn \in \mathbb{N}^* and let x1,,xn>0x_1, \dots, x_n > 0 be nn positive real numbers so that x1++xn=1x_1 + \dots + x_n = 1. Use the Cauchy-Schwarz inequality and show that (a) i=1nxi21n\displaystyle\sum_{i=1}^n x_i^2 \geq \frac{1}{n} (b) i=1n1xin2\displaystyle\sum_{i=1}^n \frac{1}{x_i} \geq n^2 Hint: Think about the dot product on Rn\mathbb{R}^n. Then, choose specific vectors x,yRn\mathbf{x}, \mathbf{y} \in \mathbb{R}^n and apply the Cauchy-Schwarz inequality.

Solution. Both parts are the same trick — choose the two vectors so that the inner product is the thing you know and the norms are the things you want.

(a) Take x=(x1,,xn)\mathbf{x} = (x_1, \dots, x_n) and y=(1,1,,1)\mathbf{y} = (1, 1, \dots, 1). Then

x,y=ixi=1,x2=ixi2,y2=n\langle\mathbf{x},\mathbf{y}\rangle = \sum_i x_i = 1, \qquad \lVert\mathbf{x}\rVert^2 = \sum_i x_i^2, \qquad \lVert\mathbf{y}\rVert^2 = n

Cauchy-Schwarz squared says x,y2x2y2\langle\mathbf{x},\mathbf{y}\rangle^2 \leq \lVert\mathbf{x}\rVert^2\lVert\mathbf{y}\rVert^2, so

1(ixi2)nixi21n.1 \leq \left(\sum_i x_i^2\right) n \qquad\Longrightarrow\qquad \sum_i x_i^2 \geq \frac{1}{n} .

(b) Now take u=(x1,,xn)\mathbf{u} = (\sqrt{x_1}, \dots, \sqrt{x_n}) and v=(1x1,,1xn)\mathbf{v} = \left(\tfrac{1}{\sqrt{x_1}}, \dots, \tfrac{1}{\sqrt{x_n}}\right) — legal because every xi>0x_i > 0. Then

u,v=ixi1xi=i1=n,u2=ixi=1,v2=i1xi\langle\mathbf{u},\mathbf{v}\rangle = \sum_i \sqrt{x_i}\cdot\frac{1}{\sqrt{x_i}} = \sum_i 1 = n, \qquad \lVert\mathbf{u}\rVert^2 = \sum_i x_i = 1, \qquad \lVert\mathbf{v}\rVert^2 = \sum_i \frac{1}{x_i}

Cauchy-Schwarz squared:

n21i1xii1xin2.n^2 \leq 1 \cdot \sum_i \frac{1}{x_i} \qquad\Longrightarrow\qquad \sum_i \frac{1}{x_i} \geq n^2 .

When is each an equality? Cauchy-Schwarz is tight exactly when the two vectors are parallel. In (a) that means x\mathbf{x} parallel to (1,,1)(1,\dots,1), so every xix_i equal — and with the sum fixed at 11, xi=1/nx_i = 1/n. In (b) it means xi\sqrt{x_i} proportional to 1/xi1/\sqrt{x_i}, so again all xix_i equal.

Both bounds are attained at the uniform distribution and nowhere else. Which makes (a) a statement you have seen elsewhere: xi2\sum x_i^2 is minimised by the uniform distribution, so it measures concentration. It is the Simpson index, and 1xi21 - \sum x_i^2 is Gini impurity — the split criterion in a decision tree.

ex_3_9.py
import numpy as np
 
rng = np.random.default_rng(7)
worst_a, worst_b = np.inf, np.inf
for _ in range(200000):
    n = int(rng.integers(2, 9))
    v = rng.random(n)
    v = v / v.sum()                              # positive, summing to 1
    worst_a = min(worst_a, float(np.sum(v ** 2) * n))       # >= 1 iff (a) holds
    worst_b = min(worst_b, float(np.sum(1 / v) / n ** 2))   # >= 1 iff (b) holds
 
print("200000 random distributions")
print("  smallest n * sum(x^2)     :", round(worst_a, 6), " (the bound is 1)")
print("  smallest sum(1/x) / n^2   :", round(worst_b, 6), " (the bound is 1)")
print()
for n in (2, 3, 5, 10):
    v = np.full(n, 1.0 / n)
    print(f"  n={n:2}  uniform: sum x^2 = {float(np.sum(v ** 2)):.6f} = 1/n = {1 / n:.6f}"
          f"   sum 1/x = {float(np.sum(1 / v)):.1f} = n^2 = {n ** 2}")
output
200000 random distributions
  smallest n * sum(x^2)     : 1.0  (the bound is 1)
  smallest sum(1/x) / n^2   : 1.0  (the bound is 1)
 
  n= 2  uniform: sum x^2 = 0.500000 = 1/n = 0.500000   sum 1/x = 4.0 = n^2 = 4
  n= 3  uniform: sum x^2 = 0.333333 = 1/n = 0.333333   sum 1/x = 9.0 = n^2 = 9
  n= 5  uniform: sum x^2 = 0.200000 = 1/n = 0.200000   sum 1/x = 25.0 = n^2 = 25
  n= 10 uniform: sum x^2 = 0.100000 = 1/n = 0.100000   sum 1/x = 100.0 = n^2 = 100

Both minima come out at exactly 1.01.0 over two hundred thousand samples — that is the bound being touched, and it happens because the sampler occasionally draws something very close to uniform. Neither ratio ever dips below 11.

Rotate the vectors x1:=[23]\mathbf{x}_1 := \begin{bmatrix}2\\3\end{bmatrix}, x2:=[01]\mathbf{x}_2 := \begin{bmatrix}0\\-1\end{bmatrix} by 30°30°.

Solution. cos30°=32\cos 30° = \tfrac{\sqrt3}{2} and sin30°=12\sin 30° = \tfrac12, so by Equation 3.76

R(30°)=[32121232]\mathbf{R}(30°) = \begin{bmatrix}\tfrac{\sqrt3}{2} & -\tfrac12\\[3pt] \tfrac12 & \tfrac{\sqrt3}{2}\end{bmatrix} Rx1=[232312212+332]=[3321+332][0.2320513.598076]\mathbf{R}\mathbf{x}_1 = \begin{bmatrix}2\cdot\tfrac{\sqrt3}{2} - 3\cdot\tfrac12\\[3pt] 2\cdot\tfrac12 + 3\cdot\tfrac{\sqrt3}{2}\end{bmatrix} = \begin{bmatrix}\sqrt3 - \tfrac32\\[3pt] 1 + \tfrac{3\sqrt3}{2}\end{bmatrix} \approx \begin{bmatrix}0.232051\\ 3.598076\end{bmatrix} Rx2=[0+12032]=[1232][0.50.866025]\mathbf{R}\mathbf{x}_2 = \begin{bmatrix}0 + \tfrac12\\[3pt] 0 - \tfrac{\sqrt3}{2}\end{bmatrix} = \begin{bmatrix}\tfrac12\\[3pt] -\tfrac{\sqrt3}{2}\end{bmatrix} \approx \begin{bmatrix}0.5\\ -0.866025\end{bmatrix}

x2=e2\mathbf{x}_2 = -\mathbf{e}_2, so Rx2\mathbf{R}\mathbf{x}_2 is minus the second column of R\mathbf{R} — rotating a basis vector reads off a column, no arithmetic required.

Checks. x1=13=3.605551\lVert\mathbf{x}_1\rVert = \sqrt{13} = 3.605551 before and after. x2=1\lVert\mathbf{x}_2\rVert = 1 before and after. The angle between them is 146.309932°146.309932° before and 146.309932°146.309932° after — nine matching digits. detR=1.000000000000000\det\mathbf{R} = 1.000000000000000. ∎

ex_3_10.py
import numpy as np
 
def rot2(theta):
    c, s = np.cos(theta), np.sin(theta)
    return np.array([[c, -s], [s, c]])
 
R = rot2(np.radians(30.0))
x1, x2 = np.array([2.0, 3.0]), np.array([0.0, -1.0])
y1, y2 = R @ x1, R @ x2
 
print("R(30) =", np.round(R, 6).tolist())
print("x1 ->", np.round(y1, 6), " exact:", round(np.sqrt(3) - 1.5, 6), round(1 + 1.5 * np.sqrt(3), 6))
print("x2 ->", np.round(y2, 6), " exact:", 0.5, round(-np.sqrt(3) / 2, 6))
 
cos = lambda a, b: float(a @ b) / (np.linalg.norm(a) * np.linalg.norm(b))
print("||x1||:", round(float(np.linalg.norm(x1)), 6), "->", round(float(np.linalg.norm(y1)), 6))
print("||x2||:", round(float(np.linalg.norm(x2)), 6), "->", round(float(np.linalg.norm(y2)), 6))
print("angle: ", round(float(np.degrees(np.arccos(np.clip(cos(x1, x2), -1, 1)))), 6),
      "->", round(float(np.degrees(np.arccos(np.clip(cos(y1, y2), -1, 1)))), 6))
print("det R =", f"{np.linalg.det(R):.15f}")
output
R(30) = [[0.866025, -0.5], [0.5, 0.866025]]
x1 -> [0.232051 3.598076]  exact: 0.232051 3.598076
x2 -> [ 0.5      -0.866025]  exact: 0.5 -0.866025
||x1||: 3.605551 -> 3.605551
||x2||: 1.0 -> 1.0
angle:  146.309932 -> 146.309932
det R = 1.000000000000000
#looks like it testsactually tests
3.1reading a formula as a matrixthat positive definiteness can be shown by completing the square, without eigenvalues
3.2positive definitenesssymmetry — the quadratic form here is positive definite and the map is still not an inner product
3.3two distance computationsthat both answers are correct, and differ by 46%46\%
3.4two angle computationsthe same, for angles
3.5the projection formulathat a spanning set is not a basis — the rank is 3, not 4, and Eq 3.59 is undefined as posed
3.6projection onto a coordinate planethat orthogonality and length both depend on the inner product — under the dot product the answer would be 0\mathbf{0} and distance 11; here it is (0.5,0,0.5)(0.5, 0, -0.5) and distance 11, while the Euclidean length of the residual is 1.2247451.224745
3.7an abstract proofthat IP\mathbf{I}-\mathbf{P} swaps image and kernel, for oblique projections too
3.8Gram-Schmidt arithmeticthat the awkward thirds cancel against the norm
3.9Cauchy-Schwarzchoosing the two vectors so the inner product is what you know
3.10matrix-vector multiplicationthat rotating ei\mathbf{e}_i reads off column ii

Three of the ten (3.2, 3.5, 3.6) fail if you apply the formula without checking its preconditions. That ratio is not an accident.

pch.quizTag Did the traps catch you?
  1. Exercise 3.2's matrix [[2, 0], [1, 2]] fails to be an inner product. Which condition fails, and what is the shortest witness?

    pch.quizShowAnswer

    B — Symmetry; the witness is <e1, e2> = 0 against <e2, e1> = 1 — The quadratic form 2x1^2 + x1x2 + 2x2^2 is positive definite: only the symmetric part of A affects it, and that part has eigenvalues 1.5 and 2.5. Testing definiteness alone passes this matrix, which is the trap.

  2. Exercise 3.5 gives four spanning vectors in R^5. What must you do first, and why?

    pch.quizShowAnswer

    B — Check the rank — it is 3, so they are not a basis, B-transpose B is singular with condition number 2e17, and Equation 3.59 is undefined as posed. The fourth vector equals u1 + 2 u2 + u3 — The book flags exactly this in a margin note in section 3.8.2. np.linalg.lstsq happens to return the right projection anyway, because it uses a minimum-norm pseudo-inverse rather than an inverse — but the formula as written does not.

  3. In Exercise 3.6, what is d(e2, U) and what is the tempting wrong answer?

    pch.quizShowAnswer

    B — Exactly 1; the wrong answer is 1.224745, from measuring the residual with the dot product instead of the exercise's inner product — Both wrong answers are available. Assuming orthogonality gives a projection of 0; measuring the correct residual (-0.5, 1, 0.5) with the dot product gives sqrt(1.5) = 1.224745. The correct A-norm of that residual is exactly 1.

  4. Exercise 3.9's two bounds are attained at the same distribution. Which, and what does part (a) turn out to be?

    pch.quizShowAnswer

    B — At the uniform distribution, since Cauchy-Schwarz is tight exactly when the two vectors are parallel — and sum of x-i squared is the Simpson index, whose complement is Gini impurity — In part (a) tightness needs x parallel to the all-ones vector, so every x-i equal, hence 1/n each. In part (b) it needs sqrt(x-i) proportional to 1 over sqrt(x-i), which again forces all equal.

Exercise B – Exercise 3.5 the wrong way, then the right way

Section titled “Exercise B – Exercise 3.5 the wrong way, then the right way”

Exercise E – Exercise 3.9’s equality case

Section titled “Exercise E – Exercise 3.9’s equality case”
  • Exercise 3.2 is about symmetry, not definiteness — the quadratic form of a non-symmetric matrix can be positive definite while the map fails to be an inner product, because only the symmetric part affects the form.
  • Exercise 3.5’s spanning set has rank three, not four, so the Gram matrix is singular and the projection formula is undefined as posed. Determine a basis first.
  • Exercise 3.6’s coordinate axes are not perpendicular in its inner product, so the projection of the second basis vector is not zero, and the distance must be measured with the same inner product — one, not the Euclidean 1.224745.
  • Exercise 3.7: the residual operator swaps image and kernel. The image of the identity minus pi is the kernel of pi and vice versa, and both idempotence conditions are the same equation.
  • Exercise 3.9’s trick is choosing the vectors so that the inner product is the quantity you already know, and both bounds are tight only at the uniform distribution.
  • Both distance exercises and both angle exercises give two different correct answers, which is the chapter’s central point restated as arithmetic.

Next: Chapter 3 Formula Sheet — every result on one page.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading