I wanted to apply the Gram-Schmidt orthogonalization to the following simple example of polynomials $1,x,x^2,x^3$ in $L^2[-1,1]$, is it correct?
$e_1 = 1$
$e'_2 = x - \int_{-1}^{1}xdx = x \implies e_2 = \frac{x}{\|x\|}$
$e'_3 = x^2 - \int_{-1}^{1}x^2dx -\int_{-1}^{1}x^2xdx = x^2 - \frac{1}{2} \implies e_4 = \frac{x^2 - \frac{1}{2}}{\|x^2 - \frac{1}{2}\|}$
$e'_4 = x^3 - \int_{-1}^{1}x^3dx -\int_{-1}^{1}x^3xdx -\int_{-1}^{1}x^3x^2dx = x^3 - \frac{2}{5} \implies e_3 = \frac{x^3 - \frac{2}{5}}{\|x^3 - \frac{2}{5}\|}$
For $e'_3$ the first integral is wrong. $\int_{-1}^1x^2dx=\frac23$. But you forgot to apply the norm at every step. For example $$e'_3=x^2-\frac{\int_{-1}^1x^2\cdot 1dx}{\int_{-1}^11\cdot1dx}-x\frac{\int_{-1}^1x^2\cdot xdx}{\int_{-1}^1x\cdot xdx}=x^2-\frac 13$$ And so on. These are the Legendre polynomials. $$e'_4=x^3-\frac{\int_{-1}^1x^3\cdot 1dx}{\int_{-1}^11\cdot1dx}-x\frac{\int_{-1}^1x^3\cdot xdx}{\int_{-1}^1x\cdot xdx}-x^2\frac{\int_{-1}^1x^3\cdot x^2dx}{\int_{-1}^1x^2\cdot x^2dx}=x^3-\frac {\frac25}{\frac23}x=x^3-\frac35x$$