# Relation between the plots of the spectrum of real signals X+jY separately and its absolute |X+jY|

I am looking forward to understand FFT more deeply. While testing with code and math I found I am having a problem in understanding two points.

First we can give to the input of FFT only $$x$$ or $$jy$$ or $$x+jy$$. If we applied real signals $$x$$ then the output will always be complex $$X+jY$$. But normally when I learned about the FFT of cosine it is said to be two symmetric deltas in the real domain with +ve sign while the sine signal will give two assymetric deltas in the imaginary domain (1st image).

But instead looking at both the plots of the real and imaginary side of $$X+jY$$ separately for both sine and cosine signals (2nd Image). Nothing shows that sine is in the imaginary domain, instead they have almost similar outputs.

How can I look or interpret the separate plots of the real and imaginary part of X+jY and its relation to what we have in the first image which we always assume to be the absolute of |$$X+jY$$| = |X(f)| (3rd plot) in which the sine is plotted in real domain as we can't draw it in imaginary domain in reality in software.

Second point is that I have a problem with confirming the plotting amplitude with amplitudes I see in math. I did a mathematical and code illustration to explain what I mean.

$$sin(2 \pi f_0 t) = \frac{e^{j \pi f_0 t}- e^{-j \pi f_0 t}}{2j}$$ $$X1(f) = \int_{-\infty}^{\infty} sin(2 \pi f_0 t) e^{-j2 \pi f t} \,dt = \int_{-\infty}^{\infty} \frac{1}{2j} [e^{j 2 \pi f_0 t} - e^{-j 2 \pi f_0 t}] e^{-j 2 \pi f t}\,dt$$

$$= \frac{1}{2j} \int_{-\infty}^{\infty} e^{-j 2 \pi (f-f_0) t} \,dt - \frac{1}{2j} \int_{-\infty}^{\infty} e^{-j 2 \pi (f+f_0) t} \,dt$$

$$=\frac{1}{2j} [(x_1 - j y_1) - (x_2 - j y_2)] = \frac{1}{2} [(y_2 - y_1) + j(x_2 - x_1)]$$

$$|X1(f)| = \frac{1}{2} \sqrt{(y_2-y_1)^2 + (x_2-x_1)^2}$$

while for cosine, $$cos(2 \pi f_0 t) = \frac{e^{j \pi f_0 t} + e^{-j \pi f_0 t}}{2}$$ $$X2(f) = \int_{-\infty}^{\infty} cos(2 \pi f_0 t) \,dt = \frac{1}{2} \int_{-\infty}^{\infty} e^{-j 2 \pi (f-f_0) t} \,dt + \frac{1}{2} \int_{-\infty}^{\infty} e^{-j 2 \pi (f+f_0) t} \,dt$$ $$=\frac{1}{2} [(x_1 - j y_1) + (x_2 - j y_2)] = \frac{1}{2} [(x_1 + x_2) - j(y_1 + y_2)]$$ $$|X2(f)| = \frac{1}{2} \sqrt{(x_1 + x_2)^2 + (y_1 + y_2)^2}$$

From that I would assume that the amplitude of cos plots is greater than the amplitude of the sine plots \begin{align} I\{X1(f)\} < R\{X2(f)\},\: R\{X1(f)\} < I\{X2(f)\}, \: |X1(f)| < |X2(f)| \end{align}

Instead the results was exactly the inverse in the code,

f = 5; fs = 1000;
t = 1 : 1 / fs : 2;
xreal = cos(2*pi*f*t);
xreal2 = sin(2*pi*f*t);

y1 = fft(xreal, 1024);
realT_realF = real(y1);
realT_compF = imag(y1);

y12 = fft(xreal2, 1024);
realT_realF2 = real(y12);
realT_compF2 = imag(y12);

f1 = 1 : 1/1024 : 2;
figure(1);
subplot(221)
plot(f1(1:end-1),realT_realF);
title('cos - Real Frequency');
idx1 = find(realT_realF==max(realT_realF),1)+100;
idx2 = max(realT_realF) - 0.2 * max(realT_realF);
text(f1(idx1),idx2,string(max(realT_realF)))

subplot(223)
plot(f1(1:end-1),realT_compF);
title('cos - Complex Frequency');

subplot(222)
plot(f1(1:end-1),realT_realF2);
title('sin - Real Frequency');

subplot(224)
plot(f1(1:end-1),realT_compF2);
title('sin - Complex Frequency');

figure(2)
subplot(211)
plot(f1(1:end-1),abs(y1));
title('cos - |X(f)|');

subplot(212)
plot(f1(1:end-1),abs(y12));
title('sin - |X(f)|');


$|X(f)|$ for both sine and cosine signals" />

Here is how this looks like with $$f = 100Hz$$, $$f_s = 1024Hz$$ and $$nfft = 1024$$. Note the y-axis scale. The "fuzzy" graphs have a scale $$10^{-12}$$, i.e. it's just numerical noise.