Showing orthogonality of two sines with the exponential form of delta function There are a lot of great websites and explanations on how to derive the orthogonality condition for the product of two sines, e.g.
\begin{equation}
\int_{-L}^{L} d\ell \sin\left(\frac{n\pi \ell}{L}\right)\sin\left(\frac{m\pi \ell}{L}\right) = \delta\left(m-n\right) L.
\end{equation}
I would like to derive the above using the definition of the $\delta$-function
\begin{equation}
\int_{-\infty}^{\infty} dk e^{ikx}  = \delta(x).
\end{equation}
My question is quite simple, since the definition of the delta function can naively be written as
\begin{equation}
\int_{-L}^L dk e^{ikx} = \delta(x),
\end{equation}
why does the following expansion fail:
\begin{align}
\int_{-L}^{L} d\ell \sin\left(\frac{n\pi \ell}{L}\right)\sin\left(\frac{m\pi \ell}{L}\right) = -\frac14 \int_{-L}^L d\ell\left[e^{(n+m)\pi i\ell/L} + e^{-(n+m)\pi i\ell/L} - e^{(n-m)\pi i\ell/L} - e^{(-n+m)\pi i\ell/L}\right]= -\frac14\times 2\pi\left[\frac{L}{\pi}\delta\left(n+m\right) + \frac{L}{\pi}\delta\left(-n-m\right) - \frac{L}{\pi}\delta\left(n-m\right) - \frac{L}{\pi}\delta\left(m-n\right)\right] = \frac12L\left[\delta\left(n-m\right)-\delta\left(n+m\right)\right] \neq \delta\left(m-n\right)L,
\end{align}
where I have used the above definition for the delta function.
 A: Besides the super-sketchiness of the problem, in your calculation, I would comment that you are treating this problem as if it were just the integral of a function (e.g. change of variables), while I do not think that you can. The reason that you do get plausible answers is that if you integrate an exponential on an interval and on a line you get similar results ($\ast$). The formula for integration of the sines comes from the result of integrating the exponential on a finite interval and so the dirac delta function is not really helpful. In fact, it is slightly confusing as explained in ($\ast$).
Your calculation makes sense, but I suppose that because you are wanting to mix up an infinite integral (integral of exponential is a delta) with a finite integral, things just do not behave the way that they seem that they should. And the reason is that $\delta(n-m)$ does not really make sense in the context of the integral over $[-L,L]$ of the product of sines, since if you integrate an actual function over an actual finite interval, you get an actual function, nothing can be infinite. If you want to let $L$ be large or something to interpret $\int_{-L}^{L}dke^{ikx} = \delta(x)$, then you cannot derive a result about the integral of the product of sines over a fixed interval of length $2L$. You have to decide what integrating on $[-L, L]$ really means. When you drop the integral over all of $\mathbb{R}$ to $[-L,L]$ of the exponential, you are essentially equivocating between these two. The only thing that is related between the two is the fact that $\int_{-\pi}^{\pi}dke^{ikx} = 2\pi\delta_{0,k}$, where this is the kronecker delta notation that means the number $0$ or $1$, not the dirac delta function.
Another reason to suspect this approach is that while there is no "$L$" in the integrand of the exponential, there is one in the integrand of the product of sines and if you wish to treat it in some sort of distribution way, then you have to get rid of the $L$ on the inside... which destroys the interpretation that you had of comparing the integral of product of sines with $\int_{-L}^{L}dk e^{ikx}$.
I would note that if your approach was fine, then you should expect something like what you got, because the product of sines with $n = m$ is negative of that when $n = -m$, because $\sin$ is an odd function. Also, the reason that you have an extra factor of $\frac{1}{2}$ is because when you integrate the actual function $1$ over the actual interval $[-L,L]$ you get $2L$, which is double that what you would expect if you just look at $\int_{-L}^{L}dk e^{ikx} = \delta(x)$ and you plug in $x = 0$ and act like this is an actual integral and $\delta(0) = 1$.
P.S. The $-\frac{1}{4}$ on your first line was confusing me for quite a while.
