First, recall what #cos(x+y)# is:
#cos(x+y)=cosxcosy+sinxsiny#
Note that:
#(sinx+siny)^2=a^2#
#->sin^2x+2sinxsiny+sin^2y=a^2#
And:
#(cosx+cosy)^2=b^2#
#->cos^2x+2cosxcosy+cos^2y=b^2#
Now we have these two equations:
#sin^2x+2sinxsiny+sin^2y=a^2#
#cos^2x+2cosxcosy+cos^2y=b^2#
If we add them together, we have:
#sin^2x+2sinxsiny+sin^2y+cos^2x+2cosxcosy+cos^2y=a^2+b^2#
Don't let the size of this equation throw you off. Look for identities and simplifications:
#(sin^2x+cos^2x)+(2sinxsiny+2cosxcosy)+(cos^2y+sin^2y)=a^2+b^2#
Since #sin^2x+cos^2x=1# (Pythagorean Identity) and #cos^2y+sin^2y=1# (Pythagorean Identity), we can simplify the equation to:
#1+(2sinxsiny+2cosxcosy)+1=a^2+b^2#
#->(2sinxsiny+2cosxcosy)+2=a^2+b^2#
We can factor out a #2# twice:
#2(sinxsiny+cosxcosy)+2=a^2+b^2#
#->2((sinxsiny+cosxcosy)+1)=a^2+b^2#
And divide:
#(sinxsiny+cosxcosy)+1=(a^2+b^2)/2#
And subtract:
#sinxsiny+cosxcosy=(a^2+b^2)/2-1#
Finally, since #cos(x+y)=cosxcosy+sinxsiny#, we have:
#cos(x+y)=(a^2+b^2)/2-1#