There are some problems with the function gaussian_binomial
in sage 2.8.14. The help string contains a typo:

 binom{n}{k}_q = frac{(1-q^m)(1-q^{m-1})... (1-q^{m-r+1})}
                     {(1-q)(1-q^2)... (1-q^r)}.

The typo is that m and r on the RHS should match n and k on the LHS.

I feel that to be useful gaussian_binomial(n,k,q) should work if n
and k are integers and 0<=k<=n, no matter what q is. At the moment,
the function requires q to be an integer but there will be
applications if q is an indeterminate.  Moreover if q = 1 this
should give the ordinary binomial coefficient but the current
implementation fails due to division by zero.

Perhaps the following is one way to improve the
function would be as follows. Then it gives the
correct behavior when q is an indeterminate or q=1.

Why does the original function use misc.prod instead
of prod?

Daniel Bump

def gaussian_binomial(n,k,q):
    r"""
    Return the gaussian binomial
    $$
       \binom{n}{k}_q = \frac{(1-q^n)(1-q^{n-1})\cdots (1-q^{n-k+1})}
                             {(1-q)(1-q^2)\cdots (1-q^k)}.
    $$ 
    
    EXAMPLES:
        sage: gaussian_binomial(5,1,2)
        31

    AUTHOR: David Joyner and William Stein
    """

    R.<x>=QQ[]

    n = prod([1 - x**i for i in range((n-k+1),n+1)])
    d = prod([1 - x**i for i in range(1,k+1)])

    return (n / d).subs(x = q)




         

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to