# Simplification of $\sum \limits_{a=0}^{m} \sum \limits_{b=0}^{n} x^{|a-b|}$

I was trying to determine a simplification of $$f(x) = \sum \limits_{a=0}^{m} \sum \limits_{b=0}^{n} x^{|a-b|}$$. One approach I considered was using a case bash, but this was quite inelegant so I tried to find a more elegant method. Another method was to consider the expression for $$f(x) + f \left ( \frac{1}{x} \right )$$. This seemed better as it was much easier to sum, resulting in the below expression:

$$f(x) + f \left ( \frac{1}{x} \right ) = \left ( \frac{x^{m+1}-1}{x-1} \right ) \left ( \frac{x^{n+1}-1}{x-1} \right ) \left ( \frac{1}{x^m} + \frac{1}{x^n} \right ) = \frac{(x^{m+1}-1)(x^{n+1}-1)(x^m+x^n)}{x^{m+n}(x-1)^2}$$

Now the issue is to isolate $$f(x)$$ from this. Any help would be great.