Compute the projection of a function in a different way

inner-productslinear algebraprojection-matrices

The problem:

Let C([0,1]) denote the vector space of all continuous real-valued functions defined on the closed unit interval [0,1]. For $f, g \, \, \in\, C([0,1])$ we define the inner product:

$$ (f,g) =\int_0^1 f(x)g(x)dz$$

Consider the subspace
$$ V= span\{1,x,x^2\} \, \text{of} \, \, C([0,1])$$

Explain how one can compute the projection of a function $ q \, \in\, C([0,1])$ onto V, i.e how one can compute $proj_vq$


My attempt:

$$proj_vq = c_0 * 1 + c_1 * x + c_2*x^2 $$
$$(q-proj_vq) \perp V \Leftrightarrow(q-proj_vq, v)= 0 \, \forall\, v \in V$$
$$\Updownarrow$$
$$(q-proj_vq, v)= 0 , \, \, v = 1, x, x^2$$
$$\Updownarrow$$
$$(q-proj_vq, 1)= 0 $$
$$(q-proj_vq, x)= 0 $$
$$(q-proj_vq, x^2)= 0$$
$$\Updownarrow$$
$$(c_0+ c_1x + c_2x^2,1) = (q,1)$$
$$(c_0+ c_1x + c_2x^2,x) = (q,x)$$
$$(c_0+ c_1x + c_2x^2,x^2) = (q,x^2)$$
$$\Updownarrow$$
$$c_0\int_0^11dx + c_1\int_0^1xdx + c_2\int_0^1x^2dx= \int_0^1q(x)dx$$
$$c_0\int_0^1xdx + c_1\int_0^1x^2dx + c_2\int_0^1x^3dx= \int_0^1q(x)*x \,dx$$
$$c_0\int_0^1x^2dx + c_1\int_0^1x^3dx + c_2\int_0^1x^4dx= \int_0^1q(x)*x^2\,dx$$

As user AMD pointed out, one would then solve this system to find the projection. Since the task didn't ask for a solution but instead explain how to get one, I didn't compute it.


Question:

I believe this is the correct solution, however I was wondering if there was another method to solve this? Perhaps something more intuitive?

Best Answer

Let's compute an orthonormal basis for $V$.

$$u_1=1, u_2=x, u_3=x^2$$

$\langle u_1, u_1 \rangle =\int_0^1 1 \, dx=1$. $u_1=1$. $\{v_1\}$ span the same space as $\{u_1\}$ and the normalized vector is $w_1=1$.

$v_2=u_2-proj_{w_1}(u_2) = u_2- \langle u_2, w_1\rangle w_1=x-\int_0^1t\, dt =x-\frac12$.

$\langle v_2, v_2 \rangle =\int_0^1 \left( t-\frac12\right)^2\, dt=\frac13\left[\left( t-\frac12\right)^3\right]_{t=0}^{t=1}=\frac23\cdot \frac18=\frac1{12}$.

The normalized $w_2=\sqrt{12}\left(x-\frac12 \right)=\sqrt{3}\left(2x-1 \right)$.

\begin{align}v_3&=u_3-proj_{w_1}(u_3) - proj_{w_2}(u_3)\\&=x^2-\int_0^1t^2\, dt -\int_0^1 \sqrt{12}(t-\frac12)t^2\, dt \cdot (\sqrt{12}(x-\frac12)) \\ &=x^2-\frac13 - 12 \int_0^1t^3-\frac12t^2 \, dt (x-\frac12) \\ &=x^2-\frac13-12\left(x-\frac12 \right)\left(\frac14-\frac16 \right)\\ &=x^2-\frac13-x+\frac12\\&=x^2-x+\frac16\end{align}

\begin{align}\langle v_3, v_3\rangle &= \int_0^1 (t^2-t+\frac16)^2 \, dt \\ &=\int_0^1 t^4-2t^3+t^2+\frac13t^2-\frac13 t+\frac1{36} \, dt \\ &=\frac15-\frac12+\frac13 + \frac19 -\frac16 + \frac1{36} \\ &= \frac{36-90+60+20-30+5}{180}\\ &= \frac{1}{180}\end{align}

$$w_3=\sqrt{180}(x^2-x+\frac16)=\sqrt5 (6x^2-6x+1)$$

$\{w_1, w_2, w_3\}$ is an orthonormal basis for $V$.

Given a new function $q$ in $C[0,1]$,

\begin{align}proj_V(q)&= proj_{w_1}(q) + proj_{w_2}(q) + proj_{w_3}(q) \\ &= \sum_{i=1}^3\langle w_i, q \rangle w_i\\ &= \sum_{i=1}^3\left( \int_0^1 w_i(t) q(t)\, dt \right) w_i(x)\end{align}

Related Question