I would like to generate automatically a polynomial in two variables $(s,t)$ which is symmetric under the exchange of those variables. There are three kinds of terms; at order $k$, we have $$(s+t)^k, \quad (st)^k, \quad (s+t)^a(st)^b,$$ where $a+b=k$. Using a simple sum it is not difficult to write down in Mathematica the first two types. If "ord" is the degree of the polynomial, I just define a function $poly[s,t,ord]$ as $$\sum_{i=0}^{ord} \big( c_i(s+t)^i +d_i(st)^i \big),$$ where $c_i,d_i$ are some coefficients.

But how can I generate the third type?

  • $\begingroup$ But the degree of (s+t)^k is k and the degree of (st)^k is 2k and the degree of (s+t)^a (st)^b is a+2b, what is the order do you want? $\endgroup$
    – cvgmt
    Commented Nov 23, 2022 at 1:23

1 Answer 1


You may use one running index: k and a second running index: a for a=0..k. b will then be k-a. With this e.g:

Sum[Subscript[c, a, i - a] (s + t)^a (s t)^(i - a), {i, 0, ord}, {a, 0, i}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.