# Range of a sum of sine waves

Suppose I'm given a function

f(x) = sin(Ax + B) + sin(Cx + D)

is there a simple (or, perhaps, not-so-simple) way to compute the range of this function? My goal is ultimately to construct a function g(x, S, T) that maps f to the range [S, T].

My strategy is to first compute the range of f, then scale it to the range [0,1], then scale that to the range [S, T].

Ideally I would like to be able to do this for an arbitrary number of waves, although to keep things simple I'm willing to be satisfied with 2 if it's the easiest route.

Numerical methods welcome, although an explicit solution would be preferable.

-
I know a simple way to do it only if $A = \pm C$. – Michael Hardy Jul 19 '11 at 7:33
Heh, unfortunately I can't make that assumption, as that would just simplify to a single wave with appropriate phase shift. – Zach Jul 19 '11 at 7:36
The question was also asked on /r/math on Reddit. Here's that discussion. – tzs Jul 19 '11 at 11:00

If ${A\over C}\in{\mathbb Q}$ we may assume $A$, $C\in{\mathbb Z}$. In this case $f$ is periodic with period $2\pi$, and the range of $f$ is found by evaluating $f$ at the zeros of $f'$. The latter have to be determined by solving a certain polynomial equation which one obtains by introducing the variable $z:=e^{ix}$.

If ${A\over C}\notin{\mathbb Q}$ then $f$ is almost periodic. In this case the range of $f$ is the open interval $\ ]{-2},2[\$, because one can find a sequence $x_n\to\infty$ such that the $x_n$ are local maxima of $x\mapsto\sin(Ax+B)$ and at the same time "almost" local maxima of $x\mapsto\sin(Cx+D)$.

${\bf Edit}$ concerning the case ${A\over C}\notin{\mathbb Q}$: As noted in yoriki's answer the range might include one of $\pm2$ if $B$ and $D$ are such that "by coincidence" two local maxima or minima of $x\mapsto\sin(Ax+B)$ and $x\mapsto\sin(Cx+D)$ coincide.

-
In a subset of the parameter space of measure $0$, the range can be $(-2,2]$ or $[-2,2)$ if $A$ and $C$ are incommensurate (see my answer). – joriki Jul 19 '11 at 9:27

I'll assume that all variables and parameters range over the reals, with $A,C\neq0$. Let's see how we can get a certain combination of phases $\alpha$, $\gamma$:

$$Ax+B=2\pi m+\alpha\;,$$ $$Cx+D=2\pi n+\gamma\;.$$

Eliminating $x$ yields

$$2\pi(nA-mC)=AB-BC+\alpha C-\gamma A\;.$$

If $A$ and $C$ are incommensurate (i.e. their ratio is irrational), given $\alpha$ we can get arbitrarily close to any value of $\gamma$, so the range in this case is at least $(-2,2)$. If $AB-BC$ happens to be an integer linear combination of $2\pi A$ and $2\pi C$, then we can reach $2$, and the range is $(-2,2]$, whereas if $AB-BC$ happens to be a half-integer linear combination of $2\pi A$ and $2\pi C$ (i.e. and odd-integer linear combination of $\pi A$ and $\pi C$), then we can reach $-2$, and the range is $[-2,2)$. (These cannot both occur if $A$ and $C$ are incommensurate.)

On the other hand, if $A$ and $C$ are commensurate (i.e. their ratio is rational), you can transform $f$ to the form

$$f(u)=\sin mu+ \sin (nu+\phi)$$

by a suitable linear transformation of the variable, so $f$ is periodic. In this case, there are periodically recurring minima and maxima, and in general you'll need to use numerical methods to find them.

-
Hi Joriki, thanks for your useful answer. Let's assume that A and C are always both themselves rational, and so therefore my case always falls into the last case you describe. Is there any reason not to simply use Newton's Method on the derivative of the original f(x)? Why go through the transformation if we're ultimately just going to use Newton's Method anyway? – Zach Jul 19 '11 at 21:23