Find an alternative expression for $y :=cos(x+\delta)-cos(x)$ 

Explain the difficulty of computing $y :=cos(x+\delta)-cos(x)$ for small values of $\delta$. Find an alternative expression of $y$ that does not exhibit these difficulties.


So far I have figured out, as Delta is very small we get $cos(x+\delta)\approx cos(x)$ Thus we experience critical rounding errors (they would cancel each other out). I can't seem to find however a good alternative form that could get rid of this problem. 
I hope someone can help me find one and maybe give me some explanation why this is a good alternative form.
 A: The issues with computing $\cos (x+ \delta) - \cos x$ directly are the same as
computing $(1+\delta) -1$. The computation of $\cos$ just adds a little more noise.
$\cos (x+ \delta) - \cos x = -2 \sin (x+ {\delta \over 2}) \sin {\delta \over 2}$.
This is exact in $\mathbb{R}$ arithmetic and there is no dogastrophic cancellation.
One way to think about it is to look at the relative error for small non zero $\delta$, with ideal computations but allowing for the fact that we have finite precision.
In particular, note that for small $\delta,\epsilon$ we have ${\cos (x+\delta+\epsilon)-\cos(x) \over \cos (x+\delta)-\cos(x) } -1 \approx {- (\sin x)  (\delta+\epsilon) \over -(\sin x) (\delta)} -1 = {\epsilon \over \delta}$.
If $\epsilon$ and $\delta$ are of the same size, then we have a very large relative error.
A: From:
$$\lim_{\delta \to 0} \frac{\cos(x+\delta)-\cos(x)}{\delta}=-\sin(x)$$
So:
$$\frac{\cos(x+\delta)-\cos(x)}{\delta}\approx-\sin(x)$$
$$\cos(x+\delta)-\cos(x)\approx-\delta\sin(x)$$
A: Apply the difference-product relation for cosines:
$\cos u - \cos v = -2\sin (\frac{u+v}{2})\sin (\frac{u-v}{2})$
$\cos (x+\delta) - \cos x = -2\sin (\frac{2x+\delta}{2})\sin (\frac{\delta}{2})$
