Lab 20 Interactive: Hilbert Spaces and Applications

Explore orthogonal projection, polynomial approximation in $L^2[0,1]$, Fourier partial sums, and kernel Gram matrices. These are concrete models of Hilbert-space linear algebra.

1. Projection onto a line in $\mathbb{R}^2$

Choose a vector $y$ and a line direction $u$. The projection is $$\operatorname{Proj}_{\operatorname{span}(u)}y=\frac{\langle y,u\rangle}{\langle u,u\rangle}u.$$

Vector $y=(y_1,y_2)$

Direction $u=(u_1,u_2)$

2. Geometry of projection

Blue: $y$. Orange: projection $p$. Dashed: residual $y-p$, orthogonal to the line.

3. Best polynomial approximation to $e^x$

Approximate $e^x$ on $[0,1]$ in the $L^2$ inner product $$\langle f,g\rangle=\int_0^1 f(x)g(x)\,dx.$$

4. Fourier partial sums

The square wave has Hilbert-space coordinate expansion $$f(x)\sim \frac4\pi\left(\sin x+\frac{\sin 3x}{3}+\frac{\sin 5x}{5}+\cdots\right).$$

5. $\ell^2$ sequence test

A sequence $x=(x_n)$ is in $\ell^2$ if $$\sum_{n=1}^{\infty}|x_n|^2<\infty.$$

6. Kernel Gram matrix

For points $x_1,x_2,x_3$, the polynomial kernel $$K(x,y)=(1+xy)^2$$ produces a Gram matrix $G=[K(x_i,x_j)]$.

7. Independent-study tasks with answers

Task A. For $y=(3,2)$ and $u=(1,1)$, compute $\operatorname{Proj}_{\operatorname{span}(u)}y$.
Answer. $\langle y,u\rangle=5$, $\langle u,u\rangle=2$, so $p=\frac52(1,1)=(2.5,2.5)$.
Task B. Explain why the residual $y-p$ is orthogonal to $u$.
Answer. By construction, $p=\frac{\langle y,u\rangle}{\langle u,u\rangle}u$, so $\langle y-p,u\rangle=\langle y,u\rangle-\frac{\langle y,u\rangle}{\langle u,u\rangle}\langle u,u\rangle=0$.
Task C. Which sequence is not in $\ell^2$: $1/n$ or $1/\sqrt n$?
Answer. $1/\sqrt n$ is not in $\ell^2$, because its square is $1/n$, and the harmonic series diverges.
Task D. Why is a Fourier partial sum a projection?
Answer. It is the orthogonal projection of a function onto the finite-dimensional subspace spanned by selected sine and cosine basis functions.

8. Workspace