
This function is an even function, so bn = 0. We only need to find a0 and an .

Now for an. We will use Scientific Notebook to perform the integration:

Recall that cos(nπ/2) = 0 for n odd and +1 or -1 for n even. So we expect 0 for every odd term.
However, we cannot have n = 3 in this expression, since the denominator would be 0. In this situation, we need to integrate for n = 3 to see if there is a value. In fact, we will use SNB to find the values up to n = 5, to see what is happening:

So we will start our series by writing out the terms for n = 2 and n = 3, then use summation notation from n = 4:

As usual, we graph the first few terms and see that our series is correct:

The integration for an could have been performed as follows. We re-express the function using a trick based on what we learned in Sum and Difference of Two Angles.

It is then necessary to substitute t = 1/2 and t = -1/2 as usual, then simplify the expression in n.
After integrating, we could have expressed an as follows:

Then we could have substituted this expression into the series. However, we would still need to consider separately the case when n = 3.