Recently, I have been doing experiments involving q-binomial coefficients in Mathematica. Starting with version 7, Mathematica is prepared for some q-business; in particular, there exists a function named QBinomial giving the q-analog of Binomial. However, this implementation turned out to not be fast enough for my needs. Here is an alternative approach which is not only way faster but provides a full factorization.
qn[n_, q_] :=
Product[If[Mod[n, d] == 0, Cyclotomic[d, q], 1], {d, 2, n}];
qfactorial[n_, q_] :=
Product[Cyclotomic[d, q]^Floor[n/d], {d, 2, n}];
qbinomial[n_, k_, q_] :=
If[k > n, 0,
Product[If[Floor[n/d] == Floor[k/d] + Floor[(n - k)/d], 1,
Cyclotomic[d, q]], {d, 2, n}]];
The above code is based on the following well-known observations. Let
be the n-th cyclotomic polynomial. Then
![]() |
where the product is taken over those 2 ≤ d ≤ n for which
. This follows from
,
![]() |
and
![]() |
Finally, note that
![]() |
Comments
Post new comment