# Visualizing the “frequency shift” theorem in FFT

I was trying to visualize the frequency shift theorem in MATLAB, which states that if the Fourier transform G(f) is shifted by a constant $$f_o$$, its inverse transform g(t) is multiplied by $$e^{j2\pi tf_o}$$.

Say one makes two symmetric real valued Gaussians (G(f)) in the frequency domain as shown in the code below as a function of bin numbers. The peaks are symmetrically displaced from the center bin by a constant. When the inverse FFT is applied G(f), the output g(t) looks look the attached photo. A displaced Gaussian in the frequency domain should produce a Gaussian multiplied by cosine waves. Intuitively, it does appear like an exponential decay times a cosine wave.

a) The FFT of a Gaussian is a Gaussian, but g(t) looks like exponential decay times a cosine. b) Another point is why do we see a two-sided symmetric output in the time domain? Shouldn't we see only one sided result in the time domain?

What is the discrepancy here in the time domain?

Thanks.

Frequency Shift Theorem

W=[1:1:9001]'; % bin numbers

n=1; % Gaussian shape, n=1 Gaussian

H=10; % Height of Gaussian

s=25; % standard deviation in frequency domain

w_left=1400; % Position of Gaussian as bin numbers

w_right=length(W)-w_left; % Position of Gaussian as bin numbers

G_left=H*exp(-((W-w_left).^2/(2*s^2)).^n);

G_right=H*exp(-((W-w_right).^2/(2*s^2)).^n);

GShifted=G_left+G_right;

Inverse_GShifted=real(ifft(GShifted));

figure (1)

subplot (1,2,1)
plot (W, GShifted,'r', 'LineWidth', 1.5);
title ('Shifted Gaussian in Frequency Domain')
xlabel('Bin Numbers (Frequency)')
ylabel('Real')
xlim([1 9001])

subplot (1,2,2)
plot (W, Inverse_GShifted,'b', 'LineWidth', 1.5);
title ('Inverse FFT of Shifted Gaussian')
xlabel('Bin Numbers (Time)')
ylabel('Real Part')
xlim([1 9001])



In the line

Inverse_GShifted=real(ifft(GShifted));


I have changed to

Inverse_GShifted=real(fftshift(ifft(GShifted)));


This is because the ifft output is from $$0 \le n \le N-1$$, but your actual time output is symmetric about $$n=0$$. So what you have to do is to center it around $$n=0$$ by doing fftshift() command. It will give the output of $$-N/2 \le n \le N/2-1$$ whose plot is below Regarding the zoomed output, the IFFT of gaussian function $$G(f)$$ is again Gaussian $$g(t)$$. It is getting modulated or point-by-point multiplied by $$e^{j\omega_0 n}$$ where $$\omega_0 = 1400/4500\pi$$ (considering $$-\pi \le \omega_0 \le \pi$$), which is the shift in frequency that you applied. ie, $$g[n].*e^{j\frac{14}{45}\pi n}$$. The period of this waveform turns out to be $$\approx 6.43$$ so you will see the peaks repeated after every 6 or 7 samples which is correct as per the zoomed plot. $$14/45$$ being irrational may be the reason why period is not an integer.

• Thanks for the analysis. The point which I am trying to convince myself is why do need an addtional fftshift step to see the time domain signal. How did we know a priori that the time signal was centered at zero? – M. Farooq Apr 1 at 14:12
• I think that is the convention followed by mathwork/python/octave etc. The input frequency array x-axis is always assumed to be $0 \le \omega \lt 2\pi$ which corresponds to $0 \le k \le N-1$, so the output will be $0 \le n \le N-1$. So you need to center it to visualize $-N/2 \le n \lt N/2$ – jithin Apr 2 at 2:01
• Thanks. Intuitively, this condition (N/2≤n<N/2) makes sense in the frequency domain due to the Nyquist criterion. You are right fftshift is needed even after IFFT to agree with the theory i.e. a displaced Gaussian in frequency domain must appear like the envelope shown above. Normally, one does not need an fftshift in going back from time domain to frequency and vice versa. Perhaps an easier way to convince is to take the fft of fftshifted time series to see if it matches with the frequency spectrum (left). Most likely a fftshift would be needed in the frequency domain to match with red curve. – M. Farooq Apr 2 at 2:38