Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50641 views
1
# CoCalc Examples Documentation File
2
# Copyright: SageMath Inc., 2016
3
# License: Creative Commons: Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
4
---
5
language: sage
6
category: Mathematics / Combinatorics
7
---
8
title: Introduction
9
descr: |
10
This goes through some of the basic functionalities regarding combinatorics.
11
Check out these resources for more in-depth information:
12
13
* [Tutorial/Combinatorics](http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/tutorial.html)
14
* [Reference/Combinatorics](http://doc.sagemath.org/html/en/reference/combinat/index.html)
15
* [Reference/Graph Theory](http://doc.sagemath.org/html/en/reference/graphs/index.html)
16
code: ""
17
---
18
title: Permutations
19
descr: >
20
SageMath offers various way to construct and work with [Permutations](http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/permutation.html).
21
code: |
22
p = Permutation([2,3,7,4,5,6,1])
23
p.left_tableau()
24
p.longest_increasing_subsequences()
25
p.complement()
26
p.peaks()
27
p.retract_okounkov_vershik(6)
28
p.saliances()
29
# and many more: http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/permutation.html
30
---
31
title: Cartesian Product
32
descr: |
33
Build a [cartesian product](http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/cartesian_product.html) of sets.
34
code: |
35
S1 = Permutations(3)
36
S2 = ['A', 'B']
37
cp = cartesian_product([S1, S2])
38
cp
39
cp.cardinality()
40
cp.list()
41
---
42
title: Finite State Machine
43
descr: |
44
Transitions and a plot of a [Finite State Machine](http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/finite_state_machine.html)
45
code: |
46
fsm = Automaton([(0, 0, 0), (0, 1, 1), (0, 0, 2), (1, 2, 2), (2, 0, 0)], initial_states=[0, 1, 2], final_states=[0, 1])
47
for transition in fsm.accessible_components().transitions():
48
print transition
49
fsm.plot()
50
---
51
52