Orthogonal polynomials and Gram Schmidt How can we use the Gram Schmidt procedure to calculate $L_0,L_1, L_2, L_3$, where ${L_0(x), L_1(x), L_2(x), L_3(x)}$ is an orthogonal set of polynomials on $(0, \infty)$ w.r.t. the weight function $w(x) = e^{-x}$ and $L_0(x)=1$. 
Can someone illustrate how to calculate $L_2$ and $L_3$? So I get the idea? I get some integrals but they seem to lead me not far.
Also, now with $L_0,L_1, L_2, L_3$, how can we compute the least squares polynomial of degree 1, 2, and 3 on the interval $(0,\infty)$ for the weight function $w(x) = e^{-x}$ for $f(x) = e^{-2x}$? 
Thanks.
 A: Just follow the Gram-Schmidt algorithm outlined there, where your inner product is the weighted inner product $$\langle u,v\rangle_w = \int_a^b u(x)v(x)w(x)\,dx.$$ Here, $w(x)$ is called the weight function.
In your context, it sounds like you want to generate the first four Laguerre polynomials, $\{L_0(x),L_1(x),L_2(x),L_3(x)\}$, by applying the Gram-Schmidt algorithm to the standard monomials $\{1,x,x^2,x^3\}$. The resulting Laguerre polynomials will form an orthogonal (or orthonormal if you include the normalization step in the Gram-Schmidt algorithm) family on $0<x<\infty$ with respect to the weight function $w(x)=e^{-x}$.
So, following the algorithm linked above (including the normalization) and using the weighted inner product above, you get (using the notation in the link):
\begin{align}
u_0(x)&=1,\\
u_1(x)&=x-{\langle x,1\rangle_w\over \langle 1,1\rangle_w}\cdot 1=x-{\int_0^\infty x\cdot 1\,e^{-x}\,dx\over \int_0^\infty 1^2\,e^{-x}\,dx}=x-1,\\
u_2(x)&=x^2-{\langle x^2,1\rangle_w\over \langle 1,1\rangle_w}\cdot 1-{\langle x^2,x-1\rangle_w\over \langle x-1,x-1\rangle_w}\cdot (x-1)\\
&=x^2-{\int_0^\infty x^2\cdot 1\,e^{-x}\,dx\over \int_0^\infty 1^2\,e^{-x}\,dx}\cdot 1-{\int_0^\infty x^2\cdot (x-1)\,e^{-x}\,dx\over \int_0^\infty (x-1)^2\,e^{-x}\,dx}\cdot (x-1)\\
&=x^2-4x+2,\\
u_3(x)&=x^3-{\langle x^3,1\rangle_w\over \langle 1,1\rangle_w}\cdot 1-{\langle x^3,x-1\rangle_w\over \langle x-1,x-1\rangle_w}\cdot (x-1)-{\langle x^3,u_2\rangle_w\over \langle u_2,u_2\rangle_w}\cdot (x^2-4x+2)\\
&=x^3-9x^2+18x-6.
\end{align}
To get the $L_k$, you just need to divide each $u_k$ above by its (weighted) norm:
\begin{align}
L_0(x)&={u_0\over \|u_0\|_w}={u_0\over \langle u_0,u_0\rangle_w^{1/2}}=1,\\
L_1(x)&={u_1\over \|u_1\|_w}={u_1\over \langle u_1,u_1\rangle_w^{1/2}}=x-1,\\
L_2(x)&={u_2\over \|u_2\|_w}={u_2\over \langle u_2,u_2\rangle_w^{1/2}}={x^2\over 2}-2x+1,\\
L_3(x)&={u_3\over \|u_3\|_w}={u_3\over \langle u_3,u_3\rangle_w^{1/2}}={x^3\over 6}-{3\over 2}x^2+3x-1.
\end{align}
and you get the first four Laguerre polynomials:
$$
\left\{1,x-1,\frac{x^2}{2}-2 x+1,\frac{x^3}{6}-\frac{3 x^2}{2}+3 x-1\right\}.
$$

Since these form an orthonormal family, you can expand $f(x)=e^{-2x}$ as follows:
$$
f(x)=\sum_{n=0}^k c_n L_n(x), \qquad c_n=\langle f,L_n\rangle_w=\int_0^\infty f(x)L_n(x)w(x)\,dx,
$$
where $k=0,1,2,3$ indicates (as you call it) the "degree" of the approximation, i.e., an expansion in terms of the first $k$ Laguerre polynomials.
For example, 
\begin{align}
c_0&=\langle e^{-2x},1\rangle_w=\int_0^\infty e^{-2x}\cdot 1\cdot e^{-x}\,dx=1/3,\\
c_1&=\langle e^{-2x},x-1\rangle_w=\int_0^\infty e^{-2x}\cdot (x-1)\cdot e^{-x}\,dx=-2/9,\\
c_2&=\langle e^{-2x},\frac{x^2}{2}-2 x+1\rangle_w=\int_0^\infty e^{-2x}\cdot \left(\frac{x^2}{2}-2 x+1\right)\cdot e^{-x}\,dx=4/27,\\
c_3&=\langle e^{-2x},\frac{x^3}{6}-\frac{3 x^2}{2}+3 x-1\rangle_w=\int_0^\infty e^{-2x}\cdot \left(\frac{x^3}{6}-\frac{3 x^2}{2}+3 x-1\right)\cdot e^{-x}\,dx=-8/81.
\end{align}
Here are the $k=0,\dots,3$ approximations of $f(x)=e^{-2x}$:

