passagemath-repl 10.5.28__py3-none-any.whl → 10.5.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/kernel.json +1 -0
  2. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo-64x64.png +0 -0
  3. passagemath_repl-10.5.29.data/data/share/jupyter/kernels/sagemath/logo.svg +352 -0
  4. {passagemath_repl-10.5.28.dist-info → passagemath_repl-10.5.29.dist-info}/METADATA +3 -3
  5. {passagemath_repl-10.5.28.dist-info → passagemath_repl-10.5.29.dist-info}/RECORD +95 -24
  6. {passagemath_repl-10.5.28.dist-info → passagemath_repl-10.5.29.dist-info}/top_level.txt +1 -0
  7. sage/ext_data/all__sagemath_repl.py +1 -0
  8. sage/interfaces/all__sagemath_repl.py +1 -0
  9. sage/repl/ipython_kernel/install.py +6 -8
  10. sage/tests/books/__init__.py +2 -0
  11. sage/tests/books/computational-mathematics-with-sagemath/__init__.py +1 -0
  12. sage/tests/books/computational-mathematics-with-sagemath/calculus_doctest.py +549 -0
  13. sage/tests/books/computational-mathematics-with-sagemath/combinat_doctest.py +1053 -0
  14. sage/tests/books/computational-mathematics-with-sagemath/domaines_doctest.py +443 -0
  15. sage/tests/books/computational-mathematics-with-sagemath/float_doctest.py +477 -0
  16. sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py +254 -0
  17. sage/tests/books/computational-mathematics-with-sagemath/graphtheory_doctest.py +418 -0
  18. sage/tests/books/computational-mathematics-with-sagemath/integration_doctest.py +290 -0
  19. sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py +454 -0
  20. sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py +421 -0
  21. sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py +234 -0
  22. sage/tests/books/computational-mathematics-with-sagemath/mpoly_doctest.py +560 -0
  23. sage/tests/books/computational-mathematics-with-sagemath/nonlinear_doctest.py +490 -0
  24. sage/tests/books/computational-mathematics-with-sagemath/numbertheory_doctest.py +155 -0
  25. sage/tests/books/computational-mathematics-with-sagemath/polynomes_doctest.py +405 -0
  26. sage/tests/books/computational-mathematics-with-sagemath/premierspas_doctest.py +180 -0
  27. sage/tests/books/computational-mathematics-with-sagemath/programmation_doctest.py +662 -0
  28. sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py +392 -0
  29. sage/tests/books/computational-mathematics-with-sagemath/sol/__init__.py +1 -0
  30. sage/tests/books/computational-mathematics-with-sagemath/sol/calculus_doctest.py +264 -0
  31. sage/tests/books/computational-mathematics-with-sagemath/sol/combinat_doctest.py +217 -0
  32. sage/tests/books/computational-mathematics-with-sagemath/sol/domaines_doctest.py +59 -0
  33. sage/tests/books/computational-mathematics-with-sagemath/sol/float_doctest.py +141 -0
  34. sage/tests/books/computational-mathematics-with-sagemath/sol/graphique_doctest.py +105 -0
  35. sage/tests/books/computational-mathematics-with-sagemath/sol/graphtheory_doctest.py +53 -0
  36. sage/tests/books/computational-mathematics-with-sagemath/sol/integration_doctest.py +56 -0
  37. sage/tests/books/computational-mathematics-with-sagemath/sol/linalg_doctest.py +56 -0
  38. sage/tests/books/computational-mathematics-with-sagemath/sol/linsolve_doctest.py +25 -0
  39. sage/tests/books/computational-mathematics-with-sagemath/sol/lp_doctest.py +47 -0
  40. sage/tests/books/computational-mathematics-with-sagemath/sol/mpoly_doctest.py +115 -0
  41. sage/tests/books/computational-mathematics-with-sagemath/sol/nonlinear_doctest.py +111 -0
  42. sage/tests/books/computational-mathematics-with-sagemath/sol/numbertheory_doctest.py +167 -0
  43. sage/tests/books/computational-mathematics-with-sagemath/sol/polynomes_doctest.py +107 -0
  44. sage/tests/books/computational-mathematics-with-sagemath/sol/recequadiff_doctest.py +58 -0
  45. sage/tests/books/judson-abstract-algebra/__init__.py +1 -0
  46. sage/tests/books/judson-abstract-algebra/actions-sage-exercises.py +51 -0
  47. sage/tests/books/judson-abstract-algebra/actions-sage.py +173 -0
  48. sage/tests/books/judson-abstract-algebra/algcodes-sage.py +130 -0
  49. sage/tests/books/judson-abstract-algebra/boolean-sage.py +269 -0
  50. sage/tests/books/judson-abstract-algebra/cosets-sage-exercises.py +87 -0
  51. sage/tests/books/judson-abstract-algebra/cosets-sage.py +170 -0
  52. sage/tests/books/judson-abstract-algebra/crypt-sage.py +151 -0
  53. sage/tests/books/judson-abstract-algebra/cyclic-sage.py +450 -0
  54. sage/tests/books/judson-abstract-algebra/domains-sage.py +163 -0
  55. sage/tests/books/judson-abstract-algebra/fields-sage.py +299 -0
  56. sage/tests/books/judson-abstract-algebra/finite-sage.py +108 -0
  57. sage/tests/books/judson-abstract-algebra/galois-sage.py +484 -0
  58. sage/tests/books/judson-abstract-algebra/groups-sage.py +280 -0
  59. sage/tests/books/judson-abstract-algebra/homomorph-sage-exercises.py +65 -0
  60. sage/tests/books/judson-abstract-algebra/homomorph-sage.py +200 -0
  61. sage/tests/books/judson-abstract-algebra/integers-sage.py +197 -0
  62. sage/tests/books/judson-abstract-algebra/isomorph-sage.py +172 -0
  63. sage/tests/books/judson-abstract-algebra/normal-sage.py +133 -0
  64. sage/tests/books/judson-abstract-algebra/permute-sage.py +319 -0
  65. sage/tests/books/judson-abstract-algebra/poly-sage.py +300 -0
  66. sage/tests/books/judson-abstract-algebra/rings-sage.py +413 -0
  67. sage/tests/books/judson-abstract-algebra/sets-sage.py +163 -0
  68. sage/tests/books/judson-abstract-algebra/struct-sage.py +63 -0
  69. sage/tests/books/judson-abstract-algebra/sylow-sage.py +250 -0
  70. sage/tests/books/judson-abstract-algebra/vect-sage-exercises.py +48 -0
  71. sage/tests/books/judson-abstract-algebra/vect-sage.py +211 -0
  72. sage/tests/memcheck/__init__.py +1 -0
  73. sage/tests/memcheck/run_tests.py +25 -0
  74. sage/tests/memcheck/run_tests_in_valgrind.py +36 -0
  75. sage/tests/memcheck/symbolic_expression.py +12 -0
  76. sage/tests/memcheck/verify_no_leak.py +28 -0
  77. sage/tests/all.py +0 -0
  78. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-cachegrind +0 -0
  79. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-callgrind +0 -0
  80. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-cleaner +0 -0
  81. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-coverage +0 -0
  82. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-eval +0 -0
  83. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-fixdoctests +0 -0
  84. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-inline-fortran +0 -0
  85. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-ipynb2rst +0 -0
  86. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-ipython +0 -0
  87. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-massif +0 -0
  88. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-notebook +0 -0
  89. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-omega +0 -0
  90. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-preparse +0 -0
  91. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-run +0 -0
  92. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-run-cython +0 -0
  93. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-runtests +0 -0
  94. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-startuptime.py +0 -0
  95. {passagemath_repl-10.5.28.data → passagemath_repl-10.5.29.data}/scripts/sage-valgrind +0 -0
  96. {passagemath_repl-10.5.28.dist-info → passagemath_repl-10.5.29.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1053 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ This file (./combinat_doctest.sage) was *autogenerated* from ./combinat.tex,
4
+ with sagetex.sty version 2011/05/27 v2.3.1.
5
+ It contains the contents of all the sageexample environments from this file.
6
+ You should be able to doctest this file with:
7
+ sage -t ./combinat_doctest.sage
8
+ It is always safe to delete this file; it is not used in typesetting your
9
+ document.
10
+
11
+ Sage example in ./combinat.tex, line 147::
12
+
13
+ sage: Suits = Set(["Hearts", "Diamonds", "Spades", "Clubs"])
14
+ sage: Values = Set([2, 3, 4, 5, 6, 7, 8, 9, 10,
15
+ ....: "Jack", "Queen", "King", "Ace"])
16
+ sage: Cards = cartesian_product([Values, Suits])
17
+
18
+ Sage example in ./combinat.tex, line 167::
19
+
20
+ sage: Suits.cardinality()
21
+ 4
22
+ sage: Values.cardinality()
23
+ 13
24
+ sage: Cards.cardinality()
25
+ 52
26
+
27
+ Sage example in ./combinat.tex, line 184::
28
+
29
+ sage: Cards.random_element() # random
30
+ (6, 'Clubs')
31
+
32
+ Sage example in ./combinat.tex, line 196::
33
+
34
+ sage: Set([Cards.random_element(), Cards.random_element()]) # random
35
+ {(2, 'Hearts'), (4, 'Spades')}
36
+
37
+ Sage example in ./combinat.tex, line 221::
38
+
39
+ sage: Hands = Subsets(Cards, 5)
40
+ sage: Hands.random_element() # random
41
+ {(4, 'Hearts'), (9, 'Diamonds'), (8, 'Spades'),
42
+ (9, 'Clubs'), (7, 'Hearts')}
43
+
44
+ Sage example in ./combinat.tex, line 236::
45
+
46
+ sage: binomial(52, 5)
47
+ 2598960
48
+
49
+ Sage example in ./combinat.tex, line 250::
50
+
51
+ sage: Hands.cardinality()
52
+ 2598960
53
+
54
+ Sage example in ./combinat.tex, line 283::
55
+
56
+ sage: Flushes = cartesian_product([Subsets(Values, 5), Suits])
57
+ sage: Flushes.cardinality()
58
+ 5148
59
+
60
+ Sage example in ./combinat.tex, line 305::
61
+
62
+ sage: Flushes.cardinality() / Hands.cardinality()
63
+ 33/16660
64
+
65
+ Sage example in ./combinat.tex, line 310::
66
+
67
+ sage: 1000.0 * Flushes.cardinality() / Hands.cardinality()
68
+ 1.98079231692677
69
+
70
+ Sage example in ./combinat.tex, line 345::
71
+
72
+ sage: def is_flush(hand):
73
+ ....: return len(set(suit for (val, suit) in hand)) == 1
74
+
75
+ Sage example in ./combinat.tex, line 354::
76
+
77
+ sage: n = 10000
78
+ sage: nflush = 0
79
+ sage: for i in range(n):
80
+ ....: hand = Hands.random_element()
81
+ ....: if is_flush(hand):
82
+ ....: nflush += 1
83
+ sage: print(n, nflush) # random
84
+ 10000, 18
85
+
86
+ Sage example in ./combinat.tex, line 600::
87
+
88
+ sage: C, z = var('C, z'); sys = [ C == z + C*C ]
89
+
90
+ Sage example in ./combinat.tex, line 605::
91
+
92
+ sage: sol = solve(sys, C, solution_dict=True); sol
93
+ [{C: -1/2*sqrt(-4*z + 1) + 1/2}, {C: 1/2*sqrt(-4*z + 1) + 1/2}]
94
+ sage: s0 = sol[0][C]; s1 = sol[1][C]
95
+
96
+ Sage example in ./combinat.tex, line 612::
97
+
98
+ sage: s0.series(z, 6)
99
+ 1*z + 1*z^2 + 2*z^3 + 5*z^4 + 14*z^5 + Order(z^6)
100
+ sage: s1.series(z, 6)
101
+ 1 + (-1)*z + (-1)*z^2 + (-2)*z^3 + (-5)*z^4 + (-14)*z^5 + Order(z^6)
102
+
103
+ Sage example in ./combinat.tex, line 622::
104
+
105
+ sage: C = s0
106
+
107
+ Sage example in ./combinat.tex, line 627::
108
+
109
+ sage: C.series(z, 11)
110
+ 1*z + 1*z^2 + 2*z^3 + 5*z^4 + 14*z^5 + 42*z^6 +
111
+ 132*z^7 + 429*z^8 + 1430*z^9 + 4862*z^10 + Order(z^11)
112
+
113
+ Sage example in ./combinat.tex, line 634::
114
+
115
+ sage: C.series(z, 101).coefficient(z,100)
116
+ 227508830794229349661819540395688853956041682601541047340
117
+
118
+ Sage example in ./combinat.tex, line 654::
119
+
120
+ sage: L.<z> = LazyPowerSeriesRing(QQ)
121
+
122
+ Sage example in ./combinat.tex, line 661::
123
+
124
+ sage: C = L.undefined(valuation=1)
125
+ sage: C.define( z + C * C )
126
+
127
+ Sage example in ./combinat.tex, line 666::
128
+
129
+ sage: [C.coefficient(i) for i in range(11)]
130
+ [0, 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862]
131
+
132
+ Sage example in ./combinat.tex, line 674::
133
+
134
+ sage: C.coefficient(100)
135
+ 227508830794229349661819540395688853956041682601541047340
136
+
137
+ Sage example in ./combinat.tex, line 684::
138
+
139
+ sage: C.coefficient(200)
140
+ 129013158064429114001222907669676675134349530552728882499810851598901419013348319045534580850847735528275750122188940
141
+
142
+ Sage example in ./combinat.tex, line 693::
143
+
144
+ sage: z = var('z'); C = s0; C
145
+ -1/2*sqrt(-4*z + 1) + 1/2
146
+
147
+ Sage example in ./combinat.tex, line 703::
148
+
149
+ sage: derivative(C, z, 1)
150
+ 1/sqrt(-4*z + 1)
151
+ sage: derivative(C, z, 2)
152
+ 2/(-4*z + 1)^(3/2)
153
+ sage: derivative(C, z, 3)
154
+ 12/(-4*z + 1)^(5/2)
155
+
156
+ Sage example in ./combinat.tex, line 716::
157
+
158
+ sage: def d(n): return derivative(C, n).subs(z=0)
159
+
160
+ Sage example in ./combinat.tex, line 721::
161
+
162
+ sage: [ (d(n+1) / d(n)) for n in range(1,17) ]
163
+ [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62]
164
+
165
+ Sage example in ./combinat.tex, line 737::
166
+
167
+ sage: def c(n): return 1/n*binomial(2*(n-1),n-1)
168
+ sage: [c(k) for k in range(1, 11)]
169
+ [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862]
170
+ sage: [catalan_number(k-1) for k in range(1, 11)]
171
+ [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862]
172
+
173
+ Sage example in ./combinat.tex, line 814::
174
+
175
+ sage: x, y, z = var('x, y, z')
176
+ sage: P = function('P')(x, y); C = function('C')(z)
177
+ sage: equation = P(x=z, y=C) == 0
178
+ sage: diff(equation, z)
179
+ diff(C(z), z)*D[1](P)(z, C(z)) + D[0](P)(z, C(z)) == 0
180
+
181
+ Sage example in ./combinat.tex, line 834::
182
+
183
+ sage: P = y^2 - y + x; Px = diff(P, x); Py = diff(P, y)
184
+ sage: - Px / Py
185
+ -1/(2*y - 1)
186
+
187
+ Sage example in ./combinat.tex, line 847::
188
+
189
+ sage: Qx = QQ['x'].fraction_field(); Qxy = Qx['y']
190
+ sage: R = Qxy.quo(P); R
191
+ Univariate Quotient Polynomial Ring in ybar
192
+ over Fraction Field of Univariate Polynomial Ring in x
193
+ over Rational Field with modulus y^2 - y + x
194
+
195
+ Sage example in ./combinat.tex, line 863::
196
+
197
+ sage: fraction = R( - Px / Py ); fraction
198
+ Traceback (most recent call last):
199
+ ...
200
+ TypeError: unable to convert -1/(2*y - 1) to an element of Univariate Quotient Polynomial Ring in ybar over Fraction Field of Univariate Polynomial Ring in x over Rational Field with modulus y^2 - y + x
201
+
202
+ Sage example in ./combinat.tex, line 869::
203
+
204
+ sage: fraction = - R(Px) / R(Py); fraction
205
+ (1/2/(x - 1/4))*ybar - 1/4/(x - 1/4)
206
+
207
+ Sage example in ./combinat.tex, line 877::
208
+
209
+ sage: fraction = fraction.lift(); fraction
210
+ (1/2/(x - 1/4))*y - 1/4/(x - 1/4)
211
+ sage: fraction(x=z, y=C)
212
+ 2*C(z)/(4*z - 1) - 1/(4*z - 1)
213
+
214
+ Sage example in ./combinat.tex, line 894::
215
+
216
+ sage: equadiff = diff(C,z) == fraction(x=z, y=C); equadiff
217
+ diff(C(z), z) == 2*C(z)/(4*z - 1) - 1/(4*z - 1)
218
+ sage: equadiff = equadiff.simplify_rational()
219
+ sage: equadiff = equadiff * equadiff.rhs().denominator()
220
+ sage: equadiff = equadiff - equadiff.rhs()
221
+ sage: equadiff
222
+ (4*z - 1)*diff(C(z), z) - 2*C(z) + 1 == 0
223
+
224
+ Sage example in ./combinat.tex, line 913::
225
+
226
+ sage: Cf = sage.symbolic.function_factory.function('C')
227
+ sage: equadiff.substitute_function(Cf, lambda z: s0(z=z))
228
+ (4*z - 1)/sqrt(-4*z + 1) + sqrt(-4*z + 1) == 0
229
+
230
+ Sage example in ./combinat.tex, line 923::
231
+
232
+ sage: Cf = sage.symbolic.function_factory.function('C')
233
+ sage: bool(equadiff.substitute_function(Cf, lambda z: s0(z=z)))
234
+ True
235
+
236
+ Sage example in ./combinat.tex, line 959::
237
+
238
+ sage: def C(n): return n if n <= 1 else (4*n-6)/n * C(n-1)
239
+ sage: [ C(i) for i in range(10) ]
240
+ [0, 1, 1, 2, 5, 14, 42, 132, 429, 1430]
241
+
242
+ Sage example in ./combinat.tex, line 1078::
243
+
244
+ sage: binomial(4, 2)
245
+ 6
246
+
247
+ Sage example in ./combinat.tex, line 1088::
248
+
249
+ sage: S = Subsets([1,2,3,4], 2); S.cardinality()
250
+ 6
251
+
252
+ Sage example in ./combinat.tex, line 1097::
253
+
254
+ sage: S.list()
255
+ [{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}]
256
+ sage: S.random_element() # random
257
+ {1, 4}
258
+ sage: S.an_element()
259
+ {2, 3}
260
+
261
+ Sage example in ./combinat.tex, line 1118::
262
+
263
+ sage: S.unrank(4)
264
+ {2, 4}
265
+ sage: S[4]
266
+ {2, 4}
267
+
268
+ Sage example in ./combinat.tex, line 1133::
269
+
270
+ sage: s = S([2,4]); S.rank(s)
271
+ 4
272
+
273
+ Sage example in ./combinat.tex, line 1145::
274
+
275
+ sage: E = Set([1,2,3,4])
276
+ sage: S = Subsets(Subsets(Subsets(E))); S.cardinality()
277
+ 2003529930406846464979072351560255750447825475569751419265016...736
278
+
279
+ Sage example in ./combinat.tex, line 1167::
280
+
281
+ sage: S.cardinality().ndigits()
282
+ 19729
283
+
284
+ Sage example in ./combinat.tex, line 1179::
285
+
286
+ sage: sorted(sorted(sorted(x) for x in y) for y in S.unrank(237102123) )
287
+ [[[], [1, 2, 4], [1, 3], [1, 3, 4], [1, 4], [2], [2, 3], [2, 4], [4]],
288
+ [[], [1, 2, 4], [1, 3], [2, 4], [3, 4]]]
289
+
290
+ Sage example in ./combinat.tex, line 1237::
291
+
292
+ sage: P5 = Partitions(5); P5
293
+ Partitions of the integer 5
294
+
295
+ Sage example in ./combinat.tex, line 1243::
296
+
297
+ sage: P5.cardinality()
298
+ 7
299
+
300
+ Sage example in ./combinat.tex, line 1251::
301
+
302
+ sage: P5.list()
303
+ [[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1],
304
+ [1, 1, 1, 1, 1]]
305
+
306
+ Sage example in ./combinat.tex, line 1279::
307
+
308
+ sage: Partitions(100000).cardinality()
309
+ 27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519
310
+
311
+ Sage example in ./combinat.tex, line 1291::
312
+
313
+ sage: P7 = Partitions(7); p = P7.unrank(5); p
314
+ [4, 2, 1]
315
+
316
+ Sage example in ./combinat.tex, line 1295::
317
+
318
+ sage: type(p)
319
+ <class 'sage.combinat.partition.Partitions_n_with_category.element_class'>
320
+
321
+ Sage example in ./combinat.tex, line 1302::
322
+
323
+ sage: print(p.ferrers_diagram())
324
+ ****
325
+ **
326
+ *
327
+
328
+ Sage example in ./combinat.tex, line 1315::
329
+
330
+ sage: Partition([4,2,1])
331
+ [4, 2, 1]
332
+ sage: P7([4,2,1])
333
+ [4, 2, 1]
334
+
335
+ Sage example in ./combinat.tex, line 1330::
336
+
337
+ sage: WeightedIntegerVectors(8, [2,3,5]).list()
338
+ [[0, 1, 1], [1, 2, 0], [4, 0, 0]]
339
+
340
+ Sage example in ./combinat.tex, line 1343::
341
+
342
+ sage: C5 = Compositions(5); C5
343
+ Compositions of 5
344
+ sage: C5.cardinality()
345
+ 16
346
+ sage: C5.list()
347
+ [[1, 1, 1, 1, 1], [1, 1, 1, 2], [1, 1, 2, 1], [1, 1, 3],
348
+ [1, 2, 1, 1], [1, 2, 2], [1, 3, 1], [1, 4], [2, 1, 1, 1],
349
+ [2, 1, 2], [2, 2, 1], [2, 3], [3, 1, 1], [3, 2], [4, 1], [5]]
350
+
351
+ Sage example in ./combinat.tex, line 1360::
352
+
353
+ sage: [ Compositions(n).cardinality() for n in range(10) ]
354
+ [1, 1, 2, 4, 8, 16, 32, 64, 128, 256]
355
+
356
+ Sage example in ./combinat.tex, line 1368::
357
+
358
+ sage: x = var('x'); sum( x^len(c) for c in C5 )
359
+ x^5 + 4*x^4 + 6*x^3 + 4*x^2 + x
360
+
361
+ Sage example in ./combinat.tex, line 1414::
362
+
363
+ sage: C = IntegerRange(3, 21, 2); C
364
+ {3, 5, ..., 19}
365
+ sage: C.cardinality()
366
+ 9
367
+ sage: C.list()
368
+ [3, 5, 7, 9, 11, 13, 15, 17, 19]
369
+
370
+ Sage example in ./combinat.tex, line 1424::
371
+
372
+ sage: C = Permutations(4); C
373
+ Standard permutations of 4
374
+ sage: C.cardinality()
375
+ 24
376
+ sage: C.list()
377
+ [[1, 2, 3, 4], [1, 2, 4, 3], [1, 3, 2, 4], [1, 3, 4, 2],
378
+ [1, 4, 2, 3], [1, 4, 3, 2], [2, 1, 3, 4], [2, 1, 4, 3],
379
+ [2, 3, 1, 4], [2, 3, 4, 1], [2, 4, 1, 3], [2, 4, 3, 1],
380
+ [3, 1, 2, 4], [3, 1, 4, 2], [3, 2, 1, 4], [3, 2, 4, 1],
381
+ [3, 4, 1, 2], [3, 4, 2, 1], [4, 1, 2, 3], [4, 1, 3, 2],
382
+ [4, 2, 1, 3], [4, 2, 3, 1], [4, 3, 1, 2], [4, 3, 2, 1]]
383
+
384
+ Sage example in ./combinat.tex, line 1455::
385
+
386
+ sage: C = SetPartitions([1,2,3]); C
387
+ Set partitions of {1, 2, 3}
388
+ sage: C.cardinality()
389
+ 5
390
+ sage: C.list() # random
391
+ [{{1, 2, 3}}, {{1}, {2, 3}}, {{1, 3}, {2}}, {{1, 2}, {3}}, {{1}, {2}, {3}}]
392
+
393
+ Sage example in ./combinat.tex, line 1466::
394
+
395
+ sage: C = Posets(8); C
396
+ Posets containing 8 elements
397
+ sage: C.cardinality()
398
+ 16999
399
+
400
+ Sage example in ./combinat.tex, line 1475::
401
+
402
+ sage: show(C.unrank(20))
403
+ Finite poset containing 8 elements
404
+
405
+ Sage example in ./combinat.tex, line 1496::
406
+
407
+ sage: len(list(graphs(5)))
408
+ 34
409
+
410
+ Sage example in ./combinat.tex, line 1504::
411
+
412
+ sage: for g in graphs(5, lambda G: G.size() <= 4):
413
+ ....: show(g)
414
+
415
+ Sage example in ./combinat.tex, line 1528::
416
+
417
+ sage: G = DihedralGroup(4); G
418
+ Dihedral group of order 8 as a permutation group
419
+ sage: G.cardinality()
420
+ 8
421
+ sage: sorted(G.list(), key=str)
422
+ [(), (1,2)(3,4), (1,2,3,4), (1,3), (1,3)(2,4), (1,4)(2,3), (1,4,3,2), (2,4)]
423
+
424
+ Sage example in ./combinat.tex, line 1542::
425
+
426
+ sage: import sage.repl.display.util
427
+ sage: sage.repl.display.util.TallListFormatter.MAX_COLUMN = 67
428
+
429
+ Sage example in ./combinat.tex, line 1547::
430
+
431
+ sage: C = MatrixSpace(GF(2), 2); C.list()
432
+ [
433
+ [0 0] [1 0] [0 1] [0 0] [0 0] [1 1] [1 0] [1 0] [0 1]
434
+ [0 0], [0 0], [0 0], [1 0], [0 1], [0 0], [1 0], [0 1], [1 0],
435
+ <BLANKLINE>
436
+ [0 1] [0 0] [1 1] [1 1] [1 0] [0 1] [1 1]
437
+ [0 1], [1 1], [1 0], [0 1], [1 1], [1 1], [1 1]
438
+ ]
439
+
440
+ Sage example in ./combinat.tex, line 1557::
441
+
442
+ sage: C.cardinality()
443
+ 16
444
+
445
+ Sage example in ./combinat.tex, line 1634::
446
+
447
+ sage: [ i^2 for i in [1, 3, 7] ]
448
+ [1, 9, 49]
449
+
450
+ Sage example in ./combinat.tex, line 1640::
451
+
452
+ sage: [ i^2 for i in range(1,10) ]
453
+ [1, 4, 9, 16, 25, 36, 49, 64, 81]
454
+
455
+ Sage example in ./combinat.tex, line 1651::
456
+
457
+ sage: [ i^2 for i in range(1,10) if is_prime(i) ]
458
+ [4, 9, 25, 49]
459
+
460
+ Sage example in ./combinat.tex, line 1661::
461
+
462
+ sage: [ (i,j) for i in range(1,6) for j in range(1,i) ]
463
+ [(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3),
464
+ (5, 1), (5, 2), (5, 3), (5, 4)]
465
+
466
+ Sage example in ./combinat.tex, line 1668::
467
+
468
+ sage: [[binomial(n, i) for i in range(n+1)] for n in range(10)]
469
+ [[1],
470
+ [1, 1],
471
+ [1, 2, 1],
472
+ [1, 3, 3, 1],
473
+ [1, 4, 6, 4, 1],
474
+ [1, 5, 10, 10, 5, 1],
475
+ [1, 6, 15, 20, 15, 6, 1],
476
+ [1, 7, 21, 35, 35, 21, 7, 1],
477
+ [1, 8, 28, 56, 70, 56, 28, 8, 1],
478
+ [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]]
479
+
480
+ Sage example in ./combinat.tex, line 1718::
481
+
482
+ sage: it = (binomial(3, i) for i in range(4))
483
+
484
+ Sage example in ./combinat.tex, line 1724::
485
+
486
+ sage: next(it)
487
+ 1
488
+ sage: next(it)
489
+ 3
490
+ sage: next(it)
491
+ 3
492
+ sage: next(it)
493
+ 1
494
+
495
+ Sage example in ./combinat.tex, line 1736::
496
+
497
+ sage: next(it)
498
+ Traceback (most recent call last):
499
+ ...
500
+ StopIteration
501
+
502
+ Sage example in ./combinat.tex, line 1754::
503
+
504
+ sage: for s in Subsets(3): s
505
+ {}
506
+ {1}
507
+ {2}
508
+ {3}
509
+ {1, 2}
510
+ {1, 3}
511
+ {2, 3}
512
+ {1, 2, 3}
513
+
514
+ Sage example in ./combinat.tex, line 1765::
515
+
516
+ sage: [ s.cardinality() for s in Subsets(3) ]
517
+ [0, 1, 1, 1, 2, 2, 2, 3]
518
+
519
+ Sage example in ./combinat.tex, line 1772::
520
+
521
+ sage: sum( [ binomial(8, i) for i in range(9) ] )
522
+ 256
523
+
524
+ Sage example in ./combinat.tex, line 1784::
525
+
526
+ sage: sum( binomial(8, i) for i in range(9) )
527
+ 256
528
+
529
+ Sage example in ./combinat.tex, line 1811::
530
+
531
+ sage: list(binomial(8, i) for i in range(9))
532
+ [1, 8, 28, 56, 70, 56, 28, 8, 1]
533
+ sage: tuple(binomial(8, i) for i in range(9))
534
+ (1, 8, 28, 56, 70, 56, 28, 8, 1)
535
+
536
+ Sage example in ./combinat.tex, line 1823::
537
+
538
+ sage: all([True, True, True, True])
539
+ True
540
+ sage: all([True, False, True, True])
541
+ False
542
+ sage: any([False, False, False, False])
543
+ False
544
+ sage: any([False, False, True, False])
545
+ True
546
+
547
+ Sage example in ./combinat.tex, line 1839::
548
+
549
+ sage: all( is_odd(p) for p in range(3,100) if is_prime(p) )
550
+ True
551
+
552
+ Sage example in ./combinat.tex, line 1852::
553
+
554
+ sage: def mersenne(p): return 2^p - 1
555
+ sage: [ is_prime(p) for p in range(1000) if is_prime(mersenne(p)) ]
556
+ [True, True, True, True, True, True, True, True, True, True,
557
+ True, True, True, True]
558
+
559
+ Sage example in ./combinat.tex, line 1867::
560
+
561
+ sage: all( [ is_prime(mersenne(p)) for p in range(1000) if is_prime(p)] )
562
+ False
563
+ sage: all( is_prime(mersenne(p)) for p in range(1000) if is_prime(p) )
564
+ False
565
+
566
+ Sage example in ./combinat.tex, line 1879::
567
+
568
+ sage: exists( (p for p in range(1000) if is_prime(p)),
569
+ ....: lambda p: not is_prime(mersenne(p)) )
570
+ (True, 11)
571
+
572
+ Sage example in ./combinat.tex, line 1895::
573
+
574
+ sage: counter_examples = \
575
+ ....: (p for p in range(1000)
576
+ ....: if is_prime(p) and not is_prime(mersenne(p)))
577
+ sage: next(counter_examples)
578
+ 11
579
+ sage: next(counter_examples)
580
+ 23
581
+
582
+ Sage example in ./combinat.tex, line 1909::
583
+
584
+ sage: cubes = [t**3 for t in range(-999,1000)]
585
+ sage: exists([(x,y) for x in cubes for y in cubes], lambda xy: sum(xy) == 218) # long time
586
+ (True, (-125, 343))
587
+ sage: exists(((x,y) for x in cubes for y in cubes), lambda xy: sum(xy) == 218) # long time
588
+ (True, (-125, 343))
589
+
590
+ Sage example in ./combinat.tex, line 1927::
591
+
592
+ sage: x = var('x'); sum( x^len(s) for s in Subsets(8) )
593
+ x^8 + 8*x^7 + 28*x^6 + 56*x^5 + 70*x^4 + 56*x^3 + 28*x^2 + 8*x + 1
594
+
595
+ Sage example in ./combinat.tex, line 1931::
596
+
597
+ sage: sum( x^p.length() for p in Permutations(3) )
598
+ x^3 + 2*x^2 + 2*x + 1
599
+
600
+ Sage example in ./combinat.tex, line 1940::
601
+
602
+ sage: P = Permutations(5)
603
+ sage: all( p in P for p in P )
604
+ True
605
+
606
+ Sage example in ./combinat.tex, line 1945::
607
+
608
+ sage: for p in GL(2, 2): print(p); print("-----")
609
+ [1 0]
610
+ [0 1]
611
+ -----
612
+ [0 1]
613
+ [1 0]
614
+ -----
615
+ [0 1]
616
+ [1 1]
617
+ -----
618
+ [1 1]
619
+ [0 1]
620
+ -----
621
+ [1 1]
622
+ [1 0]
623
+ -----
624
+ [1 0]
625
+ [1 1]
626
+ -----
627
+
628
+ Sage example in ./combinat.tex, line 1966::
629
+
630
+ sage: for p in Partitions(3): print(p)
631
+ [3]
632
+ [2, 1]
633
+ [1, 1, 1]
634
+
635
+ Sage example in ./combinat.tex, line 1987::
636
+
637
+ sage: exists( Primes(), lambda p: not is_prime(mersenne(p)) )
638
+ (True, 11)
639
+
640
+ Sage example in ./combinat.tex, line 2026::
641
+
642
+ sage: import itertools
643
+
644
+ Sage example in ./combinat.tex, line 2033::
645
+
646
+ sage: list(Permutations(3))
647
+ [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
648
+
649
+ Sage example in ./combinat.tex, line 2039::
650
+
651
+ sage: list(enumerate(Permutations(3)))
652
+ [(0, [1, 2, 3]), (1, [1, 3, 2]), (2, [2, 1, 3]),
653
+ (3, [2, 3, 1]), (4, [3, 1, 2]), (5, [3, 2, 1])]
654
+
655
+ Sage example in ./combinat.tex, line 2048::
656
+
657
+ sage: list(itertools.islice(Permutations(3), 1r, 4r))
658
+ [[1, 3, 2], [2, 1, 3], [2, 3, 1]]
659
+
660
+ Sage example in ./combinat.tex, line 2054::
661
+
662
+ sage: list(map(lambda z: z.cycle_type(), Permutations(3)))
663
+ [[1, 1, 1], [2, 1], [2, 1], [3], [3], [2, 1]]
664
+
665
+ Sage example in ./combinat.tex, line 2060::
666
+
667
+ sage: list(filter(lambda z: z.has_pattern([1,2]),
668
+ ....: Permutations(3)))
669
+ [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2]]
670
+
671
+ Sage example in ./combinat.tex, line 2069::
672
+
673
+ sage: list(map(attrcall("cycle_type"), Permutations(3)))
674
+ [[1, 1, 1], [2, 1], [2, 1], [3], [3], [2, 1]]
675
+
676
+ Sage example in ./combinat.tex, line 2084::
677
+
678
+ sage: def f(n):
679
+ ....: for i in range(n):
680
+ ....: yield i
681
+
682
+ Sage example in ./combinat.tex, line 2097::
683
+
684
+ sage: g = f(4)
685
+ sage: next(g)
686
+ 0
687
+ sage: next(g)
688
+ 1
689
+ sage: next(g)
690
+ 2
691
+ sage: next(g)
692
+ 3
693
+
694
+ Sage example in ./combinat.tex, line 2108::
695
+
696
+ sage: next(g)
697
+ Traceback (most recent call last):
698
+ ...
699
+ StopIteration
700
+
701
+ Sage example in ./combinat.tex, line 2116::
702
+
703
+ sage: [ x for x in f(5) ]
704
+ [0, 1, 2, 3, 4]
705
+
706
+ Sage example in ./combinat.tex, line 2130::
707
+
708
+ sage: def words(alphabet, l):
709
+ ....: if l == 0: yield []
710
+ ....: else:
711
+ ....: for word in words(alphabet, l-1):
712
+ ....: for l in alphabet: yield word + [l]
713
+ sage: [ w for w in words(['a','b'], 3) ]
714
+ [['a', 'a', 'a'], ['a', 'a', 'b'], ['a', 'b', 'a'], ['a', 'b', 'b'],
715
+ ['b', 'a', 'a'], ['b', 'a', 'b'], ['b', 'b', 'a'], ['b', 'b', 'b']]
716
+
717
+ Sage example in ./combinat.tex, line 2142::
718
+
719
+ sage: sum(1 for w in words(['a','b','c','d'], 10))
720
+ 1048576
721
+
722
+ Sage example in ./combinat.tex, line 2169::
723
+
724
+ sage: def dyck_words(l):
725
+ ....: if l == 0: yield ''
726
+ ....: else:
727
+ ....: for k in range(l):
728
+ ....: for w1 in dyck_words(k):
729
+ ....: for w2 in dyck_words(l-k-1):
730
+ ....: yield '(' + w1 + ')' + w2
731
+
732
+ Sage example in ./combinat.tex, line 2180::
733
+
734
+ sage: list(dyck_words(4))
735
+ ['()()()()', '()()(())', '()(())()', '()(()())', '()((()))',
736
+ '(())()()', '(())(())', '(()())()', '((()))()', '(()()())',
737
+ '(()(()))', '((())())', '((()()))', '(((())))']
738
+
739
+ Sage example in ./combinat.tex, line 2188::
740
+
741
+ sage: [ sum(1 for w in dyck_words(l)) for l in range(10) ]
742
+ [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862]
743
+
744
+ Sage example in ./combinat.tex, line 2208::
745
+
746
+ sage: BT = BinaryTree
747
+ sage: BT()
748
+ .
749
+ sage: t = BT([BT([BT(), BT([BT(),BT()])]), BT()]); t
750
+ [[., [., .]], .]
751
+
752
+ Sage example in ./combinat.tex, line 2261::
753
+
754
+ sage: C = cartesian_product([Compositions(8), Permutations(20)]); C
755
+ The Cartesian product of (Compositions of 8, Standard permutations of 20)
756
+ sage: C.cardinality()
757
+ 311411457046609920000
758
+
759
+ Sage example in ./combinat.tex, line 2274::
760
+
761
+ sage: C.random_element() # random
762
+ ([2, 3, 2, 1], [10, 6, 11, 13, 14, 3, 4, 19, 5, 12, 7, 18, 15, 8, 20, 1, 17, 2, 9, 16])
763
+
764
+ Sage example in ./combinat.tex, line 2288::
765
+
766
+ sage: G = DihedralGroup(4)
767
+ sage: H = cartesian_product([G,G])
768
+ sage: H.cardinality()
769
+ 64
770
+ sage: H in Sets().Enumerated().Finite()
771
+ True
772
+ sage: H in Groups()
773
+ True
774
+
775
+ Sage example in ./combinat.tex, line 2305::
776
+
777
+ sage: C = DisjointUnionEnumeratedSets([Compositions(4),Permutations(3)])
778
+ sage: C
779
+ Disjoint union of Family (Compositions of 4, Standard permutations of 3)
780
+ sage: C.cardinality()
781
+ 14
782
+ sage: C.list()
783
+ [[1, 1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 3], [2, 1, 1], [2, 2], [3, 1],
784
+ [4], [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
785
+
786
+ Sage example in ./combinat.tex, line 2328::
787
+
788
+ sage: F = Family(NonNegativeIntegers(), Permutations); F
789
+ Lazy family (<class 'sage.combinat.permutation.Permutations'>(i))_{i in Non negative integers}
790
+ sage: F.keys()
791
+ Non negative integers
792
+ sage: F[1000]
793
+ Standard permutations of 1000
794
+
795
+ Sage example in ./combinat.tex, line 2339::
796
+
797
+ sage: U = DisjointUnionEnumeratedSets(F); U
798
+ Disjoint union of
799
+ Lazy family (<class 'sage.combinat.permutation.Permutations'>(i))_{i in Non negative integers}
800
+
801
+ Sage example in ./combinat.tex, line 2346::
802
+
803
+ sage: U.cardinality()
804
+ +Infinity
805
+
806
+ Sage example in ./combinat.tex, line 2372::
807
+
808
+ sage: U = Permutations(); U
809
+ Standard permutations
810
+
811
+ Sage example in ./combinat.tex, line 2450::
812
+
813
+ sage: IntegerVectors(10, 3, min_part = 2, max_part = 5,
814
+ ....: inner = [2, 4, 2]).list()
815
+ [[4, 4, 2], [3, 5, 2], [3, 4, 3], [2, 5, 3], [2, 4, 4]]
816
+
817
+ Sage example in ./combinat.tex, line 2459::
818
+
819
+ sage: Compositions(5, max_part = 3,
820
+ ....: min_length = 2, max_length = 3).list()
821
+ [[3, 2], [3, 1, 1], [2, 3], [2, 2, 1], [2, 1, 2], [1, 3, 1],
822
+ [1, 2, 2], [1, 1, 3]]
823
+
824
+ Sage example in ./combinat.tex, line 2467::
825
+
826
+ sage: Partitions(5, max_slope = -1).list()
827
+ [[5], [4, 1], [3, 2]]
828
+
829
+ Sage example in ./combinat.tex, line 2484::
830
+
831
+ sage: IntegerListsLex(10, length=3, min_part = 2, max_part = 5,
832
+ ....: floor = [2, 4, 2]).list()
833
+ [[4, 4, 2], [3, 5, 2], [3, 4, 3], [2, 5, 3], [2, 4, 4]]
834
+
835
+ Sage example in ./combinat.tex, line 2489::
836
+
837
+ sage: IntegerListsLex(5, min_part = 1, max_part = 3,
838
+ ....: min_length = 2, max_length = 3).list()
839
+ [[3, 2], [3, 1, 1], [2, 3], [2, 2, 1], [2, 1, 2], [1, 3, 1],
840
+ [1, 2, 2], [1, 1, 3]]
841
+
842
+ Sage example in ./combinat.tex, line 2495::
843
+
844
+ sage: IntegerListsLex(5, min_part = 1, max_slope = -1).list()
845
+ [[5], [4, 1], [3, 2]]
846
+
847
+ Sage example in ./combinat.tex, line 2499::
848
+
849
+ sage: list(Compositions(5, max_length=2))
850
+ [[5], [4, 1], [3, 2], [2, 3], [1, 4]]
851
+
852
+ Sage example in ./combinat.tex, line 2503::
853
+
854
+ sage: list(IntegerListsLex(5, max_length=2, min_part=1))
855
+ [[5], [4, 1], [3, 2], [2, 3], [1, 4]]
856
+
857
+ Sage example in ./combinat.tex, line 2625::
858
+
859
+ sage: A = random_matrix(ZZ, 6, 3, x=7)
860
+ sage: L = LatticePolytope(A.rows())
861
+ sage: L.points() # random
862
+ M(1, 4, 3),
863
+ M(6, 4, 1),
864
+ ...
865
+ M(3, 5, 5)
866
+ in 3-d lattice M
867
+ sage: L.points().cardinality() # random
868
+ 23
869
+
870
+ Sage example in ./combinat.tex, line 2637::
871
+
872
+ sage: L.points()
873
+ M(...),
874
+ M(...),
875
+ ...
876
+ M(...)
877
+ in 3-d lattice M
878
+
879
+ Sage example in ./combinat.tex, line 2647::
880
+
881
+ sage: L.plot3d()
882
+ Graphics3d Object
883
+
884
+ Sage example in ./combinat.tex, line 2688::
885
+
886
+ sage: from sage.combinat.species.library import *
887
+ sage: o = var('o')
888
+
889
+ Sage example in ./combinat.tex, line 2697::
890
+
891
+ sage: BT = CombinatorialSpecies(min=1)
892
+ sage: Leaf = SingletonSpecies()
893
+ sage: BT.define( Leaf + (BT*BT) )
894
+
895
+ Sage example in ./combinat.tex, line 2707::
896
+
897
+ sage: BT5 = BT.isotypes([o]*5); BT5.cardinality()
898
+ 14
899
+ sage: BT5.list()
900
+ [o*(o*(o*(o*o))), o*(o*((o*o)*o)), o*((o*o)*(o*o)), o*((o*(o*o))*o),
901
+ o*(((o*o)*o)*o), (o*o)*(o*(o*o)), (o*o)*((o*o)*o), (o*(o*o))*(o*o),
902
+ ((o*o)*o)*(o*o), (o*(o*(o*o)))*o, (o*((o*o)*o))*o, ((o*o)*(o*o))*o,
903
+ ((o*(o*o))*o)*o, (((o*o)*o)*o)*o]
904
+
905
+ Sage example in ./combinat.tex, line 2727::
906
+
907
+ sage: g = BT.isotype_generating_series(); g
908
+ z + z^2 + 2*z^3 + 5*z^4 + 14*z^5 + 42*z^6 + 132*z^7 + O(z^8)
909
+
910
+ Sage example in ./combinat.tex, line 2733::
911
+
912
+ sage: g[100]
913
+ 227508830794229349661819540395688853956041682601541047340
914
+
915
+ Sage example in ./combinat.tex, line 2743::
916
+
917
+ sage: Eps = EmptySetSpecies(); Z0 = SingletonSpecies()
918
+ sage: Z1 = Eps*SingletonSpecies()
919
+ sage: FW = CombinatorialSpecies()
920
+ sage: FW.define(Eps + Z0*FW + Z1*Eps + Z1*Z0*FW)
921
+
922
+ Sage example in ./combinat.tex, line 2752::
923
+
924
+ sage: L = FW.isotype_generating_series()[:15]; L
925
+ [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]
926
+
927
+ Sage example in ./combinat.tex, line 2769::
928
+
929
+ sage: FW3 = FW.isotypes([o]*3)
930
+ sage: FW3.list()
931
+ [o*(o*(o*{})), o*(o*(({}*o)*{})), o*((({}*o)*o)*{}),
932
+ (({}*o)*o)*(o*{}), (({}*o)*o)*(({}*o)*{})]
933
+
934
+ Sage example in ./combinat.tex, line 3007::
935
+
936
+ sage: [len(list(graphs(n, property = lambda G: G.is_planar())))
937
+ ....: for n in range(7)]
938
+ [1, 1, 2, 4, 11, 33, 142]
939
+
940
+ Sage example in ./combinat.tex, line 3066::
941
+
942
+ sage: V = [1,2,3,4]
943
+ sage: F = Subsets(V, 2); F.list()
944
+ [{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}]
945
+
946
+ Sage example in ./combinat.tex, line 3072::
947
+
948
+ sage: S = SymmetricGroup(V)
949
+
950
+ Sage example in ./combinat.tex, line 3077::
951
+
952
+ sage: def on_pair(sigma, pair):
953
+ ....: return Set(sigma(i) for i in pair)
954
+ sage: def on_pairs(sigma):
955
+ ....: return [on_pair(sigma, e) for e in F]
956
+
957
+ Sage example in ./combinat.tex, line 3086::
958
+
959
+ sage: sigma = S([(1,2,3,4)]); sigma
960
+ (1,2,3,4)
961
+ sage: for e in F: print((e, on_pair(sigma, e)))
962
+ ({1, 2}, {2, 3})
963
+ ({1, 3}, {2, 4})
964
+ ({1, 4}, {1, 2})
965
+ ({2, 3}, {3, 4})
966
+ ({2, 4}, {1, 3})
967
+ ({3, 4}, {1, 4})
968
+ sage: on_pairs(sigma)
969
+ [{2, 3}, {2, 4}, {1, 2}, {3, 4}, {1, 3}, {1, 4}]
970
+
971
+ Sage example in ./combinat.tex, line 3102::
972
+
973
+ sage: G = PermutationGroup([ on_pairs(sigma) for sigma in S.gens() ],
974
+ ....: domain=F)
975
+
976
+ Sage example in ./combinat.tex, line 3109::
977
+
978
+ sage: Z = G.cycle_index(); Z
979
+ 1/24*p[1, 1, 1, 1, 1, 1] + 3/8*p[2, 2, 1, 1] + 1/3*p[3, 3] + 1/4*p[4, 2]
980
+
981
+ Sage example in ./combinat.tex, line 3117::
982
+
983
+ sage: sorted(sigma for sigma in G if sigma.cycle_type() == [4,2])
984
+ [({1,2},{1,3},{3,4},{2,4})({1,4},{2,3}),
985
+ ({1,2},{1,4},{3,4},{2,3})({1,3},{2,4}),
986
+ ({1,2},{2,3},{3,4},{1,4})({1,3},{2,4}),
987
+ ({1,2},{2,4},{3,4},{1,3})({1,4},{2,3}),
988
+ ({1,2},{3,4})({1,3},{1,4},{2,4},{2,3}),
989
+ ({1,2},{3,4})({1,3},{2,3},{2,4},{1,4})]
990
+
991
+ Sage example in ./combinat.tex, line 3136::
992
+
993
+ sage: q,t = QQ['q,t'].gens()
994
+ sage: p = Z.expand(2, [q,t]); p
995
+ q^6 + q^5*t + 2*q^4*t^2 + 3*q^3*t^3 + 2*q^2*t^4 + q*t^5 + t^6
996
+
997
+ Sage example in ./combinat.tex, line 3146::
998
+
999
+ sage: p(q=1,t=1)
1000
+ 11
1001
+
1002
+ Sage example in ./combinat.tex, line 3159::
1003
+
1004
+ sage: q = var('q')
1005
+ sage: H = sum( c * prod( 1/(1-q^k) for k in partition )
1006
+ ....: for partition, c in Z )
1007
+ sage: H
1008
+ 1/3/(q^3 - 1)^2 + 1/4/((q^4 - 1)*(q^2 - 1))
1009
+ + 3/8/((q^2 - 1)^2*(q - 1)^2) + 1/24/(q - 1)^6
1010
+
1011
+ Sage example in ./combinat.tex, line 3171::
1012
+
1013
+ sage: H.series(q)
1014
+ 1 + 1*q + 3*q^2 + 6*q^3 + 11*q^4 + 18*q^5 + 32*q^6 + 48*q^7
1015
+ + 75*q^8 + 111*q^9 + 160*q^10 + 224*q^11 + 313*q^12 + 420*q^13
1016
+ + 562*q^14 + 738*q^15 + 956*q^16 + 1221*q^17 + 1550*q^18 + 1936*q^19
1017
+ + Order(q^20)
1018
+
1019
+ Sage example in ./combinat.tex, line 3185::
1020
+
1021
+ sage: n = 10
1022
+ sage: V = range(1,n+1)
1023
+ sage: F = Subsets(V, 2)
1024
+ sage: S = SymmetricGroup(V)
1025
+ sage: G = PermutationGroup([ on_pairs(sigma) for sigma in S.gens() ],
1026
+ ....: domain=F)
1027
+ sage: q,t = QQ['q,t'].gens()
1028
+ sage: Z = G.cycle_index()
1029
+ sage: Z.expand(2, [q,t])(q=1,t=1)
1030
+ 12005168
1031
+
1032
+ Sage example in ./combinat.tex, line 3202::
1033
+
1034
+ sage: n = 20
1035
+ sage: V = range(1,n+1)
1036
+ sage: F = Subsets(V, 2)
1037
+ sage: S = SymmetricGroup(V)
1038
+ sage: CC = S.conjugacy_classes(); CC # long time
1039
+ [...
1040
+ Conjugacy class of cycle type [19, 1] in Symmetric group of order 20! as a permutation group,
1041
+ Conjugacy class of cycle type [20] in Symmetric group of order 20! as a permutation group]
1042
+
1043
+ Sage example in ./combinat.tex, line 3214::
1044
+
1045
+ sage: p = SymmetricFunctions(QQ).powersum()
1046
+ sage: G = PermutationGroup([ on_pairs(sigma) for sigma in S.gens() ],
1047
+ ....: domain=F)
1048
+ sage: Z = p.sum_of_terms([G(on_pairs(c.representative())).cycle_type(), # long time
1049
+ ....: c.cardinality()]
1050
+ ....: for c in CC) / factorial(n)
1051
+ sage: Z.expand(2, [q,t])(q=1,t=1) # long time
1052
+ 645490122795799841856164638490742749440
1053
+ """