# Maintain constant total amplitude of sum of sines

Given a set of N sine waves, each with their own amplitude and frequency, is there a straightforward way to select their phases such that the sum over all sines maintains a constant amplitude, given that the frequencies are spaced equally apart by df?

If all phases are 0, then at t=0 all the sines will constructively interfere to make a huge spike, then they will destructively interfere until they become commensurate again at t~1/df. My goal is to select a set of phases for the different sine waves which will leave the resultant sum with roughly constant peak-to-peak amplitude from t=0 to t=1/df. Picking all random phases does do a pretty good job, but ideally I'd like to find a way to find an optimal set of phases, or at the very least come up with a metric to quantify "how good" a given set of phase is at accomplishing my goal, which I can then optimize on.

edit: To clarify I'm not looking to have the sum of sines equal a constant value, but rather have the resulting periodic function have a roughly constant peak-to-peak amplitude. For instance, for a given set of frequencies all with equal amplitudes, if all phases are set to 0 then the resulting sum will look like:

If the phases are set uniformly randomly in the range [0 2pi] then the result is: .

Clearly, in the random-phase case the peak-to-peak amplitude of the resulting oscillatory function is roughly constant over the given time series, while in the 0 phase case it spikes often at times where commensurate sines add constructively. I'm looking for a way to find an optimal set of phases which keeps the peak-to-peak amplitude roughly constant, without just generating a million different random combinations and picking the best one.

Any help would be greatly appreciated.

• You want the sum of sines to be constant for all $t$, or for a specific interval? – GKH Feb 24 at 20:06
• I don't know if your problem is solvable, but there are some sets of sine waves that add to a constant value over a range: the Fourier series of a square wave. Maybe that approach can get you started in the right direction? – MBaz Feb 24 at 21:54
• Sorry, I was unclear. I am not looking to have all sines sum to a constant value, but rather have the resulting oscillatory function have (roughly) constant peak-to-peak amplitude. Please see the edit for diagrammatic description of what I'm looking for. – KHAAAAAAAAN Feb 24 at 22:32
• There are some special cases listed here: en.wikipedia.org/wiki/…. I doubt the problem has a general solution, though... – MBaz Feb 25 at 3:17

Hopefully this will be some help.

As you have stated it, this is a difficult problem to formulate and thus get an analytical solution. First, are you talking continuous or discrete? Makes a big difference.

Anyway, you want to formulate it as an optimization problem. Something like "minimizing the RMS" can be expressed as an evaluation function. "All the peaks having the same amplitude" means have to measure the value of the function with the condition applied to the derivative (=0). So, your evaluation function (a function of your free variables) could be something like:

$$F(\phi_0,\phi_1,\phi_2,...,\phi_{N-1}) = \sum_{p=1}^{P} \left( f(t_p) - \bar f \right)^2$$

Where $$f(t)$$ is your function, evaluated when $$f'(t)=0$$, and $$\bar f$$ is the average height of all those peaks.

This evaluation function is going to be periodic in all dimensions. There are going to be lots of local minima. Your only recourse (as I can see it) is to do a coarse sweep of your whole domain, then a local optimization search on the best candidates.

• Yeah, I realize it's probably not going to be possible to get an analytical solution, but thought maybe I'd missed something - in any case thanks for the advice, I'll try to implement a slightly smarter optimization algorithm than the current one based on something like this. Out of curiosity, the signal I'm thinking about is discrete, sampled at a constant time interval - does this simplify the result in anyway? – KHAAAAAAAAN Feb 25 at 7:20
• @KHAAAAAAAAN That depends on whether you using the peak sampled value for your criteria or where the peak would be between two samples. Obviously, the latter would be more computationally expensive and each approach would give slightly different results. With the "undulating landscape" you will be on, that might make the difference between one local minima or another being the global minima. – Cedron Dawg Feb 25 at 13:06