Why $\int_0^{2\pi} \sin^2 x \mathrm{d}x \neq \int_0^{2\pi}\sin x \sin nx \mathrm{d}x \to n=1$

By orthogonality, we know that

$$\int_0^{2\pi}\sin mx \sin nx \mathrm{d}x = \pi$$ iff $$m=n$$ and $$0$$ otherwise. Nevertheless, when I am calculating it as follows, I get $$0$$.

$$\int_0^{2\pi} \sin x \sin nx \mathrm{d}x = \frac{1}{2}\bigg[\frac{\sin[(1-n)x]}{1-n} - \frac{\sin[(1+n)x]}{1+n}\bigg]_0^{2\pi}$$

But the above quantity is $$0$$ even if $$n=1$$. Shouldn't it be $$\pi$$?

• Aren’t you dividing by $0$ somehow when $n=1$? – Mindlack Dec 13 '18 at 1:44
• You're right! How can I fix this. Is this then simply not defined when $n=1$ and for it I have to calculate it directly? – The Bosco Dec 13 '18 at 1:45
• This is exactly the point. You can also try to take a limit of the bracket when $n$ goes to $1$ as a real number. – Mindlack Dec 13 '18 at 1:48

Your work so far is correct, but things like these are often a sort of "by cases" thing: in this case, the cases are $$n=1$$ and $$n \neq 1$$. When $$n \neq 1$$, you can show that expression is $$0$$, but it's undefined when $$n=1$$.

Notice that, just because the expression on the right is undefined when $$n=1$$, the expression on the left isn't.

(Or, at the very least, you have no reason to suspect as much. Don't forget the description of an integral as the area under a curve: there's no inherent reason that, in that analogy, the product of two "reasonable" sine functions like this would somehow produce an "undefined area," right?)

So just let $$n=1$$ in the integral, i.e.

$$\int_0^{2\pi} \sin(x) \sin(x) dx = \int_0^{2\pi} \sin^2(x)dx$$

You can calculate this via your method of preference and show it to be $$\pi$$.

(Note: I'm not sure if "by cases, where one case is when it's defined and one case is when it's not" is the appropriate way to think of it. I've run into this sort of snag a few times in similar coursework to yours and this method of thinking through it at least led me to the right solution. My professors seemed to just assume it's obvious I guess.)

In the limit of $$n \to 0$$ you have

$$\lim_{n\to 0} x\frac{\sin(1-n)x}{(1-n)x} = x$$

Therefore

$$\lim_{n\to 0} \int_0^{2\pi} \sin x \sin(nx) dx = \frac12 \left[x -\frac{\sin 2x}{2} \right]_0^{2\pi} = \pi$$