What is the difference between sampling over $-4\pi$ to $4\pi$ and 0 to $8\pi$ I see no difference in magnitude, but the phase plots vary significantly while using NumPy and MatPlotLib to plot.
Looking at the phase plots, I feel like I'm missing something important. Also, I'm a relative newcomer to the field of DSP, so if it's something obvious, even then please explain it as an answer rather than a comment.
My doubt is whether there is some error in the phase that is being introduced by NumPy while taking the FFT of a real-valued function or if it is expected to be this way.
Plot using 512 samples over $[-4\pi,4\pi)$:
$[-4\pi,4\pi)$)" />
Plot using 512 samples over $[0,8\pi)$:
$[0,8\pi)$" />
This is my code for generating each of these DFTs of the amplitude modulated cosine wave:
t1 = np.linspace(-4*np.pi,4*np.pi,513)[:-1]
y1 = (1 + 0.1*np.cos(t1))*np.cos(10*t1)
Y1 = np.fft.fftshift(np.fft.fft(y1))/512

t2 = np.linspace(0,8*np.pi,513)[:-1]
y2 = (1 + 0.1*np.cos(t2))*np.cos(10*t2)
Y2 = np.fft.fftshift(np.fft.fft(y2))/512

Do let me know if the rest of my code would also be necessary. It's honestly just plot functions other than these.
Also, please do link me and mark it as duplicate if this is one. I tried searching on Google, but I wasn't able to find anything explaining this concept.
Your spectrum is zero at all frequencies other than at the carrier and the side bands. If the magnitude is zero the phase is undefined. Since you use finite precision math, the magnitude in your calculation will not be exactly zero but just a really really small number. So the phase can be computed but what you are seeing just random numerical noise.
As you change the time interval, the noise will change as well, but the magnitude will still be extremely small.