Can someone explain the phase spectrum of a sinc function?

The Fourier transform of a sinc function will result in a rect function. Suppose I have a discrete time-domain sinc function with a frequency of $$\omega_0 = 0.1$$ Hz and amplitude of $$A = 10^{-3}$$:

If I take an fft of this signal, I get an approximate rect function centered on zero with cutoff frequencies at $$\pm\omega_0$$ and a near-constant amplitude (see figure below).

The phase relationship of $$X(\omega)$$ is less clear to me. It's generally a linear function that runs from $$-\pi/2$$ to $$\pi/2$$ over the whole frequency range except between $$\pm\omega_0$$ where it alternates between approximately $$\pi$$ and $$0$$ at negative frequencies and $$-\pi$$ and $$0$$ at positive frequencies:

Many questions here:

1. Can someone explain this phase relationship in the simplest possible way? I can see that it follows a linear trend along $$\frac{1}{2}\omega$$ but I don't see why that is the case.
2. What determines the slope of the line? Why isn't it flat?
3. Why does it alternate back and forth within the interval $$\pm \omega_0$$ but not outside the interval?

Any clarification is appreciated.

Code to reproduce:

f = 0.1; %cosine frequency
A = 1*10^-3; %cosine amplitude

w = 2*pi*f;
fs = 1; %sample rate in Hz
N = 1000; %number of seconds
t = (-fs*N/2:1/fs:fs*N/2)-10^-6; %full time vector

%time domain signal
timeshift = 0; %set time shift to 250 as in original (unedited question)----------------------------
x = A*sin(w*(t-timeshift))./(w*(t-timeshift));
%Uncomment the next two lines if you apply a 250 s time shift.
%x = x(N/2+1:end);
%t = 0:1/fs:(fs*N/2); %truncated time vector

L = length(t); %length of time
df = fs/L; %frequency spacing
fAxis = (0:df:(fs-df)) - (fs-mod(L,2)*df)/2; %frequency vector

%FFT of time domain signal
Xfft = (fft(x)/L);

xifft = ifft(Xfft*L); %calculate ifft of spectrum
% to try to recover the original sinc function

subplot(2,1,1)
plot(fAxis,fftshift(abs(Xfft)),'-k'); hold on
grid on
xlabel('Frequency (Hz)')
ylabel('Amplitude');

subplot(2,1,2)
plot(fAxis,fftshift(angle(Xfft))*180/pi,'.k'); hold on
grid on
xlabel('Frequency (Hz)')
ylabel('Phase (degree)')

figure(2)
plot(t,x,'-k'); hold on
grid on
xlabel('Time (s)')
ylabel('Amplitude')

• You got some delay going on in there. How does delay affect phase? (Not that your phase function makes sense.) Jun 8, 2023 at 2:49
• There seems to be something wrong with your phase plotting software. It appears that you have plotted two different phase responses. Jun 8, 2023 at 10:14
• The units are really just placeholders. You could replace (s) with (ms) and (Hz) with (kHz). As is, this is infra-audio. or sub-audio. As shown, there is a delay of 250 seconds and a bandwidth of 0.1 Hz which makes your sinc ring at 0.1 Hz. Now, whatever the units, this is a delay of a positive amount, that should make the phase descend in a linear fashion with a negative slope, not an increasing slope. So something seems wrong with that. Jun 8, 2023 at 22:53
• @robertbristow-johnson You are right that I was including a time delay in the original question. I've edited it so that it no longer includes the time shift. The phase spectrum looks the same as it did before because I was shifting and truncating and (as you said) the x-axis is arbitrary in that case. See the MATLAB script I added in the edited answer. The time shift was just a confusing red herring to the question so please ignore it as it is not the root cause of my question about the phase of the sinc function. Jun 9, 2023 at 14:56
• Well, it's the way the drawing is. But did you change how the data is going into the DFT? How are you computing the spectrum? Jun 9, 2023 at 16:28

In this context, your question does not make sense mathematically.

A sinc function is defined as being purely real with even symmetry where

$$f(x) = f(-x)$$.

The Fourier transform of a real evenly symmetric signal is purely real. The phase response in the frequency domain is the inverse tangent of the real part of the Fourier transform over the imaginary part (which we just showed was zero). Classic divide by zero case and things get weird such as why you are seeing an oscillatory behavior because that is just how you solver handles this case.

• Thanks for this response. I want to mark this as the accepted answer, but I would still like to know what is special about the solver that leads to this phase response. It seems like it would be more appropriate if the solver gave all zeros or something. Jul 10, 2023 at 15:06
• The solver (it looks like Matlab in this case) has to implement it somehow. Matlab specifically defaults to use double precision floats so a zero after taking the fft might actually just be some value really close to zero. Then the phase again is the real over the imaginary and there would then be a 50% chance that that specific sample is positive or negative resulting in 180 phase changes. Jul 13, 2023 at 0:03

Why does it alternate back and forth within the interval $$\pm \omega_0$$

Because you're taking the Fourier transform of something that's delayed by a whole lot. In this case you're taking a discrete Fourier transform* of something that's delayed by all or most of half a period, so of course the phase will alternate.

For a continuous-time Fourier transform, the phase will have a slope of $$-t_0$$, where $$t_0$$ is your delay. For a DFT, if you delay your signal by half a period, you'll see a phase that bounces up and down by 180 degrees.

but not outside the interval?

Because you're not replicating a bandlimited function correctly in your FFT world, and it has a little bit of bias someplace that's coming across as that constant little slope.

Can someone explain this phase relationship in the simplest possible way? I can see that it follows a linear trend along \$\frac 1 2 \omega but I don't see why that is the case.

I can't give you an accurate, detailed picture without a lot of work and words -- basically, the residual slope is probably there because your time series is shifted somehow. But this is in the context of that homonguous shift in there, which is probably defeating whatever you really wanted to do.

What determines the slope of the line? Why isn't it flat?

Because your sinc expression leads the exact halfway point of your period by just a little bit.

What you really want to do is shift that time-domain prototype so it's centered on t = 0, keeping in mind that for an N-point DFT, N-1 is congruent to -1, N-2 is congruent to -2, etc. So you want to take the "positive time" half and just paste it in, then you want to shift he "negative time" up by N.

* The FFT is just a fast way to calculate the Discrete Fourier Transform (DFT).

• See the new edited question. The time shift does not impact the result in this case because of the way I was doing the time shift (x-axis is arbitrary depending on how you do the shift). So that was a bit of a red herring to my underlying question about the phase of the sinc function. Sorry for the confusion. Jun 9, 2023 at 15:02