Calculate the orthogonal projection of a function onto a Hilbert Space Let the Hilbert space $H = L_2[0,\infty[$ with the standard inner product
$$
\langle f,g\rangle:=\int_{0}^\infty \overline {f(x)} g(x)dx.
$$
be given.
Let $f_n \in L_2[0,\infty[  \to \mathbb{R}$ be given by
$$
f_n(x) = x^n e^{\frac {-x}{2}}.
$$
Define $H_n = span\{f_0,\ f_1,\ \dots, f_n\}$.
Denote by $p_n$ the orthogonal projection of $f_n$ onto $H_{n-1}^{\bot}$ for $n\ge 1$ and
set $p_0 = f_0$.
Show that $p_0,\ p_1, \dots, p_n$ is an orthogonal basis for $H_n$ and calculate $p_1$, $p_2$ and $p_3$.
Not sure what to do for this, any help would be appreciated!
 A: If $P_{n}$ is the orthogonal projection onto $H_{n-1}^{\perp}$, then $P_{n}f_{n}$ is orthogonal to $H_{n-1}$, and is in $H_{n}$. Another way to obtain $P_{n}f_{n}$ is as the unique $P_{n}f_{n} = f_{n}-\sum_{k=0}^{n-1}a_{n,k}f_{k}$ such that
$$
        (f_{n}-\sum_{k=0}^{n-1}a_{n,k}f_{k},f_{j})=0,\;\;\; 0 \le j \le n-1.
$$
This is a system of $n$ equations in $n$ unknowns. You may recognize $f_n$ as the non-normalized vector obtained in the Gram-Schmidt process. To find explicit expressions, it helps to know that
$$
  (f_n,f_m)=(x^{n}e^{-x/2},x^{m}e^{-x/2}) = \int_{0}^{\infty}x^{n+m}e^{-x}dx = (n+m)!.
$$
Starting with $p_0 = f_0$, then the first element for Gram-Schmidt is
$$
               u_0 = \frac{1}{(p_0,p_0)^{1/2}}p_{0}=p_{0}
$$
Then,
$$
               p_{1} = f_{1}-(f_1,u_0))u_0 = f_1-(1!)p_0 = (x-1)e^{-x},\\
     u_{1} = \frac{1}{(p_1,p_1)^{1/2}}p_{1}=\frac{1}{(2!-2(1!)+1!)^{1/2}}(x-1)e^{-x}=p_1
$$
And,
$$
\begin{align}
         p_{2} & = f_{2}-(f_2,u_1)u_1-(f_2,u_0)u_0 \\
               & = f_{2}-(x^{2}e^{-x/2},(x-1)e^{-x/2})(x-1)e^{-x/2}-(x^{2}e^{-x/2},e^{-x/2})e^{-x/2} \\
    & = \{x^{2}-(3!-2!)(x-1)-(2!)\}e^{-x/2} \\
    & = \{x^{2}-4x+2\}e^{-x/2}
\end{align}
$$
You can check that $(p_2,p_1)=0$ because it involves an integral of
$$
    (x^{2}-4x+2)(x-1)e^{-x}=(x^{3}-5x^{2}+6x-2)e^{-x}
$$
which gives $(3!)-5(2!)+6(1!)-2(0!)=6-10+6-2=0$. Likewise $(p_2,p_0)=0$ because $(2!)-4(1!)+2(0!)=0$. Finally,
$$
    u_2 = \frac{1}{(p_2,p_2)^{1/2}}p_2 \\
    p_3 = f_3 - (f_3,u_2)u_2 - (f_3,u_1)u_1 - (f_3,u_0)u_0.
$$
