# Summation of Sine waves

Tags:
1. Oct 5, 2014

### Sam Smith

Hi

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. Oct 5, 2014

### 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?

3. Oct 6, 2014

### Khashishi

Do you know the phases between the waves?

4. Oct 6, 2014

### vela

Staff Emeritus
Besides the missing factor of $t$, why did you put those red factors in? They shouldn't be there.

5. Oct 6, 2014

### Sam Smith

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
6. Oct 6, 2014

### zoki85

If I remember correctly, the resultant amplitude by Fourier analysis should be near

7. Oct 6, 2014

### Sam Smith

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?

8. Oct 6, 2014

### f95toli

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.

9. Oct 6, 2014

### Sam Smith

Yes agreed I am now plotting ;

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

10. Oct 6, 2014

### zoki85

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...

11. Oct 6, 2014

### Sam Smith

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

12. Oct 6, 2014

### f95toli

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)

13. Oct 6, 2014

### Sam Smith

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

14. Oct 6, 2014

### Khashishi

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.

15. Oct 6, 2014

### Sam Smith

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?

16. Oct 6, 2014

### Khashishi

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!

17. Oct 6, 2014

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$,
$$X(f_0) = a(f_0) + ib(f_0).$$
You can then get the sinusoidal component for $f_0$ from
$$x_0(t) = A_0 \cos (2\pi f_0 t + \phi_0)$$
where
$$A_0 = |X(f_0)| = |a(f_0) + ib(f_0)|$$
and
$$\phi_0 = \arg X(f_0) = \arctan\dfrac{b(f_0)}{a(f_0)}.$$

And of course, there may be a factor of two involved depending on the nature of the spectrum OP is reading.

18. Oct 6, 2014

### Sam Smith

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

19. Oct 6, 2014

### Sam Smith

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

20. Oct 6, 2014