1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Summation of Sine waves

  1. Oct 5, 2014 #1

    I just wanted to check my approach. I have spectrum I have peak at 10Hz another at 20Hz and a third at 30Hz. The amplitudes are 1000, 500, 250. I want to recreate the signal by summing sine waves.

    I assume that I will therefore take
    A1 = 1;
    A2 = 0.5;
    A3 = 0.25;

    I will then let y = A1*Sin(2*pi*1000*t)+A2*Sin(2*pi*2*500)+A3*Sin(2*pi*3*250);

    Is this correct because when I look at my end result it is not as I wish it to be.

    Sorry for mistake in post due to my english
  2. jcsd
  3. Oct 5, 2014 #2


    Staff: Mentor

    I think you forgot the t variable in the second and third terms, right?

    And shouldn't the A1, A2, A3 be 1000, 500, 250 instead of what you wrote?

    And lastly, the arguments for the sin terms should be of the form \omega * t and should somehow reflect the 10, 20, 30 hertz values not the amplitudes, right?
  4. Oct 6, 2014 #3


    User Avatar
    Science Advisor

    Do you know the phases between the waves?
  5. Oct 6, 2014 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    Besides the missing factor of ##t##, why did you put those red factors in? They shouldn't be there.
  6. Oct 6, 2014 #5
    Hey yea sorry I did include errors in my original post so what I actuallly have is

    y = A1*Sin(2*pi*10*t)+A2*Sin(2*pi*20t)+A3*Sin(2*pi*30t);

    the 2 and 3 reflect that they are second and thrid harmonic?

    Also have I determined my amplitudes correctly?
    Last edited: Oct 6, 2014
  7. Oct 6, 2014 #6
    If I remember correctly, the resultant amplitude by Fourier analysis should be near gif.gif
  8. Oct 6, 2014 #7
    Sorry for the error above. I have corrected it now. I should not include the 2 and 3 if I also use the new frequencies. If I stay with f1 then I can use 2 and 3. Sorry I know this but I made mistake when typing up my question. So basically I have made my time series by using the above equation. I have done it in two axes however, when I plot them against eachother I do not get shape I was expecting and so this make me think I have not done synthesis correctly?
  9. Oct 6, 2014 #8


    User Avatar
    Science Advisor
    Gold Member

    The 2 and 3 should not be there, the fact that they are harmonics in this particular case does not affect the way you sum the components of the signal.
  10. Oct 6, 2014 #9
    Yes agreed I am now plotting ;

    y(t) = A1*Sin(2*pi*10*t)+A2*Sin(2*pi*20t)+A3*Sin(2*pi*30t);
  11. Oct 6, 2014 #10
    And why should you? You don't have enough data to recreate signal waveform ( not even aproximately) .
    Zillions of combinations are possible to produce peaks you're referring to...
  12. Oct 6, 2014 #11
    Yes I know. I have been asked ot do it as a rough guide and I am really struggling. Of course I realise that I can also have bcos(wt) in my equations. It is very tricky problem but I real appreciate you to help me! Thank you
  13. Oct 6, 2014 #12


    User Avatar
    Science Advisor
    Gold Member

    You can always reproduce the time domain signal from the spectra assuming you've captured data with enough bandwidth; what you lose with an ordinary spectra (i.e. something measured with an ordinary fft analyzer) is the relative phase of the components of the signal.
    After all, if you have the spectra a simple inverse transform (ifft) will give you the time domain data.

    However, coming back to the question: are you sure the spectra shows the correct amplitude of the components? Most (albeit not all) spectra actually shows the power in each peak, usually as power spectral density. You also need to be careful about the number of points in the spectra; if the measurement is fft based (which most are) you will run into trouble with the amplitudes being wrong if not enough points were used. This is a well-known artifact of the fft algorithm (which can be solved using e.g. zero-padding)
  14. Oct 6, 2014 #13
    Hi, Well I have quite a bit of data and I am using FFT which I believ gives (absolute magnitude or amplitude) This is correct? I have not use Spectrograph or power spectra? I also realise I should use cosine really to deal with phase but I am not sure how to determine corret combination
  15. Oct 6, 2014 #14


    User Avatar
    Science Advisor

    The FFT is in general a complex function. You know what a complex number is, right? The real part of the peak value tells you about the cosine component and the imaginary part tells you about the sine component.

    The sample rate needs to be higher than twice the bandwidth of the signal for you to reconstruct the signal from the FFT. But if you are simply trying to reconstruct the sample points, that won't be an issue.
  16. Oct 6, 2014 #15
    Ahh Ok that is very helpful and so if I look at these values and say the values at 20Hz is some 0.52 + 0.99i (made up) I then use 0.52 as my a coefficient for the cosine part and 0.99 for the sine part?
  17. Oct 6, 2014 #16


    User Avatar
    Science Advisor

    Not quite. In general, you have to look at both positive and negative frequency components of the FFT. If you know that the original signal is real, then you can ignore the negative frequency components (which will just be equal to the complex conjugate of the positive frequency component. For your example, at -20Hz, you should have 0.52 - 0.99i.)
    You need to multiply the number at +20Hz by 2 since you are throwing away the -20Hz value.
    So 0.52*2 for the coefficient for the cosine, and 0.99*2 for the sine.

    Also, depending on how the FFT routine is normalized, you might need to also multiply by another number. FFT routines are all different in how they normalize the output!
  18. Oct 6, 2014 #17


    User Avatar
    Science Advisor
    Gold Member

    Of course, this depends on how the spectrum was reported. The OP may be looking at either a one- or two-sided spectrum, so whether there is a factor of two depends on that.

    Also, in my experience, working with both sines and cosines in this sort of thing can be obnoxious. It may simply be easier to assign the complex magnitude of the FFT at a particular frequency to the amplitude of the cosine term and then take the argument of the FFT at that point and incorporate it as a phase shift.

    For example, if you are trying to reconstruct ##x(t)## from its Fourier components ##X(f)##, then ##X## is complex and at a given frequency ##f_0##,
    [tex]X(f_0) = a(f_0) + ib(f_0).[/tex]
    You can then get the sinusoidal component for ##f_0## from
    [tex]x_0(t) = A_0 \cos (2\pi f_0 t + \phi_0)[/tex]
    [tex]A_0 = |X(f_0)| = |a(f_0) + ib(f_0)|[/tex]
    [tex]\phi_0 = \arg X(f_0) = \arctan\dfrac{b(f_0)}{a(f_0)}.[/tex]

    And of course, there may be a factor of two involved depending on the nature of the spectrum OP is reading.
  19. Oct 6, 2014 #18
    Thank you for the help I am trying to get the complex values at present out of the spectra that I have been given. The amplitudes are just real numbers however it seems that it fft has been used and then (abs(fft)) is plotted to give the spectra
  20. Oct 6, 2014 #19
    Thank you so much, I have just a single sided spectra. The amplitudes have been given to me in real numbers (I dont see a complex part) and I have values up to 100Hz but the sample rate was 200Hz
  21. Oct 6, 2014 #20


    User Avatar
    Science Advisor
    Gold Member

    Ask whoever gave you the spectrum if he/she can provide the complex values for you. You'll need that for phase information.
  22. Oct 6, 2014 #21
    AH Ok they have provided me with the original code. And their spectra is based on the abs of the FFT. so I am guessing if I exclude that abs I should have the complex numbers?
  23. Oct 14, 2014 #22
    Hi everyone after researching this proble more thoroughly I have decided to use the complex amplitudes to give me the amplitudes for cos and sin however I was wondering if you guys could tell me if my approach is correct. I take the fft data (I have removed abs so that I get complex data) I then get values such as this -3.25e+002 + 4.56e+002i;

    I then recreate using the formula

    y(t) = -3.25e+002*cos(2*pi*f1*t)+4.56e+002*sin(2*pi*f1*t) ;

    This is just an example, usually I have a fundamental frequency and lots of harmonics present. However this approach si not quite recreating the shapes that I would expect. Am I doing somethign wrong in my approach?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook