Ask Your Question
1

Defining q-binomial coefficients $\binom{n}{k}_q$ symbolic in $n, k$

asked 2019-09-21 16:37:29 +0200

joakim_uhlin gravatar image

updated 2019-09-23 21:35:43 +0200

I would like to verify certain identities involving sums of $q$-binomial coefficients $\binom{n}{k}_q$ and as such, I would like to treat the $q$-binomial coefficients as if they were symbolic in $n$ and $k$. But the version of $q$-binomial coefficients that are implemented in Sage cannot be used as a symbolic variable in $n$ and $k$ according to this thread. So, to this end I defined my own:

var('q,n,k')
qint = lambda n: sum([q^i for i in range(n)]) 
qfac = lambda n: 1 if n==0 else prod([qint(i) for i in range(1,n+1)])
qbin = lambda n,k:qfac(n)/(qfac(k)*qfac(n-k))

But if I write

sum(qbin(n,k),k,0,n)

I get the following error:

ValueError: cannot convert n + 1 to int

Is there a way to do these types of summations in Sage? I should note that, for my purposes, it would be enough to limit myself to the case when $n$ and $k$ are non-negative integers.

EDIT: As an example, I would like to prove something like the $q$-binomial theorem, which says

$$\sum_{k=0}^n q^{k(k-1)/2} \binom{n}{k}_q x^k = \prod_{k=0}^{n-1} (1+q^k x)$$

EDIT2: Fixed a typo.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-09-22 11:02:01 +0200

rburing gravatar image

updated 2019-09-22 11:04:03 +0200

If you want to make a symbolic sum then all the terms should be symbolic. Your example does not work because qbin(n,k) is not defined for symbolic n.

What you can do is to make qbin a symbolic function with custom typesetting:

var('q')
def qbin_latex(self, n, k):
    return '{' + str(n) + ' \choose ' + str(k) + '}_{' + str(q) + '}'
qbin = function('qbin', nargs=2, print_latex_func=qbin_latex)
var('k,n')
show(sum(qbin(n,k),k,0,n))

$$\sum_{k=0}^{n} {n \choose k}_{q}$$

To check the identities that you are interested in, you will probably have to do some substitutions by hand, and/or pass an evalf_func parameter to function in the definition of qbin. Have a look at the documentation for symbolic functions.

edit flag offensive delete link more

Comments

I will take a look at the documentation and try to make sense of it. What I am really looking for is a way to verify an identity of the form RHS(q,n,k)=LHS(q,n,k), involving some q-binomial coefficients that depend on n and k. Something like the q-binomial theorem. It seems to me that evalf_func evaluates a function numerically, so I could only confirm the identity for many values of q, n, k which is not exactly what I want.

joakim_uhlin gravatar imagejoakim_uhlin ( 2019-09-22 18:16:36 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-09-21 16:37:29 +0200

Seen: 393 times

Last updated: Sep 23 '19