diff(integrate(cos(k*x)*cos(n*x),x));



Here's one way to simplify:

(C1) diff(integrate(cos(k*x)*cos(n*x),x),x);

        COS((n + k) x)   COS((k - n) x)
(D1)    -------------- + --------------
              2                2

(C2) ratsimp(trigexpand(expand(%)));

(D2)           COS(k x) COS(n x)