we expand first (cos x +cos y)^2+(sin x-sin y)^2:
= cos^2 x + 2 cos x cos y + cos^2 y+ sin ^2 x + sin ^2 y - 2 sin x sin y
= (cos^2 x + sin ^2 x) + (cos^2 y + sin ^2 y) + 2 (cos x cos y - sin x sin y)
then, apply the trigonometric identities of addition and summation of angles
= 1 + 1 + 2 cos (x+y)
we add the following identities above that results to
2 + 2 cos (x+y)