I have a final next week and our instructor gave us some examples with solutions but I could not understand some operations.
Inner product is $$(p,q)=\int_{-1}^{1} p(t)q(t)dt$$
$W = Span\{1,t,t^2\}$ in solution it says extend this span to standard monomial basis $1,t^2,t^3,t^4$. In this basis, the matrix of the inner product is $$ \begin{bmatrix} 2 & 0 & 2\over3 & 0 & 2\over5 \\ 0 & 2\over3 & 0 & 2\over5 & 0 \\ 2\over3 & 0 & 2\over5 & 0 & 2\over7 \\ 0 & 2\over5 & 0 & 2\over7 & 0 \\ 2\over5 & 0 & 2\over7 & 0 & 2\over9 \\ \end{bmatrix} $$
How do I get this?
Thanks for answers.
Edit: Correction.
You say in comments above, you have the second part answered (if so, please add that to the answer above or edit out the second part so the Q&A stands as a self-contained "unit") so I've only answered the first part.
To obtain the matrix elements, use the inner product defined by the integral in the question.
$$ M_{ij} = \int_{-1}^{1}a_i(t) b_j(t)dt. $$
For example, the element in the first row, third column $$ M_{13} = (1,t^2) = \int_{-1}^{1}1 \dot t^2 dt = \left[ \frac{t^3}{3}\right]_{-1}^{1} = \frac{1}{3} - \frac{-1}{3} = \frac{2}{3} $$
The other elements can be obtained similarly, case by case. Generally, however, you can calculate:
$$ M_{nm} = (t^n,t^m) = \int_{-1}{1} t^{n+m} dt = \left[\frac{t^{n+m+1}}{n+m+1}\right]^{1}_{-1} = \frac{1^{n+m+1}}{n+m+1} - \frac{(-1)^{n+m+1}}{n+m+1} \\ = \begin{cases} 0, & \text{if $m+n+1$ is even} \\ 2\over{n+m+1}, & \text{if $n+m+1$ is odd} \end{cases} $$
This gives all the matrix elements (labelled with $m=0,1,2,3,\ldots$ and $n=0,1,2,3,\ldots$) and agrees with the matrix you provide.