Trigonometric identities changing sum to product

Given $\sin A + \sin B = a$ and $\cos A + \cos B = b$

where $a$ and $b$ are acute angles

find the value of $\cos(A+B)$

This is my approach

$\sin A + \sin B = 2 \sin \frac{A+B}{2} \cos \frac{A+B}{2}$

$\cos A + \cos B = 2 \cos \frac{A+B}{2} \cos \frac{A+B}{2}$

dividing yield $\tan\frac{A+B}{2}=\frac{a}{b}$

$$\tan(A+B) = \frac {2\frac{a}{b}}{1-\left(\frac{a}{b}\right)^2} = \frac{2ab}{b^2-a^2}$$

and

$$\cos(A+B)=\sqrt{\frac{1}{1+\left(\frac{2ab}{b^2-a^2}\right)^2}} = \frac{b^2-a^2}{b^2+a^2}$$

I wonder if

$$\cos(A+B)= \frac{a^2-b^2}{b^2+a^2}$$

was right, if not, why is it?

-
Note that $$\sin A + \sin B = 2\sin \dfrac{A+B}{2} \cos \dfrac{A-B}{2}$$ and $$\cos A + \cos B = 2\cos \dfrac{A+B}{2} \cos \dfrac{A-B}{2}$$ –  minthao_2011 Oct 4 '12 at 16:30
i don't get it, please elaborate, thanks –  Paul Smith Oct 4 '12 at 17:35
As minthao_2011 has already rectified your $\sin A+\sin B$ and $\cos A+\cos B$ formula, using that we get $\tan \frac{A+B}2=\frac a b$ assuming $\cos \frac{A-B}2\ne 0$
$$\cos(A+B)=\frac{1-\tan^2\frac{A+B}{2}}{1+\tan^2\frac{A+B}{2}}$$
$$=\frac{1-(\frac a b)^2}{1+(\frac a b)^2}=\frac{b^2-a^2}{b^2+a^2}$$
If we go via $\tan 2A$ or $\sin 2A$ formula, ambiguity with sign may crop up.