<s>[INST] Solving $a \sin\theta + b \cos\theta = c$ Could someone help me with the steps for solving the below equation $$a \sin\theta + b \cos\theta = c$$
I know that the solution is $$\theta = \tan^{-1} \frac{c}{^+_-\sqrt{a^2 + b^2 - c^2}} - \tan^{-1} \frac{a}{b} $$
I just can't figure out the right steps to arrive at this solution.
 [/INST] Recall the sum formula for sine
$$A\sin(\theta+\alpha)=A\sin(\theta)\cos(\alpha)+A\cos(\theta)\sin(\alpha)$$
Equating this with the L.H.S gives
$$a\sin(\theta)+b\cos(\theta)=A\cos(\alpha)\sin(\theta)+A\sin(\alpha)\cos(\theta)$$
so we get the system
$$a=A\cos(\alpha)\\b=A\sin(\alpha)$$
and so $A=\sqrt{a^2+b^2}$.
Recall that we're defining some angle $\alpha$ such that both $\cos(\alpha)=\frac{a}{\sqrt{a^2+b^2}}$ and $\sin(\alpha)=\frac{b}{\sqrt{a^2+b^2}}$, so $\alpha$ is unique over one rotation and falls within a quadrant that depends on the signs of $a$ and $b$. You should be able to convince yourself that $\alpha$ takes the value
$$\alpha=\begin{cases}
\arctan(b/a),     &a\gt0\\
\arctan(b/a)+\pi, &a\lt0
\end{cases}$$
So for $a>0$, we get
$$
a\sin(\theta)+b\cos(\theta)=\sqrt{a^2+b^2}\sin(\theta+\arctan(b/a))
$$
and from the identity $\sin(\theta+\pi)=-\sin(\theta)$, then for $a<0$ we get
$$
\sqrt{a^2+b^2}\sin(\theta+\arctan(b/a)+\pi)=-\sqrt{a^2+b^2}\sin(\theta+\arctan(b/a))
$$
so we can conclude that in general
$$
a\sin(\theta)+b\cos(\theta)=\frac{a}{|a|}\sqrt{a^2+b^2}\sin(\theta+\arctan(b/a))\quad (a\neq 0)
$$
For $-\sqrt{a^2+b^2}\leq c\leq\sqrt{a^2+b^2}$, we get
$$
\frac{a}{|a|}\sqrt{a^2+b^2}\sin(\theta+\arctan(b/a))=c\\
\implies\sin(\theta+\arctan(b/a))=\frac{|a|c}{a\sqrt{a^2+b^2}}\\
\implies\theta_1=\arcsin\left(\frac{|a|c}{a\sqrt{a^2+b^2}}\right)-\arctan\left(\frac{b}{a}\right),\\
\theta_2=\pi-\arcsin\left(\frac{|a|c}{a\sqrt{a^2+b^2}}\right)-\arctan\left(\frac{b}
{a}\right)
$$
Use the identity $\arcsin(x)=\arctan\left(\frac{x}{\sqrt{1-x^2}}\right)$ with $x=\frac{|a|c}{a\sqrt{a^2+b^2}}$ to get
$$
\arcsin\left(\frac{|a|c}{a\sqrt{a^2+b^2}}\right)=\arctan\left(\frac{|a|c}{a\sqrt{a^2+b^2}}\cdot\frac{\sqrt{a^2+b^2}}{\sqrt{a^2+b^2-c^2}}\right)\\
=\arctan\left(\frac{|a|c}{a\sqrt{a^2+b^2-c^2}}\right)
$$
and conclude that the general solution becomes
$$
\theta_1=\arctan\left(\frac{|a|c}{a\sqrt{a^2+b^2-c^2}}\right)-\arctan\left(\frac{b}{a}\right)+2\pi k_1\\
\theta_2=-\arctan\left(\frac{|a|c}{a\sqrt{a^2+b^2-c^2}}\right)-\arctan\left(\frac{b}{a}\right)+\pi(2k_2+1)
$$
where $k_1,k_2\in\mathbb{Z}$ and $a\neq 0$.
As desired.
</s>