Bug #1605
binomial: domain of defn?
Description
What should the domain of definition of binomial(n,r)
be?
Most restrictive is 0 <= r <= n
.
More flexible is 0 <= r <= abs(n)
.
Or we could allow allow all pairs.
The current implementations are inconsistent (depending on whether args are MachineInt
or BigInt
).
History
#1 Updated by John Abbott over 2 years ago
The sample implementations on the Wikipedia page accept all pairs of integers as args, with
the convention that the value is 0 if the second arg is negative.
Wolfram proposes the following convention https://mathworld.wolfram.com/BinomialCoefficient.html
(namely the value is 0 whenever r < 0
or r > abs(n)
#2 Updated by John Abbott over 2 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 10
So the main question is: is it better to allow the fully general definition, or better to "protect the careless user"?
Right now I am favouring allowing the fully general definition.
#3 Updated by John Abbott over 2 years ago
- Subject changed from binomial: range of defn? to binomial: domain of defn?
- Description updated (diff)
#4 Updated by John Abbott over 2 years ago
- Status changed from In Progress to Resolved
- Assignee set to John Abbott
- % Done changed from 10 to 50
I have changed the code to use the fully general defn... not really sure why it was not already so defined.
Changed test-BigInt2.C
as well.
Will check in a bit later.
#5 Updated by Anna Maria Bigatti over 2 years ago
John Abbott wrote:
I have changed the code to use the fully general defn... not really sure why it was not already so defined.
Changedtest-BigInt2.C
as well.
Will check in a bit later.
Sounds ok to me.
#6 Updated by John Abbott over 2 years ago
- Status changed from Resolved to Feedback
- % Done changed from 50 to 90
Mostly done now.
#7 Updated by John Abbott over 2 years ago
- Status changed from Feedback to Closed
- % Done changed from 90 to 100
- Estimated time set to 1.51 h