I have this double summation that I want to simplify:
$$\sum^{q} _{j=-q} \sum^{q} _{i=-q} \mathbb{1}_{ \{h+j-i=0 \}}$$
A given solution says the answer is $2q+1-h$ for $|h| \leq 2q$ and $0$ otherwise.
I don't see this. For example, when I take $q=1$ and $h = 2*q = 2$ the summation sums up to $0$ which is unequal to $2q+1-h = 1$.
Anyone can help me out?
First note that the example $q=1, h=2$ works, since \begin{align*} \color{blue}{\sum_{j=-1}^1\sum_{i=-1}^1 1_{\{2+i-j=0\}}} &=\sum_{j=-1}^1\left(1_{\{j=1\}}+1_{\{j=2\}}+1_{\{j=3\}}\right)\\ &=\sum_{j=-1}^11_{\{j=1\}}\\ &=1\\ &\,\,\color{blue}{=2q+1-h} \end{align*}
Comment:
In (1) we shift the indices to start from $0$ and do the compensation in the the indicator function.
In (2) we simplify the indicator function by shifting the index $i$ to start from $-h$.
In (3) we see thanks to the simple indicator condition $\{i=j\}$ that we can set the lower limit of the index $i$ resp. $j$ depending on $h\geq 0$ resp. $-h\geq 0$.
In (4) we also set the upper limit of the indices $i$ and $j$ depending on $h$.
In (5) we simplify the inner sums.
In (6) we simplify the sums and can write the condition for $h$ conveniently.