# Any efficient way to make complete homogeneous symmetric functions in Mathematica?

We do have elementary symmetric functions, SymmetricPolynomial[k, {x_1, ..., x_n}] .

But I didn't find complete homogeneous symmetric functions.

The induction method to compute $h_n$ from $e_i$ and $h_j$ ($j\leq n-1$) is not that efficient.

Is there any easier way to do this?

-

## migrated from math.stackexchange.comJun 9 '12 at 13:57

This question came from our site for people studying math at any level and professionals in related fields.

For example:

completeSymmetricPolynomial[i_?IntegerQ, vars_?ListQ] :=
Total@Union@Tuples[Times @@ vars, {i}];

completeSymmetricPolynomial[2, {a, b, c, d}]

(* a^2 + a b + b^2 + a c + b c + c^2 + a d + b d + c d + d^2 *)


Edit

You can verify the fundamental relationship between complete and incomplete symmetric polynomials:

$$\sum_{i=0}^m (-1)^i e_i(X_1,\dots,X_n)h_{m-i}(X_1,\dots,X_n)=0$$

FullSimplify@
Table[Sum[(-1)^i completeSymmetricPolynomial[i, {a, b, c, d}]
SymmetricPolynomial[m - i, {a, b, c, d}],
{i, 0, m}], {m, 1, 4}]

(* -> {0, 0, 0, 0} *)

-
I think you can replace Times[Sequence @@ vars] with Times @@ vars. – Mr.Wizard Jun 9 '12 at 15:21
...and the Plus @@ stuff is more compactly written as Total[stuff]. – J. M. Jun 9 '12 at 15:33
Thanks, edits done – belisarius has settled Jun 9 '12 at 16:08
The fundamental relationship belisarius is using to check his implementation is essentially the second method in my answer. – J. M. Jun 9 '12 at 17:11
The only little issue is 0-th order is not well defined, i.e. completeSymmetricPolynomial[0, {a, b, c, d}] – Osiris Xu Jun 12 '12 at 21:44

What I'd do, based on the generating function identity in your Wikipedia link:

completeSymmetricPolynomial[k_Integer, vars_List] :=
SeriesCoefficient[
Apply[Times, 1/(1 - vars \[FormalT])], {\[FormalT], 0, k}] /;
0 <= k <= Length[vars]


This is somewhat slower, but I want to demonstrate that the induction approach can be made to work as well (and is easily modified if you want all the $n$-variable polynomials all at once, as opposed to just one):

completeSymmetricPolynomial[k_Integer, vars_List] :=
Expand[LinearSolve[ToeplitzMatrix[
Table[(-1)^\[FormalK] SymmetricPolynomial[\[FormalK], vars],
{\[FormalK], 0, Length[vars] - 1}],
UnitVector[Length[vars], 1]],
-Table[(-1)^\[FormalK] SymmetricPolynomial[\[FormalK], vars],
{\[FormalK], Length[vars]}]][[k]]]

-
:) Yes, this works too. – Osiris Xu Jun 9 '12 at 21:22

This variant seems competitive in terms of speed.

completeSymmetricPolynomial2[i_?IntegerQ, vars_?ListQ] :=
Expand[(Total@vars)^i]/. aa_Integer*bb_ :> bb

-
cool. Thanks. :) – Osiris Xu Jun 9 '12 at 21:22