Computations with 
Symmetric  Functions

Programming

<<  "Algebra`SymmetricPolynomials`"
<<  "DiscreteMath`Combinatorica`"
\(\(\(Off[General::"spell1"]\)\(
\)\(
\)\(
\)
    \) (*\ Define\ elementary\ symmetric\ polynomials\ *) \)
Clear[eps]
eps[X_, 0]  =  0;
\(eps[X_, \ k_Integer]\  := \ 

      If[k <= \ Length[X], 
SymmetricPolynomial[X, k]\ , 0]\)
\(\(\(eps[X_, \ lambda_List]\  := \ 
      Expand[Product[
          eps[X, \ lambda[\([i]\)]], \ {i, \ 1, \ Length[lambda]}]]\)\(
\)
    \)\)
\(\(\(power[X_List, lambda_List]\  := \ \ If[
        Length[lambda]\  <= \ Length[X], \ 
        Product[X[\([i]\)]^lambda[\([i]\)], {i, 1, Length[lambda]}], 
        0]\)\(
\)\(
\)\(
\)
    \) (*Expansion\ in\ elementary\ symmetric\ functions*) \)
Clear[logg]
logg[x[k_],  k_]  :=  1
logg[x[k_]^a_,  k_]  :=  a
logg[y___*x[k_],  k_]  :=  1
logg[y___*x[k_]^a_,  k_]  :=  a
logg[z_, k_]  :=  0  /;  FreeQ[z,  x[k]]
\(	llambda[z_]\  := \ Table[logg[z, k], \ {k, 1, NumbVars}]\)
myorderQ[a_, b_]  :=  OrderedQ[llambda[a],  llambda[b]]
mysort[p_]  :=  
      Sort[Apply[List,  p],   myorderQ[{#1,  #2}] &]
\(leadingTerm[p_]\  := 
		If[
        Head[p] === Plus, \ \(mysort[p]\)[\([1]\)], p]\)
leadingPartition[p_]  :=  llambda[leadingTerm[p]]
\(leadingMonomial[p_]\  := \ 
      Module[{a}, 
		a = \ leadingPartition[p]; 
		Product[
          x[i]^a[\([i]\)], \ {i, 1, NumbVars}]]\)
leadingCoefficient[p_]  :=  
      leadingTerm[p]/leadingMonomial[p]
\(\(\(Clear[ϵ]\)\(
\)\(
\)
    \)\)
\(\(\(elementaryExpand[p_]\  := \ 
      Module[{p1, plist, \ ϵϵ}, 
		n\  = \ 
          NumbVars; 
		ϵϵ := \ 
          Array[ϵ, \ n]; 
		p1 = \ Expand[p]; 
	
        plist\  = \ {}; 
		While[
          Not[p1\  === \ 0], 
		plist\  = \ 
            Append[plist, \ {leadingCoefficient[p1], 
                TransposePartition[
                  leadingPartition[p1]]}]; 
			p1\  = \ 
			Expand[
              p1\  - \ leadingCoefficient[p1]*
                  eps[X, TransposePartition[
                      leadingPartition[p1]]]];
			]; 

	
        plist\ \  = 
          Apply[Plus, \ 
            Map[#[\([1]\)]*
                  Product[\ ϵϵ[\([#[\([2, 
                            i]\)]]\)]\ \ , {i, 1, Length[#[\([2]\)]]}] &, 
              plist]]
		]\)\(
\)\(
\)\(
\)\( (*\ 
      Compute\ monomial\ symmetric\ function\ corresponding\ to\ a\ partition . \ An\ alphabet\ of\ variables\ must\ be\ \(\(specified\)\(.\)\)*) \)\(
\)
    \)\)
\(\(\(monomialSymmetric[X_, \ lambda_List]\  := \ 
      Module[{permlist, mu}, 
		mu\  = \ 
          lambda //. \ {a__, 0}\  -> \ {a}; 
	
        If[Length[mu]\  > \ Length[X], \ Return[0]]; 
		While[
          Length[mu]\  < \ Length[X], \ 
          mu\  = \ Append[mu, 0]]; 
		permlist\  = \ 
          DistinctPermutations[mu]; 
		permlist\  = \ 
          Apply[Plus, 
            Map[\ power[X, #]\  &\ , \ 
              permlist]]
]\)\(
\)\(
\)\(
\)\(
\)\(
\)
    \)\)
\(\(\(Discr[X_]\  := 

      Product[X[\([i]\)] - X[\([j]\)], \ {i, 1, Length[X] - 1}, {j, i + 1, 
            Length[X]}]^2\)\(
\)\(
\)\(
\)\(	\)\(
\)
    \)\)

Monomial symmetric functions

Given a partition α of length no more than n,   there is a monomial (x^α) in n variables. The monomial symmetric function  (Subscript[m, α])((Subscript[x, 1]),   ... ,  (Subscript[x, n]))  is the polynomial which is the sum of each  monomial in the orbit of the symmetric group (Subscript[S, n])acting on (Subscript[x, α]).  For example, with n = 3,  \(TraditionalForm\`m\_\((2, 1)\)\  = \ \ \(x\_1\^2\) \(x\_\(\(2\)\(\ \)\)\) x\_3\  + \ \ \ \(x\_1\) \(x\_2\^2\) x\_3\  + \ \(x\_1\) \(x\_2\) 
            x\_3\^2\).   Although (Subscript[S, 3])has order 6, there are only three terms in the sum because the orbit of the leading monomial is of size 3.

The computation of monomial symmetric functions is automated by the command monomialSymmetric[X, λ].

\(\(X\  = \ Array[x, \ 3]; 
monomialSymmetric[X, \ {3, 3, 2}]
\)\)

\(\(X\  = \ Array[x, \ 4]; 
monomialSymmetric[X, \ {3, 3, 2}]
\)\)

Expansions in elementary symmetric functions

Any symmetric polynomial can be expanded expressed uniquely as a polynomial in elementary symmetric polynomials.  An algorithm for computing the expansion in elementary symmetric polynomials can be described briefly as follows:  A symmetric polynomial has a leading term, which is the momonial highest in lexicographic order.
If λ = ((Subscript[λ, 1]), (Subscript[λ, 2]), ..., (Subscript[λ, n]))  is the vector of degrees of this leading momonial, then
λ is necessarily a partition.  Let μ denote the transposed partition.  Then the elementary symmetric function (Subscript[ϵ, μ]) has the same leading monomial, and subtracting off (Subscript[ϵ, μ]) gives a symmetric function with lexicographically lower leading monomial.  Continuing this process eventually gives zero.

You can step through this process, without having to do all thel bookkeeping, as shown in the following example.

n = 3; 
X = X = Array[x, n]; 
ϵϵ = Array[ϵ, n]; 
p = x[1]^2 + x[2]^2 + x[3]^2

x[1]^2 + x[2]^2 + x[3]^2

The leading term  is  x[1]^2,  so we should subtract off  (Subscript[ϵ, 1, 1]).

eps[X,  {1, 1}]p1  =  Expand[p  -  eps[X, {1, 1}]]

Now the leading term is (-2) x[1] x[2]  , so we should subtract off  -2 (Subscript[ϵ, 2])

eps[X,  {2}]p2  =  Expand[p1  -  (-2) eps[X, {2}]]

Thus the expansion of     p = x[1]^2 + x[2]^2 + x[3]^2  is ϵ[1]^2 - 2 ϵ[2].
Let's try another example:

p = x[1]^3 + x[2]^3 + x[3]^3
p1 = Expand[p - eps[X, {1, 1, 1}]]

p2  =  Expand[p1  -  (-3) eps[X,  {2, 1}]]

p3  =   Expand[p2  -  (3) eps[X,  {3}]]

\(Thus\ the\ expansion\ of\ \((p = 
            x[1]\^3 + x[2]\^3 + x[3]\^3)\)\ is\ \((ϵ[1]\^3 - 
              3\ ϵ[1]\ ϵ[2] + 3\ ϵ[3])\) . 
          This\ process\ is\ automated\ with\ the\ command\ elementaryExpand[
            p] . Here\ are\ a\ few\ examples . 
          Note\ that\ it\ is\ necessary\ to\ set\ the\ number\ of\ variables\ with\ the\ \(commands : 

n\) = \(NumbVars = 3\); X = Array[x, n];\)

\(n\  = \ \ \(NumbVars = \ 3\); 
X\  = \ Array[x, n]; 

    p\  = \ x[1]^3\  + \ x[2]^3\  + \ x[3]^3\)elementaryExpand[p]

n = NumbVars = 4; 
X = Array[x, n]; 
p = x[1]^4 + x[2]^4 + x[3]^4 + x[4]^4
elementaryExpand[p]

n = NumbVars = 4; 
X = Array[x, n]; 
p = (x[1]^4 + x[2]^4 + x[3]^4 + x[4]^4) (x[1]^2 + x[2]^2 + 
            x[3]^2 + x[4]^2)
elementaryExpand[p]

\(
n\  = \ \(NumbVars\  = \ 5\); 
X\  = \ Array[x, \ n]; 

    p\  = \ monomialSymmetric[X, \ {3, 3, 2}]\)\(elementaryExpand[p]
\)

The discriminant

The discriminant polynomial is defined as follows:

Discr[
        X_] := ((((∏_(i = 1)^(Length[X] - 1))(∏_(j = i + 1)^(Length[X]))(X[[i]] - X[[j]])))^2)

Here is the discriminant polynomial in 4 variables and its expansion in elementary symmetric polynomials.  This would be rather painful to compute by hand.

\(n\  = \ \ \(NumbVars = \ 4\); 
X = Array[x, n]; 
Discr[X]\)elementaryExpand[Discr[X]]

Here is the same thing in 5 variables; even my computer found it somewhat painful to do this computation.

n  =   NumbVars =  5;
X = Array[x, n];
Discr[X]
elementaryExpand[Discr[X]]