Function Repository Resource:

EulerianNumber

Source Notebook

Get the number of permutations with a given number of ascents

Contributed by: Wolfram Staff

ResourceFunction["EulerianNumber"][n,k]

gives the number of permutations of {1,2,,n} with k ascents.

Details and Options

The index i of a permutation written as p1,p2,,pn in one-line notation is an ascent if pi<pi+1.

Examples

Basic Examples (3) 

Count the number of ascents of the 24 permutations of {1,2,3,4}:

In[1]:=
Length@*ResourceFunction[
ResourceObject[<|{"Name" -> "PermutationAscents", "UUID" -> "a06fd265-b3d3-4d52-9ca7-167a000b6bd3", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Gives the indices of a permutation where there is an immediate ascent", "RepositoryLocation" -> URL[
       "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"],
       "WolframLanguageVersionRequired" -> "10.0", "SymbolName" -> "FunctionRepository`$eefbf0824b5b4570b1d3261358fb10dd`PermutationAscents", "ShortName" -> "PermutationAscents"}|>, ResourceSystemBase -> "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"]] /@ Permutations@Range[4]
Out[1]=

Tally up permutations by the number of ascents:

In[2]:=
Last /@ Tally[Sort@Flatten@%]
Out[2]=

EulerianNumber gives the same list, calculated without implicitly listing the individual ascents:

In[3]:=
ResourceFunction["EulerianNumber"][4, #] & /@ Range[4]
Out[3]=

Scope (2) 

The numbers form an infinite lower-triangular matrix:

In[4]:=
Table[ResourceFunction["EulerianNumber"][n, k], {n, 7}, {k, n}] // Grid
Out[4]=

The row sums are the factorials because they count the number of permutations:

In[5]:=
Total /@ Table[
  ResourceFunction["EulerianNumber"][n, k], {n, 7}, {k, n}]
Out[5]=
In[6]:=
% == Factorial[Range[7]]
Out[6]=

Neat Examples (4) 

Here the entries are signed in a checkerboard pattern:

In[7]:=
Table[(-1)^(n - k) ResourceFunction["EulerianNumber"][n, k], {n, 7}, {k, n}] // Grid
Out[7]=

Here are those row sums:

In[8]:=
Total /@ Table[(-1)^(n - k) ResourceFunction["EulerianNumber"][n, k], {n, 12}, {k, n}]
Out[8]=

Expand Tan[x]:

In[9]:=
CoefficientList[Series[Tan[x], {x, 0, 12}], x]
Out[9]=

Get rid of the factorials in the denominators to match the row sums up to signs and a shift:

In[10]:=
% Range[0, 11]!
Out[10]=

Publisher

George Beck

Version History

  • 3.0.0 – 28 June 2019
  • 2.0.0 – 28 March 2019
  • 1.0.0 – 15 March 2019

Related Resources

License Information