Let $$M=\frac{a\sin\left(\frac{f\left(x\right)-g\left(x\right)}{2}\right)+b\cos\left(\frac{f\left(x\right)-g\left(x\right)}{2}\right)}{a\cos\left(\frac{f\left(x\right)-g\left(x\right)}{2}\right)+b\sin\left(\frac{f\left(x\right)-g\left(x\right)}{2}\right)}$$
Suppose that either it is the case that $a$ and $b$ are a pair of single-variable functions of $x$ or it is the case that $a$ and $b$ are a pair of constants.
The question is:
On what union of intervals $I$ is it true that $$a\sin(f(x))+b\cos(g(x))$$ $$=$$ $$\sqrt{a^2+b^2+2ab\sin(f(x)-g(x))}\sin(\frac{f(x)+g(x)}{2}+\arctan{M})?$$
What is known - I claim - is that for all $x$ $\in$ $ℝ\setminus{I}$ we have:
$$a\sin(f(x))+b\cos(g(x))$$ $$=$$ $$-\sqrt{a^2+b^2+2ab\sin(f(x)-g(x))}\sin(\frac{f(x)+g(x)}{2}+\arctan{M})$$
I'm interested in defining the union of intervals $I$ in terms of $a,b,f$ and $g$
In the case of $a$ and $b$ being functions of $x$, it's worth pointing out that the process of condensing a sum of two terms like $a(x)\sin(f(x))$ and $b(x)\cos(g(x))$ into one term can be iterated in order to consolidate an expression with arbitrarily many sine and cosine terms into one term, by taking two at a time until you end up with only one. The potential to consolidate large expressions of that form in this way provides me the motivation for wanting to know how it works when we have only two terms.
An immediate observation that can be made is that trying a calculus-based approach will inevitably result in very large and messy expressions. Here you can see how long and messy of an expression the derivative is.
Here (1) in desmos I've set up a way to easily see that on some intervals it would be appropriate to use the positive square root (on these intervals the graphs overlap perfectly) and on every other interval it would instead be appropriate to use the negative square root (on these intervals the graphs do not overlap)
Here (2) in desmos I've set up the same thing but with $a$ and $b$ as functions instead of constants
Here is the derivation: $$a\sin\left[f\left(x\right)\right]+b\cos\left[g\left(x\right)\right]=a\sin\left(\frac{f\left(x\right)+g\left(x\right)}{2}+\frac{f\left(x\right)-g\left(x\right)}{2}\right)+b\cos\left(\frac{f\left(x\right)+g\left(x\right)}{2}-\frac{f\left(x\right)-g\left(x\right)}{2}\right)$$
- Let $$u=\frac{f\left(x\right)+g\left(x\right)}{2}$$ $$v=\frac{f\left(x\right)-g\left(x\right)}{2}$$
With that substitution we then have $$a\sin\left(u+v\right)+b\cos\left(u-v\right)=\left[a\cos\left(v\right)+b\sin\left(v\right)\right]\sin\left(u\right)+\left[a\sin\left(v\right)+b\cos\left(v\right)\right]\cos\left(u\right)$$
Now suppose this can be expressed as $A(x)\sin\left(u+\phi\right)$. Then we have
$$A(x)\sin\left(u+\phi\right)=A(x)\sin\left(u\right)\cos\left(\phi\right)+A(x)\cos\left(u\right)\sin\left(\phi\right)$$ Combining this with the above we have $$A(x)\cos\phi=a\cos (v)+b\sin (v)$$ and $$A(x)\sin\phi=a\sin (v)+b\cos (v)$$
This implies that $$[A(x)]^{2}=a^{2}+b^{2}+4ab\cdot\sin\left(v\right)\cos\left(v\right)=a^{2}+b^{2}+2ab\cdot\sin\left(2v\right)$$
and $$\tan\phi=\frac{a\sin (v)+b\cos (v)}{a\cos (v)+b\sin (v)}$$
Here's a bit of progress I made.
Case 1
This is a special case of case 3
Suppose $a$ and $b$ are constant coefficients and $f(x)=g(x)$. By testing out all possible combinations of $a,b$ (-,-), (-,+), (+,-), (+,+), you can deduce the following:
If a is nonnegative, then $$a\sin(f(x))+b\cos(f(x))=\sqrt{a^2+b^2}\sin(f(x)+\arctan{(\frac{b}{a}}))$$
If a is negative, then $$a\sin(f(x))+b\cos(f(x))=-\sqrt{a^2+b^2}\sin(f(x)+\arctan{(\frac{b}{a}}))$$
Here (3) in desmos I've set up a way to verify that these hold by adjusting the values for $a$ and $b$ and modifying $f(x)$ to be any function of your choosing
Case 2
Suppose that $a(x)$ and $b(x)$ are $x^\alpha$ and $x^\beta$ respectively and $f(x)=g(x)$
- For all $x$ $\in$ $[0,∞)$ we have $$a(x)\sin(f(x))+b(x)\cos(f(x))=\sqrt{(a(x))^2+(b(x))^2}\sin(f(x)+\arctan{(x^{\beta-\alpha}})).$$
Here (4) in desmos I've set up a way to verify that this indeed holds regardless of what values you choose for $\alpha$ and $\beta$ and regardless of what function you choose $f$ to be.
More does need to be said about this case but for now this is all I've worked out for case 2.
Case 3
Suppose that $a$ and $b$ are constant coefficients
Let $$u=\frac{f(x)+g(x)}{2}$$
Let $$v=\frac{f(x)-g(x)}{2}$$
Let $$\tan\psi=\frac{a\sin(v)+b\cos(v)}{a\cos(v)+b\sin(v)}$$
Then
$$\cos^{2}\left(ψ\right)=\frac{a^{2}\cos^{2}\left(v\right)+ab\cdot\sin\left(2v\right)+b^{2}\sin^{2}\left(v\right)}{a^{2}+b^{2}+2ab\cdot\sin\left(2v\right)}$$
and
$$\sin^{2}\left(ψ\right)=\frac{a^{2}\sin^{2}\left(v\right)+ab\cdot\sin\left(2v\right)+b^{2}\cos^{2}\left(v\right)}{a^{2}+b^{2}+2ab\cdot\sin\left(2v\right)}$$
- We want to express $a\sin\left[f\left(x\right)\right]+b\cos\left[g\left(x\right)\right]$ in the form $A(x)\sin(u+\psi)$
- We can see that $A(x)\sin(u+\psi)=A(x)\cos(\psi)\sin(u)+A(x)\sin(\psi)\cos(u)$
- Thus, we can observe that we have to carefully choose the appropriate square root of $\cos^{2}\left(ψ\right)$ as well as carefully choose the appropriate square root of $\sin^{2}\left(ψ\right)$
We can rewrite $a\sin\left[f\left(x\right)\right]+b\cos\left[g\left(x\right)\right]$ as $a\sin(u+v)+b\cos(u-v))$ which then becomes $(a\cos(v)+b\sin(v))\sin(u)+(a\sin(v)+b\cos(v))\cos(u)$
- Thus, we have $(a\cos(v)+b\sin(v))\sin(u)+(a\sin(v)+b\cos(v))\cos(u)=A(x)\cos(\psi)\sin(u)+A(x)\sin(\psi)\cos(u)$
This gives us the following two facts:
- $a\cos(v)+b\sin(v)=A(x)\cos(\psi)$
- $a\sin(v)+b\cos(v)=A(x)\sin(\psi)$
If $b$ is nonnegative then $a\cos(v)+b\sin(v)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
If $b$ is negative then $a\cos(v)+b\sin(v)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
Here (5) in desmos you can verify this for yourself by adjusting the sliders for $a$ and $b$
If $a$ is nonnegative then $a\sin(v)+b\cos(v)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$
If $a$ is negative then $a\sin(v)+b\cos(v)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$
Here (6) in desmos you can verify this for yourself by adjusting the sliders for $a$ and $b$
Thus, we have:
- If $b$ is nonnegative then $A(x)\cos(\psi)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
- If $b$ is negative then $A(x)\cos(\psi)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
- If $a$ is nonnegative then $A(x)\sin(\psi)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$
- If $a$ is negative then $A(x)\sin(\psi)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$
We effectively demonstrated earlier that $$\cos\left(ψ\right)=\frac{±(a\cos\left(v\right)+b\sin\left(v\right))}{\sqrt{a^{2}+b^{2}+2ab\cdot\sin\left(2v\right)}}$$
and $$\sin\left(ψ\right)=\frac{±(a\sin\left(v\right)+b\cos\left(v\right))}{\sqrt{a^{2}+b^{2}+2ab\cdot\sin\left(2v\right)}}$$
And we also know that $$A(x)=±\sqrt{a^{2}+b^{2}+2ab\cdot\sin\left(2v\right)}$$
Subcase A
Suppose both $a$ and $b$ are nonnegative constant coefficients
Then:
- $A(x)\cos(\psi)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
- $A(x)\sin(\psi)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$
Subcase B
Suppose $a$ is a nonnegative constant coefficient and $b$ is a negative constant coefficient
Then:
- $A(x)\cos(\psi)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
- $A(x)\sin(\psi)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$
Subcase C
Suppose $a$ is a negative constant coefficient and $b$ is a nonnegative constant coefficient
Then:
- $A(x)\cos(\psi)=\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
- $A(x)\sin(\psi)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$
Subcase D
Suppose both $a$ and $b$ are negative constant coefficients
Then:
- $A(x)\cos(\psi)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{a}{b})})$
- $A(x)\sin(\psi)=-\sqrt{a^2+b^2}\sin(v+\arctan{(\frac{b}{a})})$