Linear-Algebra-Done-Right Β· Unit 17 Β· Video 1 Β· Interactive Practice

The Closest Point Is the Projection: Fitting Sine on [βˆ’Ο€, Ο€]

IKey Formulas

FormulaNameWhen it applies
βˆ₯vβˆ’PUvβˆ₯≀βˆ₯vβˆ’uβˆ₯\|v - P_U v\| \le \|v - u\| for all u∈Uu \in U, with equality iff u=PUvu = P_U vClosest point is the projectionUU finite-dimensional, v∈Vv \in V
βˆ₯vβˆ’uβˆ₯2=βˆ₯vβˆ’PUvβˆ₯2+βˆ₯PUvβˆ’uβˆ₯2\|v - u\|^2 = \|v - P_U v\|^2 + \|P_U v - u\|^2Pythagoras behind the proofvβˆ’PUv∈UβŠ₯v - P_U v \in U^\perp, PUvβˆ’u∈UP_U v - u \in U
PUv=⟨v,e1⟩e1+β‹―+⟨v,em⟩emP_U v = \langle v, e_1 \rangle e_1 + \cdots + \langle v, e_m \rangle e_mComputing the closest pointe1,…,eme_1, \dots, e_m orthonormal basis of UU
⟨f,g⟩=βˆ«βˆ’Ο€Ο€fg\langle f, g \rangle = \displaystyle\int_{-\pi}^{\pi} f gInner product on C[βˆ’Ο€,Ο€]C[-\pi, \pi]Makes βˆ₯sinβ‘βˆ’uβˆ₯2\|\sin - u\|^2 the integrated squared error

Key Insight: Projecting sin⁑\sin onto P5(R)\mathcal{P}_5(\mathbf{R}) gives u(x)=0.987862xβˆ’0.155271x3+0.00564312x5u(x) = 0.987862x - 0.155271x^3 + 0.00564312x^5, the degree-5 polynomial with the smallest βˆ«βˆ’Ο€Ο€βˆ£sin⁑xβˆ’u(x)∣2 dx\int_{-\pi}^{\pi} |\sin x - u(x)|^2\,dx β€” the theorem guarantees the integral, not the error at each point.

IIThe Closest Point Is the Foot of the Perpendicular

For every u∈Uu \in U, the legs vβˆ’PUvv - P_U v and PUvβˆ’uP_U v - u are orthogonal, so βˆ₯vβˆ’uβˆ₯\|v - u\| is a hypotenuse.

IIIProjecting sin⁑\sin onto P5(R)\mathcal{P}_5(\mathbf{R}) One Term at a Time

Each orthonormal term ⟨sin⁑,ek⟩ek\langle \sin, e_k \rangle e_k lowers the squared error by exactly ⟨sin⁑,ek⟩2\langle \sin, e_k \rangle^2.

  1. e1=0.398942e_1 = 0.398942 is even, so ⟨sin⁑,e1⟩=0\langle \sin, e_1 \rangle = 0.
  2. e2=0.219948xe_2 = 0.219948x is odd, and ⟨sin⁑,e2⟩=1.38198\langle \sin, e_2 \rangle = 1.38198.
  3. e3=0.135577x2βˆ’0.446031e_3 = 0.135577x^2 - 0.446031 is even, so ⟨sin⁑,e3⟩=0\langle \sin, e_3 \rangle = 0.
  4. e4=0.0851039x3βˆ’0.503965xe_4 = 0.0851039x^3 - 0.503965x is odd, and ⟨sin⁑,e4⟩=βˆ’1.09734\langle \sin, e_4 \rangle = -1.09734.
  5. e5=0.0537539x4βˆ’0.454740x2+0.448810e_5 = 0.0537539x^4 - 0.454740x^2 + 0.448810 is even, so ⟨sin⁑,e5⟩=0\langle \sin, e_5 \rangle = 0.
  6. e6=0.0340493x5βˆ’0.373392x3+0.789692xe_6 = 0.0340493x^5 - 0.373392x^3 + 0.789692x is odd, and ⟨sin⁑,e6⟩=0.165734\langle \sin, e_6 \rangle = 0.165734.

IVProjection Versus Taylor

The projection minimizes the integrated squared error, yet the Taylor polynomial still wins pointwise near x=0x = 0.

VQuiz Questions

Problem 1 Β· Distance to a Plane

Given: In R3\mathbf{R}^3 with the dot product, U=span⁑(e1,e2)U = \operatorname{span}(e_1, e_2) where e1=12(1,1,0)e_1 = \tfrac{1}{\sqrt{2}}(1, 1, 0) and e2=(0,0,1)e_2 = (0, 0, 1) are orthonormal, and v=(3,1,2)v = (3, 1, 2). Find min⁑u∈Uβˆ₯vβˆ’uβˆ₯\min_{u \in U} \|v - u\|.

βœ… Correct! PUv=(2,2,2)P_U v = (2, 2, 2), so the minimum is βˆ₯vβˆ’PUvβˆ₯=βˆ₯(1,βˆ’1,0)βˆ₯=2\|v - P_U v\| = \|(1, -1, 0)\| = \sqrt{2}.
❌ Not quite. 22 is the squared distance βˆ₯vβˆ’PUvβˆ₯2\|v - P_U v\|^2; take its square root.
❌ Not quite. 14=βˆ₯vβˆ₯=βˆ₯vβˆ’0βˆ₯\sqrt{14} = \|v\| = \|v - 0\| is the distance to one particular point of UU, the origin, not the closest one.
❌ Not quite. 23=βˆ₯PUvβˆ₯2\sqrt{3} = \|P_U v\| is the length of the projection itself; the distance is the length of the perpendicular piece vβˆ’PUvv - P_U v.
Show solution

By the theorem the closest point is PUvP_U v, computed with the orthonormal basis:

⟨v,e1⟩=3+12=22,⟨v,e2⟩=2,\langle v, e_1 \rangle = \tfrac{3 + 1}{\sqrt{2}} = 2\sqrt{2}, \qquad \langle v, e_2 \rangle = 2, PUv=22β‹…12(1,1,0)+2(0,0,1)=(2,2,2).P_U v = 2\sqrt{2}\cdot\tfrac{1}{\sqrt{2}}(1, 1, 0) + 2(0, 0, 1) = (2, 2, 2).

Then vβˆ’PUv=(1,βˆ’1,0)v - P_U v = (1, -1, 0), which is orthogonal to both e1e_1 and e2e_2, and

min⁑u∈Uβˆ₯vβˆ’uβˆ₯=βˆ₯vβˆ’PUvβˆ₯=1+1+0=2.\min_{u \in U} \|v - u\| = \|v - P_U v\| = \sqrt{1 + 1 + 0} = \sqrt{2}.

Problem 2 Β· The Formula Needs an Orthonormal Basis

Given: In R3\mathbf{R}^3 with the dot product, U=span⁑((1,1,0),(1,0,0))U = \operatorname{span}\big((1, 1, 0), (1, 0, 0)\big) and v=(1,2,3)v = (1, 2, 3). Find the point of UU closest to vv.

βœ… Correct! UU is the xyxy-plane, and Gram–Schmidt gives the orthonormal basis (1,0,0),(0,1,0)(1, 0, 0), (0, 1, 0), so PUv=(1,2,0)P_U v = (1, 2, 0).
❌ Close, but… ⟨v,w1⟩w1+⟨v,w2⟩w2\langle v, w_1 \rangle w_1 + \langle v, w_2 \rangle w_2 with w1=(1,1,0)w_1 = (1, 1, 0), w2=(1,0,0)w_2 = (1, 0, 0) uses a basis that is neither orthogonal nor normalized; run Gram–Schmidt first.
❌ Not quite. (32,32,0)\big(\tfrac{3}{2}, \tfrac{3}{2}, 0\big) is the projection onto the line spanned by (1,1,0)(1, 1, 0) alone, a smaller subspace than UU.
❌ Not quite. (0,0,3)=vβˆ’PUv(0, 0, 3) = v - P_U v is the piece of vv in UβŠ₯U^\perp; the closest point is the piece in UU.
Show solution

Run Gram–Schmidt on w1=(1,1,0)w_1 = (1, 1, 0), w2=(1,0,0)w_2 = (1, 0, 0):

e1=12(1,1,0),w2βˆ’βŸ¨w2,e1⟩e1=(1,0,0)βˆ’12(1,1,0)=(12,βˆ’12,0),e2=12(1,βˆ’1,0).e_1 = \tfrac{1}{\sqrt{2}}(1, 1, 0), \qquad w_2 - \langle w_2, e_1 \rangle e_1 = (1, 0, 0) - \tfrac{1}{2}(1, 1, 0) = \big(\tfrac{1}{2}, -\tfrac{1}{2}, 0\big), \qquad e_2 = \tfrac{1}{\sqrt{2}}(1, -1, 0).

Now apply the formula:

⟨v,e1⟩=32,⟨v,e2⟩=βˆ’12,PUv=32(1,1,0)βˆ’12(1,βˆ’1,0)=(1,2,0).\langle v, e_1 \rangle = \tfrac{3}{\sqrt{2}}, \quad \langle v, e_2 \rangle = -\tfrac{1}{\sqrt{2}}, \quad P_U v = \tfrac{3}{2}(1, 1, 0) - \tfrac{1}{2}(1, -1, 0) = (1, 2, 0).

Check: vβˆ’PUv=(0,0,3)v - P_U v = (0, 0, 3) is orthogonal to both (1,1,0)(1, 1, 0) and (1,0,0)(1, 0, 0), so it lies in UβŠ₯U^\perp, and the closest point is (1,2,0)(1, 2, 0) at distance 33.

Problem 3 Β· Best Line for Sine

Given: V=C[βˆ’Ο€,Ο€]V = C[-\pi, \pi] with ⟨f,g⟩=βˆ«βˆ’Ο€Ο€fg\langle f, g \rangle = \int_{-\pi}^{\pi} f g, U=P1(R)U = \mathcal{P}_1(\mathbf{R}), and v=sin⁑v = \sin. You may use βˆ«βˆ’Ο€Ο€xsin⁑x dx=2Ο€\int_{-\pi}^{\pi} x \sin x \, dx = 2\pi, βˆ«βˆ’Ο€Ο€x2 dx=2Ο€33\int_{-\pi}^{\pi} x^2 \, dx = \tfrac{2\pi^3}{3} and βˆ«βˆ’Ο€Ο€sin⁑2x dx=Ο€\int_{-\pi}^{\pi} \sin^2 x \, dx = \pi. Find the closest point u=PU(sin⁑)u = P_U(\sin) and the minimum value of βˆ«βˆ’Ο€Ο€βˆ£sin⁑xβˆ’u(x)∣2 dx\int_{-\pi}^{\pi} |\sin x - u(x)|^2 \, dx.

What is PU(sin⁑)P_U(\sin)?

What is the minimum of βˆ«βˆ’Ο€Ο€βˆ£sin⁑xβˆ’u(x)∣2 dx\int_{-\pi}^{\pi} |\sin x - u(x)|^2 \, dx?

βœ… Correct! PU(sin⁑)=3Ο€2xβ‰ˆ0.304xP_U(\sin) = \tfrac{3}{\pi^2}x \approx 0.304x, and the squared error is Ο€βˆ’6Ο€β‰ˆ1.2317\pi - \tfrac{6}{\pi} \approx 1.2317.
❌ Not quite. xx is the degree-1 Taylor polynomial, which matches sin⁑\sin at 00; it is not the closest point of UU in the integral norm.
❌ Close, but… ⟨sin⁑,x⟩x\langle \sin, x \rangle x forgets to divide by βˆ₯xβˆ₯2=2Ο€33\|x\|^2 = \tfrac{2\pi^3}{3}; the formula needs a unit vector.
❌ Not quite. The projection onto span⁑(x)\operatorname{span}(x) is ⟨sin⁑,x⟩βˆ₯xβˆ₯2 x\tfrac{\langle \sin, x \rangle}{\|x\|^2}\, x; compute that ratio carefully.
❌ Not quite. By Pythagoras, βˆ₯sinβ‘βˆ’PUsin⁑βˆ₯2=βˆ₯sin⁑βˆ₯2βˆ’βŸ¨sin⁑,e2⟩2\|\sin - P_U \sin\|^2 = \|\sin\|^2 - \langle \sin, e_2 \rangle^2, where e2=x/βˆ₯xβˆ₯e_2 = x / \|x\|.
Show solution

Orthonormal basis of UU. On the symmetric interval ⟨1,x⟩=0\langle 1, x \rangle = 0, so Gram–Schmidt only normalizes: e1=12Ο€e_1 = \tfrac{1}{\sqrt{2\pi}} and e2=x/2Ο€3/3e_2 = x \big/ \sqrt{2\pi^3/3}.

Coefficients. ⟨sin⁑,e1⟩=0\langle \sin, e_1 \rangle = 0 because sin⁑\sin is odd. Then

PU(sin⁑)=⟨sin⁑,e2⟩e2=⟨sin⁑,x⟩βˆ₯xβˆ₯2 x=2Ο€2Ο€3/3 x=3Ο€2 xβ‰ˆ0.304x.P_U(\sin) = \langle \sin, e_2 \rangle e_2 = \frac{\langle \sin, x \rangle}{\|x\|^2}\, x = \frac{2\pi}{2\pi^3/3}\, x = \frac{3}{\pi^2}\, x \approx 0.304x.

Minimum squared error. Since sin⁑=PU(sin⁑)+(sinβ‘βˆ’PUsin⁑)\sin = P_U(\sin) + (\sin - P_U \sin) with orthogonal pieces,

βˆ₯sinβ‘βˆ’PUsin⁑βˆ₯2=βˆ₯sin⁑βˆ₯2βˆ’βŸ¨sin⁑,e2⟩2=Ο€βˆ’(2Ο€)22Ο€3/3=Ο€βˆ’6Ο€β‰ˆ1.2317.\|\sin - P_U \sin\|^2 = \|\sin\|^2 - \langle \sin, e_2 \rangle^2 = \pi - \frac{(2\pi)^2}{2\pi^3/3} = \pi - \frac{6}{\pi} \approx 1.2317.

Problem 4 Β· What the Theorem Guarantees

Given: U=P5(R)βŠ†C[βˆ’Ο€,Ο€]U = \mathcal{P}_5(\mathbf{R}) \subseteq C[-\pi, \pi] with the integral inner product, u=PU(sin⁑)u = P_U(\sin), and the Taylor polynomial p(x)=xβˆ’x33!+x55!p(x) = x - \tfrac{x^3}{3!} + \tfrac{x^5}{5!}, which lies in UU and is not equal to uu. Which statement follows from the theorem?

βœ… Correct! The inequality βˆ₯vβˆ’PUvβˆ₯≀βˆ₯vβˆ’pβˆ₯\|v - P_U v\| \le \|v - p\| is strict because equality would force p=PUvp = P_U v; numerically the two integrals are about 0.0001160.000116 and 0.1190.119.
❌ Not quite. The theorem compares norms, and this norm is an integral. At x=0.5x = 0.5 the Taylor error is about 0.00000150.0000015 while ∣sin⁑0.5βˆ’u(0.5)βˆ£β‰ˆ0.0047|\sin 0.5 - u(0.5)| \approx 0.0047.
❌ Not quite. Equality in the theorem holds only when the competitor is PUvP_U v itself, and pβ‰ up \ne u.
❌ Not quite. The hypothesis is that UU is finite-dimensional, which P5(R)\mathcal{P}_5(\mathbf{R}) is (dim⁑U=6\dim U = 6); VV may be infinite-dimensional.
Show solution

The theorem applies because U=P5(R)U = \mathcal{P}_5(\mathbf{R}) is finite-dimensional, and p∈Up \in U. It gives βˆ₯sinβ‘βˆ’uβˆ₯≀βˆ₯sinβ‘βˆ’pβˆ₯\|\sin - u\| \le \|\sin - p\|, with equality iff p=up = u. Since pβ‰ up \ne u, the inequality is strict, and squaring the norms gives

βˆ«βˆ’Ο€Ο€βˆ£sin⁑xβˆ’u(x)∣2 dx<βˆ«βˆ’Ο€Ο€βˆ£sin⁑xβˆ’p(x)∣2 dx.\int_{-\pi}^{\pi} |\sin x - u(x)|^2\,dx \lt \int_{-\pi}^{\pi} |\sin x - p(x)|^2\,dx.

Numerically the left side is about 0.0001160.000116 and the right side about 0.1190.119. The theorem says nothing about single points: for ∣x∣|x| below about 1.211.21 the Taylor polynomial is the closer of the two, while at x=3x = 3 the error of uu is about 0.00140.0014 against 0.380.38 for pp, a fact we checked, not one the theorem promises.

Solved: 0 / 4