Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Extracting a fourier series of pure tones from a signal

  1. Feb 25, 2014 #1
    I believe this is an error minimization problem so I am trying to solve the following equation

    Min((∑ ( (S(t) - A cos(b t + C)))^2 )

    Where S(t) is the input signal, t is time and I will sum over t, A is the amplitude, b is radians per second (frequency), and C is the phase angle. I need to solve for A and C so I can subtract the pure tone from the signal, and repeat the function for the next higher frequency.

    It is my understanding that to find the minimum I need to find the derivative of (∑((S(t) - A cos(b t + C)))^2 and that presents a problem since the input signal is a set of data and not an actual function so I don't know how to find its derivative. Without the derivative of S(t) I don't believe I can find the derivative of the entire function (∑((S(t) - A cos(b t + C)))^2.

    Is this possible to solve, and if so, how?

    note: After the fact I realized that I could extract phase angle to a certain degree of error by using a partial derivative holding A=1 and performing these calculations for each possible angle. So for +/- ∏/360 radians (+/- 0.5 degrees) I would need to calculate for all angles 0 <= C < 2∏ and take the minimum from that. I can't do the same for the amplitude since it's domain is infinite. If this can be solved for a known phase angle C, that would also be helpful.
    Last edited: Feb 25, 2014
  2. jcsd
  3. Feb 25, 2014 #2


    User Avatar

    Staff: Mentor

    You are not minimizing with respect to t, but with respect to A and C, for which S(t) is constant. Look up non-linear least squares.
  4. Feb 25, 2014 #3
    Thanks. I've never heard of non-linear least squares before but it does look like what I'm looking for. I've been doing image processing and noise reduction and am trying to reduce the artifacts that come into play when eliminating high frequencies from an FFT. I suspect a large part of the artifacts are coming from the complex tones so I want to see if I only reduce or eliminate the pure tones if that will provide better noise reduction with less artifacts. The noise I'm dealing with is very regular so I expect it is made up of pure tones so if I can remove only the noise by finding their pure tones I can clean the image. The FFT itself is expensive processing wise, and I expect this is going to be more expensive, but I'm more interested in capability than performance at this point.
  5. Feb 26, 2014 #4
    What if I divide each point by the selected frequency with the calculated phase angle and take the average? Will that produce the amplitude with the least error? The way I see it that would basically be re-scaling the space by a cosine and the results at each point would then be an amplitude correct?

    Z = A cos(b t + c)
    Z/ cos(b t + c) = A

    If that is the case than I should be able to use the non-linear least square to more accurately determine the phase angle and with that I can determine the amplitude. Either way I think I'm facing another problem, a signal can contain more than one pure tone at the same frequency and a different phase angle so it seems I will need to repeat this process for each frequency until an amplitude is below a certain cutoff.

    Anyhow, I think I see where this is going. If I'm testing 40,000 frequencies and 360 phase angles I end up with 40,000 X 360 items in my Fourier series, or actually 40,000 X 40,000 X 360 considering I'm working in two dimensions. Dropping the high frequencies is trivial since I never need to calculate them in the first place so I should be able to reconstruct the image simply from the pure tones that I'm interested in. This may be worth trying but it isn't computationally sane since a small image could use hundreds of gigabytes simply to store the results.
    Last edited: Feb 26, 2014
  6. Feb 26, 2014 #5


    User Avatar
    Science Advisor
    Homework Helper

    In practice, this is unlikely to work very well. The reason is that if your estimate of the frequency is wrong by a "large" amount, your estimated sine wave will go in an out of phase with the measured data several times along the length of the data sample. If you sketch a graph of what this looks like, it is fairly clear that the least-squares error will be almost constant, independent of the error in the frequency estimate.

    There are better ways. Here are some places to start exploring:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook