Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  chap16_mj.html   Sprache: HTML

 
 products/sources/formale Sprachen/GAP/doc/ref/chap16_mj.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<title>GAP (ref) - Chapter 16: Combinatorics</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap16"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a>  <a href="chap1_mj.html">1</a>  <a href="chap2_mj.html">2</a>  <a href="chap3_mj.html">3</a>  <a href="chap4_mj.html">4</a>  <a href="chap5_mj.html">5</a>  <a href="chap6_mj.html">6</a>  <a href="chap7_mj.html">7</a>  <a href="chap8_mj.html">8</a>  <a href="chap9_mj.html">9</a>  <a href="chap10_mj.html">10</a>  <a href="chap11_mj.html">11</a>  <a href="chap12_mj.html">12</a>  <a href="chap13_mj.html">13</a>  <a href="chap14_mj.html">14</a>  <a href="chap15_mj.html">15</a>  <a href="chap16_mj.html">16</a>  <a href="chap17_mj.html">17</a>  <a href="chap18_mj.html">18</a>  <a href="chap19_mj.html">19</a>  <a href="chap20_mj.html">20</a>  <a href="chap21_mj.html">21</a>  <a href="chap22_mj.html">22</a>  <a href="chap23_mj.html">23</a>  <a href="chap24_mj.html">24</a>  <a href="chap25_mj.html">25</a>  <a href="chap26_mj.html">26</a>  <a href="chap27_mj.html">27</a>  <a href="chap28_mj.html">28</a>  <a href="chap29_mj.html">29</a>  <a href="chap30_mj.html">30</a>  <a href="chap31_mj.html">31</a>  <a href="chap32_mj.html">32</a>  <a href="chap33_mj.html">33</a>  <a href="chap34_mj.html">34</a>  <a href="chap35_mj.html">35</a>  <a href="chap36_mj.html">36</a>  <a href="chap37_mj.html">37</a>  <a href="chap38_mj.html">38</a>  <a href="chap39_mj.html">39</a>  <a href="chap40_mj.html">40</a>  <a href="chap41_mj.html">41</a>  <a href="chap42_mj.html">42</a>  <a href="chap43_mj.html">43</a>  <a href="chap44_mj.html">44</a>  <a href="chap45_mj.html">45</a>  <a href="chap46_mj.html">46</a>  <a href="chap47_mj.html">47</a>  <a href="chap48_mj.html">48</a>  <a href="chap49_mj.html">49</a>  <a href="chap50_mj.html">50</a>  <a href="chap51_mj.html">51</a>  <a href="chap52_mj.html">52</a>  <a href="chap53_mj.html">53</a>  <a href="chap54_mj.html">54</a>  <a href="chap55_mj.html">55</a>  <a href="chap56_mj.html">56</a>  <a href="chap57_mj.html">57</a>  <a href="chap58_mj.html">58</a>  <a href="chap59_mj.html">59</a>  <a href="chap60_mj.html">60</a>  <a href="chap61_mj.html">61</a>  <a href="chap62_mj.html">62</a>  <a href="chap63_mj.html">63</a>  <a href="chap64_mj.html">64</a>  <a href="chap65_mj.html">65</a>  <a href="chap66_mj.html">66</a>  <a href="chap67_mj.html">67</a>  <a href="chap68_mj.html">68</a>  <a href="chap69_mj.html">69</a>  <a href="chap70_mj.html">70</a>  <a href="chap71_mj.html">71</a>  <a href="chap72_mj.html">72</a>  <a href="chap73_mj.html">73</a>  <a href="chap74_mj.html">74</a>  <a href="chap75_mj.html">75</a>  <a href="chap76_mj.html">76</a>  <a href="chap77_mj.html">77</a>  <a href="chap78_mj.html">78</a>  <a href="chap79_mj.html">79</a>  <a href="chap80_mj.html">80</a>  <a href="chap81_mj.html">81</a>  <a href="chap82_mj.html">82</a>  <a href="chap83_mj.html">83</a>  <a href="chap84_mj.html">84</a>  <a href="chap85_mj.html">85</a>  <a href="chap86_mj.html">86</a>  <a href="chap87_mj.html">87</a>  <a href="chapBib_mj.html">Bib</a>  <a href="chapInd_mj.html">Ind</a>  </div>

<div class="chlinkprevnexttop"> <a href="chap0_mj.html">[Top of Book]</a>   <a href="chap0_mj.html#contents">[Contents]</a>    <a href="chap15_mj.html">[Previous Chapter]</a>    <a href="chap17_mj.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap16.html">[MathJax off]</a></p>
<p><a id="X7BDA99EE7CEADA7C" name="X7BDA99EE7CEADA7C"></a></p>
<div class="ChapSects"><a href="chap16_mj.html#X7BDA99EE7CEADA7C">16 <span class="Heading">Combinatorics</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap16_mj.html#X800E48927D5C83F5">16.1 <span class="Heading">Combinatorial Numbers</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X87665F748594BF29">16.1-1 Factorial</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7A9AF5F58682819D">16.1-2 Binomial</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7DC5667580522BDA">16.1-3 Bell</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X792FF6EA786A5C2B">16.1-4 Bernoulli</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X85037456785BB33C">16.1-5 Stirling1</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7C93E14D7BC360F0">16.1-6 Stirling2</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap16_mj.html#X81B4696585C38147">16.2 <span class="Heading">Combinations, Arrangements and Tuples</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X8770F16D794C0ADB">16.2-1 Combinations</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X78DD5C0D81057540">16.2-2 <span class="Heading">Iterator and enumerator of combinations</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X82A6E98C85714FD0">16.2-3 NrCombinations</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7837B3357C7566C8">16.2-4 Arrangements</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7DE1ABD47D19F140">16.2-5 NrArrangements</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X81601C6786120DDC">16.2-6 UnorderedTuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7959281584C42C52">16.2-7 NrUnorderedTuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X86A3CA0F7CC8C320">16.2-8 Tuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7BA135297E8DA819">16.2-9 EnumeratorOfTuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X86416A31807B0086">16.2-10 IteratorOfTuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X85E18A9A87FD4CA2">16.2-11 NrTuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7B0143FB83F359B7">16.2-12 PermutationsList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X8629A2908050EB3A">16.2-13 NrPermutationsList</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X79C159507B2BF1C9">16.2-14 Derangements</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7C1741B181A9AB9C">16.2-15 NrDerangements</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7A13D8DC8204525F">16.2-16 PartitionsSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7BCD7FC2876386F1">16.2-17 NrPartitionsSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X84A6D15F8107008B">16.2-18 Partitions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X8793AEBD7E529E1D">16.2-19 IteratorOfPartitions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7EBD746A8607D0B8">16.2-20 IteratorOfPartitionsSet</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X86933C4F795C4EBD">16.2-21 NrPartitions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X820DF201871F2723">16.2-22 OrderedPartitions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X80BB9F4982CA1E8B">16.2-23 NrOrderedPartitions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X8009520C82942461">16.2-24 PartitionsGreatestLE</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7CB8D4FF8592A9BB">16.2-25 PartitionsGreatestEQ</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7A70D4F3809494E7">16.2-26 RestrictedPartitions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X800B43838742FBF4">16.2-27 NrRestrictedPartitions</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7F4EDCCA780B469D">16.2-28 SignPartition</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7DB9BEB6856EC03D">16.2-29 AssociatedPartition</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7A95D8A6820363A8">16.2-30 PowerPartition</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X877D997B7F66A119">16.2-31 PartitionTuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7F44AD098561DE32">16.2-32 NrPartitionTuples</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X8796C1D783ED9CB4">16.2-33 BetaSet</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap16_mj.html#X83DC50B67D74E674">16.3 <span class="Heading">Fibonacci and Lucas Sequences</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X85AE1D70803A886C">16.3-1 Fibonacci</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7830A03181D67192">16.3-2 Lucas</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap16_mj.html#X821888E77EB43F67">16.4 <span class="Heading">Permanent of a Matrix</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap16_mj.html#X7F0942DD83BBAB7A">16.4-1 Permanent</a></span>
</div></div>
</div>

<h3>16 <span class="Heading">Combinatorics</span></h3>

<p>This chapter describes functions that deal with combinatorics. We mainly concentrate on two areas. One is about <em>selections</em>, that is the ways one can select elements from a set. The other is about <em>partitions</em>, that is the ways one can partition a set into the union of pairwise disjoint subsets.</p>

<p><a id="X800E48927D5C83F5" name="X800E48927D5C83F5"></a></p>

<h4>16.1 <span class="Heading">Combinatorial Numbers</span></h4>

<p><a id="X87665F748594BF29" name="X87665F748594BF29"></a></p>

<h5>16.1-1 Factorial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Factorial</code>( <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the <em>factorial</em> <span class="SimpleMath">\(n!\)</span> of the positive integer <var class="Arg">n</var>, which is defined as the product <span class="SimpleMath">\(1 \cdot 2 \cdot 3 \cdots n\)</span>.</p>

<p><span class="SimpleMath">\(n!\)</span> is the number of permutations of a set of <span class="SimpleMath">\(n\)</span> elements. <span class="SimpleMath">\(1 / n!\)</span> is the coefficient of <span class="SimpleMath">\(x^n\)</span> in the formal series <span class="SimpleMath">\(\exp(x)\)</span>, which is the generating function for factorial.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..10], Factorial );</span>
[ 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Factorial( 30 );</span>
265252859812191058636308480000000
</pre></div>

<p><code class="func">PermutationsList</code> (<a href="chap16_mj.html#X7B0143FB83F359B7"><span class="RefLink">16.2-12</span></a>) computes the set of all permutations of a list.</p>

<p><a id="X7A9AF5F58682819D" name="X7A9AF5F58682819D"></a></p>

<h5>16.1-2 Binomial</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Binomial</code>( <var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the <em>binomial coefficient</em> <span class="SimpleMath">\({{n \choose k}}\)</span> of integers <var class="Arg">n</var> and <var class="Arg">k</var>. This is defined by the conditions <span class="SimpleMath">\({{n \choose k}} = 0\)</span> for <span class="SimpleMath">\(k < 0\)</span>, <span class="SimpleMath">\({{0 \choose k}} = 0\)</span> for <span class="SimpleMath">\(k \neq 0\)</span>, <span class="SimpleMath">\({{0 \choose 0}} = 1\)</span> and the relation <span class="SimpleMath">\({{n \choose k}} = {{n-1 \choose k}} + {{n-1 \choose k-1}}\)</span> for all <span class="SimpleMath">\(n\)</span> and <span class="SimpleMath">\(k\)</span>.</p>

<p>There are many ways of describing this function. For example, if <span class="SimpleMath">\(n \geq 0\)</span> and <span class="SimpleMath">\(0 \leq k \leq n\)</span>, then <span class="SimpleMath">\({{n \choose k}} = n! / (k! (n-k)!)\)</span> and for <span class="SimpleMath">\(n < 0\)</span> and <span class="SimpleMath">\(k \geq 0\)</span> we have <span class="SimpleMath">\({{n \choose k}} = (-1)^k {{-n+k-1 \choose k}}\)</span>.</p>

<p>If <span class="SimpleMath">\(n \geq 0\)</span> then <span class="SimpleMath">\({{n \choose k}}\)</span> is the number of subsets with <span class="SimpleMath">\(k\)</span> elements of a set with <span class="SimpleMath">\(n\)</span> elements. Also, <span class="SimpleMath">\({{n \choose k}}\)</span> is the coefficient of <span class="SimpleMath">\(x^k\)</span> in the polynomial <span class="SimpleMath">\((x + 1)^n\)</span>, which is the generating function for <span class="SimpleMath">\({{n \choose .}}\)</span>, hence the name.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"># Knuth calls this the trademark of Binomial:</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..4], k->Binomial( 4, k ) );</span>
[ 1, 4, 6, 4, 1 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..6], n->List( [0..6], k->Binomial( n, k ) ) );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput"># the lower triangle is called Pascal's triangle:

<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray( last );</span>
[ [   1,   0,   0,   0,   0,   0,   0 ],
  [   1,   1,   0,   0,   0,   0,   0 ],
  [   1,   2,   1,   0,   0,   0,   0 ],
  [   1,   3,   3,   1,   0,   0,   0 ],
  [   1,   4,   6,   4,   1,   0,   0 ],
  [   1,   5,  10,  10,   5,   1,   0 ],
  [   1,   6,  15,  20,  15,   6,   1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Binomial( 50, 10 );</span>
10272278170
</pre></div>

<p><code class="func">NrCombinations</code> (<a href="chap16_mj.html#X82A6E98C85714FD0"><span class="RefLink">16.2-3</span></a>) is the generalization of <code class="func">Binomial</code> for multisets. <code class="func">Combinations</code> (<a href="chap16_mj.html#X8770F16D794C0ADB"><span class="RefLink">16.2-1</span></a>) computes the set of all combinations of a multiset.</p>

<p><a id="X7DC5667580522BDA" name="X7DC5667580522BDA"></a></p>

<h5>16.1-3 Bell</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Bell</code>( <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the <em>Bell number</em> <span class="SimpleMath">\(B(n)\)</span>. The Bell numbers are defined by <span class="SimpleMath">\(B(0) = 1\)</span> and the recurrence <span class="SimpleMath">\(B(n+1) = \sum_{{k = 0}}^n {{n \choose k}} B(k)\)</span>.</p>

<p><span class="SimpleMath">\(B(n)\)</span> is the number of ways to partition a set of <var class="Arg">n</var> elements into pairwise disjoint nonempty subsets (see <code class="func">PartitionsSet</code> (<a href="chap16_mj.html#X7A13D8DC8204525F"><span class="RefLink">16.2-16</span></a>)). This implies of course that <span class="SimpleMath">\(B(n) = \sum_{{k = 0}}^n S_2(n,k)\)</span> (see <code class="func">Stirling2</code> (<a href="chap16_mj.html#X7C93E14D7BC360F0"><span class="RefLink">16.1-6</span></a>)). <span class="SimpleMath">\(B(n)/n!\)</span> is the coefficient of <span class="SimpleMath">\(x^n\)</span> in the formal series <span class="SimpleMath">\(\exp( \exp(x)-1 )\)</span>, which is the generating function for <span class="SimpleMath">\(B(n)\)</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..6], n -> Bell( n ) );</span>
[ 1, 1, 2, 5, 15, 52, 203 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Bell( 14 );</span>
190899322
</pre></div>

<p><a id="X792FF6EA786A5C2B" name="X792FF6EA786A5C2B"></a></p>

<h5>16.1-4 Bernoulli</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Bernoulli</code>( <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the <var class="Arg">n</var>-th <em>Bernoulli number</em> <span class="SimpleMath">\(B_n\)</span>, which is defined by <span class="SimpleMath">\(B_0 = 1\)</span> and <span class="SimpleMath">\(B_n = -\sum_{{k = 0}}^{{n-1}} {{n+1 \choose k}} B_k/(n+1)\)</span>.</p>

<p><span class="SimpleMath">\(B_n / n!\)</span> is the coefficient of <span class="SimpleMath">\(x^n\)</span> in the power series of <span class="SimpleMath">\(x / (\exp(x)-1)\)</span>. Except for <span class="SimpleMath">\(B_1 = -1/2\)</span> the Bernoulli numbers for odd indices are zero.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Bernoulli( 4 );</span>
-1/30
<span class="GAPprompt">gap></span> <span class="GAPinput">Bernoulli( 10 );</span>
5/66
<span class="GAPprompt">gap></span> <span class="GAPinput">Bernoulli( 12 );  # there is no simple pattern in Bernoulli numbers</span>
-691/2730
<span class="GAPprompt">gap></span> <span class="GAPinput">Bernoulli( 50 );  # and they grow fairly fast</span>
495057205241079648212477525/66
</pre></div>

<p><a id="X85037456785BB33C" name="X85037456785BB33C"></a></p>

<h5>16.1-5 Stirling1</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Stirling1</code>( <var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the <em>Stirling number of the first kind</em> <span class="SimpleMath">\(S_1(n,k)\)</span> of the integers <var class="Arg">n</var> and <var class="Arg">k</var>. Stirling numbers of the first kind are defined by <span class="SimpleMath">\(S_1(0,0) = 1\)</span>, <span class="SimpleMath">\(S_1(n,0) = S_1(0,k) = 0\)</span> if <span class="SimpleMath">\(n, k \ne 0\)</span> and the recurrence <span class="SimpleMath">\(S_1(n,k) = (n-1) S_1(n-1,k) + S_1(n-1,k-1)\)</span>.</p>

<p><span class="SimpleMath">\(S_1(n,k)\)</span> is the number of permutations of <var class="Arg">n</var> points with <var class="Arg">k</var> cycles. Stirling numbers of the first kind appear as coefficients in the series <span class="SimpleMath">\(n! {{x \choose n}} = \sum_{{k = 0}}^n S_1(n,k) x^k\)</span> which is the generating function for Stirling numbers of the first kind. Note the similarity to <span class="SimpleMath">\(x^n = \sum_{{k = 0}}^n S_2(n,k) k! {{x \choose k}}\)</span> (see <code class="func">Stirling2</code> (<a href="chap16_mj.html#X7C93E14D7BC360F0"><span class="RefLink">16.1-6</span></a>)). Also the definition of <span class="SimpleMath">\(S_1\)</span> implies <span class="SimpleMath">\(S_1(n,k) = S_2(-k,-n)\)</span> if <span class="SimpleMath">\(n, k < 0\)</span>. There are many formulae relating Stirling numbers of the first kind to Stirling numbers of the second kind, Bell numbers, and Binomial coefficients.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"># Knuth calls this the trademark of S_1:</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..4], k -> Stirling1( 4, k ) );</span>
[ 0, 6, 11, 6, 1 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..6], n->List( [0..6], k->Stirling1( n, k ) ) );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput"># note the similarity with Pascal's triangle for Binomial numbers
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray( last );</span>
[ [    1,    0,    0,    0,    0,    0,    0 ],
  [    0,    1,    0,    0,    0,    0,    0 ],
  [    0,    1,    1,    0,    0,    0,    0 ],
  [    0,    2,    3,    1,    0,    0,    0 ],
  [    0,    6,   11,    6,    1,    0,    0 ],
  [    0,   24,   50,   35,   10,    1,    0 ],
  [    0,  120,  274,  225,   85,   15,    1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Stirling1(50,10);</span>
101623020926367490059043797119309944043405505380503665627365376
</pre></div>

<p><a id="X7C93E14D7BC360F0" name="X7C93E14D7BC360F0"></a></p>

<h5>16.1-6 Stirling2</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Stirling2</code>( <var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the <em>Stirling number of the second kind</em> <span class="SimpleMath">\(S_2(n,k)\)</span> of the integers <var class="Arg">n</var> and <var class="Arg">k</var>. Stirling numbers of the second kind are defined by <span class="SimpleMath">\(S_2(0,0) = 1\)</span>, <span class="SimpleMath">\(S_2(n,0) = S_2(0,k) = 0\)</span> if <span class="SimpleMath">\(n, k \ne 0\)</span> and the recurrence <span class="SimpleMath">\(S_2(n,k) = k S_2(n-1,k) + S_2(n-1,k-1)\)</span>.</p>

<p><span class="SimpleMath">\(S_2(n,k)\)</span> is the number of ways to partition a set of <var class="Arg">n</var> elements into <var class="Arg">k</var> pairwise disjoint nonempty subsets (see <code class="func">PartitionsSet</code> (<a href="chap16_mj.html#X7A13D8DC8204525F"><span class="RefLink">16.2-16</span></a>)). Stirling numbers of the second kind appear as coefficients in the expansion of <span class="SimpleMath">\(x^n = \sum_{{k = 0}}^n S_2(n,k) k! {{x \choose k}}\)</span>. Note the similarity to <span class="SimpleMath">\(n! {{x \choose n}} = \sum_{{k = 0}}^n S_1(n,k) x^k\)</span> (see <code class="func">Stirling1</code> (<a href="chap16_mj.html#X85037456785BB33C"><span class="RefLink">16.1-5</span></a>)). Also the definition of <span class="SimpleMath">\(S_2\)</span> implies <span class="SimpleMath">\(S_2(n,k) = S_1(-k,-n)\)</span> if <span class="SimpleMath">\(n, k < 0\)</span>. There are many formulae relating Stirling numbers of the second kind to Stirling numbers of the first kind, Bell numbers, and Binomial coefficients.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput"># Knuth calls this the trademark of S_2:</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..4], k->Stirling2( 4, k ) );</span>
[ 0, 1, 7, 6, 1 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">List( [0..6], n->List( [0..6], k->Stirling2( n, k ) ) );;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput"># note the similarity with Pascal's triangle for Binomial numbers
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintArray( last );</span>
[ [   1,   0,   0,   0,   0,   0,   0 ],
  [   0,   1,   0,   0,   0,   0,   0 ],
  [   0,   1,   1,   0,   0,   0,   0 ],
  [   0,   1,   3,   1,   0,   0,   0 ],
  [   0,   1,   7,   6,   1,   0,   0 ],
  [   0,   1,  15,  25,  10,   1,   0 ],
  [   0,   1,  31,  90,  65,  15,   1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Stirling2( 50, 10 );</span>
26154716515862881292012777396577993781727011
</pre></div>

<p><a id="X81B4696585C38147" name="X81B4696585C38147"></a></p>

<h4>16.2 <span class="Heading">Combinations, Arrangements and Tuples</span></h4>

<p><a id="X8770F16D794C0ADB" name="X8770F16D794C0ADB"></a></p>

<h5>16.2-1 Combinations</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Combinations</code>( <var class="Arg">mset</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all combinations of the multiset <var class="Arg">mset</var> (a list of objects which may contain the same object several times) with <var class="Arg">k</var> elements; if <var class="Arg">k</var> is not given it returns all combinations of <var class="Arg">mset</var>.</p>

<p>A <em>combination</em> of <var class="Arg">mset</var> is an unordered selection without repetitions and is represented by a sorted sublist of <var class="Arg">mset</var>. If <var class="Arg">mset</var> is a proper set, there are <span class="SimpleMath">\({{|\textit{mset}| \choose \textit{k}}}\)</span> (see <code class="func">Binomial</code> (<a href="chap16_mj.html#X7A9AF5F58682819D"><span class="RefLink">16.1-2</span></a>)) combinations with <var class="Arg">k</var> elements, and the set of all combinations is just the <em>power set</em> of <var class="Arg">mset</var>, which contains all <em>subsets</em> of <var class="Arg">mset</var> and has cardinality <span class="SimpleMath">\(2^{{|\textit{mset}|}}\)</span>.</p>

<p>To loop over combinations of a larger multiset use <code class="func">IteratorOfCombinations</code> (<a href="chap16_mj.html#X78DD5C0D81057540"><span class="RefLink">16.2-2</span></a>) which produces combinations one by one and may save a lot of memory. Another memory efficient representation of the list of all combinations is provided by <code class="func">EnumeratorOfCombinations</code> (<a href="chap16_mj.html#X78DD5C0D81057540"><span class="RefLink">16.2-2</span></a>).</p>

<p><a id="X78DD5C0D81057540" name="X78DD5C0D81057540"></a></p>

<h5>16.2-2 <span class="Heading">Iterator and enumerator of combinations</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IteratorOfCombinations</code>( <var class="Arg">mset</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EnumeratorOfCombinations</code>( <var class="Arg">mset</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">IteratorOfCombinations</code> returns an <code class="func">Iterator</code> (<a href="chap30_mj.html#X83ADF8287ED0668E"><span class="RefLink">30.8-1</span></a>) for combinations (see <code class="func">Combinations</code> (<a href="chap16_mj.html#X8770F16D794C0ADB"><span class="RefLink">16.2-1</span></a>)) of the given multiset <var class="Arg">mset</var>. If a non-negative integer <var class="Arg">k</var> is given as second argument then only the combinations with <var class="Arg">k</var> entries are produced, otherwise all combinations.</p>

<p><code class="func">EnumeratorOfCombinations</code> returns an <code class="func">Enumerator</code> (<a href="chap30_mj.html#X7EF8910F82B45EC7"><span class="RefLink">30.3-2</span></a>) of the given multiset <var class="Arg">mset</var>. Currently only a variant without second argument <var class="Arg">k</var> is implemented.</p>

<p>The ordering of combinations from these functions can be different and also different from the list returned by <code class="func">Combinations</code> (<a href="chap16_mj.html#X8770F16D794C0ADB"><span class="RefLink">16.2-1</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">m:=[1..15];; Add(m, 15);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">NrCombinations(m);</span>
49152
<span class="GAPprompt">gap></span> <span class="GAPinput">i := 0;; for c in Combinations(m) do i := i+1; od;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">i;</span>
49152
<span class="GAPprompt">gap></span> <span class="GAPinput">cm := EnumeratorOfCombinations(m);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">cm[1000];</span>
[ 1, 2, 3, 6, 7, 8, 9, 10 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Position(cm, [1,13,15,15]);</span>
36866
</pre></div>

<p><a id="X82A6E98C85714FD0" name="X82A6E98C85714FD0"></a></p>

<h5>16.2-3 NrCombinations</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrCombinations</code>( <var class="Arg">mset</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">Combinations(<var class="Arg">mset</var>,<var class="Arg">k</var>)</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Combinations( [1,2,2,3] );</span>
[ [  ], [ 1 ], [ 1, 2 ], [ 1, 2, 2 ], [ 1, 2, 2, 3 ], [ 1, 2, 3 ],
  [ 1, 3 ], [ 2 ], [ 2, 2 ], [ 2, 2, 3 ], [ 2, 3 ], [ 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput"># number of different hands in a game of poker:</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">NrCombinations( [1..52], 5 );</span>
2598960
</pre></div>

<p>The function <code class="func">Arrangements</code> (<a href="chap16_mj.html#X7837B3357C7566C8"><span class="RefLink">16.2-4</span></a>) computes ordered selections without repetitions, <code class="func">UnorderedTuples</code> (<a href="chap16_mj.html#X81601C6786120DDC"><span class="RefLink">16.2-6</span></a>) computes unordered selections with repetitions, and <code class="func">Tuples</code> (<a href="chap16_mj.html#X86A3CA0F7CC8C320"><span class="RefLink">16.2-8</span></a>) computes ordered selections with repetitions.</p>

<p><a id="X7837B3357C7566C8" name="X7837B3357C7566C8"></a></p>

<h5>16.2-4 Arrangements</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Arrangements</code>( <var class="Arg">mset</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of arrangements of the multiset <var class="Arg">mset</var> that contain <var class="Arg">k</var> elements. If <var class="Arg">k</var> is not given it returns all arrangements of <var class="Arg">mset</var>.</p>

<p>An <em>arrangement</em> of <var class="Arg">mset</var> is an ordered selection without repetitions and is represented by a list that contains only elements from <var class="Arg">mset</var>, but maybe in a different order. If <var class="Arg">mset</var> is a proper set there are <span class="SimpleMath">\(|mset|! / (|mset|-k)!\)</span> (see <code class="func">Factorial</code> (<a href="chap16_mj.html#X87665F748594BF29"><span class="RefLink">16.1-1</span></a>)) arrangements with <var class="Arg">k</var> elements.</p>

<p><a id="X7DE1ABD47D19F140" name="X7DE1ABD47D19F140"></a></p>

<h5>16.2-5 NrArrangements</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrArrangements</code>( <var class="Arg">mset</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">Arrangements(<var class="Arg">mset</var>,<var class="Arg">k</var>)</code>.</p>

<p>As an example of arrangements of a multiset, think of the game Scrabble. Suppose you have the six characters of the word <code class="code">"settle"</code> and you have to make a four letter word. Then the possibilities are given by</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Arrangements( ["s","e","t","t","l","e"], 4 );</span>
[ [ "e""e""l""s" ], [ "e""e""l""t" ], [ "e""e""s""l" ],
  [ "e""e""s""t" ], [ "e""e""t""l" ], [ "e""e""t""s" ],
  ... 93 more possibilities ...
  [ "t""t""l""s" ], [ "t""t""s""e" ], [ "t""t""s""l" ] ]
</pre></div>

<p>Can you find the five proper English words, where <code class="code">"lets"</code> does not count? Note that the fact that the list returned by <code class="func">Arrangements</code> (<a href="chap16_mj.html#X7837B3357C7566C8"><span class="RefLink">16.2-4</span></a>) is a proper set means in this example that the possibilities are listed in the same order as they appear in the dictionary.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">NrArrangements( ["s","e","t","t","l","e"] );</span>
523
</pre></div>

<p>The function <code class="func">Combinations</code> (<a href="chap16_mj.html#X8770F16D794C0ADB"><span class="RefLink">16.2-1</span></a>) computes unordered selections without repetitions, <code class="func">UnorderedTuples</code> (<a href="chap16_mj.html#X81601C6786120DDC"><span class="RefLink">16.2-6</span></a>) computes unordered selections with repetitions, and <code class="func">Tuples</code> (<a href="chap16_mj.html#X86A3CA0F7CC8C320"><span class="RefLink">16.2-8</span></a>) computes ordered selections with repetitions.</p>

<p><a id="X81601C6786120DDC" name="X81601C6786120DDC"></a></p>

<h5>16.2-6 UnorderedTuples</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UnorderedTuples</code>( <var class="Arg">set</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all unordered tuples of length <var class="Arg">k</var> of the set <var class="Arg">set</var>.</p>

<p>An <em>unordered tuple</em> of length <var class="Arg">k</var> of <var class="Arg">set</var> is an unordered selection with repetitions of <var class="Arg">set</var> and is represented by a sorted list of length <var class="Arg">k</var> containing elements from <var class="Arg">set</var>. There are <span class="SimpleMath">\({{|set| + k - 1 \choose k}}\)</span> (see <code class="func">Binomial</code> (<a href="chap16_mj.html#X7A9AF5F58682819D"><span class="RefLink">16.1-2</span></a>)) such unordered tuples.</p>

<p>Note that the fact that <code class="func">UnorderedTuples</code> returns a set implies that the last index runs fastest. That means the first tuple contains the smallest element from <var class="Arg">set</var> <var class="Arg">k</var> times, the second tuple contains the smallest element of <var class="Arg">set</var> at all positions except at the last positions, where it contains the second smallest element from <var class="Arg">set</var> and so on.</p>

<p><a id="X7959281584C42C52" name="X7959281584C42C52"></a></p>

<h5>16.2-7 NrUnorderedTuples</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrUnorderedTuples</code>( <var class="Arg">set</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">UnorderedTuples(<var class="Arg">set</var>,<var class="Arg">k</var>)</code>.</p>

<p>As an example for unordered tuples think of a poker-like game played with 5 dice. Then each possible hand corresponds to an unordered five-tuple from the set <span class="SimpleMath">\(\{ 1, 2, \ldots, 6 \}\)</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">NrUnorderedTuples( [1..6], 5 );</span>
252
<span class="GAPprompt">gap></span> <span class="GAPinput">UnorderedTuples( [1..6], 5 );</span>
[ [ 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 2 ], [ 1, 1, 1, 1, 3 ], [ 1, 1, 1, 1, 4 ],
  [ 1, 1, 1, 1, 5 ], [ 1, 1, 1, 1, 6 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 3 ],
  ... 100 more tuples ...
  [ 1, 3, 5, 5, 6 ], [ 1, 3, 5, 6, 6 ], [ 1, 3, 6, 6, 6 ], [ 1, 4, 4, 4, 4 ],
  ... 100 more tuples ...
  [ 3, 3, 5, 5, 5 ], [ 3, 3, 5, 5, 6 ], [ 3, 3, 5, 6, 6 ], [ 3, 3, 6, 6, 6 ],
  ... 32 more tuples ...
  [ 5, 5, 5, 6, 6 ], [ 5, 5, 6, 6, 6 ], [ 5, 6, 6, 6, 6 ], [ 6, 6, 6, 6, 6 ] ]
</pre></div>

<p>The function <code class="func">Combinations</code> (<a href="chap16_mj.html#X8770F16D794C0ADB"><span class="RefLink">16.2-1</span></a>) computes unordered selections without repetitions, <code class="func">Arrangements</code> (<a href="chap16_mj.html#X7837B3357C7566C8"><span class="RefLink">16.2-4</span></a>) computes ordered selections without repetitions, and <code class="func">Tuples</code> (<a href="chap16_mj.html#X86A3CA0F7CC8C320"><span class="RefLink">16.2-8</span></a>) computes ordered selections with repetitions.</p>

<p><a id="X86A3CA0F7CC8C320" name="X86A3CA0F7CC8C320"></a></p>

<h5>16.2-8 Tuples</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Tuples</code>( <var class="Arg">set</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all ordered tuples of length <var class="Arg">k</var> of the set <var class="Arg">set</var>.</p>

<p>An <em>ordered tuple</em> of length <var class="Arg">k</var> of <var class="Arg">set</var> is an ordered selection with repetition and is represented by a list of length <var class="Arg">k</var> containing elements of <var class="Arg">set</var>. There are <span class="SimpleMath">\(|\textit{set}|^{\textit{k}}\)</span> such ordered tuples.</p>

<p>Note that the fact that <code class="func">Tuples</code> returns a set implies that the last index runs fastest. That means the first tuple contains the smallest element from <var class="Arg">set</var> <var class="Arg">k</var> times, the second tuple contains the smallest element of <var class="Arg">set</var> at all positions except at the last positions, where it contains the second smallest element from <var class="Arg">set</var> and so on.</p>

<p><a id="X7BA135297E8DA819" name="X7BA135297E8DA819"></a></p>

<h5>16.2-9 EnumeratorOfTuples</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EnumeratorOfTuples</code>( <var class="Arg">set</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function is referred to as an example of enumerators that are defined by functions but are not constructed from a domain. The result is equal to that of <code class="code">Tuples( <var class="Arg">set</var>, <var class="Arg">k</var> )</code>. However, the entries are not stored physically in the list but are created/identified on demand.</p>

<p><a id="X86416A31807B0086" name="X86416A31807B0086"></a></p>

<h5>16.2-10 IteratorOfTuples</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IteratorOfTuples</code>( <var class="Arg">set</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>For a set <var class="Arg">set</var> and a positive integer <var class="Arg">k</var>, <code class="func">IteratorOfTuples</code> returns an iterator (see <a href="chap30_mj.html#X85A3F00985453F95"><span class="RefLink">30.8</span></a>) of the set of all ordered tuples (see <code class="func">Tuples</code> (<a href="chap16_mj.html#X86A3CA0F7CC8C320"><span class="RefLink">16.2-8</span></a>)) of length <var class="Arg">k</var> of the set <var class="Arg">set</var>. The tuples are returned in lexicographic order.</p>

<p><a id="X85E18A9A87FD4CA2" name="X85E18A9A87FD4CA2"></a></p>

<h5>16.2-11 NrTuples</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrTuples</code>( <var class="Arg">set</var>, <var class="Arg">k</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">Tuples(<var class="Arg">set</var>,<var class="Arg">k</var>)</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Tuples( [1,2,3], 2 );</span>
[ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ],
  [ 3, 1 ], [ 3, 2 ], [ 3, 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrTuples( [1..10], 5 );</span>
100000
</pre></div>

<p><code class="code">Tuples(<var class="Arg">set</var>,<var class="Arg">k</var>)</code> can also be viewed as the <var class="Arg">k</var>-fold cartesian product of <var class="Arg">set</var> (see <code class="func">Cartesian</code> (<a href="chap21_mj.html#X7E1593B979BDF2CD"><span class="RefLink">21.20-15</span></a>)).</p>

<p>The function <code class="func">Combinations</code> (<a href="chap16_mj.html#X8770F16D794C0ADB"><span class="RefLink">16.2-1</span></a>) computes unordered selections without repetitions, <code class="func">Arrangements</code> (<a href="chap16_mj.html#X7837B3357C7566C8"><span class="RefLink">16.2-4</span></a>) computes ordered selections without repetitions, and finally the function <code class="func">UnorderedTuples</code> (<a href="chap16_mj.html#X81601C6786120DDC"><span class="RefLink">16.2-6</span></a>) computes unordered selections with repetitions.</p>

<p><a id="X7B0143FB83F359B7" name="X7B0143FB83F359B7"></a></p>

<h5>16.2-12 PermutationsList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PermutationsList</code>( <var class="Arg">mset</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">PermutationsList</code> returns the set of permutations of the multiset <var class="Arg">mset</var>.</p>

<p>A <em>permutation</em> is represented by a list that contains exactly the same elements as <var class="Arg">mset</var>, but possibly in different order. If <var class="Arg">mset</var> is a proper set there are <span class="SimpleMath">\(|\textit{mset}| !\)</span> (see <code class="func">Factorial</code> (<a href="chap16_mj.html#X87665F748594BF29"><span class="RefLink">16.1-1</span></a>)) such permutations. Otherwise if the first elements appears <span class="SimpleMath">\(k_1\)</span> times, the second element appears <span class="SimpleMath">\(k_2\)</span> times and so on, the number of permutations is <span class="SimpleMath">\(|\textit{mset}| ! / (k_1! k_2! \ldots)\)</span>, which is sometimes called multinomial coefficient.</p>

<p><a id="X8629A2908050EB3A" name="X8629A2908050EB3A"></a></p>

<h5>16.2-13 NrPermutationsList</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrPermutationsList</code>( <var class="Arg">mset</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">PermutationsList(<var class="Arg">mset</var>)</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PermutationsList( [1,2,3] );</span>
[ [ 1, 2, 3 ], [ 1, 3, 2 ], [ 2, 1, 3 ], [ 2, 3, 1 ], [ 3, 1, 2 ],
  [ 3, 2, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PermutationsList( [1,1,2,2] );</span>
[ [ 1, 1, 2, 2 ], [ 1, 2, 1, 2 ], [ 1, 2, 2, 1 ], [ 2, 1, 1, 2 ],
  [ 2, 1, 2, 1 ], [ 2, 2, 1, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrPermutationsList( [1,2,2,3,3,3,4,4,4,4] );</span>
12600
</pre></div>

<p>The function <code class="func">Arrangements</code> (<a href="chap16_mj.html#X7837B3357C7566C8"><span class="RefLink">16.2-4</span></a>) is the generalization of <code class="func">PermutationsList</code> (<a href="chap16_mj.html#X7B0143FB83F359B7"><span class="RefLink">16.2-12</span></a>) that allows you to specify the size of the permutations. <code class="func">Derangements</code> (<a href="chap16_mj.html#X79C159507B2BF1C9"><span class="RefLink">16.2-14</span></a>) computes permutations that have no fixed points.</p>

<p><a id="X79C159507B2BF1C9" name="X79C159507B2BF1C9"></a></p>

<h5>16.2-14 Derangements</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Derangements</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all derangements of the list <var class="Arg">list</var>.</p>

<p>A <em>derangement</em> is a fixpointfree permutation of <var class="Arg">list</var> and is represented by a list that contains exactly the same elements as <var class="Arg">list</var>, but in such an order that the derangement has at no position the same element as <var class="Arg">list</var>. If the list <var class="Arg">list</var> contains no element twice there are exactly <span class="SimpleMath">\(|\textit{list}|! (1/2! - 1/3! + 1/4! - \cdots + (-1)^n / n!)\)</span> derangements.</p>

<p>Note that the ratio <code class="code">NrPermutationsList( [ 1 .. n ] ) / NrDerangements( [ 1 .. n ] )</code>, which is <span class="SimpleMath">\(n! / (n! (1/2! - 1/3! + 1/4! - \cdots + (-1)^n / n!))\)</span> is an approximation for the base of the natural logarithm <span class="SimpleMath">\(e = 2.7182818285\ldots\)</span>, which is correct to about <span class="SimpleMath">\(n\)</span> digits.</p>

<p><a id="X7C1741B181A9AB9C" name="X7C1741B181A9AB9C"></a></p>

<h5>16.2-15 NrDerangements</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrDerangements</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">Derangements(<var class="Arg">list</var>)</code>.</p>

<p>As an example of derangements suppose that you have to send four different letters to four different people. Then a derangement corresponds to a way to send those letters such that no letter reaches the intended person.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Derangements( [1,2,3,4] );</span>
[ [ 2, 1, 4, 3 ], [ 2, 3, 4, 1 ], [ 2, 4, 1, 3 ], [ 3, 1, 4, 2 ],
  [ 3, 4, 1, 2 ], [ 3, 4, 2, 1 ], [ 4, 1, 2, 3 ], [ 4, 3, 1, 2 ],
  [ 4, 3, 2, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrDerangements( [1..10] );</span>
1334961
<span class="GAPprompt">gap></span> <span class="GAPinput">Int( 10^7*NrPermutationsList([1..10])/last );</span>
27182816
<span class="GAPprompt">gap></span> <span class="GAPinput">Derangements( [1,1,2,2,3,3] );</span>
[ [ 2, 2, 3, 3, 1, 1 ], [ 2, 3, 1, 3, 1, 2 ], [ 2, 3, 1, 3, 2, 1 ],
  [ 2, 3, 3, 1, 1, 2 ], [ 2, 3, 3, 1, 2, 1 ], [ 3, 2, 1, 3, 1, 2 ],
  [ 3, 2, 1, 3, 2, 1 ], [ 3, 2, 3, 1, 1, 2 ], [ 3, 2, 3, 1, 2, 1 ],
  [ 3, 3, 1, 1, 2, 2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrDerangements( [1,2,2,3,3,3,4,4,4,4] );</span>
338
</pre></div>

<p>The function <code class="func">PermutationsList</code> (<a href="chap16_mj.html#X7B0143FB83F359B7"><span class="RefLink">16.2-12</span></a>) computes all permutations of a list.</p>

<p><a id="X7A13D8DC8204525F" name="X7A13D8DC8204525F"></a></p>

<h5>16.2-16 PartitionsSet</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PartitionsSet</code>( <var class="Arg">set</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all unordered partitions of the set <var class="Arg">set</var> into <var class="Arg">k</var> pairwise disjoint nonempty sets. If <var class="Arg">k</var> is not given it returns all unordered partitions of <var class="Arg">set</var> for all <var class="Arg">k</var>.</p>

<p>An <em>unordered partition</em> of <var class="Arg">set</var> is a set of pairwise disjoint nonempty sets with union <var class="Arg">set</var> and is represented by a sorted list of such sets. There are <span class="SimpleMath">\(B( |set| )\)</span> (see <code class="func">Bell</code> (<a href="chap16_mj.html#X7DC5667580522BDA"><span class="RefLink">16.1-3</span></a>)) partitions of the set <var class="Arg">set</var> and <span class="SimpleMath">\(S_2( |set|, k )\)</span> (see <code class="func">Stirling2</code> (<a href="chap16_mj.html#X7C93E14D7BC360F0"><span class="RefLink">16.1-6</span></a>)) partitions with <var class="Arg">k</var> elements.</p>

<p><a id="X7BCD7FC2876386F1" name="X7BCD7FC2876386F1"></a></p>

<h5>16.2-17 NrPartitionsSet</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrPartitionsSet</code>( <var class="Arg">set</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">PartitionsSet(<var class="Arg">set</var>,<var class="Arg">k</var>)</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">PartitionsSet( [1,2,3] );</span>
[ [ [ 1 ], [ 2 ], [ 3 ] ], [ [ 1 ], [ 2, 3 ] ], [ [ 1, 2 ], [ 3 ] ],
  [ [ 1, 2, 3 ] ], [ [ 1, 3 ], [ 2 ] ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">PartitionsSet( [1,2,3,4], 2 );</span>
[ [ [ 1 ], [ 2, 3, 4 ] ], [ [ 1, 2 ], [ 3, 4 ] ],
  [ [ 1, 2, 3 ], [ 4 ] ], [ [ 1, 2, 4 ], [ 3 ] ],
  [ [ 1, 3 ], [ 2, 4 ] ], [ [ 1, 3, 4 ], [ 2 ] ],
  [ [ 1, 4 ], [ 2, 3 ] ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrPartitionsSet( [1..6] );</span>
203
<span class="GAPprompt">gap></span> <span class="GAPinput">NrPartitionsSet( [1..10], 3 );</span>
9330
</pre></div>

<p>Note that <code class="func">PartitionsSet</code> (<a href="chap16_mj.html#X7A13D8DC8204525F"><span class="RefLink">16.2-16</span></a>) does currently not support multisets and that there is currently no ordered counterpart.</p>

<p><a id="X84A6D15F8107008B" name="X84A6D15F8107008B"></a></p>

<h5>16.2-18 Partitions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Partitions</code>( <var class="Arg">n</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all (unordered) partitions of the positive integer <var class="Arg">n</var> into sums with <var class="Arg">k</var> summands. If <var class="Arg">k</var> is not given it returns all unordered partitions of <var class="Arg">n</var> for all <var class="Arg">k</var>.</p>

<p>An <em>unordered partition</em> is an unordered sum <span class="SimpleMath">\(n = p_1 + p_2 + \cdots + p_k\)</span> of positive integers and is represented by the list <span class="SimpleMath">\(p = [ p_1, p_2, \ldots, p_k ]\)</span>, in nonincreasing order, i.e., <span class="SimpleMath">\(p_1 \geq p_2 \geq \ldots \geq p_k\)</span>. We write <span class="SimpleMath">\(p \vdash n\)</span>. There are approximately <span class="SimpleMath">\(\exp(\pi \sqrt{{2/3 n}}) / (4 \sqrt{{3}} n)\)</span> such partitions, use <code class="func">NrPartitions</code> (<a href="chap16_mj.html#X86933C4F795C4EBD"><span class="RefLink">16.2-21</span></a>) to compute the precise number.</p>

<p>If you want to loop over all partitions of some larger <var class="Arg">n</var> use the more memory efficient <code class="func">IteratorOfPartitions</code> (<a href="chap16_mj.html#X8793AEBD7E529E1D"><span class="RefLink">16.2-19</span></a>).</p>

<p>It is possible to associate with every partition of the integer <var class="Arg">n</var> a conjugacy class of permutations in the symmetric group on <var class="Arg">n</var> points and vice versa. Therefore <span class="SimpleMath">\(p(n) := \)</span><code class="code">NrPartitions</code><span class="SimpleMath">\((n)\)</span> is the number of conjugacy classes of the symmetric group on <var class="Arg">n</var> points.</p>

<p>Ramanujan found the identities <span class="SimpleMath">\(p(5i+4) = 0\)</span> mod 5, <span class="SimpleMath">\(p(7i+5) = 0\)</span> mod 7 and <span class="SimpleMath">\(p(11i+6) = 0\)</spanmod 11 and many other fascinating things about the number of partitions.</p>

<p><a id="X8793AEBD7E529E1D" name="X8793AEBD7E529E1D"></a></p>

<h5>16.2-19 IteratorOfPartitions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IteratorOfPartitions</code>( <var class="Arg">n</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>For a positive integer <var class="Arg">n</var>, <code class="func">IteratorOfPartitions</code> returns an iterator (see <a href="chap30_mj.html#X85A3F00985453F95"><span class="RefLink">30.8</span></a>) of the set of partitions of <var class="Arg">n</var> (see <code class="func">Partitions</code> (<a href="chap16_mj.html#X84A6D15F8107008B"><span class="RefLink">16.2-18</span></a>)). The partitions of <var class="Arg">n</var> are returned in lexicographic order.</p>

<p><a id="X7EBD746A8607D0B8" name="X7EBD746A8607D0B8"></a></p>

<h5>16.2-20 IteratorOfPartitionsSet</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IteratorOfPartitionsSet</code>( <var class="Arg">set</var>[, <var class="Arg">k</var>[, <var class="Arg">flag</var>]] )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">IteratorOfPartitionsSet</code> returns an iterator (see <a href="chap30_mj.html#X85A3F00985453F95"><span class="RefLink">30.8</span></a>) for all unordered partitions of the set <var class="Arg">set</var> into pairwise disjoint nonempty sets (see <code class="func">PartitionsSet</code> (<a href="chap16_mj.html#X7A13D8DC8204525F"><span class="RefLink">16.2-16</span></a>)). If <var class="Arg">k</var> given and <var class="Arg">flag</var> is omitted or equal to <code class="keyw">false</code>, then only partitions of size <var class="Arg">k</var> are computed. If <var class="Arg">k</var> is given and <var class="Arg">flag</var> is equal to <code class="keyw">true</code>, then only partitions of size at most <var class="Arg">k</var> are computed.</p>

<p><a id="X86933C4F795C4EBD" name="X86933C4F795C4EBD"></a></p>

<h5>16.2-21 NrPartitions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrPartitions</code>( <var class="Arg">n</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">Partitions(<var class="Arg">set</var>,<var class="Arg">k</var>)</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Partitions( 7 );</span>
[ [ 1, 1, 1, 1, 1, 1, 1 ], [ 2, 1, 1, 1, 1, 1 ], [ 2, 2, 1, 1, 1 ],
  [ 2, 2, 2, 1 ], [ 3, 1, 1, 1, 1 ], [ 3, 2, 1, 1 ], [ 3, 2, 2 ],
  [ 3, 3, 1 ], [ 4, 1, 1, 1 ], [ 4, 2, 1 ], [ 4, 3 ], [ 5, 1, 1 ],
  [ 5, 2 ], [ 6, 1 ], [ 7 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">Partitions( 8, 3 );</span>
[ [ 3, 3, 2 ], [ 4, 2, 2 ], [ 4, 3, 1 ], [ 5, 2, 1 ], [ 6, 1, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrPartitions( 7 );</span>
15
<span class="GAPprompt">gap></span> <span class="GAPinput">NrPartitions( 100 );</span>
190569292
</pre></div>

<p>The function <code class="func">OrderedPartitions</code> (<a href="chap16_mj.html#X820DF201871F2723"><span class="RefLink">16.2-22</span></a>) is the ordered counterpart of <code class="func">Partitions</code> (<a href="chap16_mj.html#X84A6D15F8107008B"><span class="RefLink">16.2-18</span></a>).</p>

<p><a id="X820DF201871F2723" name="X820DF201871F2723"></a></p>

<h5>16.2-22 OrderedPartitions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OrderedPartitions</code>( <var class="Arg">n</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all ordered partitions of the positive integer <var class="Arg">n</var> into sums with <var class="Arg">k</var> summands. If <var class="Arg">k</var> is not given it returns all ordered partitions of <var class="Arg">set</var> for all <var class="Arg">k</var>.</p>

<p>An <em>ordered partition</em> is an ordered sum <span class="SimpleMath">\(n = p_1 + p_2 + \ldots + p_k\)</span> of positive integers and is represented by the list <span class="SimpleMath">\([ p_1, p_2, \ldots, p_k ]\)</span>. There are totally <span class="SimpleMath">\(2^{{n-1}}\)</span> ordered partitions and <span class="SimpleMath">\({{n-1 \choose k-1}}\)</span> (see <code class="func">Binomial</code> (<a href="chap16_mj.html#X7A9AF5F58682819D"><span class="RefLink">16.1-2</span></a>)) ordered partitions with <var class="Arg">k</var> summands.</p>

<p>Do not call <code class="func">OrderedPartitions</code> with an <var class="Arg">n</var> much larger than <span class="SimpleMath">\(15\)</span>, the list will simply become too large.</p>

<p><a id="X80BB9F4982CA1E8B" name="X80BB9F4982CA1E8B"></a></p>

<h5>16.2-23 NrOrderedPartitions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrOrderedPartitions</code>( <var class="Arg">n</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">OrderedPartitions(<var class="Arg">set</var>,<var class="Arg">k</var>)</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">OrderedPartitions( 5 );</span>
[ [ 1, 1, 1, 1, 1 ], [ 1, 1, 1, 2 ], [ 1, 1, 2, 1 ], [ 1, 1, 3 ],
  [ 1, 2, 1, 1 ], [ 1, 2, 2 ], [ 1, 3, 1 ], [ 1, 4 ], [ 2, 1, 1, 1 ],
  [ 2, 1, 2 ], [ 2, 2, 1 ], [ 2, 3 ], [ 3, 1, 1 ], [ 3, 2 ],
  [ 4, 1 ], [ 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">OrderedPartitions( 6, 3 );</span>
[ [ 1, 1, 4 ], [ 1, 2, 3 ], [ 1, 3, 2 ], [ 1, 4, 1 ], [ 2, 1, 3 ],
  [ 2, 2, 2 ], [ 2, 3, 1 ], [ 3, 1, 2 ], [ 3, 2, 1 ], [ 4, 1, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrOrderedPartitions(20);</span>
524288
</pre></div>

<p>The function <code class="func">Partitions</code> (<a href="chap16_mj.html#X84A6D15F8107008B"><span class="RefLink">16.2-18</span></a>) is the unordered counterpart of <code class="func">OrderedPartitions</code> (<a href="chap16_mj.html#X820DF201871F2723"><span class="RefLink">16.2-22</span></a>).</p>

<p><a id="X8009520C82942461" name="X8009520C82942461"></a></p>

<h5>16.2-24 PartitionsGreatestLE</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PartitionsGreatestLE</code>( <var class="Arg">n</var>, <var class="Arg">m</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all (unordered) partitions of the integer <var class="Arg">n</var> having parts less or equal to the integer <var class="Arg">m</var>.</p>

<p><a id="X7CB8D4FF8592A9BB" name="X7CB8D4FF8592A9BB"></a></p>

<h5>16.2-25 PartitionsGreatestEQ</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PartitionsGreatestEQ</code>( <var class="Arg">n</var>, <var class="Arg">m</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the set of all (unordered) partitions of the integer <var class="Arg">n</var> having greatest part equal to the integer <var class="Arg">m</var>.</p>

<p><a id="X7A70D4F3809494E7" name="X7A70D4F3809494E7"></a></p>

<h5>16.2-26 RestrictedPartitions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RestrictedPartitions</code>( <var class="Arg">n</var>, <var class="Arg">set</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>In the first form <code class="func">RestrictedPartitions</code> returns the set of all restricted partitions of the positive integer <var class="Arg">n</var> into sums with <var class="Arg">k</var> summands with the summands of the partition coming from the set <var class="Arg">set</var>. If <var class="Arg">k</var> is not given all restricted partitions for all <var class="Arg">k</var> are returned.</p>

<p>A <em>restricted partition</em> is like an ordinary partition (see <code class="func">Partitions</code> (<a href="chap16_mj.html#X84A6D15F8107008B"><span class="RefLink">16.2-18</span></a>)) an unordered sum <span class="SimpleMath">\(n = p_1 + p_2 + \ldots + p_k\)</span> of positive integers and is represented by the list <span class="SimpleMath">\(p = [ p_1, p_2, \ldots, p_k ]\)</span>, in nonincreasing order. The difference is that here the <span class="SimpleMath">\(p_i\)</span> must be elements from the set <var class="Arg">set</var>, while for ordinary partitions they may be elements from <code class="code">[ 1 .. n ]</code>.</p>

<p><a id="X800B43838742FBF4" name="X800B43838742FBF4"></a></p>

<h5>16.2-27 NrRestrictedPartitions</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NrRestrictedPartitions</code>( <var class="Arg">n</var>, <var class="Arg">set</var>[, <var class="Arg">k</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the number of <code class="code">RestrictedPartitions(<var class="Arg">n</var>,<var class="Arg">set</var>,<var class="Arg">k</var>)</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">RestrictedPartitions( 8, [1,3,5,7] );</span>
[ [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 3, 1, 1, 1, 1, 1 ], [ 3, 3, 1, 1 ],
  [ 5, 1, 1, 1 ], [ 5, 3 ], [ 7, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">NrRestrictedPartitions(50,[1,2,5,10,20,50]);</span>
451
</pre></div>

<p>The last example tells us that there are 451 ways to return 50 pence change using 1, 2, 5, 10, 20 and 50 pence coins.</p>

<p><a id="X7F4EDCCA780B469D" name="X7F4EDCCA780B469D"></a></p>

<h5>16.2-28 SignPartition</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SignPartition</code>( <var class="Arg">pi</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the sign of a permutation with cycle structure <var class="Arg">pi</var>.</p>

<p>This function actually describes a homomorphism from the symmetric group <span class="SimpleMath">\(S_n\)</span> into the cyclic group of order 2, whose kernel is exactly the alternating group <span class="SimpleMath">\(A_n\)</span> (see <code class="func">SignPerm</code> (<a href="chap42_mj.html#X7BE5011B7C0DB704"><span class="RefLink">42.4-1</span></a>)). Partitions of sign 1 are called <em>even</em> partitions while partitions of sign <span class="SimpleMath">\(-1\)</span> are called <em>odd</em>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">SignPartition([6,5,4,3,2,1]);</span>
-1
</pre></div>

<p><a id="X7DB9BEB6856EC03D" name="X7DB9BEB6856EC03D"></a></p>

<h5>16.2-29 AssociatedPartition</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AssociatedPartition</code>( <var class="Arg">pi</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">AssociatedPartition</code> returns the associated partition of the partition <var class="Arg">pi</var> which is obtained by transposing the corresponding Young diagram.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">AssociatedPartition([4,2,1]);</span>
[ 3, 2, 1, 1 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">AssociatedPartition([6]);</span>
[ 1, 1, 1, 1, 1, 1 ]
</pre></div>

<p><a id="X7A95D8A6820363A8" name="X7A95D8A6820363A8"></a></p>

<h5>16.2-30 PowerPartition</h5>

--> --------------------

--> maximum size reached

--> --------------------

100%


¤ Dauer der Verarbeitung: 0.71 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge