Symmetric Functions
system:sage


<h2>Symmetric functions and bases</h2>
<p>by Anne Schilling and Mike Zabrocki</p>
<p>This Sage notebook is a demonstration of the new symmetric function functionality that will soon be merged into sage. Comments are welcome!</p>
<p>We create the ring of symmetric functions over the rationals and build the Schur, homogeneous, elementrary and power sum bases.</p>

{{{id=1|
Sym = SymmetricFunctions(QQ)
s = Sym.schur()
h = Sym.homogeneous()
e = Sym.elementary()
m = Sym.monomial()
p = Sym.powersum()
///
}}}

{{{id=2|
s[2]
///
s[2]
}}}

<p>We can multiply two Schur functions:</p>

{{{id=3|
s[2,1]*s[2]
///
s[2, 2, 1] + s[3, 1, 1] + s[3, 2] + s[4, 1]
}}}

<p>Or we can multiply different bases. Sage automatically coerces into one of the bases.</p>

{{{id=4|
p(s[2,1]*p[2])
///
1/3*p[2, 1, 1, 1] - 1/3*p[3, 2]
}}}

{{{id=21|
f = s[2,1] + s[1] + s[[]]; f.expand(3)
///
x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2 + x0 + x1 + x2 + 1
}}}

{{{id=22|
g = f.expand(3); m.from_polynomial(g)
///
m[] + m[1] + 2*m[1, 1, 1] + m[2, 1]
}}}

<h2>Hopf algebra structure</h2>
<p>For a graded Hopf algebra we have a product, a coproduct, an antipode. The antipode and coproduct play nicely with the product.</p>

{{{id=5|
show(s[2,1].coproduct())
///
<html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}s_{} \otimes s_{2,1} + s_{1} \otimes s_{1,1} + s_{1} \otimes s_{2} + s_{1,1} \otimes s_{1} + s_{2} \otimes s_{1} + s_{2,1} \otimes s_{}</div></html>
}}}

{{{id=10|
m[2,1].coproduct()
///
m[] # m[2, 1] + m[1] # m[2] + m[2] # m[1] + m[2, 1] # m[]
}}}

{{{id=20|
p[2, 1].coproduct()
///
p[] # p[2, 1] + p[1] # p[2] + p[2] # p[1] + p[2, 1] # p[]
}}}

{{{id=11|
s[2,1].antipode()
///
-s[2, 1]
}}}

{{{id=16|
s([3,2,1]).coproduct()
///
s[] # s[3, 2, 1] + s[1] # s[2, 2, 1] + s[1] # s[3, 1, 1] + s[1] # s[3, 2] + s[1, 1] # s[2, 1, 1] + s[1, 1] # s[2, 2] + s[1, 1] # s[3, 1] + s[1, 1, 1] # s[2, 1] + s[2] # s[2, 1, 1] + s[2] # s[2, 2] + s[2] # s[3, 1] + s[2, 1] # s[1, 1, 1] + 2*s[2, 1] # s[2, 1] + s[2, 1] # s[3] + s[2, 1, 1] # s[1, 1] + s[2, 1, 1] # s[2] + s[2, 2] # s[1, 1] + s[2, 2] # s[2] + s[2, 2, 1] # s[1] + s[3] # s[2, 1] + s[3, 1] # s[1, 1] + s[3, 1] # s[2] + s[3, 1, 1] # s[1] + s[3, 2] # s[1] + s[3, 2, 1] # s[]
}}}

{{{id=15|
f = s([3,2,1]).coproduct().monomial_coefficients();f
///
{([2, 1, 1], [1, 1]): 1, ([3, 1, 1], [1]): 1, ([1, 1], [2, 1, 1]): 1, ([2, 1, 1], [2]): 1, ([3, 1], [2]): 1, ([3], [2, 1]): 1, ([2, 2, 1], [1]): 1, ([2, 2], [2]): 1, ([2], [2, 1, 1]): 1, ([2], [3, 1]): 1, ([2, 2], [1, 1]): 1, ([1], [2, 2, 1]): 1, ([2, 1], [3]): 1, ([3, 2, 1], []): 1, ([1], [3, 2]): 1, ([1, 1], [3, 1]): 1, ([1, 1], [2, 2]): 1, ([3, 2], [1]): 1, ([3, 1], [1, 1]): 1, ([], [3, 2, 1]): 1, ([1, 1, 1], [2, 1]): 1, ([2, 1], [1, 1, 1]): 1, ([2], [2, 2]): 1, ([1], [3, 1, 1]): 1, ([2, 1], [2, 1]): 2}
}}}

{{{id=13|
sum( f[nu]*s(nu[0])*s(nu[1]).antipode() for nu in f.keys())
///
0
}}}

{{{id=17|
SymmetricFunctions
///
<class 'sage.combinat.sf.sf.SymmetricFunctions'>
}}}

{{{id=19|
( ( h[2,1] * ( 1 + 3 * h[2,1]) ) + s[2]. antipode()) . coproduct()
///
h[] # h[1, 1] - h[] # h[2] + h[] # h[2, 1] + 3*h[] # h[2, 2, 1, 1] + h[1] # h[1] + h[1] # h[1, 1] + h[1] # h[2] + 6*h[1] # h[2, 1, 1, 1] + 6*h[1] # h[2, 2, 1] + h[1, 1] # h[] + h[1, 1] # h[1] + 3*h[1, 1] # h[1, 1, 1, 1] + 12*h[1, 1] # h[2, 1, 1] + 3*h[1, 1] # h[2, 2] + 6*h[1, 1, 1] # h[1, 1, 1] + 6*h[1, 1, 1] # h[2, 1] + 3*h[1, 1, 1, 1] # h[1, 1] - h[2] # h[] + h[2] # h[1] + 6*h[2] # h[2, 1, 1] + h[2, 1] # h[] + 6*h[2, 1] # h[1, 1, 1] + 12*h[2, 1] # h[2, 1] + 12*h[2, 1, 1] # h[1, 1] + 6*h[2, 1, 1] # h[2] + 6*h[2, 1, 1, 1] # h[1] + 3*h[2, 2] # h[1, 1] + 6*h[2, 2, 1] # h[1] + 3*h[2, 2, 1, 1] # h[]
}}}

<h2>Hall-Littlewood symmetric functions</h2>
<p>Hall-Littlewood symmetric functions form a basis of the ring of symmetric functions over $\mathbb{Q}[t]$</p>

{{{id=24|
Sym = SymmetricFunctions(FractionField(QQ['t']))
HL = Sym.hall_littlewood()
HL
///
Hall-Littlewood polynomials over Fraction Field of Univariate Polynomial Ring in t over Rational Field
}}}

{{{id=25|
HL.base_ring()
///
Fraction Field of Univariate Polynomial Ring in t over Rational Field
}}}

{{{id=26|
Qp = HL.Qp()
s = Sym.schur()
s[1]*Qp[2,1]
///
s[2, 1, 1] + s[2, 2] + (t+1)*s[3, 1] + t*s[4]
}}}

<p>Now we specialize the parameter $t$:</p>

{{{id=28|
t = Sym.base_ring().gen()
HL = Sym.hall_littlewood(t=t^2)
///
}}}

{{{id=30|
Qp = HL.Qp()
s = Sym.schur()
s[1]*Qp[2,1]
///
s[2, 1, 1] + s[2, 2] + (t^2+1)*s[3, 1] + t^2*s[4]
}}}

{{{id=31|
HL = Sym.hall_littlewood(t=1)
Qp = HL.Qp()
s[1]*Qp[2,1]
///
s[2, 1, 1] + s[2, 2] + 2*s[3, 1] + s[4]
}}}

{{{id=32|
h = Sym.homogeneous()
h(Qp[3,2,1].plethysm((1-t)*s[1]))
///
(t^6-3*t^5+3*t^4-t^3)*h[1, 1, 1, 1, 1, 1] + (-3*t^6+7*t^5-3*t^4-3*t^3+2*t^2)*h[2, 1, 1, 1, 1] + (2*t^6-3*t^5-2*t^4+4*t^3-t)*h[2, 2, 1, 1] + (t^6-2*t^5+t^4-t^3+2*t^2-t)*h[3, 1, 1, 1] + (-t^6+t^5+t^4-t^2-t+1)*h[3, 2, 1]
}}}

<p>The bases $P$ and $Q'$ are dual to each other:</p>

{{{id=35|
HL = Sym.hall_littlewood()
P = HL.P()
Qp = HL.Qp()
///
}}}

{{{id=36|
M = matrix( [[P(la).scalar(Qp(mu)) for la in Partitions(4)] for mu in Partitions(4)] )
M
///
[1 0 0 0 0]
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]
}}}

<h2>Macdonald symmetric functions</h2>
<p>&nbsp;</p>

{{{id=38|
Sym = SymmetricFunctions(FractionField(QQ['q,t']))
Mac = Sym.macdonald()
Ht = Mac.Ht()
s = Sym.schur()
s(Ht[2,1])
///
q*t*s[1, 1, 1] + (q+t)*s[2, 1] + s[3]
}}}

{{{id=61|
(q,t) = Sym.base_ring().gens()
///
}}}

{{{id=39|
f = Ht[3]+Ht[2,1]+Ht[1,1,1]; f
///
McdHt[1, 1, 1] + McdHt[2, 1] + McdHt[3]
}}}

{{{id=40|
f.nabla(q=1/q,t=1/t).nabla()
///
McdHt[1, 1, 1] + McdHt[2, 1] + McdHt[3]
}}}

{{{id=41|
s[3,2].nabla()
///
(q^6*t^4+q^5*t^5+q^4*t^6)*s[1, 1, 1, 1, 1] + (q^6*t^3+2*q^5*t^4+2*q^4*t^5+q^3*t^6+q^4*t^4)*s[2, 1, 1, 1] + (q^5*t^3+2*q^4*t^4+q^3*t^5)*s[2, 2, 1] + (q^5*t^3+q^4*t^4+q^3*t^5+q^4*t^3+q^3*t^4)*s[3, 1, 1] + (q^4*t^3+q^3*t^4)*s[3, 2] + q^3*t^3*s[4, 1]
}}}

<h2>LLT symmetric functions</h2>

{{{id=42|
Sym = SymmetricFunctions(FractionField(QQ['t']))
s = Sym.schur()
LLT = Sym.llt(3)
LLT
///
LLT polynomials at level 3 over Fraction Field of Univariate Polynomial Ring in t over Rational Field
}}}

{{{id=44|
s(LLT.cospin([3,2,1]))
///
t*s[1, 1] + s[2]
}}}

<h2>$k$-Schur functions</h2>
<p>$k$-Schur functions form a basis of the subspace spanned by $&lt;h_1,\ldots,h_k&gt;$.</p>
<p>&nbsp;</p>

{{{id=45|
Sym = SymmetricFunctions(QQ)
s = Sym.schur()
ks = Sym.kschur(3,t=1)
ks
///
3-Schur functions with t=1
}}}

{{{id=47|
ks.realization_of()
///
3-bounded Symmetric Functions over Rational Field
}}}

<p>When $t=1$, then the $k$-bounded subspace is in fact a subring.</p>

{{{id=48|
ks[2,1]*ks[2,1]
///
ks3[2, 2, 1, 1] + ks3[2, 2, 2] + ks3[3, 1, 1, 1]
}}}

{{{id=49|
ks(s([3,2,1]))
///
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_39.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("a3MocyhbMywyLDFdKSk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "/private/var/folders/nR/nRzFEby2FV8wW6eFUOQcgU+++TI/-Tmp-/tmppW15_x/___code___.py", line 3, in <module>
    exec compile(u'ks(s([_sage_const_3 ,_sage_const_2 ,_sage_const_1 ]))' + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "parent.pyx", line 1058, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7943)
  File "morphism.pyx", line 243, in sage.categories.morphism.SetMorphism._call_ (sage/categories/morphism.c:4059)
  File "/Applications/sage-5.0/local/lib/python2.7/site-packages/sage/categories/modules_with_basis.py", line 1609, in preimage
    raise ValueError, "%s is not in the image of %s"%(f, self)
ValueError: s[3, 2, 1] is not in the image of Generic morphism:
  From: 3-Schur functions with t=1
  To:   Symmetric Function Algebra over Rational Field, Schur symmetric functions as basis
}}}

<p>For general $t$ we can also build the $k$-Schur functions living in the $k$-bounded subspace given by $\mathcal{L} \{ s_\lambda^{(k)}[X;t] \} = \mathcal{L} \{ s_\lambda[X/(1-t)] \} = \mathcal{L} \{ Q'_\lambda[X;t] \} = \mathcal{L} \{ H_\lambda[X;q,t] \}$ where everywhere $\lambda_1 \le k$.</p>

{{{id=53|
Sym = SymmetricFunctions(FractionField(QQ['q,t']))
Mac = Sym.macdonald()
H = Mac.H()
ks = Sym.kschur(3)
s = Sym.s()
///
}}}

{{{id=54|
ks(H[3,3])
///
q^6*ks3[1, 1, 1, 1, 1, 1] + (q^5*t+q^5+q^4*t+q^4)*ks3[2, 1, 1, 1, 1] + (q^4+q^3*t+q^3+q^2)*ks3[2, 2, 1, 1] + (q^4*t+q^3*t+q^3+q^2*t)*ks3[2, 2, 2] + (q^4*t+q^3*t^2+2*q^3*t+q^3+q^2*t)*ks3[3, 1, 1, 1] + (q^2*t+q^2+q*t+q)*ks3[3, 2, 1] + ks3[3, 3]
}}}

{{{id=55|
ks(H[3,2,1])
///
q^4*ks3[1, 1, 1, 1, 1, 1] + (q^4*t^2+q^3*t+q^3+q^2)*ks3[2, 1, 1, 1, 1] + (q^3*t^2+q^2*t+q^2+q)*ks3[2, 2, 1, 1] + (q^3*t^2+q^2*t^2+q^2*t+q)*ks3[2, 2, 2] + (q^3*t^3+q^3*t^2+q^2*t^2+q^2*t+q*t+q)*ks3[3, 1, 1, 1] + (q^2*t^2+q*t^2+q*t+1)*ks3[3, 2, 1] + t*ks3[3, 3]
}}}

{{{id=56|
H(ks[3,1])
///
(q^2/(q^2*t^5-q*t^3-q*t^2+1))*McdH[1, 1, 1, 1] + ((-q^3*t^2-q^3*t+q^2*t^2+q)/(q^4*t^6-q^3*t^5-q^3*t^3-q^2*t^4+q^2*t^2+q*t^3+q*t-1))*McdH[2, 1, 1] + ((-q*t+q)/(q^3*t^4-2*q^2*t^3-q^2*t^2+q*t^2+2*q*t-1))*McdH[2, 2] + (1/(q^3*t^3-q^2*t^2-q*t+1))*McdH[3, 1]
}}}

{{{id=9|
ks(ks[3,2]+s[2])
///
ks3[2] + ks3[3, 2]
}}}

{{{id=57|

///
}}}

{{{id=63|

///
}}}