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.


closed as off-topic by Wjx, m_goldberg, Feyre, Young, QuantumDot Sep 6 '16 at 10:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Wjx, m_goldberg, Feyre, Young, QuantumDot
If this question can be reworded to fit the rules in the help center, please edit the question.


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.

  • 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.