Sum of a step function Please help me to find the following summation
$$\sum_{m=0}^{N} \sum_{n=0}^N \sum_{i=0}^N \sum_{j=0}^N \mathbb{1}(m,n,i,j)$$
where
$1(m,n,i,j)= \left\{ \begin{matrix} 1 \qquad m+n=i+j \\0 \qquad \; \; \; \;\; \textrm{otherwise} \end{matrix}\right.$
Thank you very much!
 A: Your indicator function is just a Kronecker delta $\delta_{m+n,i+j}$. The Kronecker delta admits an integral representation
$$
\delta_{a,b}=\int_{0}^{2\pi}\frac{d\xi}{2\pi}e^{i\xi (a-b)}\ ,
$$
therefore your sum is
$$
\sum_{m=0}^{N} \sum_{n=0}^N \sum_{i=0}^N \sum_{j=0}^N \mathbb{1}(m,n,i,j)=
\int_{0}^{2\pi}\frac{d\xi}{2\pi}\sum_{m=0}^{N} \sum_{n=0}^N \sum_{i=0}^N \sum_{j=0}^N e^{i \xi (m+n-i-j)}
$$
$$
=\int_{0}^{2\pi}\frac{d\xi}{2\pi}\left(\sum_{m=0}^{N} e^{i\xi m}\right)^2 \left(\sum_{j=0}^{N} e^{-i\xi j}\right)^2 =\int_{0}^{2\pi}\frac{d\xi}{2\pi}\left(\frac{-1+e^{i N \xi +i \xi }}{-1+e^{i \xi }}\right)^2\left(\frac{e^{-i N \xi } \left(-1+e^{i N \xi +i \xi }\right)}{-1+e^{i \xi }}\right)^2=\frac{1}{3} \left(2 (N+1)^3+N+1\right)
$$
A: Given any $m,i$ there are $N+1-|m-i|$ pairs $n,j$ such that $m+n=i+j$ and so
\begin{eqnarray}
\sum_{m=0}^N \sum_{i=0}^N \sum_{j=0}^N \sum_{n=0}^N 1(m,n,i,j) &=& \sum_{m=0}^N \sum_{i=0}^N ( N+1-|m-i|  ) \\
&=& (N+1)^3 - \sum_{m=0}^N \sum_{i=0}^N |m-i| \\
&=& (N+1)^3 - 2\sum_{m=0}^N \sum_{i=0}^m (m-i) \\
&=& (N+1)^3 - 2\left( \sum_{m=0}^N \sum_{i=0}^m m - \sum_{m=0}^N \sum_{i=0}^m i \right)\\
&=& (N+1)^3 - 2\left( \sum_{m=0}^N m (m+1) - \sum_{m=0}^N {1 \over 2} m (m+1) \right)\\
&=& (N+1)^3 -  \sum_{m=0}^N m (m+1)\\
&=& (N+1)^3 - {1 \over 3} N (N+1)(N+2)\\
&=& {1 \over 3} (N+1)(2N^2+4N +3)
\end{eqnarray}
