To begin, we need a set of vectors (polynomials) on the set and we can take the standard basis
\(\{1,x,x^2,x^3\}\text{.}\) Call these
\(p_0,p_1,p_2,p_3\) and weβll use Gram-Schmidt to find a set
\(\{q_0,q_1,q_2,q_3\}\) that is orthogonal.
It is very helpful to recall that \(x^n\) is an odd function if \(n\) is odd. Also \(\int_{-1}^1
x^n \,dx =0\) if \(n\) is odd.
\begin{align*}
q_0 \amp= p_0 = 1, \\
q_1 \amp= p_1 - \frac{\langle p_1,q_0 \rangle}{\langle q_0,q_0 \rangle } q_0 \\
\amp = x - \frac{\int_{-1}^1 x \cdot 1 \, dx} {\int_{-1}^1 1 \cdot 1 \, dx} 1
\end{align*}
and since
\(x\cdot 1= x\) is odd, the integral in the numerator is 0, so
\(q_1=x\) and
\begin{align*}
q_2 \amp = p_2 - \frac{\langle p_2,q_1 \rangle}{\langle q_1,q_1 \rangle } q_1 -
\frac{\langle p_2,q_0 \rangle}{\langle q_0,q_0 \rangle } q_0 \\
\amp = x^2 - \frac{\int_{-1}^1 x^2 \cdot x \, dx}{ \int_{-1}^1 x \cdot x \, dx} -
\frac{\int_{-1}^1 x^2 \cdot 1 \, dx}{\int_{-1}^1 1 \cdot 1 \, dx} 1
\end{align*}
and
\(x^2\cdot x=x^3\) is odd, so the first integral is 0 and also
\(\int_{-1}^1 1
\,dx = 2\text{,}\)
\begin{align*}
\amp = x^2 - \frac{x^3/3 \bigl\vert_{-1}^1}{2} 1 = x^2-\frac{1}{3} \\
q_3 \amp = q_3 - \frac{\langle p_3,q_2 \rangle}{\langle q_2,q_2 \rangle } q_2 -
\frac{\langle p_3,q_1 \rangle}{\langle q_1,q_1 \rangle } q_1 - \frac{\langle p_3,q_0
\rangle}{\langle q_0,q_0 \rangle } q_0 \\
\amp = x^3 - \frac{\int_{-1}^1 x^3 (x^2-1/3) \,dx}{\int_{-1}^1 (x^2-1/3)^2 \, dx }
\bigl(x^2-\frac{1}{3} \bigr) - \frac{\int_{-1}^1 x^3 \cdot x \, dx}{\int_{-1}^1 x
\cdot x
\, dx}
x - \frac{\int_{-1}^1 x^3 \cdot 1 \,dx }{\int_{-1}^1 1 \cdot 1 \, dx}
\end{align*}
and the integrals in the numerators of the 2nd and 4th terms are 0 due to the functions being odd, so
\begin{align*}
\amp = x^3 - \frac{ x^5/5 \bigr\vert_{-1}^1}{x^3/3 \bigr\vert_{-1}^1} x \\
\amp = x^3 - \frac{3}{5} x
\end{align*}
There an orthogonal set of cubic polynomials that span
\(\mathcal{P}_3[-1,1]\) is
\begin{equation*}
\{1,x,x^2-\frac{1}{3},x^3-\frac{3}{5}x \}
\end{equation*}
and these are the first four Legendre Polynomials. Also, they are a basis of
\(\mathcal{P}_3[-1,1]\text{.}\)