$\displaystyle \frac{d}{dw}{[a\cos^{2}\pi w +b\sin^{2}\pi w ]}$ (a,b constants)

How do I go about this?

The constant "a" or "b" independent from cos/sin here?..

Is this is correct?

$\displaystyle \frac{d}{dw}{[(a\cos\pi w)^{2} +(b\sin\pi w)^{2} ]}$

OR this one is the correct one?

$\displaystyle \frac{d}{dw}{[a(\cos\pi w)^{2} +b(\sin\pi w)^{2} ]}$