Show that the polynomial function f(m, n) = (m + n - 2)(m + n -1)/2 + m is one-to-one and onto 
Show that the polynomial function $f(m, n) = (m + n - 2)(m + n -1)/2 + m$ is one-to-one and onto.
  Both domain and codomain are positive integer.

this is an exercise from "discrete mathematics and its applications 6th", section 2.3, exercise 77. I actually have the answer, but I'm afraid I don't understand it. I post it here:
It is clear from the formula that the range of values the function
takes on for a fixed value of m + n, say m + n = x, is (x-2)(x-1)/2+1 
through (x-2)(x-1)/2+(x-1), because m can assume the values 1,2...x-1 
under these conditions, and the first term in the formula is a fixed
positive integer when m+n is fixed. to show that this function is
one-to-one and onto, we merely need to show that the range of values
from x+1 picks up precisely where the range of values for x left off,
i.e., that f(x-1,1)+1=f(1,x). we have 
f(x-1,1)+1=(x-2)(x-1)/2+(x-1)+1=(x^2-x+2)/2=(x-1)x/2+1=f(1,x)

I do have no idea why it can replace m+n with x, because I think m+n=x is 
not an one-to-one function, how can it be used here?
 A: But the solution doesn't claim that $m+n=x$ is a one-to-one correspondence — of course it isn't. The solution simply makes an observation that the expression $m+n$ appears several times in the formula for this function, so they introduce a new notation $x$ to simplify the formula. If we let $x$ denote (temporarily, we might say) $m+n$, i.e. we define a new variable $x=m+n$, then the formula, especially its first term, looks a lot more simple and more understandable:
$$f(m,n)=\frac{(m+n-2)(m+n-1)}{2}+m=\frac{(x-2)(x-1)}{2}+m.$$
Note the phrase

... the values the function takes on for a fixed value of $m+n$ ...

What it means is that (as you pointed out) many different choices of $m$ and $n$ can result in the same $x$. But if we consider the same, i.e. fixed, $x$ — which means considering all those different possibilities for $m$ and $n$ that add up to this $x$ — then we can make an observation about the function's range. Specifically, since $x=m+n$ and both $m$ and $n$ are positive integers, $m$ can range from at least $m=1$ (in which case $n=x-1$) up to at most $m=x-1$ (in which case $n=1$), and so the range of the function is from $\frac{(x-2)(x-1)}{2}+1$ up to $\frac{(x-2)(x-1)}{2}+x-1$.
I hope you can take it from there.
