Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Mathematica notation, I am looking for the function f[m,n] for real numbers m and n defined by

f[m_,n_]:=Integrate[SquareWave[m x]SquareWave[n x],{x,0,1}].

I'm trying to get a closed form for the integral for general m and n, but am having trouble, as Mathematica cannot do it.

I found a closed form for f[m,n] for integer m, n:

f[m,n] = Mod[m,2]Mod[n,2]GCD[m,n]^2/(m n).

I am just wondering if there exists a closed formula for f[m,n] for real values of m and n. It seems like a simple problem but I'm not sure how to solve it, or if a closed form even exists. I found the integer m,n result using Fourier series for the square waves, along with properties of the dilogarithm function (which shows up in Mathematica when I compute the needed sums of products of Fourier coefficients).

Naturally, if this has already been answered I will remove it, but was curious if anyone has any input. I feel like I'm attacking the problem using the wrong method (analysis) and that it would be better to use number theory or something like that. Any insights? This is just for fun, so if no one figures it out there's no harm done.

share|cite|improve this question
Here is a plot of f[m,n] for m in [2.5,3.5] and n in [4.5,5.5], made by numerical evaluation of f[m,n]. The red regions are positive and the blue regions are negative. The resolution is a bit low (should have used more points) but it certainly appears to have some nontrivial behavior. – PJR Nov 26 '12 at 2:19
Here's a higher res pic: – PJR Nov 26 '12 at 2:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.