# Tangent sinusoids: simplification in terms of point of tangency

TLDR: simplify $\phi-2\arctan\left(\frac{s\sin(\phi-\omega)}{q+s\cos(\phi-\omega)}\right)$ as much as possible for the benefit of using $\phi$ as a variable.

I have a sinusoid $f(\theta) = q+s\cos(\theta-\omega)$, and I wish to create a second sinusoid with the same period that is tangent to this and the $\theta$ axis, with the point of tangency to the sinusoid at $(\phi, f(\phi))$. This is to say I am looking for functions $g_\phi(\theta) = k_\phi(1+\cos(\theta-\rho_\phi))$ where $g_\phi(\phi) = f(\phi)$ and $g'_\phi(\phi)=f'(\phi)$.

As you can see by my lovely animation here I've technically already solved it; I can find the appropriate $k_\phi$ and $\rho_\phi$ with relative ease. The problem, though, is tractibility. This is only one step in a larger problem in orbital mechanics, and after finding $k_\phi$ and $\rho_\phi$ I will need to manipulate them further by adding $g_\phi$ to another sinusoid and then perform some calculus in terms of $\phi$. So the nicer I can make it in terms of $\phi$ the better off I am.

$k_\phi$ I've already gotten a decent result for, or as close as I can hope for; it's $$k_\phi = q+\frac{s^2-q^2}{2(q+s\cos(\phi-\omega))}=\frac{q^2+s^2+2qs\cos(\phi-\omega)}{2(q+s\cos(\phi-\omega))}$$

But $\rho_\phi$ is rather meaner:

$$\rho_\phi = \phi-2\arctan\left(\frac{s\sin(\phi-\omega)}{q+s\cos(\phi-\omega)}\right)$$

I've tried simplifying this and I've come to the conclusion that I'm just plain not good enough at trigonometry to do it. I've also asked Sage and Wolfram Alpha for help; Sage doesn't seem to even recognize trigonometric identities, and Wolfram Alpha either does nothing to it or rejects my input as too long.

One path I find interesting is that many parts of my results are similar to results from phasor addition: $q\cos(\theta) + s\cos(\theta + \omega - \phi) = (q^2+s^2+2qs\cos(\phi-\omega))\cos\left(\theta + \arctan\left(\frac{s\sin(\phi-\omega)}{q+s\cos(\phi-\omega)}\right)\right)$

But I haven't been able to get that to help me any yet: the $-2$ doesn't help. It's possible that $g_\phi$ might be better expressed as the sum of several less annoying sinusoids, which would work fine too.

$$z=\frac1{q+s\text{ cis}(\phi-\omega)}.$$
$$k_\phi=\frac1{2\Re(z)},\\ \rho_\phi=\phi+2\angle z.$$