
Define the production function $Q=f(x_1,..,x_k)$, where $x_i$ denotes the ith input.
Next recall that the total differential of output can be written as
$\Delta Q = \sum_{i=1}^{\ k}\frac{\partial Q}{\partial x_i}\Delta x_i$
Now we are interested in returns to scale, which is the change in output due to the multiplication of every input with a constant. We can write: $x_{1i}=ax_i$, for every x where a is a constant and the subscript 1 means the new x due to the multiplication. It follows that:
$\Delta x =x_{1i}-x_i =ax_i-x_i=(a-1)x_i$
Substitute this last result into the total differential. We obtain:
$\Delta Q = \sum_{i=1}^{\ k}\frac{\partial Q}{\partial x_i}\ (a-1)x_i$
which can be rewritten as
$\Delta Q = (a-1)\sum_{i=1}^{\ k}\frac{\partial Q}{\partial x_i}\ x_i $
Now recall that the output elasticity with respect to an input i can be written as
$\epsilon\ = \frac{\partial Q}{\partial x_i}\ \frac{x_i}{\ Q}$
rewrite this to the expression
$\epsilon\ Q = \frac{\partial Q}{\partial x_i}\ x_i$
Substitute this result into the last version of the total differential which becomes:
$\Delta Q = (a-1)\sum_{i=1}^{\ k}\ \epsilon\ Q = (a-1)Q\sum_{i=1}^{\ k}\ \epsilon$
Rewriting this we obtain the multiplicator of the output associated with multiplication of every input with $a$:
$\frac{Q_1}{Q} = (a-1) \sum_{i=1}^{\ k} \epsilon +1$
Where $Q_1$ is output ex post.
From this last expression it can be immediatly seen that constant returns to scale ($ax \implies aQ$) follow from the sum of elasticities being equal to 1, increasing returns to scale from it being greater than 1 and decreasing when it's smaller than 1.
The graph is plotted for a=2. In red all points which correspond to decreasing returns to scale, in green for increasing returns to scale. Further, it can be seen that
$\sum_{i=1}^{\ k} \epsilon = 1 \implies \frac{Q_1}{Q} = a$