I wanted to visualise at how the frequency spectrum of square waves changes with duty. But I got stuck at the first hurdle:

FourierTransform[SquareWave[x], x, w]

Doesn't evaluate. Why not? Can I make it do so?

I tried a couple of other things, like If[Sin[x]>0,1,0] but they don't work. I would have thought the built in square wave would have worked.


One way to investigate the spectrum of the SquareWave and other periodic functions is via the FourierSeries. Here are the first few coefficients:

FourierSeries[SquareWave[x], x, 10, FourierParameters -> {1, 2 Pi}]

If you want to see real values, then use FourierSinSeries and FourierCosSeries.

| improve this answer | |
  • 2
    $\begingroup$ The Fourier transform of an infinite periodic function is not an easy function to visualize: it's a series of weighted delta functions. The weights themselves are more illuminating, and FourierSeries gives you those. $\endgroup$ – John Doty Sep 5 '16 at 13:56
  • $\begingroup$ That's a very useful suggestion. $\endgroup$ – Lucas Sep 5 '16 at 17:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.