Wolfram Research

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

Consider the permutation:

In[1]:=
p = {2, 8, 1, 5, 4, 7, 6, 3, 9};

Here are its four ascents, corresponding to 2<8, 1<5, 4<7, 3<9:

In[2]:=
ResourceFunction[
ResourceObject[
Association[
   "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", "FunctionLocation" -> LocalObject[
     "file:///Users/georgebeck/Library/Wolfram/Objects/Resources/a06/\
a06fd265-b3d3-4d52-9ca7-167a000b6bd3/download/DefinitionData"], "ShortName" -> "PermutationAscents"], ResourceSystemBase -> "https://www.wolframcloud.com/objects/\
resourcesystem/api/1.0"]]@p
Out[2]=

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

In[3]:=
Length@*ResourceFunction[
ResourceObject[
Association[
    "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", "FunctionLocation" -> LocalObject[
      "file:///Users/georgebeck/Library/Wolfram/Objects/Resources/a06/\
a06fd265-b3d3-4d52-9ca7-167a000b6bd3/download/DefinitionData"], "ShortName" -> "PermutationAscents"], ResourceSystemBase -> "https://www.wolframcloud.com/objects/\
resourcesystem/api/1.0"]] /@ Permutations@Range[4]
Out[3]=

This tallies up permutations by the number of ascents:

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

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

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

Scope

The numbers form an infinite lower-triangular matrix:

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

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

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

Neat Examples

Here the entries are signed in a checkerboard pattern:

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

Here are those row sums:

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

Expand Tan[x]:

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

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

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

Resource History

See Also

License Information