This was asked but never answered at MSE.

Let $f(x) = \sin(a_1x) + \sin(a_2x) + \cdots + \sin(a_nx)$, where the $a_i$'s represent distinct positive integers. Suppose also that $f(x)$ satisfies the inequality $f(x) \geq 0$ on the open interval $0 < x < \pi.$

In the case n=1 of a single summand it is obvious that only $f(x) = \sin x$ satisfies the condition. For two summands, a short argument shows that only $f(x) = \sin x + \sin(3x)$ works. Following up on this, we define $g_n(x) = \sin x + \sin(3x) + \sin(5x) + \cdots + \sin((2n-1)x)$. Computing the sum explicitly yields $g_n(x) = \frac{\sin^2(nx)}{\sin x}$ which makes it clear that $g_n(x)$ is nonnegative on $(0,\pi).$

Questions: (1) Are there any other examples of $f(x)$ as above besides $g_n(x)$? If so, can one classify them all?

(2) The special case $f(x) = g_1(x) = \sin x$ satisfies the stronger condition of being strictly positive over $0 < x < \pi$. Is $\sin x$ the unique such instance of $f(x) > 0$ on $(0,\pi)$?

Thanks