Let f(x) = sin x for 0 < x < pi . Let a0 + summation from n = 1 to infinity an cosnx be the fourier cosine series which represents f(x) find the value of the coefficient a4.

when i attempted this question when integrating from -pi to pi f(x) cosnx, i treated f(x) to be 0 from x= -pi to 0 since its not defined. however, in the solution, they extended f(x) to be an even function on -pi to pi. why is it that they can do that?