I am trying to find the projection of a function onto a space spanned by

{1, sinx, cosx} on the interval $\displaystyle [\pi, -\pi] $ This is equal to the first 3 terms of the fourier expansion of f(x)

The function is $\displaystyle f(x) = x^{2} + x $

I found the first term of the fourier expansion to be:

a0 = $\displaystyle \frac{\pi^{2}}{3} $

Im not to sure on calculating the 2nd term...

can i use a1 = $\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}f(x) cosxdx $?

or should i use a1 = $\displaystyle \frac{1}{\pi}\int_{-\pi}^{\pi}f(x) sinxdx $? because sinx is the 2nd term of the span..

Im fine with the integration itself, its just the formula...

sorry if question is badly constructed, am still in early days of using laTex