General formula for mth degree polynomial in n variables The general formula for a $\text{m}^{\text{th}}$ degree polynomial in n variables is something like this:
$$ \sum_{\substack{a_1+ . . .+ a_n \; \leq \; m \\ a_1, . . . , a_n \; \geq \; 0 \\ a \;  = \; a_1, . . .a_n \\ a_1, . . . ,a_n  \; \in \; \mathbb{Z}}} c_a x_1^{a_1} \cdot \cdot \cdot x_n^{a_n}   \; ,\quad \text{where only finitely many terms are non_zero}
$$
Do I need to specify the upper limit of the sum, or does this say that the $a_i$'s vary over all integers as long as the three index equations are true? 
 A: You might be interested in using multi-index notation.
A multi-index is any $\alpha \in \mathbb N^n$. We denote by $\alpha_i$ the $i$-th component of $\alpha$ and let $\lvert \alpha \rvert = \alpha_1 + \dotsb + \alpha_n$.
Then, an $m$-th degree polynomial in the indeterminates $x_1, \dotsc, x_n$ with coefficients in $R$ can be simply defined as any expression of the form
$$\sum_{\lvert \alpha \rvert \le m} c_\alpha x_1^{\alpha_1} \dotsb x_n^{\alpha_n}$$
with $c_\alpha \in R$ for any $\alpha \in \mathbb N^n$. Notice that there is no need to specify the upper limit of the sum, and in fact it is customary to omit that $\alpha \in \mathbb N^n$ as well.
A: I would use as a basis such a formula for a polynomial of two variables:
$\begin{cases}
        \sum_{i=0}^{n}\sum_{j=0}^{m}[p_{ij}x^iy^j] & \text{if } i+j ≤ \max(n,m)\\
        0 & \text{if } i+j > \max(n,m)
    \end{cases}$
where $n,m$ - required powers for variables $x$ and $y$
I made such a code in Mathematica. From it you can understand the principle and use for programming.
pars = {n = 2, m = 3};

Sum[Sum[Piecewise[{{Subscript[p, 
       StringJoin @@ ToString /@ {i, j}] Power[x, i] Power[y, j], 
     i + j <= Max[n, m]}, {0, i + j > Max[n, m]}}], {i, 0, n}], {j, 0,
   m}]

