# FFTs of a complex signal - separating the real and imaginary parts

I have a complex time varying signal at a single frequency x = a + jb where a represents the contribution from the cosine basis function and b represents the contribution from the sinusoid basis function.

I am trying to understand how the output differs if I was to take a complex FFT of x and inspect the real and imaginary components compared to taking two FFTs of the real and imaginary parts separately. I naively expected these to be equal when a=b. What am I missing?

% signal parameters
fs    = 1e3;
f0    = 50;
t     = (0:999)/fs;
wt    = 0.5; %weighting between cosine and sin basis functions
NFFT  = 1024;
freq  = linspace(-fs/2,fs/2, NFFT);
freq2 = linspace(0,fs/2, NFFT/2);
wnd   = hanning(length(t)).';

% Complex signal
x = wt*cos(2*pi*f0.*t) + (1-wt)*1j*sin(2*pi*f0.*t);

% 1 - Take FFT of complex signal and split into re/im components
X   = fft(x.*wnd, NFFT);
Xre = abs(X(1:NFFT/2));
Xim = abs(fliplr(X(NFFT/2+1:end)));

% 2 - Split the signal into Re/Im and compute FFTs
Yre = abs(fft(real(x).*wnd, NFFT));
Yim = abs(fft(imag(x).*wnd, NFFT));

close all;
figure;
ax(1)=subplot(221);
plot(freq2, Xre, 'b');
legend('Cmplx Re');
ax(2)=subplot(222);
plot(freq2, Yre(1:NFFT/2), 'r');
legend('Split Re');
ax(3)=subplot(223);
plot(freq2, Xim, 'b');
legend('Cmplx Im');
ax(4)=subplot(224);
plot(freq2, Yim(1:NFFT/2), 'r');
legend('Split Im');

figure;
plot(freq, fftshift(abs(X)));


Below is a chart I had of "Universal Fourier Transform Properties", that apply in either direction (going from time to frequency or going from frequency to time). For example, a signal that is periodic in one domain, will be discrete in the other: a digitized time domain signal becomes periodic in frequency (such that we can concern ourselves with the spectrum from $-F_s/2$ to $+F_s/2$ only. Similarly a signal that is periodic in time will only have discrete frequencies (at the fundamental repetition rate and its harmonics in frequency).

Specific to your case I draw attention to the properties when a signal is only real, and when a signal in only imaginary:

This may help you to see what is going on, specifically the FT of a signal that is only real in the time domain, and the FT of a signal that is only imaginary in the time domain. A signal that is only real will have a spectrum that is conjugate symmetric: the positive half of the spectrum is equal in magnitude to the negative half but opposite in phase (Meaning the real portion of the FFT is "even" and the imaginary portion of the FFT is "odd", in the same fashion that a cosine in time is an even function and a sine in time is an odd function. Similarly a signal that is only imaginary will be have the FFT real components to be odd and the FFT odd components to be even.

So hopefully you see the difference between taking the fft of b, and taking the fft of jb, where to be clear b is real, so jb is imaginary (we could complicate this by allowing a and b to be complex numbers but my guess in your case they are indeed real).

This is also interesting in showing how causal time domain signals MUST be complex in frequency, and the imaginary and real components are related by the Hilbert transform: if you consider the real and imaginary components of the spectrum seperately, we see via the odd/even relationship that everything for t<0 cancels while everything for t>0 adds.

This last point is further elaborated by Sir Robert Bristow-Johnson in this post: What is the easiest, most straight-forward way to prove this about minimum-phase filters? The Fourier transform is linear, so you have that $$\mathcal{F}[a+jb]=\mathcal{F}[a]+j\mathcal{F}[b].$$ Now, $\mathcal{F}[a]$ and $\mathcal{F}[b]$ are complex, so you have that \begin{align} \text{Real}\lbrace\mathcal{F}[a+jb]\rbrace &= \text{Real}\lbrace \mathcal{F}[a]+j\mathcal{F}[b] \rbrace \\ &= \text{Real}\lbrace\mathcal{F}[a]\rbrace-\text{Imag}\lbrace \mathcal{F}[b] \rbrace. \end{align}

There's a similar relationship for $\text{Imag}\lbrace\mathcal{F}[a+jb]\rbrace$.