Patch is attached.

Ralf

On 10/24/25 14:02, Ralf Hemmecke wrote:
Ooops.

%%% (309) -> stirling1(0,0)$IntegerCombinatoricFunctions(Integer)

    (309)  0
                                                     Type: Integer
That should be 1, right?

    stirling1(n, m) ==
       -- Definition: (-1)^(n-m) S[n, m] is the number of
       -- permutations of n symbols which have m cycles.
       n < 0 or m < 1 or m > n => 0
       m = n => 1
       S.Sn = n => coefficient(S.Sp, convert(m)@Z :: N)
       x := monomial(1, 1)$SUP(I)
       S.Sn := n
       S.Sp := x
       for k in 1 .. convert(n-1)@Z repeat S.Sp := S.Sp * (x - k::SUP(I))
       coefficient(S.Sp, convert(m)@Z :: N)

It seems that the condition "m < 1" in the first line should only be applied if n>0, i.e. it should be:

       n < 0 or (n > 0 and m < 1) or m > n => 0

Probably the same problem in stirling2.

Ralf



--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/fricas-devel/b4b4d1b7-6dd7-4a8b-a25f-5411d618d4ec%40hemmecke.org.
From 98709d5d73ddf373c22bae13aca9685b09aad52e Mon Sep 17 00:00:00 2001
From: Ralf Hemmecke <[email protected]>
Date: Sun, 9 Nov 2025 14:37:11 +0100
Subject: correct stirling1(0,0)=stirling2(0,0)=1

---
 src/algebra/combinat.spad | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/algebra/combinat.spad b/src/algebra/combinat.spad
index 18ac0dee..17452892 100644
--- a/src/algebra/combinat.spad
+++ b/src/algebra/combinat.spad
@@ -157,6 +157,7 @@ IntegerCombinatoricFunctions(I : IntegerNumberSystem) : with
    stirling1(n, m) ==
       -- Definition: (-1)^(n-m) S[n, m] is the number of
       -- permutations of n symbols which have m cycles.
+      zero? n and zero? m => 1
       n < 0 or m < 1 or m > n => 0
       m = n => 1
       S.Sn = n => coefficient(S.Sp, convert(m)@Z :: N)
@@ -169,6 +170,7 @@ IntegerCombinatoricFunctions(I : IntegerNumberSystem) : with
    stirling2(n, m) ==
       -- definition: SS[n, m] is the number of ways of partitioning
       -- a set of n elements into m non-empty subsets
+      zero? n and zero? m => 1
       n < 0 or m < 1 or m > n => 0
       m = 1 or n = m => 1
       s : I := if odd? m then -1 else 1
-- 
2.43.0

Reply via email to