How to obtain the right-hand side of the following equation? How to obtain the right-hand side of the following equation\begin{align*}
&\mathrel{\phantom{=}}\sum_{m=1}^{w-2}\sum_{n=2}^{2w-2m-1} 2^{n-2} g(2m+n,2w-2m-n)\\
&=\frac{1}{6}\sum_{k=4}^{2w-1}[2^{k-1}-3+(-1)^k] g(k,2w-k)
\end{align*}
by substituting $k=2m+n$ into the left-hand side of the above equation?
I understand that $4 \le k \le 2w-1 $. But I don't know how to change the boundry of $n$ and obtain the right-hand side.

There might be an easier way, but this is what I could do. First of all, I will ignore the function $g$, since it is clear that it does not have to do with what we want to show, namely:
$$ \sum_{m=1}^{w-2}\sum_{n=2}^{2w-2m-1}2^{n-2} = \frac{1}{6} \sum_{k=4}^{2w-1} \left(2^{k-1}-3+(-1)^k \right)$$
We start from the LHS. First of all, with the substitution $k:=2m+n$ we obtain
$$ \sum_{m=1}^{w-2}\ \sum_{k=2m+2}^{2w-1} \ 2^{k-2m-2}$$
We want to exchange the summations, but this is not so easy because of the factor $2$ in $2m$. If you draw a grid with axes $m$ and $k$ and fix some $w$, and draw a point for all the values of $(m,k)$ that you want to consider, then you can see that the above sum is equal to
$$ \sum_{k=4}^{2w-1} \ \sum_{m=1}^{\lfloor\frac{k-2}{2}\rfloor} \ 2^{k-2m-2}$$
This is probably the hardest step. If it is not clear, try to exchange easier summations, like
$$ \sum_{k=1}^{w} \ \sum_{m=1}^{k} = \sum_{m=1}^{w} \ \sum_{k=m}^{w}$$
Anyway, once we have this sum, we are only left to show that
$$\sum_{m=1}^{\lfloor\frac{k-2}{2}\rfloor} \ 2^{k-2m-2} = \frac{1}{6}\left(2^{k-1}-3+(-1)^k\right)$$
But this is just a geometric series and the fact that $\lfloor\frac{k-2}{2}\rfloor = \frac{2k-5+(-1)^k}{4}$:
$$\sum_{m=1}^{\lfloor\frac{k-2}{2}\rfloor} \ 2^{k-2m-2} = \sum_{m=0}^{\lfloor\frac{k-2}{2}\rfloor-1} \ 2^{k-4}\left(2^{-2}\right)^{m} 
 = 2^{k-4} \frac{1-\left(2^{-2}\right)^{\lfloor\frac{k-2}{2}\rfloor}}{1-2^{-2}} = \frac{2^{k-1}}{6} \left( 1-2^\frac{-2k+5-(-1)^k}{2} \right) = \frac{1}{6}\left(2^{k-1}-3+(-1)^k\right).$$
