You can memorize the pattern
$$f(a)+\varepsilon f(b)=2\delta g\left(\frac{a+b}{2}\right)h\left(\frac{a-b}{2}\right)$$
where $f$, $g$ and $h$ are either $\sin$ or $\cos$, and $\varepsilon$ and $\delta$ are either $1$ or $-1$. Given $f$ and $\varepsilon$, you then need a strategy to find $g$, $h$ and $\delta$.
Step 1: Find $g$ and $h$
Specializing this for $b=a$ we get
$$f(a)+\varepsilon f(a)=2\delta g\left(a\right)h\left(0\right)$$
and for $b=-a$ we get
$$f(a)+\varepsilon f(-a)=2\delta g\left(0\right)h\left(a\right)$$
Note that if the function that is given $0$ as input is $\sin$ then the right-hand side is $0$ for all $a$, while it if is $\cos$, the right-hand side is non-zero for some $a$. Using the (a)symmetry of $f$, we can easily determine if the left-hand side is zero for all $a$, and hence what $g$ and $h$ are:
- If $f(a)+\varepsilon f(a)=0$ for all $a$ then $h=\sin$ and otherwise $h=\cos$;
- If $f(a)+\varepsilon f(-a)=0$ for all $a$ then $g=\sin$ and otherwise $g=\cos$.
Step 2: Find $\delta$
Taking $a=\frac{\pi}{2}$ and $b=0$ yields
$$f\left(\frac{\pi}{2}\right)+\varepsilon f(0)=2\delta g\left(\frac{\pi}{4}\right)h\left(\frac{\pi}{4}\right)$$
Since both $\sin$ and $\cos$ evaluate to $\frac{\sqrt{2}}{2}$ at $\frac{\pi}{4}$, we therefore have
$$f\left(\frac{\pi}{2}\right)+\varepsilon f(0)=\delta $$
which gives us $\delta$.
Plugging other specific values for which both sides are easy to evaluate would also work as long as both $g\left(\frac{a+b}{2}\right)$ and $h\left(\frac{a-b}{2}\right)$ are non-zero (so you do not need to remember to take $a=\frac{\pi}{2}$ and $b=0$).
Example
$$\cos(a)- \cos(b)=2\delta g\left(\frac{a+b}{2}\right)h\left(\frac{a-b}{2}\right)$$
Taking $a=b$ on the left-hand side makes it $0$ so $h=\sin$. Taking $a=-b$ also makes it zero so $g=\sin$:
$$\cos(a)- \cos(b)=2\delta \sin\left(\frac{a+b}{2}\right)\sin\left(\frac{a-b}{2}\right)$$
Specializing to $b=0$ we get
$$\cos(a)-\cos(0)=2\delta \sin\left(\frac{a}{2}\right)\sin\left(\frac{a}{2}\right)$$
so we just need to pick a value of $a$ such that $\sin\left(\frac{a}{2}\right)\not = 0$. Taking $a=\pi$ gives:
$$\cos(\pi)-\cos(0)=2\delta \sin\left(\frac{\pi}{2}\right)\sin\left(\frac{\pi}{2}\right)$$
i.e.
$$-2=2\delta $$
which allows to conclude $\delta=-1$ and hence:
$$\cos(a)- \cos(b)=-2 \sin\left(\frac{a+b}{2}\right)\sin\left(\frac{a-b}{2}\right)$$