http://img232.imageshack.us/img232/9657/22513792.gif

Here's the solution provided:

http://img651.imageshack.us/img651/1880/68859494.gif

I don't understand how they got that answer! This is my own attempt:

Since $\displaystyle f$ is a piece-wise function I divided the interval to two and calculated the inner product like this:

$\displaystyle \left\langle f, sin(x) \right\rangle = \int^{0}_{-\pi} -sin(x)+\int^{\pi}_{0} sin(x)=$$\displaystyle cos(0)-cos(\pi)-(-cos(\pi)-cos(0))=-2$

So, why is my method and my answer wrong? And could anyone please explain the method used in the model answers?