Hard contest type trigonometry proof
Solution 1:
note $$\cos{(x+y)}=\cos{[(x+y+z)-z]}=\cos{(x+y+z)}\cos{z}+\sin{(x+y+z)}\sin{z}$$ and $$\cos{(y+z)}=\cos{(x+y+z)}\cos{x}+\sin{(x+y+z)}\sin{x}$$ $$\cos{(z+x)}=\cos{(x+y+z)}\cos{y}+\sin{(x+y+z)}\sin{y}$$ add this three \begin{align*} &\cos{(x+y)}+\cos{(y+z)}+\cos{(x+z)}\\ &=(\cos{x}+\cos{y}+\cos{z})\cos{(x+y+z)}+(\sin{x}+\sin{y}+\sin{z})\sin{(x+y+z)}\\ &=p\cos^2{(x+y+z)}+p\sin^2{(x+y+z)}\\ &=p \end{align*}
Solution 2:
I prefer @math110's solution, but here's a brute force method using complex exponentials, with $$\cos \theta = \frac{e^{i\theta}+e^{-i\theta}}{2} \qquad \sin\theta = \frac{e^{i\theta}-e^{-i\theta}}{2i}$$ We define $$a := e^{ix} \qquad b := e^{iy} \qquad c := e^{iz}$$ so that $$p = \frac{\cos x + \cos y + \cos z}{\cos(x+y+z)} \implies p(a^2b^2c^2 +1) = abc (a+b+c) + bc + ca + ab \qquad (1)$$ $$p = \frac{\sin x + \sin y + \sin z}{\sin(x+y+z)} \implies p(a^2b^2c^2 - 1 ) = abc (a+b+c) - bc - ca - ab \qquad (2)$$
Thus, from $(1)-(2)$ and $(1)+(2)$, we have $$p = bc + ca + ab \qquad\qquad p = \frac{a+b+c}{abc} = \frac{1}{bc}+\frac{1}{ca}+\frac{1}{ab}$$ whereupon $$2p = bc+\frac{1}{bc}\;+\;ca+\frac{1}{ca}\;+\;ab+\frac{1}{ab} = 2\left( \cos(y+z)+\cos(z+x)+\cos(x+y)\right)$$
Solution 3:
Since \begin{align*} p \cos(x+y+z) &= \cos x + \cos y + \cos z \\ p \sin(x+y+z) &= \sin x + \sin y +\sin z \end{align*} \begin{align*} p e^{i(x+y+z)} & = e^{ix} + e^{iy} + e^{iz} \end{align*} Multiplying throughout by $e^{-i(x+y+z)}$, we get \begin{align*} p = e^{-i(y+z)} + e^{-i(z+x)} + e^{-i(x+y)} \end{align*} Since $p$ is real, equating the real parts, we get $$\cos(y+z) + \cos(z+x) + \cos(x+y) = p $$