Skip to content

Implement the unsigned Lah numbers #17161

@PeterLuschny

Description

@PeterLuschny

Implement the unsigned Lah numbers which for n>=1, k>=1 are
the number of ways a set of n elements can be partitioned into
k nonempty linearly ordered subsets.

Lah numbers are defined for all integers n, k by the following
formula if the Stirling numbers are extended to negative integers
n, k in the way it is recommended by Graham/Knuth/Patashnik
in 'Concrete Mathematics' Section 6.1 (see Table 253).
(This extension is implemented in GAP’s Stirling functions.)

def Lah(n,k):
    return sum(stirling_number1(n,j)*stirling_number2(j,k,"gap") for j in (k..n))

(Note how inconsistently at present this formula has to be
written to get consistent results (because stirling_number1
and stirling_number2 are based on different, non-compatible
algorithms! See also ticket #17159)

for n in (-6..6):
    print [Lah(n,k) for k in (-6..6)]    

    1,   .,  ., ., ., ., .,   .,    .,    .,   .,  ., .,
   30,   1,  ., ., ., ., .,   .,    .,    .,   .,  ., .,
  300,  20,  1, ., ., ., .,   .,    .,    .,   .,  ., .,
 1200, 120, 12, 1, ., ., .,   .,    .,    .,   .,  ., .,
 1800, 240, 36, 6, 1, ., .,   .,    .,    .,   .,  ., .,
  720, 120, 24, 6, 2, 1, .,   .,    .,    .,   .,  ., .,
    .,   .,  ., ., ., ., 1,   .,    .,    .,   .,  ., .,
    .,   .,  ., ., ., ., .,   1,    .,    .,   .,  ., .,
    .,   .,  ., ., ., ., .,   2,    1,    .,   .,  ., .,
    .,   .,  ., ., ., ., .,   6,    6,    1,   .,  ., .,
    .,   .,  ., ., ., ., .,  24,   36,   12,   1,  ., .,
    .,   .,  ., ., ., ., ., 120,  240,  120,  20,  1, .,
    .,   .,  ., ., ., ., ., 720, 1800, 1200, 300, 30, 1,

Component: combinatorics

Keywords: Lah numbers

Issue created by migration from https://trac.sagemath.org/ticket/17161

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions