#12179: Binomial of integer (mod n) returns integer
-------------------------------------+-------------------------------------
Reporter: scotts | Owner: AlexGhitza
Type: defect | Status: needs_work
Priority: major | Milestone: sage-5.11
Component: basic arithmetic | Resolution:
Keywords: binomial | Merged in:
coefficient modulo sd35 | Reviewers: Colton Pauderis,
Authors: Sam Scott, Marco | Johan Bosman, Marco Streng
Streng | Work issues:
Report Upstream: N/A | Dependencies:
Branch: |
Stopgaps: |
-------------------------------------+-------------------------------------
Changes (by {'newvalue': u'Sam Scott, Marco Streng', 'oldvalue': u'Sam Scott'}):
* dependencies: #11417 =>
* author: Sam Scott => Sam Scott, Marco Streng
Old description:
> {{{
> sage: R = Integers(6)
> sage: binomial(R(5), R(2))
> 10
> sage: binomial(R(5), R(2)).parent()
> Integer Ring
> }}}
>
> But {{{binomial(R(5), R(2))}}} is nonsense, both as an element of ZZ and
> as an element of R:
> {{{
> sage: binomial(5, 2)
> 10
> sage: binomial(11, 2)
> 55
> sage: binomial(5, 8)
> 0
> }}}
>
> On input {{{binomial(x, y)}}}, what Sage should do instead is the
> following:
> * If the parent of y is Zmod(n) rather than ZZ, a `TypeError` should be
> raised.
> * If factorial(y) is zero or a zero-divisor in the parent of x, a
> `ZeroDivisionError` should be raised. This is automatic if one computes
> binomial(x, y) simply as
> {{{
> x.parent()(prod([x-k for k in range(y)]) / factorial(y))
> }}}
New description:
{{{
sage: R = Integers(6)
sage: binomial(R(5), R(2))
10
sage: binomial(R(5), R(2)).parent()
Integer Ring
}}}
But {{{binomial(R(5), R(2))}}} is nonsense, both as an element of ZZ and
as an element of R:
{{{
sage: binomial(5, 2)
10
sage: binomial(11, 2)
55
sage: binomial(5, 8)
0
}}}
On input {{{binomial(x, y)}}}, what Sage should do instead is the
following:
* If the parent of y is Zmod(n) rather than ZZ, a `TypeError` should be
raised.
* If factorial(y) is zero or a zero-divisor in the parent of x, a
`ZeroDivisionError` should be raised. This is automatic if one computes
binomial(x, y) simply as
{{{
x.parent()(prod([x-k for k in range(y)]) / factorial(y))
}}}
Apply:
* [attachment:12179_new.patch]
--
Comment:
apply only 12179_new.patch
--
Ticket URL: <http://trac.sagemath.org/ticket/12179#comment:16>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.