Confusion with integrating sin(nx)sin(mx) and Kroenecker delta

The specific integral I'm working with is the following: $$\int_0^a\sin(n\pi y/a)\sin(n'\pi y/a)$$ This is supposed to come out to $$0$$ in the case that $$n \neq n'$$ and $$\frac{1}{2}a$$ in the case that $$n= n'$$. I can obtain this result sometimes, but the method I'm using currently is giving me a value of $$0$$ all the time. I'm applying a product-to-sum formula and then integrating. Only resources I've managed to find on this equate the following expression (which is my final result before applying limits of integration) to the Kroenecker delta: $$\frac{\sin((n-m)\pi)}{(n-m)\pi} - \frac{\sin((n+m)\pi)}{(n+m)\pi}$$

Basically asserting that this evaluates to $$1$$ when $$n = m$$ and to $$0$$ when $$n \neq m$$. I've been staring at this for minutes now and I feel like I'm going insane. It seems obvious to me that if I set $$n =m$$ the whole thing evaluates to $$0$$ regardless. We get $$\sin(0)$$ in the first term and we get $$\sin(2n\pi)$$ in the second term, which also is $$0$$ because $$n$$ is an integer. What am I missing here?

Look at the denominator of the first term. It also is equal to $$0$$ when $$m=n$$. So you get $$\frac 0 0$$. In fact, the first term is to be interpreted as the limit when $$m\rightarrow n$$, and it converges to $$1$$.

• This makes sense to me. To clarify further, I would take something like L'Hopital's and choose to evaluate the indeterminate expression as a limit? Then I would receive 1 as desired. This is valid? – Bookie Feb 17 at 22:19
• Yes, that's one way to think about it. But as @GReyes said, you don't have to think of it as a limit. His answer shows a way to evaluate at $m=n$. – Stefan Lafon Feb 17 at 22:28
• Using limits here creates confusion. This integral can be (trivially) computed in all cases. – GReyes Feb 18 at 1:04
• I think you're right. – Stefan Lafon Feb 18 at 4:44

The problem is that when $$n=n'$$, when you transform into a sum, you get $$\frac{1}{2}\left[\cos\left(\frac{(n-n')\pi y}{a}\right)-\cos\left(\frac{(n+n')\pi y}{a}\right)\right]$$ When $$n=n'$$ the first cosine is just $$=1$$ and integrates as $$y$$, NOT as the corresponding sine.

• This seem to not jive with the answer given above. I'm not sure what to think. – Bookie Feb 17 at 22:16
• You do not need any kind of limit procedure here. When $n=n'$ your integrand has a first piece equal to $1/2$ and integrates to $y/2$. Please let me know what is not clear. – GReyes Feb 17 at 22:24
• The formula to transform a product of sines into a sum of cosines is general. What does not make sense is to integrate $\cos 0$ as $\sin 0$. – GReyes Feb 17 at 22:26
• @Bookie Forget about the limit argument. You are only trying to prove this for integer values of $n$ and $n'$ so you can't take any "limits as $n$ tends to something." When $n = n'$ you are just integrating $\sin^2(n\pi y/a)$ which you learned how to do in Calculus 2 - it doesn't need clever arguments about limits. – alephzero Feb 18 at 0:51
• The basic formulas here are $\cos(p+q) = \cos p \cos q - \sin p \sin q$ and $\cos(p-q) = \cos p \cos q + \sin p \sin q$. So $\sin p \sin q = (\cos(p-q) - \cos(p+q))/2$. When $p = q$, you have $\sin^2 p = (1 - \cos 2p)/2$. That's all there is to it. – alephzero Feb 18 at 1:22