Q: Trigonometric series vanishes implies that we can "group" elements. Define
$$
 f_i(x) = A_i\sin(a_i x + \alpha_i) + B_i\cos(a_i x + \beta_i)
$$
 and suppose that
$$
\sum_{i=1}^\infty f_i(x) = \sum_{i=1}^\infty \left[A_i\sin(a_i x + \alpha_i) + B_i\cos(a_i x + \beta_i)\right] = 0
$$
for all $x\in \mathbb{R}$. I am reading a proof in which the author claims that if the above is true, then element $f_i \not\equiv 0$ cancel out in "groups". That is, if $f_i\not\equiv 0$, then there exists a subset $I\subseteq \mathbb{N}$ containing $i$ such that $\lvert a_j\rvert$ is constant over $j\in I$ and
$$
\sum_{j\in I}^\infty f_j(x) = 0 \qquad\forall x\in\mathbb{R}.
$$
In the text, this is simply stated without justification. While the result does make some sense, it is not clear to me why it has to be true. How could I go about proving this? I'm not even sure how to go about a proof if the sum is finite, let alone infinite.

A: First, a simplification: we can get rid of some of the constants, expressing $f_i$ as a single shifted sine wave. Dropping all of the subscripts for convenience,
\begin{align*}f(x) &= A\sin(ax+\alpha)+B\cos(ax+\beta)\\
&= A\sin(\alpha)\cos(ax) + A\cos(\alpha)\sin(ax) + B\cos(\beta)\cos(ax) - B\sin(\beta)\sin(ax)\\
&= (A\cos(\alpha)-B\sin(\beta))\sin(ax) + (A\sin(\alpha)+B\cos(\beta))\cos(ax)\\
&= C\cos(ax+\gamma)\end{align*}
where $C=\sqrt{\left(A\cos(\alpha)-B\sin(\beta)\right)^2+\left(A\sin(\alpha)+B\cos(\beta)\right)^2}=\sqrt{A^2+B^2+2AB\sin(\alpha-\beta)}$ and $\gamma$ is chosen so that $\cos\gamma=\frac{A\sin(\alpha)+B\cos(\beta)}{C}$ and $\sin(\gamma)=\frac{A\cos(\alpha)-B\sin(\beta)}{C}$.
Part 1: Finite sums
Now, a proof for the case of a finite sum. This is a linear independence result; we show that the complex exponential functions $e_j(x)=\exp(i\alpha_j x)$ for distinct real $\alpha_j$ are linearly independent. To do so, we use the Wronskian:
$$W(x) = \begin{vmatrix}\exp(i\alpha_1x)&\exp(i\alpha_2x)&\cdots&\exp(i\alpha_nx)\\ i\alpha_1\exp(i\alpha_1x)&i\alpha_2\exp(i\alpha_nx)&\cdots&i\alpha_n\exp(i\alpha_nx)\\ \vdots&\vdots&\ddots&\vdots\\ (i\alpha_1)^n\exp(i\alpha_1x)&(i\alpha_2)^n\exp(i\alpha_2x)&\vdots&(i\alpha_n)^n\exp(i\alpha_nx)\end{vmatrix}$$
Pull out the exponentials, and what's left is a Vandermonde determinant. We get
$$W(x)=\exp\left(ix\sum_{j=1}^n \alpha_j\right)\cdot\prod_{1\le j< k\le n}(i\alpha_k-i\alpha_j)$$
That is never zero, so the functions $e_j$ that went into it are linearly independent on any interval. In order for a sum of them to be identically zero, each coefficient must be zero.
Going back to the real form of sines and cosines, the pair $\exp(i\alpha x)$ and $\exp(-i\alpha x)$ corresponds to the pair $\sin(\alpha x)$ and $\cos(\alpha x)$. We can decompose all of the terms with the same (up to sign) angular velocity $\alpha$ into complex exponential parts, and the linear independence we just proved tells us that the sum of the coefficients of $\exp(i\alpha x)$ and $\exp(-i\alpha x)$ must each be zero if the overall function is zero.The finite version of the result is true.
Part 2: Infinite sums
If the constants $A_i$ and $B_i$ are restricted enough, we can get uniform convergence. Then, under the inner product $\langle g,h\rangle = \lim_{M\to\infty}\frac1{2M}\int_{-M}^M f(x)g(x)\,dx$, $f_i$ and $f_j$ are orthogonal if they have different angles, and an estimate in the $2$-norm gets us what we want.
But wait - there isn't any such restriction in the problem statement I see. And that allows for some pathological examples, in which we get pointwise convergence by pushing the bad behavior off to $\infty$. I will now construct one such example, proving the claimed result false.
Let $c_k=\frac1{k!}$ - or, really, any sufficiently rapidly decaying sequence. We build our sum in stages, using the sum-to-product identity repeatedly. For the first stage, let
$$g_1(x)=\sin(c_1x)$$
That's $f_1$. For the second stage, let
$$g_2(x) = \sin(c_1x)-\sin([c_1+c_2]x) = -2\sin\left(\frac{c_2}{2}x\right)\cos \left(\left[c_1+\frac{c_2}{2}\right]x\right)$$
That's $f_1+f_2$; $f_2(x)=-\sin([c_1+c_2]x)$. For the third stage, let
\begin{align*}g_3(x) &= -2\sin\left(\frac{c_2}{2}x\right)\cos \left(\left[c_1+\frac{c_2}{2}\right]x\right) + 2\sin\left(\left[\frac{c_2}{2}+\frac{c_3}{2}\right]x\right)\cos \left(\left[c_1+\frac{c_2}{2}\right]x\right)\\
&= 4\sin\left(\frac{c_3}{4}x\right)\cos \left(\left[\frac{c_2}{2}+\frac{c_3}{4}\right]x\right)\cos\left(\left[c_1+\frac{c_2}{2}\right]x\right)\end{align*}
How do we get there from $g_2$? We add two more terms $-\sin\left(\left[c_1-\frac{c_3}{2}\right]x\right)$ and $\sin\left(\left[c_1+c_2+\frac{c_3}{2}\right]x\right)$. The fourth stage is
\begin{align*}g_4(x) &= g_3(x)- 4\sin\left(\left[\frac{c_3}{4}+\frac{c_4}{4}\right]x\right)\cos \left(\left[ \frac{c_2}{2}+\frac{c_3}{4}\right]x\right)\cos\left(\left[c_1+\frac{c_2}{2}\right]x\right)\\
&= -8\sin\left(\frac{c_4}{8}x\right)\cos\left(\left[\frac{c_3}{4}+\frac{c_4}{8}\right]x\right)\cos \left(\left[ \frac{c_2}{2}+\frac{c_3}{4}\right]x\right)\cos\left(\left[c_1+\frac{c_2}{2}\right]x\right)\end{align*}
That's four new terms $-\sin\left(\left[c_1+\frac{c_4}{4}\right]x\right)$, $\sin\left(\left[c_1+c_2-\frac{c_4}{4}\right]x\right)$, $\sin\left(\left[c_1-\frac{c_3}{2}-\frac{c_4}{4}\right]x\right)$, and $-\sin\left(\left[c_1+c_2+\frac{c_3}{2}+\frac{c_4}{4}\right]x\right)$.
We keep going in this vein, for
$$g_k(x)=(-2)^{k-1}\sin\left(\frac{c_k}{2^{k-1}}x\right)\prod_{j=1}^{k-1}\cos \left(\left[\frac{c_j}{2^{j-1}}+\frac{c_{j+1}}{2^j}\right]x\right)$$
From the estimate $|\sin(t)|\le t$ and $|\cos t|\le 1$, we get $|g_k(x)|\le c_kx$ for all $x$. As $k\to\infty$ for any fixed $x$, that goes to zero.
We're not quite done with this; when we unpack $g_{k+1}-g_k$ into $2^{k-1}$ individual sine terms, each of them has amplitude coefficient $1$. If we used those as the $f_i$ directly, the partial sums would change by as much as $1$ for each new term, at points not far from the origin.
To avoid that, we split each of those new sine terms in $g_{k+1}-g_k$ into $N=4^{k-1}$ equal pieces, and group them into blocks that sum to $\frac1{N}(g_{k+1}-g_k)$. By the basic estimate $|\sin t|\le 1$, the sum of part of any such block is at most $2^{k-1}\cdot\frac1{N}=2^{-k+1}$ in absolute value, uniformly. By the stronger (near zero) estimate $|\sin t|\le t$ and $|\cos t|\le 1$,
\begin{align*}|g_{k+1}(x)-g_k(x)| &= \left|-(-2)^{k-1}\sin\left(\left[\frac{c_k}{2^{k-1}}+\frac{c_{k+1}}{2^{k-1}}\right]x\right)\prod_{j=1}^{k-1}\cos \left(\left[\frac{c_j}{2^{j-1}}+\frac{c_{j+1}}{2^j}\right]x\right)\right|\\
&\le (c_k+c_{k+1})x\end{align*}
so the sum of a full block is at most $\frac1N (c_k+c_{k+1})x$ in absolute value. Taking a partial block and any number of full blocks, the difference between $g_k(x)$ and any partial sum of the $f_i$ between $g_k$ and $g_{k+1}$ is at most $2^{-k+1}+(c_k+c_{k+1})x$. This goes to zero as $k\to\infty$ for any fixed $x$.
Combined with the earlier result that $g_k(x)\to 0$ pointwise, we have that $\sum_i f_i(x)$ converges pointwise to zero on the full real line. Also, for any particular $\alpha_i$, only finitely many terms have angular coefficient $\alpha_i$, and they sum to the nonzero function $\sin(\alpha_i x)$. The claimed result fails.
We don't actually need $c_k$ to decay rapidly for the pointwise convergence; it suffices for the $c_k$ to go to zero. Instead, the rapid decay ensures that the various angular velocity coefficients are all different, and we don't get any accidental cancellation.
