Skip to content

Instantly share code, notes, and snippets.

@Gro-Tsen
Created November 17, 2025 08:15
Show Gist options
  • Select an option

  • Save Gro-Tsen/d13cf698e5693ef2d68fb50dbf808a4e to your computer and use it in GitHub Desktop.

Select an option

Save Gro-Tsen/d13cf698e5693ef2d68fb50dbf808a4e to your computer and use it in GitHub Desktop.
Plot the Fourier transform of μ(n)/n
destdir = "."
nbsamp = 403200
fft = FastFourierTransform(nbsamp)
for i in range(nbsamp):
fft[i] = N(moebius(i)/i) if i>0 else 0
fft.forward_transform()
plot = list_plot([(N(i/nbsamp-1), N(fft[i][1])) for i in range(nbsamp)]+[(N(i/nbsamp), N(fft[i][1])) for i in range(nbsamp)], plotjoined=True, thickness=0.5, color="red") + list_plot([(N(i/nbsamp-1), N(fft[i][0])) for i in range(nbsamp)]+[(N(i/nbsamp), N(fft[i][0])) for i in range(nbsamp)], plotjoined=True, thickness=0.5)
plot.save(filename=(destdir+"/moebius.png"), dpi=192, aspect_ratio=0.4)
parplot = list_plot([(N(fft[i][0]), N(fft[i][1])) for i in range(nbsamp)], plotjoined=True, thickness=0.5, color="purple")
parplot.save(filename=(destdir+"/moebius-curve.png"), dpi=192, aspect_ratio=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment