11
$\begingroup$

Now(2023), Mathematica has some QFunctions for q-anlaog. See Official Documentation. e.g.:

  • QPochhammer
  • QFactorial
  • QBinomial
  • QGamma
  • QHypergeometricPFQ
  • QPolyGamma

I found one post about how to implement q-StirlingS2

A[n_, k_, i_, j_] := 
  Binomial[n, k + i] Binomial[n, k - j] - 
   Binomial[n, k + i + 1] Binomial[n, k - j - 1];
QStirlingS2Fast[n_, k_, q_] := 
  1/(1 - q)^(n - k) Sum[(-1)^i*
     A[n, k, i, j] q^Binomial[j + 1, 2] QBinomial[i, j, q], {j, 0, 
     k}, {i, j, n - k}];
QStirlingS2Fast[5, 3, q] // FunctionExpand // Expand

Imitating the code, I implemented q-StirlingS1

B[n_, k_, i_, j_] := 
  Binomial[n + j - 1, k - 1] Binomial[n - i - 1, k - 1] - 
   Binomial[n + j, k - 1] Binomial[n - i - 2, k - 1];

QStirlingS1Fast[n_, k_, q_] := 
  1/((1 - q)^(n - k))*
   Sum[(-1)^j*B[n, k, i, j]*q^Binomial[j + 1, 2]*
     QBinomial[i, j, q], {j, 0, n - k}, {i, j, n - k}];
QStirlingS1Fast[5, 3, q] // FunctionExpand // Expand

My question is:

In addition to these, can you give some practical QFunctions and corresponding Mathematica implementations? Can you give a faster implementation with Mathematica?

Any help would be appreciated.

$\endgroup$

2 Answers 2

15
$\begingroup$

There are lots of QFunctions (see also wikipedia)

Some are the q(,t)-analog version of the original MATH objects. (orthogonal polynomials, special functions, etc. ) However, it seems to me that some of these are nothing more than terms created to generalize some concepts. Even, for the q-expotential, academics can not standardize the notation.

Some can also be used in q(,t)-analog technique for enumerative combinatorics. On one hand, $q,t$ are just formal variables. On the other hand, it looks like the introducing of these notations can transform the formula shorter. I'm focusing on these.

[TOC]

The MacMahon q-analog of the Catalan numbers

Q[n_] := (1 - q^n)/(1 - q);
QMacMahonCatalan[n_, q_] := QBinomial[2 n, n, q]/Q[n + 1];
QMacMahonCatalan[3, q] // FunctionExpand // Expand

The Carlitz and Riordan q-analog of the Catalan numbers

QCarlitzAndRiordanCatalan[0] := 1;
QCarlitzAndRiordanCatalan[1] := 1;
QCarlitzAndRiordanCatalan[n_] := 
  Sum[QCarlitzAndRiordanCatalan[k]*
    QCarlitzAndRiordanCatalan[n - 1 - k]*q^(k), {k, 0, n - 1}];
QCarlitzAndRiordanCatalan /@ Range[0, 5] // Expand

The Carlitz q-analog of the Catalan numbers

QCarlitzCatalan[0] := 1;
QCarlitzCatalan[1] := 1;
QCarlitzCatalan[n_] := 
  Sum[QCarlitzCatalan[k]*QCarlitzCatalan[n - 1 - k]*
    q^((k + 1) (n - 1 - k)), {k, 0, n - 1}];
QCarlitzCatalan /@ Range[0, 5] // Expand

The q-analog of Fuß–Catalan numbers

Q[n_] := (1 - q^n)/(1 - q);
QFußCatalan[n_, m_, q_] := QBinomial[(m + 1) n, n - 1, q]/Q[n];
QFußCatalan[2, 3, q] // FunctionExpand // Expand

The rational Catalan numbers

Q[n_] := (1 - q^n)/(1 - q);
RationalCatalan[a_, b_, q_] := QBinomial[a + b, a, q]/Q[a + b];
RationalCatalan[2, 3, q] // FunctionExpand // Expand

the q,t-Catalan numbers

It descibes the distribution:

$$ C_n(q,t)=\sum_{\pi \in L_{n, n}^{+}} q^{\operatorname{area}(\pi)} t^{\text {bounce }(\pi)} $$

I'd like to use this formula:

$$ C_n(q,t)= \sum_{b=1}^n \sum_{\substack{\alpha_1+\alpha_2+\ldots+\alpha_b=n \\ \alpha_i>0}} t^{\alpha_2+2 \alpha_3+\ldots+(b-1) \alpha_b} q^{\sum_{i=1}^b\left(\begin{array}{c} \alpha_i \\ 2 \end{array}\right)} \prod\limits_{i=1}^{b-1}\left[\begin{array}{c} \alpha_i+\alpha_{i+1}-1 \\ \alpha_{i+1} \end{array}\right] $$

QTCatalan[n_, q_, t_] := 
 Module[{CalculateTerm}, 
  CalculateTerm[avec_List] := Module[{part1, part2, part3, b},
    b = Length[avec];
    part1 = t^Sum[(i - 1)*avec[[i]], {i, 2, b - 1}];
    part2 = q^Sum[Binomial[avec[[i]], 2], {i , 1, b}];
    part3 = 
     Product[QBinomial[avec[[i]] + avec[[i + 1]] - 1, avec[[i + 1]], 
       q], {i, 1, b - 1}];
    part1*part2*part3
    ];
  Sum[Sum[
    CalculateTerm[avec], {avec, 
     FrobeniusSolve[Array[1 &, b], n]}], {b, 1, n}]
  ]

QTCatalan[#, q, t] &    /@ Range[1, 3] // FunctionExpand // Expand

q,t-Narayana numbers

It describes the distribution:

$$ N(n;q,t)=\sum_{w \in D P(n)} q^{\mathrm{maj}(w)} t^{\text {peaks }(w)} $$

Where we sum over all Dyck paths.

I'd like to use the formula:

$$ N(n,k;q) = \frac{q^{k(k-1)}}{[n]_q}\left[\begin{array}{l} n \\ k \end{array}\right]_q\left[\begin{array}{c} n \\ k-1 \end{array}\right]_q $$

$$ N(n;q,t)=\sum\limits_{k=1}^{n} t^k N(n,k;q) $$

Q[n_] := (1 - q^n)/(1 - q);
QNarayana[n_, k_, q_] := 
  QBinomial[n, k, q]*QBinomial[n, k - 1, q]*q^(k (k - 1))/Q[n];
QNarayana[3, 2, q] // FunctionExpand // Expand


QTNarayana[n_, q_, t_] := Sum[t^k*QNarayana[n, k, q], {k, 1, n}]
QTNarayana[3, q, t] // FunctionExpand // Expand

q-Multinomial

It describes the distribution:

$$ \left[\begin{array}{c} m_1+m_2+\cdots+m_r \\ m_1, m_2, \ldots, m_r \end{array}\right]=\sum_{w \in R(\mathbf{m})} q^{\operatorname{maj} w} $$

Where we sum over all the words of length $m=m_1+m_2+\cdots + m_r$ which are rearrangments of the nondecreasing word $1^{m_1} 2^{m_2} \cdots r^{m_r}$ (i.e. the number of character $1$ is $m_1$, the number of character $2$ is $m_2$, $\cdots$)

QMultinomial[mlist_List, q_] := 
 QPochhammer[q, q, Total@mlist]/
  Product[QPochhammer[q, q, mi], {mi, mlist}]
QMultinomialDefinition2[mlist_List, q_] := 
 QFactorial[Total@mlist, q]/Product[QFactorial[mi, q], {mi, mlist}]



QMultinomial[{1, 2, 3}, q] // FunctionExpand // Expand
Limit[%, q -> 1]
Multinomial[1, 2, 3]

The Euler-Mahonian polynomial $A_{\mathbf{m}}(t, q)$

I'd like to use the formula:

$$ \frac{1}{(t ; q)_{m+1}} A_{\mathbf{m}}(t, q)=\sum_{s \geq 0} t^s\left[\begin{array}{c} m_1+s \\ s \end{array}\right] \ldots\left[\begin{array}{c} m_r+s \\ s \end{array}\right] $$

EulerMahonianPolynomial[mlist_List, t_, q_] := 
 QPochhammer[t, q, Length[mlist]+1 ]*
  Sum[t^s*Product[QBinomial[mi + s, s, q], {mi, mlist}], {s, 0, 
    Infinity}]
  
EulerMahonianPolynomialLimitedVersion[mlist_List, t_, q_] := 
 QPochhammer[t, q, Length[mlist]+1 ]*
  Sum[t^s*Product[QBinomial[mi + s, s, q], {mi, mlist}], {s, 0, 8}]

EulerMahonianPolynomialLimitedVersion[{1, 2, 3}, t, q] // FunctionExpand // 
  FullSimplify // Expand

the q-maj-Eulerian polynomial ${}^{\operatorname{maj}} A_r (t,q)$

When the multi-index $\mathbf{m}$ is of the form $(1^r)=(1,1,\cdots,1)$, the Euler-Mahonian polynomial $A_{\mathbf{m}}(t, q)$ will be denoted by ${}^{\operatorname{maj}} A_r (t,q)$ and referred to as the q-maj-Eulerian polynomial.

QMajEulerianPolynomial[r_, t_, q_] := 
 EulerMahonianPolynomial[Array[1 &, r], t, q]

...


Reference

THE q-SERIES IN COMBINATORICS; PERMUTATION STATISTICS
The q, t-Catalan Numbers and the Space of Diagonal Harmonics

$\endgroup$
1
  • 1
    $\begingroup$ Wow ,useful Things. +1) $\endgroup$ Aug 11, 2023 at 9:30
2
$\begingroup$

I have some of these implemented in my CombinatoricTools.m package; see my GitHub page.

qInteger;
qFactorial;
qBinomial;
qMultinomial;
qHookFormula;
qCatalan;
qCarlitzCatalan;
qtCatalan;
qNarayana;
qKreweras;

I had forgotten that I had the qt-Catalans implemented, but this is the code from the above mentioned package. I suspect this recursive formula is faster than the one mentioned in a different answer (it is apparently Thm. 3.4 from Jim's book).

qBinomial[n_Integer,k_Integer,q_:1]:=qBinomial[n,k,q]=FunctionExpand[QBinomial[n,k,q]];

(* This recursion is basically thm 3.4 in Jims book *)
qtH[n_, n_, q_, t_] := q^Binomial[n, 2];
qtH[n_, k_, q_, t_] := 
  qtH[n, k, q, t] = t^(n - k) q^Binomial[k, 2] Sum[
     qBinomial[r + k - 1, r, q] qtH[n - k, r, q, t], {r, n - k}];
qtCatalan::usage = "qtCatalan[n,q,t] is the qt-Catalan polynomial.";
qtCatalan[n_Integer, q_: 1, t_: 1] := Together[qtH[n + 1, 1, q, t]/t^n];

In general, I found it useful to define this FunctionExpanded qbinomial version and memoize it for speed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.