Are you evaluating this over an interval or is it an indefinite integral?
The method you use is a bit tricky if it is not over a small interval (i.e., one where cos x is always positive or negative) because:
P.S. Mouse over the math symbols to see the code used to generate them.
You could also do this problem using