u can solve this question by quardadic equation or by using graph
for quardadic
p =cosx+cosy - cos(x+y) = (cosx+cosy) - cos(x+y)
=2cos(x+y/2)cos(x-y/2) - 2cos2(x+y/2)+1
cos(x+y/2) = a
than 2acos(x-y/2)-2a2+1= p
2a2_2acos(x-y/2)+(p-1) = 0
if the root of this equation are real than
D>=0
4cos(x-y/2)2 - 8(p-1)>=0
cos(x-y/2)2 >= 2(p-1)
2(p-1)<=cos(x-y/2)2<= 1
(p-1)<=1/2
p<=3/2