Skip to content

Commit 225852c

Browse files
committed
fix some doctests in demo-symmetric-functions
1 parent b2045ec commit 225852c

File tree

2 files changed

+72
-138
lines changed

2 files changed

+72
-138
lines changed

demo-number-theory.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Demonstration: Sage combines the power of multiple software
55
===========================================================
66

7+
.. linkall
8+
79
(taken from a talk from William Stein)
810

911
Construct an elliptic curve using John Cremona's table::

demo-symmetric-functions.rst

Lines changed: 70 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -11,82 +11,67 @@ Demonstration: Symmetric functions
1111

1212
::
1313

14-
sage: SymmetricFunctions?
14+
sage: SymmetricFunctions? # not tested
1515

16-
::
16+
The ring of symmetric functions over the rational numbers::
1717

18-
sage: S = SymmetricFunctions(QQ) # The ring of symmetric functions over the rational numbers
18+
sage: S = SymmetricFunctions(QQ)
1919

20+
Typing 'objectname.<tab>' gives a lot of information about what
21+
you can do with the object::
2022

21-
::
23+
sage: S. # not tested
2224

23-
sage: # Typing 'objectname.<tab>' gives a lot of information about what
24-
sage: # you can do with the object
25-
sage: S.
25+
The usual bases for symmetric functions::
2626

27-
::
28-
29-
sage: # The usual bases for symmetric functions
3027
sage: p = S.powersum(); s = S.schur(); m = S.monomial(); h = S.homogeneous(); e = S.elementary()
3128

29+
The 'forgotten basis' is dual to the elementary basis::
3230

33-
::
34-
35-
sage: # The 'forgotten basis' is dual to the elementary basis
3631
sage: f = e.dual_basis()
3732

33+
Different ways of entering symmetric functions::
3834

39-
::
40-
41-
sage: # Different ways of entering symmetric functions
4235
sage: p[2,1] == p([2,1]) and p[2,1] == p(Partition([2,1]))
4336
True
4437

45-
::
38+
Changing bases::
4639

47-
sage: # Changing bases
4840
sage: p(s[2,1])
4941
1/3*p[1, 1, 1] - 1/3*p[3]
5042

51-
::
43+
Sums of different bases are automatically converted to a single basis::
5244

53-
sage: # Sums of different bases are automatically converted to a single basis
5445
sage: h[3] + s[3] + e[3] + p[3]
5546
2*h[1, 1, 1] - 5*h[2, 1] + 6*h[3]
5647

57-
::
48+
Littlewood-Richardson coefficients are relatively fast::
5849

59-
sage: # Littlewood-Richardson coefficients are relatively fast
6050
sage: timeit('s[10]^4')
61-
5 loops, best of 3:..
51+
5 loops, best of 3:...
6252

63-
::
53+
Changing bases::
6454

65-
sage: # Changing bases
66-
sage: time h(s[10]^4);
55+
sage: h(s[10]^4);
6756
h[10, 10, 10, 10]
68-
Time: CPU 1.07 s, Wall: 1.08 s
6957

70-
::
58+
We get an arbitrary symmetric function to demonstrate some functionality::
7159

72-
sage: # We get an arbitrary symmetric function to demonstrate some functionality
73-
sage: foo = h.an_element()
60+
sage: foo = 1/2*h([]) + 3*h([1, 1, 1]) + 2*h([2, 1, 1])
7461
sage: foo
7562
1/2*h[] + 3*h[1, 1, 1] + 2*h[2, 1, 1]
7663

77-
::
64+
The omega involution::
7865

79-
sage: foo.omega() # The omega involution
66+
sage: foo.omega()
8067
1/2*h[] + 3*h[1, 1, 1] + 2*h[1, 1, 1, 1] - 2*h[2, 1, 1]
8168

82-
::
83-
8469
sage: e(foo.omega())
8570
1/2*e[] + 3*e[1, 1, 1] + 2*e[2, 1, 1]
8671

87-
::
72+
The Hall scalar product::
8873

89-
sage: foo.scalar(s[3,1]) # The Hall scalar product
74+
sage: foo.scalar(s[3,1])
9075
4
9176

9277
::
@@ -99,60 +84,44 @@ Demonstration: Symmetric functions
9984
sage: foo.skew_by(e[2,1])
10085
9*h[] + 10*h[1]
10186

102-
::
87+
We can define skew partition directly::
10388

104-
sage: # We can define skew partition directly
10589
sage: mu = Partition([3,2])/Partition([2,1])
10690
sage: mu
107-
[[3, 2], [2, 1]]
108-
109-
::
91+
[3, 2] / [2, 1]
11092

11193
sage: s(mu)
11294
s[1, 1] + s[2]
11395

114-
::
96+
We can expand a symmetric function in monomials::
11597

116-
sage: # We can expand a symmetric function in monomials
11798
sage: s(mu).expand(3)
11899
x0^2 + 2*x0*x1 + x1^2 + 2*x0*x2 + 2*x1*x2 + x2^2
119100

120-
::
101+
Or we can choose our alphabet::
121102

122-
sage: # Or we can choose our alphabet
123103
sage: s(mu).expand(3,alphabet=['a','b','c'])
124104
a^2 + 2*a*b + b^2 + 2*a*c + 2*b*c + c^2
125105

126-
::
127-
128106
sage: mu = Partition([32,18,16,4,1])/Partition([14,3,2,1])
129107
sage: la = Partition([33,19,17,4,1])/Partition([15,4,3,1])
130108

131-
132-
::
133-
134109
sage: (s(la) - s(mu)).is_schur_positive()
135110
True
136111

137-
::
138-
139112
sage: foo.kronecker_product(foo)
140113
1/4*h[] + 54*h[1, 1, 1] + 20*h[1, 1, 1, 1] + 8*h[2, 1, 1]
141114

142-
::
143-
144115
sage: foo.plethysm(h[3])
145116
1/2*h[] + 3*h[3, 3, 3] + 2*h[4, 3, 3, 2] - 2*h[5, 3, 3, 1] + 2*h[6, 3, 3]
146117

147118
::
148119

149-
sage: foo.inner_plethysm?
150-
120+
sage: foo.inner_plethysm? # not tested
151121

152-
::
122+
The transition matrix from the Schur basis to the power basis
123+
Try s.transition_matrix? for more information::
153124

154-
sage: # The transition matrix from the Schur basis to the power basis
155-
sage: # Try s.transition_matrix? for more information
156125
sage: s.transition_matrix(m,5)
157126
[1 1 1 1 1 1 1]
158127
[0 1 1 2 2 3 4]
@@ -162,9 +131,8 @@ Demonstration: Symmetric functions
162131
[0 0 0 0 0 1 4]
163132
[0 0 0 0 0 0 1]
164133

165-
::
134+
The sum of degree 6 Schur functions whose first part is even::
166135

167-
sage: # The sum of degree 6 Schur functions whose first part is even
168136
sage: foo = sum([s[mu] for mu in Partitions(6) if mu[0]%2 == 0])
169137
sage: foo
170138
s[2, 1, 1, 1, 1] + s[2, 2, 1, 1] + s[2, 2, 2] + s[4, 1, 1] + s[4, 2] + s[6]
@@ -175,16 +143,13 @@ Demonstration: Symmetric functions
175143
....: r""" Remove the last part from a partition """
176144
....: return Partition(mu[:-1])
177145

146+
We can apply this map to all the partitions appearing in 'foo'::
178147

179-
::
180-
181-
sage: # We can apply this map to all the partitions appearing in 'foo'
182148
sage: foo.map_support(remove_last_part)
183149
s[] + s[2, 1, 1, 1] + s[2, 2] + s[2, 2, 1] + s[4] + s[4, 1]
184150

185-
::
151+
Warning! This gives different results depending on the basis in which foo is expressed::
186152

187-
sage: # Warning! This gives different results depending on the basis in which foo is expressed
188153
sage: h(foo).map_support(remove_last_part)
189154
3*h[] + h[2, 1, 1, 1] + h[2, 2] - 2*h[2, 2, 1] - 2*h[3, 1, 1] + 2*h[3, 2] - 2*h[4] + 4*h[4, 1] - 4*h[5]
190155

@@ -193,62 +158,47 @@ Demonstration: Symmetric functions
193158
sage: foo.map_support(remove_last_part) == h(foo).map_support(remove_last_part)
194159
False
195160

196-
::
161+
We can easily get specific coefficients::
197162

198-
sage: # We can easily get specific coefficients
199163
sage: foo.coefficient([4,2])
200164
1
201165

202-
::
203-
204-
sage: # There are many forms of symmetric functions in sage.
205-
sage: # They do not (yet) all appear under 'SymmetricFunctions'
206-
sage: # These are the ~H[X;q,t] often called the 'modified Macdonald polynomials'
207-
sage: Ht = MacdonaldPolynomialsHt(QQ)
208-
166+
There are many forms of symmetric functions in sage.
167+
These are the `~H[X;q,t]` often called the 'modified Macdonald polynomials'::
209168

169+
sage: S = SymmetricFunctions(FractionField(QQ['q','t']))
170+
sage: Ht = S.macdonald().Ht(); Ht
171+
Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald Ht basis
172+
sage: p = S.powersum(); s = S.schur(); m = S.monomial(); h = S.homogeneous(); e = S.elementary();
210173
::
211174

212175
sage: s(Ht([3,2]))
213-
Traceback (most recent call last):
214-
...
215-
TypeError
176+
q^4*t^2*s[1, 1, 1, 1, 1] + (q^4*t+q^3*t^2+q^3*t+q^2*t^2)*s[2, 1, 1, 1] + (q^4+q^3*t+q^2*t^2+q^2*t+q*t^2)*s[2, 2, 1] + (q^3*t+q^3+2*q^2*t+q*t^2+q*t)*s[3, 1, 1] + (q^3+q^2*t+q^2+q*t+t^2)*s[3, 2] + (q^2+q*t+q+t)*s[4, 1] + s[5]
216177

217178
::
218179

219180
sage: Ht.base_ring()
220181
Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field
221182

222-
::
223-
224-
sage: S.base_ring()
225-
Rational Field
226-
227183
::
228184

229185
sage: q
230186
Traceback (most recent call last):
231187
...
232188
NameError: name 'q' is not defined
233189

234-
::
190+
The following is a shortcut notation (based on Magma).
191+
It defines R to be the polynomial ring in the variables
192+
'q' and 't' over the rational numbers, and makes these variables
193+
available for use::
235194

236-
sage: # The following is a shortcut notation (based on Magma).
237-
sage: # It defines R to be the polynomial ring in the variables
238-
sage: # 'q' and 't' over the rational numbers, and makes these variables
239-
sage: # available for use
240195
sage: R.<q,t> = Frac(ZZ['q','t'])
241196

242-
243-
::
244-
245197
sage: S = SymmetricFunctions(R)
246-
247-
::
248-
249198
sage: p = S.powersum(); s = S.schur(); m = S.monomial(); h = S.homogeneous(); e = S.elementary();
250-
sage: Ht = MacdonaldPolynomialsHt(R)
251199

200+
sage: Ht = S.macdonald().Ht(); Ht
201+
Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Integer Ring in the Macdonald Ht basis
252202

253203
::
254204

@@ -258,80 +208,62 @@ Demonstration: Symmetric functions
258208
::
259209

260210
sage: latex(_)
261-
q^{4} t^{2}s_{1,1,1,1,1} + \left(q^{4} t + q^{3} t^{2} + q^{3} t + q^{2} t^{2}\right)s_{2,1,1,1} + \left(q^{4} + q^{3} t + q^{2} t^{2} + q^{2} t + q t^{2}\right)s_{2,2,1} + \left(q^{3} t + q^{3} + 2 q^{2} t + q t^{2} + q t\right)s_{3,1,1} + \left(q^{3} + q^{2} t + q^{2} + q t + t^{2}\right)s_{3,2} + \left(q^{2} + q t + q + t\right)s_{4,1} + s_{5}
211+
q^{4} t^{2} s_{1,1,1,1,1} + \left(q^{4} t + q^{3} t^{2} + q^{3} t + q^{2} t^{2}\right) s_{2,1,1,1} + \left(q^{4} + q^{3} t + q^{2} t^{2} + q^{2} t + q t^{2}\right) s_{2,2,1} + \left(q^{3} t + q^{3} + 2 q^{2} t + q t^{2} + q t\right) s_{3,1,1} + \left(q^{3} + q^{2} t + q^{2} + q t + t^{2}\right) s_{3,2} + \left(q^{2} + q t + q + t\right) s_{4,1} + s_{5}
262212

263213
::
264214

265215
sage: s(Ht([3,2])).coefficient([2,1,1,1]).subs({q:q^(-1), t:t^(-1)}) *q^5 * t^5
266216
q^3*t^3 + q^2*t^4 + q^2*t^3 + q*t^4
267217

268-
::
218+
We can also create the ring of Macdonald Polynomials
219+
using different parameters::
269220

270-
sage: # We can also create the ring of Macdonald Polynomials
271-
sage: # using different parameters
272221
sage: A.<a,b> = QQ[]
273-
sage: P = MacdonaldPolynomialsP(FractionField(A),a,b)
274-
sage: sa = SymmetricFunctions(FractionField(A)).schur()
275-
222+
sage: S = SymmetricFunctions(FractionField(A))
223+
sage: sa = S.schur()
224+
sage: P = S.macdonald(a,b).P()
276225

277226
::
278227

279228
sage: sa(P[2,1])
280229
((a*b-b^2+a-b)/(-a*b^2+1))*s[1, 1, 1] + s[2, 1]
281230

282-
::
283-
284-
sage: # Press <tab> after the following to see the different
285-
sage: # variants of Macdonald polynomials in sage
286-
sage: MacdonaldPolynomials
287-
Traceback (most recent call last):
288-
...
289-
NameError: name 'MacdonaldPolynomials' is not defined
231+
Press <tab> after the following to see the different
232+
variants of Macdonald polynomials in sage
290233

291-
::
234+
sage: Sym = SymmetricFunctions(FractionField(QQ['q',t']))
235+
sage: J = Sym.macdonald()
236+
sage: J.TAB # not tested
292237

293-
sage: # Press <tab> after the following to see the different
294-
sage: # variants of Jack polynomials in sage
295-
sage: JackPolynomials
238+
Press <tab> after the following to see the different variants of Jack polynomials in sage::
296239

240+
sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
241+
sage: J = Sym.jack()
242+
sage: J.TAB # not tested
297243

298-
::
244+
Press <tab> after the following to see the different
245+
variants of Hall-Littlewood polynomials in sage
299246

300-
sage: # Press <tab> after the following to see the different
301-
sage: # variants of Hall-Littlewood polynomials in sage
247+
sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
248+
sage: H = Sym.hall_littlewood()
302249
sage: HallLittlewood
303250

251+
Now some examples with `k`-Schur functions::
304252

305-
::
306-
307-
sage: ks2 = kSchurFunctions(R,2,t=R(t))
308-
sage: s = SymmetricFunctions(R).schur()
309-
253+
sage: Sym = SymmetricFunctions(QQ['t'])
254+
sage: KB = Sym.kBoundedSubspace(2)
255+
sage: ks2 = KB.kschur()
256+
sage: s = Sym.schur()
310257

311258
::
312259

313260
sage: s(ks2[2,2,1])
314261
s[2, 2, 1] + t*s[3, 1, 1] + (t^2+t)*s[3, 2] + (t^3+t^2)*s[4, 1] + t^4*s[5]
315262

316-
::
317-
318263
sage: ks2(s[1])
319264
ks2[1]
320265

321-
::
322-
323266
sage: ks2(s[3])
324267
Traceback (most recent call last):
325268
...
326-
ValueError: s[3] is not in the space spanned by k-Schur Functions at level 2 over Multivariate Polynomial Ring in q, t over Rational Field.
327-
328-
::
329-
330-
sage: # Warning: Not well supported yet!
331-
sage: SchubertPolynomialRing
332-
333-
334-
::
335-
336-
sage: # Warning: Not well supported yet!
337-
sage: LLT
269+
ValueError: s[3] is not in the image

0 commit comments

Comments
 (0)