\documentclass[12pt,reqno]{article}

\usepackage[usenames]{color}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amscd}
\usepackage{graphicx}

\usepackage[colorlinks=true,
linkcolor=webgreen,
filecolor=webbrown,
citecolor=webgreen]{hyperref}

\definecolor{webgreen}{rgb}{0,.5,0}
\definecolor{webbrown}{rgb}{.6,0,0}

\usepackage{color}
\usepackage{fullpage}
\usepackage{float}

\usepackage{psfig}
\usepackage{graphics}
\usepackage{latexsym}
\usepackage{epsf}
\usepackage{breakurl}
\usepackage{mathrsfs}
\usepackage{mathtools}

\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{.1in}
\setlength{\evensidemargin}{.1in}
\setlength{\topmargin}{-.1in}
\setlength{\textheight}{8.4in}

\newcommand{\seqnum}[1]{\href{https://oeis.org/#1}{\underline{#1}}}

\newcommand{\NN}{\mathbb{N}}
\newcommand{\DD}{\mathfrak{D}}
\newcommand{\Der}{\mathscr{D}}

\newcommand{\falling}[2]{{#1}^{\underline{#2}}}
\newcommand{\rising}[2]{{#1}^{\overline{#2}}}

\newcommand{\Mchoose}[2]{{\left(\!\!\!{ #1 \choose #2 }\!\!\!\right)}}

\begin{document}

\begin{center}
\epsfxsize=4in
\leavevmode\epsffile{logo129.eps}
\end{center}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{conjecture}[theorem]{Conjecture}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\begin{center}
\vskip 1cm{\LARGE\bf $q$-Derangement Identities\\
\vskip 1cm}
\large
Emanuele Munarini \\
Dipartimento di Matematica \\
Politecnico di Milano \\
Piazza Leonardo da Vinci 32 \\
Milano \\
Italy \\
\href{mailto:emanuele.munarini@polimi.it}{\tt emanuele.munarini@polimi.it}\\
\end{center}

\vskip .2 in

\begin{abstract}
 In this paper, we derive several combinatorial identities involving the $q$-derangement numbers (for the major index)
 and many other $q$-numbers and $q$-polynomials of combinatorial interest,
 such as the $q$-binomial coefficients, the $q$-Stirling numbers, the $q$-Bell numbers,
 the $q$-Pochhammer symbol, the Gaussian polynomials,
 the Rogers-Szeg\H{o} polynomials and the Galois numbers,
 and the Al-Salam-Carlitz polynomials.
 We also obtain two determinantal identities
 expressing the $q$-derangement numbers as tridiagonal determinants
 and as Hessenberg determinants.
\end{abstract}

\section{Introduction}

The \emph{derangement number} $ d_n $ (sequence \seqnum{A000166} in
the {\it On-Line Encyclopedia of Integer Sequences})
counts the derangements (i.e., permutation with no fixed points) of an $n$-set.
By a simple application of the principle of inclusion-exclusion, we have the formula
\begin{equation}\label{def-derN}
 d_n = \sum_{k=0}^n { n \choose k } (n-k)!\, (-1)^k \, .
\end{equation}
Moreover, these numbers satisfy the recurrences
\begin{align}
 & d_{n+1} = (n+1)\, d_n + (-1)^{n+1} \label{rec-derN01} \\
 & d_{n+2} = (n+1)\, d_{n+1} + (n+1)\, d_n \label{rec-derN02}
\end{align}
with initial conditions $ d_0 = 1 $ and $ d_1 = 0 $.

The \emph{$q$-derangement numbers} \cite{Wachs,ChenRota} are defined by the formula
\begin{equation}\label{def-qderN}
 d_n(q) = \sum_{k=0}^n { n \choose k }_{\!\!q} [n-k]_q!\, (-1)^k q^{{ k \choose 2 }} \, ,
\end{equation}
where $ [n]_q = 1+q+q^2+\cdots+q^{n-1} $, and satisfy the recurrences
\begin{align}
 & d_{n+1}(q) = [n+1]_q\, d_n(q) + (-1)^{n+1} q^{{ n+1 \choose 2 }} \label{rec-qderN01} \\
 & d_{n+2}(q) = [n+1]_q\, d_{n+1}(q) + [n+1]_q\, q^{n+1} d_n(q) \label{rec-qderN02}
\end{align}
with initial conditions $ d_0(q) = 1 $ and $ d_1(q) = 0 $.

The \emph{major index} $ \mathrm{maj}(\sigma) $
of a permutation $ \sigma $ of $ \{1,2,\ldots,n\} $
is the sum of all positions $ k $ for which $ \sigma(k) > \sigma(k+1) $.
The $q$-numbers $ d_n(q) $ arise from the $q$-counting of derangements
by major index
and have several interesting combinatorial properties.
Indeed, if $ \Der_n $ is the set of all derangements of $ \{1,2,\ldots,n\} $,
then we have \cite{Wachs}
$$ d_n(q) = \sum_{\sigma\in\Der_n} q^{\mathrm{maj}(\sigma)} \, . $$
Moreover, considered as a polynomial in $ q $, the $q$-derangement number $ d_n(q) $
has non-negative integer coefficients forming a unimodal sequence \cite{ChenRota}.
These coefficients have a spiral property \cite{Zhang},
which implies their unimodality and also the fact that
the maximum coefficient of $ d_n(q) $ appears exactly in the middle of the polynomial,
i.e., is the coefficient of $ q^{\lfloor n(n-1)/4 \rfloor} $
(as conjectured by Chen and Rota \cite{ChenRota}).
Furthermore, they have the ratio monotonicity property (for $ n \geq 6 $) \cite{ChenXia}
which implies log-concavity and the spiral property.

For the ordinary derangement numbers $ d_n $
(and their generalizations \cite{CFMunariniZ,FerrariMunarini,MunariniA,MunariniC,MunariniO})
there are a lot of combinatorial identities.
In this paper, we derive several $q$-analogues of these identities.
They involve the $q$-derangement numbers $ d_n(q) $
and many other $q$-numbers or $q$-polynomials,
such as the $q$-binomial coefficients,
the $q$-Stirling numbers and the $q$-Bell numbers,
the $q$-Pochhammer symbol, the Gaussian polynomials,
the Rogers-Szeg\H{o} polynomials and the Galois numbers,
and the Al-Salam-Carlitz polynomials.
Finally, we obtain two determinantal identities
expressing the $q$-derangement numbers as tridiagonal determinants
and as Hessenberg determinants.

\section{$q$-binomial identities}\label{sec-qBin}

We start by recalling some basic definitions of $q$-number theory.
For every $ n \in \NN $, we have the \emph{$q$-natural number} $ [n]_q = 1+q+q^2+\cdots+q^{n-1} $
and the \emph{$q$-factorial number} $ [n]_q! = [n]_q[n-1]_q\cdots[2]_q[1]_q $.
Then, for every $ n, k \in \NN $,
we have the \emph{$q$-binomial coefficients}
(or \emph{Gaussian coefficients} \cite{Gauss}) defined by
$$
 { n \choose k }_{\!\!q} =
 \begin{cases}
  \displaystyle \frac{[n]_q!}{[k]_q![n-k]_q!}, & \mbox{if } k \leq n; \\[2mm]
   0, & \mbox{otherwise,}
 \end{cases}
$$
and satisfying the recurrence
\begin{equation}\label{RecqBin}
 { n+1 \choose k+1 }_{\!\!q} = { n \choose k }_{\!\!q} + q^{n+1} { n \choose k+1 }_{\!\!q}
\end{equation}
with initial conditions $ { n \choose 0 }_{\!\!q} = 1 $ and
$ { 0 \choose k }_{\!\!q} = \delta_{k,0} $.
Moreover, we have the relations
\begin{equation}\label{qBinRel}
 [n]_{q^{-1}} = \frac{1}{q^{n-1}}\,[n]_q \, , \qquad
 [n]_{q^{-1}}! = [n]_q!\; q^{-{n \choose 2 }} \, , \qquad
 { n \choose k }_{\!\!q^{-1}} = { n \choose k }_{\!\!q} q^{-k(n-k)} \, .
\end{equation}

\medskip

In this first section, we derive some $q$-binomial identities
using an elementary approach \cite{MunariniSP}
which exploits the properties of the $q$-binomial coefficients
and the recurrences of the $q$-derangement numbers.
In Section \ref{sec-qES}, we derive some other $q$-binomial identities
by using the more advanced technique of the $q$-exponential series.

Our first result is the following:
\begin{theorem}
 For every $ n \in \NN $, we have the identity
 \begin{equation}\label{IdqBinqDer}
  1 + \sum_{k=1}^n { n \choose k }_{\!\!q} \frac{d_{k+1}(q)}{[k]_q} =
  \sum_{k=0}^n { n+1 \choose k+1 }_{\!\!q} d_k(q) \, .
 \end{equation}
\end{theorem}
\begin{proof}
 By recurrence (\ref{rec-qderN02}), we have
 $$ \frac{d_{k+2}(q)}{[k+1]_q} = d_{k+1}(q) + q^{k+1} d_k(q)\, . $$
 Consequently, we have
 $$
  \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} \frac{d_{k+2}(q)}{[k+1]_q} =
  \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} d_{k+1}(q) +
  \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} q^{k+1} d_k(q)
 $$
 or
 $$
  \sum_{k=1}^n { n \choose k }_{\!\!q} \frac{d_{k+1}(q)}{[k]_q} =
  \sum_{k=1}^n { n \choose k }_{\!\!q} d_k(q) +
  \sum_{k=0}^n { n \choose k+1 }_{\!\!q} q^{k+1} d_k(q)
 $$
 or
 $$
  \sum_{k=1}^n { n \choose k }_{\!\!q} \frac{d_{k+1}(q)}{[k]_q} =
  \sum_{k=0}^n \left( { n \choose k }_{\!\!q} + q^{k+1} { n \choose k+1 }_{\!\!q} \right) d_k(q) - d_0(q) \, .
 $$
 By recurrence (\ref{RecqBin}) and the initial condition $ d_0(q) = 1 $,
 we have identity (\ref{IdqBinqDer}).
\end{proof}

Similarly, we have the following formula.
\begin{theorem}
 For every $ n \in \NN $, we have the identity
 \begin{equation}\label{IdqBinqDer2}
  \sum_{k=0}^n { n \choose k }_{\!\!q} d_{k+1}(q) =
  \sum_{k=0}^n { n+1 \choose k+1 }_{\!\!q} [k]_q d_k(q) +
  \sum_{k=1}^n { n \choose k }_{\!\!q} q^{2k-1} d_{k-1}(q) \, .
 \end{equation}
\end{theorem}
\begin{proof}
 By recurrence (\ref{rec-qderN02}), we have
 $$
  \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} d_{k+2}(q)
  = \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} [k+1]_q d_{k+1}(q)
  + \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} [k+1]_q q^{k+1} d_k(q)
 $$
 or
 $$
  \sum_{k=1}^n { n \choose k }_{\!\!q} d_{k+1}(q)
  = \sum_{k=1}^n { n \choose k }_{\!\!q} [k]_q d_k(q)
  + \sum_{k=0}^n { n \choose k+1 }_{\!\!q} [k+1]_q q^{k+1} d_k(q)
 $$
 or
 $$
  \sum_{k=0}^n { n \choose k }_{\!\!q} d_{k+1}(q) - d_1(q)
  = \sum_{k=0}^n { n \choose k }_{\!\!q} [k]_q d_k(q)
  + \sum_{k=0}^n { n \choose k+1 }_{\!\!q} ([k]_q+q^k) q^{k+1} d_k(q)
 $$
 or
 $$
  \sum_{k=0}^n { n \choose k }_{\!\!q} d_{k+1}(q) - d_1(q)
  = \sum_{k=0}^n \left( { n \choose k }_{\!\!q} + q^{k+1} { n \choose k+1 }_{\!\!q} \right) [k]_q d_k(q)
  + \sum_{k=0}^n { n \choose k+1 }_{\!\!q} q^{2k+1} d_k(q) \, .
 $$
 By recurrence (\ref{RecqBin}) and the initial condition $ d_1(q) = 0 $,
 we have identity (\ref{IdqBinqDer2}).
\end{proof}

We also have the following formula.
\begin{theorem}
 For every $ m,n \in \NN $, we have the identity
 \begin{equation}\label{IdBin11}
   \sum_{k=0}^n { m+n+1 \choose m+k+1 }_{\!\!q} \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{{ m+k+1 \choose 2 }} d_k(q) =
   \sum_{k=0}^n { m+n \choose m+k }_{\!\!q} \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{{ m+k+1 \choose 2 }+{ k \choose 2 }} \, .
 \end{equation}
 In particular, for $ m = 0 $, we have the identity
 \begin{equation}\label{IdBin12}
  \sum_{k=0}^n { n+1 \choose k+1 }_{\!\!q} \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{{ k+1 \choose 2 }} d_k(q) =
  \sum_{k=0}^n { n \choose k }_{\!\!q} \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{k^2}.
 \end{equation}
\end{theorem}
\begin{proof}
 From recurrence (\ref{rec-qderN01}), we have
 $$ \frac{d_{k+1}(q)}{[k+1]_q!} = \frac{d_{k}(q)}{[k]_q!} + (-1)^{k+1} \frac{q^{{ k+1 \choose 2 }}}{[k+1]_q!}\, . $$
 and consequently
 \begin{align*} 
   & \sum_{k=0}^{n-1} { m+n \choose m+k+1 }_{\!\!q} (-1)^{k+1} [n]_q! q^{{ m+k+2 \choose 2 }} \frac{d_{k+1}(q)}{[k+1]_q!}  \\ 
& =   \sum_{k=0}^{n-1} { m+n \choose m+k+1 }_{\!\!q} (-1)^{k+1} [n]_q! q^{{ m+k+2 \choose 2 }} \frac{d_{k}(q)}{[k]_q!} + 
   \sum_{k=0}^{n-1} { m+n \choose m+k+1 }_{\!\!q} [n]_q! q^{{ m+k+2 \choose 2 }} \frac{q^{{ k+1 \choose 2 }}}{[k+1]_q!}\, ;
\end{align*}
 that is,
  \begin{align*}
   & \sum_{k=1}^n { m+n \choose m+k }_{\!\!q} \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{{ m+k+1 \choose 2 }} d_k(q) + 
   \sum_{k=0}^{n-1} { m+n \choose m+k+1 }_{\!\!q} \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{{ m+k+1 \choose 2 }} q^{m+k+1} d_k(q)  \\
   & \qquad = \sum_{k=1}^n { m+n \choose m+k }_{\!\!q} \frac{[n]_q!}{[k]_q!} q^{{ m+k+1 \choose 2 }} q^{{ k \choose 2 }}\, ,
  \end{align*}
or
\begin{align*}   
   & \sum_{k=0}^n \left( { m+n \choose m+k }_{\!\!q} + q^{m+k+1} { m+n \choose m+k+1 }_{\!\!q} \right)
    \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{{ m+k+1 \choose 2 }} d_k(q)  \\
   & \qquad = { m+n \choose m }_{\!\!q} [n]_q! q^{{ m+1 \choose 2 }}
   + \sum_{k=1}^n { m+n \choose m+k }_{\!\!q} \frac{[n]_q!}{[k]_q!} q^{{ m+k+1 \choose 2 }+{ k \choose 2 }}\, .
\end{align*} 
 Hence, by formula (\ref{RecqBin}), we have identity (\ref{IdBin11}).
\end{proof}

Using the same approach, we also have the following result.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdU}
  q \sum_{k=0}^n [k]_q d_k(q) + \sum_{k=0}^n (-1)^k q^{{ k \choose 2 }} = [n+1]_q d_n(q) \, .
 \end{equation}
\end{theorem}
\begin{proof}
 Since $ [k+1]_q = 1+q[k]_q $, recurrence (\ref{rec-qderN01}) can be rewritten as
 $$ d_{k+1}(q) = (1+q[k]_q)\, d_k(q) + (-1)^{k+1} q^{{ k+1 \choose 2 }} $$
 or $$ d_{k+1}(q)-d_k(q) = q[k]_q\, d_k(q) + (-1)^{k+1} q^{{ k+1 \choose 2 }}\, . $$
 Hence, we have
 $$ \sum_{k=0}^n d_{k+1}(q) - \sum_{k=0}^n d_k(q) = q \sum_{k=0}^n [k]_q\, d_k(q) + \sum_{k=0}^n (-1)^{k+1} q^{{ k+1 \choose 2 }} $$
 or
 $$ \sum_{k=1}^{n+1} d_k(q) - \sum_{k=0}^n d_k(q) = q \sum_{k=0}^n [k]_q\, d_k(q) + \sum_{k=1}^{n+1} (-1)^k q^{{ k \choose 2 }} $$
 or
 $$ d_{n+1}(q) - d_0(q) = q \sum_{k=0}^n [k]_q\, d_k(q) + \sum_{k=0}^{n+1} (-1)^k q^{{ k \choose 2 }} - 1 \, . $$
 Hence, by the recurrence (\ref{rec-qderN01}) once again, we have the identity
 $$
  [n+1]_q d_n(q) + (-1)^{n+1} q^{{ n+1 \choose 2 }}
  = q \sum_{k=0}^n [k]_q\, d_k(q) + \sum_{k=0}^n (-1)^k q^{{ k \choose 2 }} + (-1)^{n+1} q^{{ n+1 \choose 2 }}
 $$
 which simplifies to identity (\ref{IdU}).
\end{proof}

Similarly, we also have the following property.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdUU}
   \sum_{k=0}^n { n+1 \choose k+1 }_{\!\!q} (-1)^k q^{{ k+1 \choose 2 }} d_k(q) =
   q \sum_{k=1}^n { n \choose k }_{\!\!q} (-1)^k q^{{ k+1 \choose 2 }} [k-1]_q d_{k-1}(q) +
   \sum_{k=0}^n { n \choose k }_{\!\!q} q^{k^2}.
 \end{equation}
\end{theorem}
\begin{proof}
 Once again, we start by the recurrence (\ref{rec-qderN01}) written as
 $$ d_{k+1}(q)-d_k(q) = q[k]_q\, d_k(q) + (-1)^{k+1} q^{{ k+1 \choose 2 }}\, . $$
 Then we have
 $$
  \begin{aligned}
   \MoveEqLeft
   \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} (-1)^{k+1} q^{{ k+2 \choose 2 }} d_{k+1}(q) -
   \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} (-1)^{k+1} q^{{ k+2 \choose 2 }} d_k(q) = \\ &
   q \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} (-1)^{k+1} q^{{ k+2 \choose 2 }} [k]_q\, d_k(q) +
   \sum_{k=0}^{n-1} { n \choose k+1 }_{\!\!q} q^{{ k+2 \choose 2 }} q^{{ k+1 \choose 2 }},
  \end{aligned}
 $$
which is
 $$
  \begin{aligned}
   \MoveEqLeft
   \sum_{k=1}^n { n \choose k }_{\!\!q} (-1)^k q^{{ k+1 \choose 2 }} d_k(q) +
   \sum_{k=0}^n { n \choose k+1 }_{\!\!q} (-1)^k q^{{ k+1 \choose 2 }} q^{k+1} d_k(q) = \\ &\qquad 
   q \sum_{k=1}^n { n \choose k }_{\!\!q} (-1)^k q^{{ k+1 \choose 2 }} [k-1]_q\, d_{k-1}(q) +
   \sum_{k=1}^n { n \choose k }_{\!\!q} q^{{ k+1 \choose 2 }} q^{{ k \choose 2 }}
  \end{aligned}
 $$
 or
 $$
  \begin{aligned}
   \MoveEqLeft
   \sum_{k=0}^n \left( { n \choose k }_{\!\!q} + q^{k+1} { n \choose k+1 }_{\!\!q} \right) (-1)^k q^{{ k+1 \choose 2 }} d_k(q) - 1  \\  
&  =  q \sum_{k=1}^n { n \choose k }_{\!\!q} (-1)^k q^{{ k+1 \choose 2 }} [k-1]_q\, d_{k-1}(q) +
   \sum_{k=0}^n { n \choose k }_{\!\!q} q^{{ k+1 \choose 2 }} q^{{ k \choose 2 }} - 1\, .
  \end{aligned}
 $$
 By recurrence (\ref{RecqBin}), this last identity simplifies
 to identity (\ref{IdUU}).
\end{proof}

\section{$q$-Stirling identities}\label{sec-qSti}

The \emph{$q$-Stirling numbers of the second kind}
are defined as the connection constants \cite{MunariniCC,MunariniSP}
between the ordinary powers $ x^n $ and the $q$-falling factorials
$ \falling{x}{n}_q = x(x-[1]_q)(x-[2]_q)\cdots(x-[n-1]_q) $,
that is, as the coefficients $ { n \brace k }_{\!\!q} $ for which
$$ x^n = \sum_{k=0}^n { n \brace k }_{\!\!q} \falling{x}{k}_q \, . $$
Equivalently, they are the numbers defined by the recurrence
\begin{equation}\label{Rec-StirlingS2}
 { n+1 \brace k+1 }_{\!\!q} = { n \brace k }_{\!\!q} + [k+1]_q { n \brace k+1 }_{\!\!q}
\end{equation}
with initial values $ { n \brace 0 }_{\!\!q} = \delta_{n,0} $
and $ { 0 \brace k }_{\!\!q} = \delta_{k,0} $.

Similarly, the \emph{$q$-Stirling numbers of the first kind}
are defined as the connection constants \cite{MunariniCC,MunariniSP}
between the $q$-rising factorials $ \rising{x}{n}_q = x(x+[1]_q)(x+[2]_q)\cdots(x+[n-1]_q) $
and the ordinary powers $ x^n $,
that is, as the coefficients $ { n \brack k }_{\!q} $ for which
$$ \rising{x}{n}_q = \sum_{k=0}^n { n \brack k }_{\!q} x^k \, . $$
Equivalently, they are the numbers defined by the recurrence
\begin{equation}\label{Rec-StirlingS1}
 { n+1 \brack k+1 }_{\!q} = { n \brack k }_{\!q} + [n]_q { n \brack k+1 }_{\!q}
\end{equation}
with initial values $ { n \brack 0 }_{\!q} = \delta_{n,0} $
and $ { 0 \brack k }_{\!q} = \delta_{k,0} $.

For the $q$-Stirling numbers, we have the inverse relations
\begin{equation}\label{Stirling-inversion}
 f_n = \sum_{k=0}^n { n \brace k }_{\!\!q} g_k
 \qquad\iff\qquad
 g_n = \sum_{k=0}^n { n \brack k }_{\!q} (-1)^{n-k} f_k
\end{equation}
and
\begin{equation}\label{Stirling-inversion1}
 f_n = \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} g_k
 \qquad\iff\qquad
 g_n = \sum_{k=0}^n { n+1 \brack k+1 }_{\!q} (-1)^{n-k} f_k\, .
\end{equation}

Consider the \emph{$q$-Bell numbers} defined by
\begin{equation}\label{qBellN}
 b_n(q) = \sum_{k=0}^n { n \brace k }_{\!\!q} q^{{ k \choose 2 }} \, .
\end{equation}
Although they are not the cumulative constants of the $q$-Stirling numbers considered above,
we have the following formulas relating the $q$-derangement numbers and the $q$-Bell numbers,
\begin{theorem}
 We have the identities
 \begin{align}
  & \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} (-1)^k d_k(q) = b_n(q) \label{Id-qDer-qBell} \\
  & \sum_{k=0}^n { n+1 \brack k+1 }_{\!q} (-1)^k b_k(q) = d_n(q) \label{Id-qBell-qDer} \, .
 \end{align}
\end{theorem}
\begin{proof}
 By recurrence (\ref{rec-qderN01}), we have
 $$ d_{k+1}(q) - [k+1]_q d_k(q) = (-1)^{k+1} q^{{ k+1 \choose 2 }}\, . $$
 Hence, we have the identity
 $$
  \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} d_{k+1}(q) -
  \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} [k+1]_q d_k(q) =
  \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} q^{{ k+1 \choose 2 }}
 $$
 or
 $$
  \sum_{k=1}^n { n \brace k }_{\!\!q} (-1)^k d_k(q) +
  \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^k [k+1]_q d_k(q) =
  \sum_{k=1}^n { n \brace k }_{\!\!q} q^{{ k \choose 2 }}
 $$
 or
 $$
  \sum_{k=0}^n \left( { n \brace k }_{\!\!q} + [k+1]_q { n \brace k+1 }_{\!\!q} \right) (-1)^k d_k(q) =
  \sum_{k=0}^n { n \brace k }_{\!\!q} q^{{ k \choose 2 }}
 $$
 By recurrence (\ref{Rec-StirlingS2}) and definition (\ref{qBellN}),
 we have identity (\ref{Id-qDer-qBell}).
 Then, by this identity, we get identity (\ref{Id-qBell-qDer}) at once
 as its inverse relation (by property (\ref{Stirling-inversion1})).
\end{proof}

To prove the next theorem, we need the following result.
\begin{lemma}
 For every $ n,k \in \NN $, we have the identity
 \begin{equation}\label{IdqStirling}
  { n+1 \brace k+1 }_{\!\!q} = \sum_{i=k}^n { n \choose i } { i \brace k }_{\!\!q} q^{i-k} \, .
 \end{equation}
\end{lemma}
\begin{proof}
 Since
 \begin{align*}
  x^{n+1} = \sum_{k=1}^{n+1} { n+1 \brace k }_{\!\!q} \falling{x}{k}_q
          = \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} \falling{x}{k+1}_q
          = \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} x(x-[1]_q)\cdots(x-[k]_q)\, ,
 \end{align*}
 we have
 \begin{align*}
  x^n &= \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} (x-[1]_q)(x-[2]_q)\cdots(x-[k]_q) \\
      &= \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} (x-1)(x-1-q[1]_q)\cdots(x-1-q[k-1]_q)
 \end{align*}
 or
 $$
  (qx+1)^n = \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} q^k x(x-[1]_q)\cdots(x-[k-1]_q)
           = \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} q^k \falling{x}{k}_q \, .
 $$
 Then, from this relation, we have
 $$
   \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} q^k \falling{x}{k}_q
   = \sum_{i=0}^n { n \choose i } q^i x^i
   = \sum_{i=0}^n { n \choose i } q^i \sum_{k=0}^i { i \brace k }_{\!\!q} \falling{x}{k}_q
   = \sum_{k=0}^i \left( \sum_{i=k}^n { n \choose i } { i \brace k }_{\!\!q} q^i \right) \falling{x}{k}_q\, .
 $$
 By equating the coefficients of $ \falling{x}{k}_q $,
 we obtain identity (\ref{IdqStirling}).
\end{proof}

Now we can prove the following result.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdSSB1}
  \sum_{k=0}^n { n \brace k }_{\!\!q} (-1)^k q^{n-k} d_k(q) =
  \sum_{k=0}^n { n \choose k } (-1)^{n-k} b_k(q)\, .
 \end{equation}
\end{theorem}
\begin{proof}
 By identities (\ref{Id-qDer-qBell}) and (\ref{IdqStirling}), we have
 $$
  b_n(q)
  = \sum_{k=0}^n \left(\sum_{i=0}^n { n \choose i } { i \brace k }_{\!\!q} q^{i-k}\right) (-1)^k d_k(q)
  = \sum_{i=0}^n { n \choose i } \sum_{k=0}^i { i \brace k }_{\!\!q} (-1)^k q^{i-k} d_k(q)\, .
 $$
 Thus, if we set
 $$ z_n(q) = \sum_{k=0}^n { n \brace k }_{\!\!q} (-1)^k q^{n-k} d_k(q) \, , $$
 then we have the identity
 $$ b_n(q) = \sum_{i=0}^n { n \choose i } z_i(q), $$
 whose inverse is
 $$ z_n(q) = \sum_{i=0}^n { n \choose i } (-1)^{n-i} b_i(q)\, . $$
 This is identity (\ref{IdSSB1}).
\end{proof}

We also have the following result.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdSS11}
  \sum_{k=0}^n { n+1 \brace k+1 }_{\!\!q} (-1)^k d_{k+1}(q) =
  \sum_{k=0}^n { n \brace k }_{\!\!q} (-1)^k q^k [k]_q d_{k-1}(q)\, .
 \end{equation}
\end{theorem}
\begin{proof}
 By recurrence (\ref{rec-qderN02}), we have
 $$ d_{k+2}(q) - [k+1]_q d_{k+1}(q) = [k+1]_q q^{k+1} d_k(q)\, . $$
 Then we have
 $$
  \begin{aligned}
   \MoveEqLeft
   \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} d_{k+2}(q) -
   \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} [k+1]_q d_{k+1}(q) = \\
   & = \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} [k+1]_q q^{k+1} d_k(q),
  \end{aligned}
 $$
 or
 $$
   \sum_{k=1}^n { n \brace k }_{\!\!q} (-1)^k d_{k+1}(q) +
   \sum_{k=0}^n { n \brace k+1 }_{\!\!q} (-1)^k [k+1]_q d_{k+1}(q) =
   \sum_{k=1}^n { n \brace k }_{\!\!q} (-1)^k [k]_q q^k d_{k-1}(q),
 $$
 or
 $$
  \sum_{k=1}^n \left( { n \brace k }_{\!\!q} + [k+1]_q { n \brace k+1 }_{\!\!q} \right) (-1)^k d_{k+1}(q) =
  \sum_{k=1}^n { n \brace k }_{\!\!q} (-1)^k [k]_q q^k d_{k-1}(q)\, .
 $$
 By recurrence (\ref{Rec-StirlingS2}), we have identity (\ref{IdSS11}).
\end{proof}

Similarly, we also have the following formula.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdSS01}
  \sum _{k=0}^n { n \brace k }_{\!\!q} (-1)^k q^{-{k+1 \choose 2 }} d_k(q)^2 =
  \sum _{k=0}^n { n+1 \brace k+1 }_{\!\!q} (-1)^k q^{-{ k+1 \choose 2 }} d_k(q) d_{k+1}(q) \, .
 \end{equation}
\end{theorem}
\begin{proof}
 By recurrence (\ref{rec-qderN02}), we have
 $$ d_{k+1}(q) d_{k+2}(q) = [k+1]_q d_{k+1}(q)^2 + [k+1]_q q^{k+1} d_k(q) d_{k+1}(q), $$
 or
 $$ [k+1]_q d_{k+1}(q)^2 = d_{k+1}(q) d_{k+2}(q) - [k+1]_q q^{k+1} d_k(q) d_{k+1}(q)\, . $$
 Hence, we have
  \begin{align*}
&   \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} q^{-{ k+2 \choose 2 }} [k+1]_q d_{k+1}(q)^2  \\
   & = \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} q^{-{ k+2 \choose 2 }} d_{k+1}(q) d_{k+2}(q) \\ 
   & \qquad - \sum_{k=0}^{n-1} { n \brace k+1 }_{\!\!q} (-1)^{k+1} q^{-{ k+2 \choose 2 }} [k+1]_q q^{k+1} d_k(q) d_{k+1}(q)
  \end{align*}
 or
  \begin{align*}
   & \sum_{k=1}^n { n \brace k }_{\!\!q} (-1)^k q^{-{ k+1 \choose 2 }} [k]_q d_k(q)^2  \\ 
   & = \sum_{k=1}^n { n \brace k }_{\!\!q} (-1)^k q^{-{ k+1 \choose 2 }} d_k(q) d_{k+1}(q) \\ 
 & \qquad +     \sum_{k=0}^n { n \brace k+1 }_{\!\!q} [k+1]_q (-1)^k q^{-{ k+1 \choose 2 }} d_k(q) d_{k+1}(q)\, .
  \end{align*}
 Since $ [0]_q = 0 $ and $ d_1(q) = 0 $, we have
  \begin{align*}
   & \sum_{k=0}^n { n \brace k }_{\!\!q} (-1)^k q^{-{ k+1 \choose 2 }} [k]_q d_k(q)^2  \\ 
   & \qquad = \sum_{k=0}^n \left( { n \brace k }_{\!\!q} + [k+1]_q { n \brace k+1 }_{\!\!q} \right)
     (-1)^k q^{-{ k+1 \choose 2 }} d_k(q) d_{k+1}(q) \, .
\end{align*} 
 Finally, by the recurrence (\ref{Rec-StirlingS2}), this identity simplifies to identity (\ref{IdSS01}).
\end{proof}

Now consider the \emph{$q$-Bell numbers} $ B_n(q) $ defined by the recurrence
\begin{equation}\label{rec-qBellD}
 B_{n+1}(q) = \sum_{k=0}^n { n \choose k }_{\!\!q} q^{n(n-k)} B_k(q)
\end{equation}
with initial value $ B_0(q) = 1 $.
Notice that the $q$-numbers $ b_n(q) $ and $ B_n(q) $
are different $q$-analogues of the ordinary Bell numbers (\seqnum{A000110}).
For these $q$-Bell numbers, we have the following result.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdDerBellD}
   \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^{n-k} q^{-{ k+1 \choose 2 }} B_k(q)\, d_{n-k}(q) =
   \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^{n-k} q^{-{ k+1 \choose 2 }} B_{k+1}(q)\, [n-k]_q!
 \end{equation}
\end{theorem}
\begin{proof}
 Let $ \sigma_n(q) $ be the sum on the right-hand side of identity (\ref{IdDerBellD}).
 Then, by the recurrence (\ref{rec-qBellD}), we have
 \begin{align*}
  \sigma_n(q)
  &= \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^{n-k} q^{-{ k+1 \choose 2 }} [n-k]_q!\, B_{k+1}(q) \\
  &= \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^{n-k} q^{-{ k+1 \choose 2 }} [n-k]_q!
      \sum_{i=0}^k { k \choose i }_{\!\!q} q^{k(k-i)} B_i(q) \\
  &= \sum_{i=0}^n \left( \sum_{k=i}^n { n \choose k }_{\!\!q} { k \choose i }_{\!\!q}
     [n-k]_q! (-1)^{n-k} q^{-{ k+1 \choose 2 }} q^{k(k-i)} \right) B_i(q) \\
  &= \sum_{i=0}^n { n \choose i }_{\!\!q} \left( \sum_{k=i}^n { n-i \choose k-i }_{\!\!q}
     [n-k]_q! (-1)^{n-k} q^{-{ k+1 \choose 2 }} q^{k(k-i)} \right) B_i(q) \\
  &= \sum_{i=0}^n { n \choose i }_{\!\!q} \left( \sum_{k=0}^{n-i} { n-i \choose k }_{\!\!q}
     [n-k-i]_q! (-1)^{n-k-i} q^{-{ k+i+1 \choose 2 }} q^{(k+i)k} \right) B_i(q) \\
  &= \sum_{i=0}^n { n \choose i }_{\!\!q} (-1)^{n-i} \left( \sum_{k=0}^{n-i} { n-i \choose k }_{\!\!q}
     [n-k-i]_q! (-1)^k q^{-{ i+1 \choose 2 }-{ k+1 \choose 2 }-ik} q^{(k+i)k} \right) B_i(q) \\
  &= \sum_{i=0}^n { n \choose i }_{\!\!q} (-1)^{n-i} q^{-{ i+1 \choose 2 }}
     \left( \sum_{k=0}^{n-i} { n-i \choose k }_{\!\!q}
     [n-k-i]_q! (-1)^k q^{{ k \choose 2 }} \right) B_i(q) \, .
 \end{align*}
 Finally, by formula (\ref{def-qderN}), we have
 $$ \sigma_n(q) = \sum_{i=0}^n { n \choose i }_{\!\!q} (-1)^{n-i} q^{-{ i+1 \choose 2 }} d_{n-i}(q)\, B_i(q), $$
 and this is the claimed identity.
\end{proof}

\section{Elementary identities}\label{sec-Eul}

Several combinatorial identities can be derived from the following property
of linear recurrences of the first order: the general solution of the recurrence
$$ y_{n+1} = a_{n +1}y_n + b_{n+1} $$
is given by
\begin{equation}\label{LinRecGenSol}
 y_n = a_n^* y_0 + \sum_{k=1}^n \frac{a_n^*}{a_k^*}\, b_k,
\end{equation}
where $ a_n^* = a_1 a_2 \cdots a_n $, provided that $ a_n \ne 0 $ for all $ n \in \NN $.

First of all, we have the following simple result.
\begin{theorem}
 For every $ m, n \in \NN $, we have the identity
 \begin{equation}\label{IdE000}
  \begin{aligned}
   \MoveEqLeft
   d_{m+n+2}(q) = { m+n+1 \choose m }_{\!\!q} [n+1]_q! d_{m+1}(q)  \\
   &\hspace{1.5cm} + [m+n+1]_q \sum_{k=0}^n { m+n \choose m+k}_{\!\!q} [n-k]_q! q^{k+m+1} d_{m+k}(q)
  \end{aligned}
 \end{equation}
 In particular, for $ m = 0 $, we have the identity
 \begin{equation}\label{IdE001}
  d_{n+2}(q) = [n+1]_q \sum_{k=0}^n {n \choose k }_{\!\!q} [n-k]_q! q^{k+1} d_k(q)\, .
 \end{equation}
\end{theorem}
\begin{proof}
 Let $ y_n(q) = d_{m+n+1}(q) $.
 By recurrence (\ref{rec-qderN02}), we have
 $$ y_{n+1}(q) = d_{m+n+2}(q) = [m+n+1]_q\, d_{m+n+1}(q) + [m+n+1]_q\, q^{m+n+1} d_{m+n}(q), $$
 or $$ y_{n+1}(q) = [m+n+1]_q\, y_n(q) + [m+n+1]_q\, q^{m+n+1} d_{m+n}(q)\, . $$
 This is a linear recurrence of the first order with coefficients $ a_n = [m+n]_q $
 and $\: b_n = [m+n]_q\, q^{m+n} d_{m+n-1}(q) $.
 Since
 $$ a_n^* = [m+n]_q\cdots[m]_q = \frac{[m+n]_q}{[m]_q} = { m+n \choose m }_{\!\!q} [n]_q! \, , $$
 then the solution, being $ y_0(q) = d_{m+1}(q) $, is
 \begin{align*}
  y_n(q)
  &= { m+n \choose m }_{\!\!q} [n]_q! d_{m+1}(q)
   + \sum_{k=1}^n \frac{[m+n]_q}{[m]_q} \frac{[m]_q}{[m+k]_q} [m+k]_q\, q^{m+k} d_{m+k-1}(q) \\
  &= { m+n \choose m }_{\!\!q} [n]_q! d_{m+1}(q)
   + \sum_{k=1}^n \frac{[m+n]_q}{[m+k]_q}\; [m+k]_q\, q^{m+k} d_{m+k-1}(q) \\
  &= { m+n \choose m }_{\!\!q} [n]_q! d_{m+1}(q)
   + \sum_{k=1}^n { m+n \choose m+k }_{\!\!q} [m+k]_q [n-k]_q!\, q^{m+k} d_{m+k-1}(q) \\
  &= { m+n \choose m }_{\!\!q} [n]_q! d_{m+1}(q)
   + [m+n]_q \sum_{k=1}^n { m+n-1 \choose m+k-1 }_{\!\!q} [n-k]_q!\, q^{m+k} d_{m+k-1}(q) \\
  &= { m+n \choose m }_{\!\!q} [n]_q! d_{m+1}(q)
   + [m+n]_q \sum_{k=0}^{n-1} { m+n-1 \choose m+k }_{\!\!q} [n-k-1]_q!\, q^{m+k+1} d_{m+k}(q) \, .
 \end{align*}
 Finally, by replacing $ n $ by $ n+1 $, we obtain formula (\ref{IdE000}).
\end{proof}

\begin{theorem}
 For every $ m, n \in \NN $, we have the identity
 \begin{equation}\label{IdE01}
  \frac{d_{m+n+2}(q)}{[m+n+1]_q!} = \frac{d_{m+1}(q)}{[m]_q!} +
  \sum _{k=0}^n q^{m+k+1} \frac{d_{m+k}(q)}{[m+k]_q!} \, .
 \end{equation}
 In particular, for $ m = 0 $, we have the identity
 \begin{equation}\label{IdE02}
  \frac{d_{n+2}(q)}{[n+1]_q!} = \sum _{k=0}^n q^{k+1} \frac{d_k(q)}{[k]_q!} \, .
 \end{equation}
\end{theorem}
\begin{proof}
 Let $ y_n(q) = \frac{d_{m+n+1}(q)}{[m+n]_q!} $.
 By recurrence (\ref{rec-qderN02}), we have
 \begin{align*}
  y_{n+1}(q)
  &= \frac{d_{m+n+2}(q)}{[m+n+1]_q!}
   = \frac{[m+n+1]_q(d_{m+n+1}(q) + q^{m+n+1} d_{m+n}(q))}{[m+n+1]_q!} \\
  &= \frac{d_{m+n+1}(q)}{[m+n]_q!} + q^{m+n+1} \frac{d_{m+n}(q)}{[m+n]_q!},
 \end{align*}
 or $$ y_{n+1}(q) = y_n(q) + q^{m+n+1} \frac{d_{m+n}(q)}{[m+n]_q!} \, . $$
This is a linear recurrence of the first order with $ a_n = 1 $
 and $ b_n = q^{m+n} \frac{d_{m+n-1}(q)}{[m+n-1]_q!} $ for $ n \geq 1 $.
 So, by formula (\ref{LinRecGenSol}), we have the solution
 $$
  y_n(q) = y_0(q) + \sum_{k=1}^n q^{m+k} \frac{d_{m+k-1}(q)}{[m+k-1]_q!}
         = y_0(q) + \sum_{k=0}^{n-1} q^{m+k+1} \frac{d_{m+k}(q)}{[m+k]_q!},
 $$
 or
 $$
  \frac{d_{m+n+1}(q)}{[m+n]_q!} = \frac{d_{m+1}(q)}{[m]_q!} +
  \sum_{k=0}^{n-1} q^{m+k+1} \frac{d_{m+k}(q)}{[m+k]_q!}\, .
 $$
 Now by replacing $ n $ by $ n+1 $, we obtain identity (\ref{IdE01}).
\end{proof}

\begin{theorem}
 For every $ m, n \in \NN $, we have the identity
 \begin{equation}\label{IdE03}
  \frac{d_{m+n+1}(q) d_{m+n+2}(q)}{q^{\binom{n+2}{2}} [m+n+1]_q!}
  = q^{m(n+1)}\,\frac{d_m(q) d_{m+1}(q)}{[m]_q!} +
    \sum _{k=0}^n q^{m (n-k)} \frac{d_{m+k+1}(q)^2}{q^{\binom{k+2}{2}} [m+k]_q!}
 \end{equation}
 In particular, for $ m = 0 $, we have the identity
 \begin{equation}\label{IdE04}
  \frac{d_{n+1}(q) d_{n+2}(q)}{q^{\binom{n+2}{2}} [n+1]_q!} = \sum _{k=0}^n \frac{d_{k+1}(q)^2}{q^{{ k+2 \choose 2 }} [k]_q!}
 \end{equation}
\end{theorem}
\begin{proof}
 Let $ y_n(q) = \frac{d_{m+n}(q)d_{m+n+1}(q)}{[m+n]_q!} $.
 By recurrence (\ref{rec-qderN02}), we have
 \begin{align*}
  y_{n+1}(q)
  &= \frac{d_{m+n+1}(q)d_{m+n+2}(q)}{[m+n+1]_q!}
   = \frac{d_{m+n+1}(q)\,(d_{m+n+1}(q) + q^{m+n+1} d_{m+n}(q))}{[m+n]_q!} \\
  &= \frac{d_{m+n+1}(q)^2}{[m+n]_q!} + q^{m+n+1} \frac{d_{m+n}(q)d_{m+n+1}(q)}{[m+n]_q!},
 \end{align*}
 or $$ y_{n+1}(q) = q^{m+n+1} y_n(q) + \frac{d_{m+n+1}(q)^2}{[m+n]_q!} \, . $$
 This is a linear recurrence of the first order with $ a_n = q^{m+n} $
 and $ b_n = \frac{d_{m+n}(q)^2}{[m+n-1]_q!} $ for $ n \geq 1 $.
 Since $ a_n^* = q^{mn+{ n+1 \choose 2 }} $, by formula (\ref{LinRecGenSol}), we have the solution
 \begin{align*}
  y_n(q) &= q^{mn+{ n+1 \choose 2 }} y_0(q)
          + \sum_{k=1}^n \frac{q^{mn+{ n+1 \choose 2 }}}{q^{mk+{ k+1 \choose 2 }}} \frac{d_{m+k}(q)^2}{[m+k-1]_q!} \\
         &= q^{mn+{ n+1 \choose 2 }} y_0(q)
          + q^{{ n+1 \choose 2 }} \sum_{k=0}^{n-1} q^{m(n-k-1)} \frac{d_{m+k+1}(q)^2}{q^{{ k+2 \choose 2 }}[m+k]_q!},
 \end{align*}
 or
 $$
  \frac{d_{m+n}(q)d_{m+n+1}(q)}{q^{{ n+1 \choose 2 }}[m+n]_q!} = q^{mn} \frac{d_{m}(q)d_{m+1}(q)}{[m]_q!}
  + \sum_{k=0}^{n-1} q^{m(n-k-1)} \frac{d_{m+k+1}(q)^2}{q^{{ k+2 \choose 2 }}[m+k]_q!}\, .
 $$
 Now by replacing $ n $ by $ n+1 $, we obtain identity (\ref{IdE03}).
\end{proof}

The next formula can be obtained with the same elementary approach used in Section \ref{sec-qBin}.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdE06}
  \begin{aligned}
   \MoveEqLeft
   \frac{d_{m+n+1}(q)^2-q^{2{ m+n+1 \choose 2 }}}{[m+n+1]_q!^2} =
   \frac{d_m(q)^2-q^{2{ m \choose 2 }}}{[m]_q!^2} + \\
   & + 2 \sum_{k=0}^n (-1)^{m+k+1} q^{{ m+k+1 \choose 2 }} \frac{d_{m+k}(q)}{[m+k]_q![k+m+1]_q!} +
   \sum_{k=0}^n \frac{q^{2{ m+k \choose 2 }}}{[m+k]_q!^2} \, .
  \end{aligned}
 \end{equation}
 In particular, for $ m = 0 $, we have the identity
 \begin{equation}\label{IdE07}
  \frac{d_{n+1}(q)^2-q^{n(n+1)}}{[n+1]_q!{}^2} =
  2 \sum_{k=0}^n (-1)^{k+1} q^{\binom{k+1}{2}} \frac{d_k(q)}{[k]_q! [k+1]_q!} +
  \sum_{k=0}^n \frac{q^{k (k-1)}}{[k]_q!{}^2} \, .
 \end{equation}
\end{theorem}
\begin{proof}
 By recurrences (\ref{rec-qderN01}), we have
 $$
  \begin{aligned}
   \MoveEqLeft
   d_{m+k+1}(q)^2 = \Big( [m+k+1]_q d_{m+k}(q) + (-1)^{m+k+1} q^{{ m+k+1 \choose 2 }} \Big)^{\!2} \\
   &= [m+k+1]_q^2 d_{m+k}(q)^2 + 2 (-1)^{m+k+1} q^{{ m+k+1 \choose 2 }} [m+k+1]_q d_{m+k}(q)
    + q^{2{ m+k+1 \choose 2 }} \, .
  \end{aligned}
 $$
 Hence, we can write
 $$
   \frac{d_{m+k+1}(q)^2}{[m+k+1]_q!^2} = \frac{d_{m+k}(q)^2}{[m+k]_q!^2}
    + 2 (-1)^{m+k+1} q^{{ m+k+1 \choose 2 }} \frac{d_{m+k}(q)}{[m+k]_q![m+k+1]_q!}
    + \frac{q^{2{ m+k+1 \choose 2 }}}{[m+k+1]_q!^2}
 $$
 and, consequently, we have
 $$
  \begin{aligned}
   \MoveEqLeft
   \sum_{k=0}^n \frac{d_{m+k+1}(q)^2}{[m+k+1]_q!^2} = \sum_{k=0}^n \frac{d_{m+k}(q)^2}{[m+k]_q!^2}  \\
    & + 2 \sum_{k=0}^n (-1)^{m+k+1} q^{{ m+k+1 \choose 2 }} \frac{d_{m+k}(q)}{[m+k]_q![m+k+1]_q!}
      + \sum_{k=0}^n \frac{q^{2{ m+k+1 \choose 2 }}}{[m+k+1]_q!^2},
  \end{aligned}
 $$
 or
 $$
  \begin{aligned}
   \MoveEqLeft
   \sum_{k=1}^{n+1} \frac{d_{m+k}(q)^2}{[m+k]_q!^2} = \sum_{k=0}^n \frac{d_{m+k}(q)^2}{[m+k]_q!^2}  \\
    & + 2 \sum_{k=0}^n (-1)^{m+k+1} q^{{ m+k+1 \choose 2 }} \frac{d_{m+k}(q)}{[m+k]_q![m+k+1]_q!}
      + \sum_{k=1}^{n+1} \frac{q^{2{ m+k \choose 2 }}}{[m+k]_q!^2}\, .
  \end{aligned}
 $$
 By simplifying, we get the identity
 $$
  \begin{aligned}
   \MoveEqLeft
   \frac{d_{m+n+1}(q)^2}{[m+n+1]_q!^2} = \frac{d_{m}(q)^2}{[m]_q!^2}
      + 2 \sum_{k=0}^n (-1)^{m+k+1} q^{{ m+k+1 \choose 2 }} \frac{d_{m+k}(q)}{[m+k]_q![m+k+1]_q!} \\
    &\hspace{2.4cm} + \sum_{k=0}^n \frac{q^{2{ m+k \choose 2 }}}{[m+k]_q!^2}
      + \frac{q^{2{ m+n+1 \choose 2 }}}{[m+n+1]_q!^2} - \frac{q^{2{ m \choose 2 }}}{[m]_q!^2}
  \end{aligned}
 $$
 which yields identity (\ref{IdE06}) at once.
\end{proof}

\section{$q$-exponential series}\label{sec-qES}

Many identities can be obtained by using the $q$-exponential generating series.
Recall that the product of two $q$-exponential series
$ f(t) = \sum_{n\geq0} f_n \frac{t^n}{[n]_q!} $ and
$ g(t) = \sum_{n\geq0} g_n \frac{t^n}{[n]_q!} $ is given by
$$
 f(t)\cdot g(t) = \sum_{n\geq0} \left(\sum_{k=0}^n { n \choose k }_{\!\!q} f_k g_{n-k}\right) \frac{t^n}{[n]_q!},
$$
and that the \emph{$q$-derivative} (\emph{Jackson's derivative}) $ \DD_q $
of a $q$-exponential generating series $ f(t) = \sum_{n\geq0} f_n \frac{t^n}{[n]_q!} $
is defined \cite{Jackson,Jackson1908,Jackson1910} by the formula
$$ \DD_q f(t) = \frac{f(qt)-f(t)}{(q-1)t} = \sum_{n\geq0} f_{n+1} \frac{t^n}{[n]_q!} \, . $$

The \emph{$q$-exponential series} (\emph{Jackson's $q$-exponential}) \cite{Jackson}
\begin{equation}\label{series-E}
 E_q(t) = \sum_{n\geq0} \frac{t^n}{[n]_q!} = \prod_{k\geq0} \frac{1}{1+(q-1)q^kt}
\end{equation}
is the eigenfunction of the $q$-derivative, that is,
$$ \DD_q E_q(\lambda t) = \lambda E_q(t) \, . $$
In particular, since $ \DD_q E_q(t) = E_q(t) $, we have the relation
\begin{equation}\label{EEqq}
 E_q(qt) = (1-(1-q)t)\,E_q(t) \, .
\end{equation}
Consequently, considering the \emph{$q$-Pochhammer symbol}
$ (x;q)_m = (1-x)(1-qx)\cdots(1-q^{m-1}x) $,
we have, for every $ m \in \NN $, the identity
\begin{equation}\label{mEEqq}
 E_q(q^mt) = \prod_{k=0}^{m-1} (1-(1-q)q^kt)\cdot E_q(t) = ((1-q)t;q)_m\, E_q(t)\, .
\end{equation}

Moreover, the inverse of the $q$-exponential series is
\begin{equation}\label{series-Einv}
 E_q(t)^{-1} = \sum_{n\geq0} (-1)^n q^{{ n \choose 2 }} \frac{t^n}{[n]_q!}
\end{equation}
and we have the identities \cite{Ubriaco}
\begin{align}
  E_q(-t)\, E_{q^{-1}}(t) &= 1 \label{qExp01} \\
  E_q(t)\, E_q(-t) &= E_{q^2}\Big(\frac{1-q}{1+q}\,t^2\Big)\, . \label{qExp02}
\end{align}

By definition (\ref{def-qderN}) and series (\ref{series-Einv}),
we have at once that the $q$-exponential generating series of the $q$-derangement numbers is
\begin{equation}\label{series-derN}
 D_q(t) = \sum_{n\geq0} d_n(q) \frac{t^n}{[n]_q!} = \frac{E_q(t)^{-1}}{1-t} \, .
\end{equation}

We consider the following $q$-polynomials:
\begin{itemize}
 \item the \emph{$q$-Pochhammer symbol}
  \begin{equation}\label{qPochhammer}
   (x;q)_n = (1-x)(1-qx)\cdots(1-q^{n-1}x)
   = \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^k q^{{ k \choose 2 }} x^k\, ,
  \end{equation}
 \item the \emph{Gaussian polynomials} \cite{GoldmanRota,GoldmanRota70,MunariniCC}
  $$
   g_n(q;x) = (x-1)(x-q)\cdots(x-q^{n-1})
   = \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^{n-k} q^{{ n-k \choose 2 }} x^k\, ,
  $$
 \item the \emph{$q$-Hermite polynomials} (or \emph{Rogers-Szeg\H{o} polynomials})
  (\cite{Szego,Carlitz,AlSalamCarlitz,GoldmanRota}, \cite[p.\ 180]{Roman})
  $$ H_n(q;x) = \sum_{k=0}^n { n \choose k }_{\!\!q} x^k $$
  and the \emph{Galois numbers} \cite{GoldmanRota,NijenhuisSolowWilf}
  \begin{equation}\label{GaloisN}
   G_n(q) = \sum_{k=0}^n { n \choose k }_{\!\!q}\, ,
  \end{equation}
 \item the \emph{$q$-Carlitz polynomials} (or \emph{Al-Salam-Carlitz polynomials})
  (\cite{AlSalamCarlitzU}, \cite[p.\ 195]{Chihara},
  \cite{Ismail,ChenSaadSun,Kim})
  $$ U_n^{(\alpha)}(q;x) = \sum_{k=0}^n { n \choose k }_{\!\!q} (-\alpha)^{n-k} g_k(x)\, , $$
\end{itemize}
having $q$-exponential generating series
\begin{align}
  P_q(x,t) &= \sum_{n\geq0} (x;q)_n \frac{t^n}{[n]_q!}
            = \frac{E_q(t)}{E_q(xt)} = E_q(t)\, E_q(xt)^{-1} \label{series-P} \\
  g_q(x,t) &= \sum_{n\geq0} g_n(q;x) \frac{t^n}{[n]_q!}
            = \frac{E_q(xt)}{E_q(t)} = E_q(t)^{-1} E_q(xt) \label{series-g} \\
  H_q(x,t) &= \sum_{n\geq0} H_n(q;x) \frac{t^n}{[n]_q!}
            = E_q(t)\, E_q(xt) \label{series-G} \\
  G_q(t) &= \sum_{n\geq0} G_n(q) \frac{t^n}{[n]_q!}
          = E_q(t)^2 \label{series-Galois} \\
  U_q(x,t) &= \sum_{n\geq0} U_n^{(\alpha)}(q;x) \frac{t^n}{[n]_q!}
            = \frac{E_q(xt)}{E_q(t)E_q(\alpha t)} = E_q(\alpha t)^{-1} g_q(x,t) \, . \label{series-U}
\end{align}
Using the properties of the $q$-exponential series, we have at once the following results.
\begin{theorem}
 We have the identities
 \begin{align}
   \sum_{k=0}^n { n \choose k }_{\!\!q} d_{n-k}(q)\, (x;q)_k &=
    \sum_{k=0}^n { n \choose k }_{\!\!q} [n-k]_q!\, (-1)^k q^{{ k \choose 2 }} x^k \label{IdqP00} \\
   \sum_{k=0}^n { n \choose k }_{\!\!q} d_{n-k}(q)\, x^k &=
    \sum_{k=0}^n { n \choose k }_{\!\!q} [n-k]_q!\, g_k(q;x) \label{IdqP01} \\
   \sum_{k=0}^n { n \choose k }_{\!\!q} d_{n-k}(q)\, G_k(q,x) &=
    \sum_{k=0}^n { n \choose k }_{\!\!q} [n-k]_q!\, x^k \label{IdqP02} \\
   \sum_{k=0}^n { n \choose k }_{\!\!q} \alpha^{n-k} d_{n-k}(q)\, g_k(x) &=
    \sum_{k=0}^n { n \choose k }_{\!\!q} \alpha^{n-k} [n-k]_q!\, U^{(\alpha)}_k(q;x) \label{IdqP03} \, .
 \end{align}
\end{theorem}
\begin{proof}
 By series (\ref{series-derN}), (\ref{series-P}), (\ref{series-g}), (\ref{series-G}), (\ref{series-U})
 and (\ref{series-Einv}), we have the identities
 \begin{align*}
  & D_q(t)\, P_q(x,t) = \frac{E_q(xt)^{-1}}{1-t} \\
  & D_q(t)\, E_q(x,t) = \frac{g_q(x,t)}{1-t} \\
  & D_q(t)\, H_q(x,t) = \frac{E_q(xt)}{1-t} \\
  & D_q(\alpha t)\, g_q(x,t) = \frac{U_q^{(\alpha)}(xt)}{1-\alpha t}
 \end{align*}
 which are equivalent to identities (\ref{IdqP00}), (\ref{IdqP01}), (\ref{IdqP02}) and (\ref{IdqP03}),
 respectively.
\end{proof}

Moreover, we also have the next result.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdqQ1}
  \sum_{k=0}^n (-1)^k \frac{d_k(q)}{[k]_q!}\,\frac{d_{n-k}(q^{-1})}{[n-k]_{q^{-1}}!} = \frac{1+(-1)^n}{2}
 \end{equation}
 or, equivalently,
 \begin{equation}\label{IdqQ2}
  \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^k d_k(q)\, d_{n-k}(q^{-1}) = \frac{1+(-1)^n}{2}\,[n]_q!\, .
 \end{equation}
\end{theorem}
\begin{proof}
 By identity (\ref{qExp01}), we have
 $$ D_q(-t)\, D_{q^{-1}}(t) = \frac{E_q(-t)\, E_{q^{-1}}(t)}{(1-t)(1+t)} = \frac{1}{1-t^2}\, . $$
 Now we have
 $$
  D_q(-t)\, D_{q^{-1}}(t)
  = \sum_{i\geq0} (-1)^i d_i(q) \frac{t^i}{[i]_q!} \sum_{j\geq0} d_j(q^{-1}) \frac{t^j}{[j]_{q^{-1}}!}
  = \sum_{i,j\geq0} (-1)^i \frac{d_i(q)}{[i]_q!}\,\frac{d_j(q^{-1})}{[j]_{q^{-1}}!}\;t^{i+j} \, .
 $$
 Setting $ i+j=n $ and replacing $i $ by $ k $, we have
 $$
  D_q(-t)\, D_{q^{-1}}(t) =
  \sum_{n\geq0} \left( \sum_{k=0}^n (-1)^k \frac{d_k(q)}{[k]_q!}\,\frac{d_{n-k}(q^{-1})}{[n-k]_{q^{-1}}!}\right) t^n \, .
 $$
 Hence, we have the identity
 $$
  \sum_{n\geq0} \left( \sum_{k=0}^n (-1)^k \frac{d_k(q)}{[k]_q!}\,\frac{d_{n-k}(q^{-1})}{[n-k]_{q^{-1}}!}\right) t^n
  = \sum_{n\geq0} \frac{1+(-1)^n}{2}\; t^n
 $$
 and this yields identity (\ref{IdqQ1}).
 This identity and $ [n]_{q^{-1}}! = [n]_q!\, q^{-{ n \choose 2 }} $,
 immediately yield identity (\ref{IdqQ2}).
\end{proof}

\begin{theorem}
 We have the identity
 \begin{equation}\label{IdqConv}
  \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^k d_k(q)\, d_{n-k}(q) =
  \frac{1+(-1)^n}{2} \sum_{k=0}^{n/2} (-1)^k q^{k^2-k}
  \left(\frac{1-q}{1+q}\right)^{\!\!k} \frac{[n]_q!}{[k]_{q^2}!}\, .
 \end{equation}
\end{theorem}
\begin{proof}
 By identity (\ref{qExp02}), we have
 \begin{align*}
  D_q(t) D_q(-t)
  &= \frac{E_q(t)^{-1}E_q(-t)^{-1}}{(1-t)(1+t)} \\
  &= \frac{1}{1-t^2}\; E_{q^2}\Big(\frac{1-q}{1+q}\,t^2\Big)^{\!\!-1} \\
  &= \sum_{i\geq0} t^{2i}\cdot \sum_{k\geq0} (-1)^k q^{2{ k \choose 2 }} \left(\frac{1-q}{1+q}\right)^{\!\!k} \frac{t^{2k}}{[k]_{q^2}!} \\
  &= \sum_{i,k\geq0} (-1)^k q^{k^2-k} \left(\frac{1-q}{1+q}\right)^{\!\!k} \frac{[2i+2k]_q!}{[k]_{q^2}!} \frac{t^{2i+2k}}{[2i+2k]_q!} \\
  &= \sum_{n\geq0} \left(\sum_{k=0}^n (-1)^k q^{k^2-k} \left(\frac{1-q}{1+q}\right)^{\!\!k} \frac{[2n]_q!}{[k]_{q^2}!}\right) \frac{t^{2n}}{[2n]_q!} \\
  &= \sum_{n\geq0} \left(\frac{1+(-1)^n}{2}\sum_{k=0}^{n/2} (-1)^k q^{k^2-k} \left(\frac{1-q}{1+q}\right)^{\!\!k} \frac{[n]_q!}{[k]_{q^2}!}\right) \frac{t^n}{[n]_q!} \, .
 \end{align*}
 Taking the coefficients of $ \frac{t^n}{[n]_q!} $ in the first and in the last series, we have identity (\ref{IdqConv}).
\end{proof}

Recall that for the $q$-binomial coefficients we have the $q$-series
\begin{equation}\label{series-qBin}
 \sum_{n\geq0} { m+n \choose m }_{\!\!q} t^n = \frac{1}{(1-t)(1-qt)(1-q^2t)\cdots(1-q^mt)}
 = \frac{1}{(t;q)_{m+1}}\, .
\end{equation}
Then we have the following result.
\begin{theorem}
 For every $ m, n \in \NN $, we have the identities
 \begin{align}
   \sum_{k=0}^n { n \choose k }_{\!\!q} { m+k \choose m }_{\!\!q} [k]_q! q^k d_{n-k}(q) &=
    \sum_{k=0}^n { n \choose k }_{\!\!q} { m+k+1 \choose m+1 }_{\!\!q} (-1)^{n-k} [k]_q! q^{{ n-k \choose 2 }}
    \label{IdBB01} \\
   \sum_{k=0}^n { n \choose k }_{\!\!q} { \alpha+k \choose k } [k]_q! d_{n-k}(q) &=
    \sum_{k=0}^n { n \choose k }_{\!\!q} { \alpha+k+1 \choose k } (-1)^{n-k} [k]_q! q^{{ n-k \choose 2 }}
    \label{IdBB02} \, .
 \end{align}
\end{theorem}
\begin{proof}
 From the $q$-series (\ref{series-qBin}), we have the $q$-exponential series
 \begin{align*}
   \frac{1}{(1-t)(1-qt)\cdots(1-q^mt)} &=
    \sum_{n\geq0} { m+n \choose m }_{\!\!q} [n]_q! \frac{t^n}{[n]_q!} \\
   \frac{1}{(1-qt)(1-q^2t)\cdots(1-q^{m+1}t)} &=
    \sum_{n\geq0} { m+n \choose m }_{\!\!q} [n]_q! q^n \frac{t^n}{[n]_q!} \, .
 \end{align*}
 Then, by formula (\ref{series-derN}), we have the identity
 $$
  \frac{D_q(t)}{(1-qt)(1-q^2t)\cdots(1-q^{m+1}t)} =
  \frac{E_q(t)^{-1}}{(1-t)(1-qt)(1-q^2t)\cdots(1-q^{m+1}t)}
 $$
 which is equivalent to identity (\ref{IdBB01}).
 Similarly, we have the identity
 $$ \frac{D_q(t)}{(1-t)^{\alpha+1}} = \frac{E_q(t)^{-1}}{(1-t)^{\alpha+2}} $$
 which is equivalent to identity (\ref{IdBB02}).
\end{proof}

To prove the next theorem, we need the following result.
\begin{lemma}
 We have the $q$-exponential series
 \begin{equation}\label{seriesE-2}
  E_q(t)^{-2} = \sum_{n\geq0} (-1)^n q^{{ n \choose 2 }}\, G_n(q^{-1})\,\frac{t^n}{[n]_q!} \, .
 \end{equation}
\end{lemma}
\begin{proof}
 By formula (\ref{series-Einv}) and relations (\ref{qBinRel}),
 the coefficient of $ \frac{t^n}{[n]_q!} $ in the $q$-exponential series $ E_q(t)^{-2} $ is
 $$
   \sum_{k=0}^n { n \choose k }_{\!\!q} (-1)^k q^{{ k \choose 2 }} (-1)^{n-k} q^{{ n-k \choose 2 }}
   = (-1)^n q^{{ n \choose 2 }} \sum_{k=0}^n { n \choose k }_{\!\!q} q^{-k(n-k)}
   = (-1)^n q^{{ n \choose 2 }} \sum_{k=0}^n { n \choose k }_{\!\!q^{-1}}.
 $$
 By the definition (\ref{GaloisN}) of the Galois numbers, this implies identity (\ref{seriesE-2}).
\end{proof}

Recall that the \emph{$q$-multiset coefficients} are defined by
$$
 \Mchoose{n}{k}_{\!\!q} =
 \begin{cases}
  \displaystyle { n+k-1 \choose k }_{\!\!q}, & \mbox{if } k \geq 1; \\
  1, & \mbox{if } k = 0
 \end{cases}
$$
and that they have $q$-generating series
\begin{equation}\label{series-qMulti}
 \sum_{k\geq0} \Mchoose{n}{k}_{\!\!q} t^k
 = \frac{1}{(1-t)(1-qt)(1-q^2t)\cdots(1-q^{n-1}t)}
 = \frac{1}{(t;q)_n}\, .
\end{equation}

\begin{theorem}
 For every $ m, n \in \NN $, we have the identity
 \begin{equation}\label{IdW}
  \sum_{k=0}^n { n \choose k }_{\!\!q} q^{mk}\, d_k(q) =
  [n]_q! \sum_{k=0}^n \Mchoose{m}{k}_{\!\!q} (1-q)^k q^{m(n-k)} \, .
 \end{equation}
\end{theorem}
\begin{proof}
 We have the $q$-exponential series
 $$
  L(q;t) =
  \sum_{n\geq0} \left( \sum_{k=0}^n { n \choose k }_{\!\!q} q^{mk}\, d_k(q) \right) \frac{t^n}{[n]_q!}
  = E_q(t) D_q(q^mt)
  = \frac{E_q(t) E_q(q^mt)^{-1}}{1-q^mt}\, .
 $$
 By identity (\ref{mEEqq}), we have
 \begin{align*}
  L(q;t)
  &= \frac{E_q(t) E_q(t)^{-1}}{(1-q^mt)((1-q)t;q)_m}
   = \frac{1}{1-q^mt}\cdot \frac{1}{((1-q)t;q)_m} \\
  &= \sum_{n\geq0} \left( [n]_q!\sum_{k=0}^n \Mchoose{m}{k}_{\!\!q} (1-q)^k q^{m(n-k)} \right) \frac{t^n}{[n]_q!}
 \end{align*}
 from which we have at once identity (\ref{IdW}).
\end{proof}

We conclude this section proving the following elementary identity involving the $q$-Pochhammer symbol.
\begin{theorem}
 We have the identity
 \begin{equation}\label{IdZ}
   \frac{d_{n+2}(q)}{[n+1]_q!}\, \frac{x^{n+1}}{(qx;q)_{n+1}} +
   \sum_{k=0}^n \frac{d_{k+1}(q)+d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_k} =
   \sum_{k=0}^n \frac{ d_{k+1}(q)\,x^{k+1}+d_k(q)\,x^k}{[k]_q!(qx;q)_{k+1}} \, .
 \end{equation}
\end{theorem}
\begin{proof}
 By recurrence (\ref{rec-qderN02}), we have
 \begin{align*}
  d_{k+2}(q)\, x
  &= [k+1]_q\, d_{k+1}(q)\, x + [k+1]_q\, q^{k+1} x \, d_k(q) \\
  &= [k+1]_q\, d_{k+1}(q)\, x + [k+1]_q \, d_k(q) - [k+1]_q\, (1-q^{k+1} x) \, d_k(q),
 \end{align*}
 and consequently
 $$
  \frac{d_{k+2}(q)}{[k+1]_q!}\, \frac{x^{k+1}}{(qx;q)_{k+1}}
  = \frac{ d_{k+1}(q)}{[k]_q!}\, \frac{x^{k+1}}{(qx;q)_{k+1}} +
    \frac{d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_{k+1}} -
    \frac{d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_k} \, .
 $$
 Then we have
 $$
   \sum_{k=0}^n \frac{d_{k+2}(q)}{[k+1]_q!}\, \frac{x^{k+1}}{(qx;q)_{k+1}}
   = \sum_{k=0}^n \frac{ d_{k+1}(q)}{[k]_q!}\, \frac{x^{k+1}}{(qx;q)_{k+1}} +
     \sum_{k=0}^n \frac{d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_{k+1}} -
     \sum_{k=0}^n \frac{d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_k} \, ,
 $$
 which is
 $$
  \sum_{k=1}^{n+1} \frac{d_{k+1}(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_k} +
  \sum_{k=0}^n \frac{d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_k} =
  \sum_{k=0}^n \frac{ d_{k+1}(q)}{[k]_q!}\, \frac{x^{k+1}}{(qx;q)_{k+1}} +
  \sum_{k=0}^n \frac{d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_{k+1}} \, ,
 $$
or
 $$
  \frac{d_{n+2}(q)}{[n+1]_q!}\, \frac{x^{n+1}}{(qx;q)_{n+1}} +
  \sum_{k=0}^n \frac{d_{k+1}(q)+d_k(q)}{[k]_q!}\, \frac{x^k}{(qx;q)_k}
  = \sum_{k=0}^n \frac{ d_{k+1}(q)\,x^{k+1}+d_k(q)\,x^k}{[k]_q!(qx;q)_{k+1}} \, .
 $$
 This is the claimed identity.
\end{proof}

\section{Determinantal identities}\label{sec-det}

Since the $q$-derangement numbers satisfy a three-term recurrence,
they can be represented in terms of \emph{tridiagonal determinants}
(or \emph{continuants} (\cite[pp.\ 516--525]{Muir}, \cite{VeinDale})).
\begin{theorem}
 We have the identity
 \begin{equation}\label{d-tridiagonal}
  d_n(q) =
  \begin{vmatrix}
   [0]_q & -q \\
   [1]_q & [1]_q & -q^2 \\
         & [2]_q & [2]_q & -q^3 \\
         &       & \ddots & \ddots  & \ddots \\
         &       &        & [n-2]_q & [n-2]_q & -q^{n-1} \\
         &       &        &         & [n-1]_q & [n-1]_q
  \end{vmatrix}_{n\times n}\hspace{-5mm}.
 \end{equation}
\end{theorem}
\begin{proof}
 The tridiagonal determinants in formula (\ref{d-tridiagonal})
 satisfy recurrence (\ref{rec-qderN02}) with the appropriate initial values.
 This implies at once the claimed identity.
\end{proof}

The $q$-derangement numbers can also be represented
in terms of \emph{Hessenberg determinants} \cite[p.\ 90]{VeinDale}, as follows.
\begin{theorem}
 Consider the $ n \times n $ lower Hessenberg matrix
 $$
  A_n(q) = \begin{bmatrix}
            a_{00}(q) & -1 & 0 & 0 & \cdots & 0 \\
            a_{10}(q) & a_{11}(q) & -1 & 0 & \cdots & 0 \\
            a_{20}(q) & a_{21}(q) & a_{22}(q) & -1 & \cdots & 0 \\
            \vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\
            a_{n-2,1}(q) & a_{n-2,2}(q) & a_{n-2,3}(q) & a_{n-2,4}(q) & \cdots & -1 \\
            a_{n-1,1}(q) & a_{n-1,2}(q) & a_{n-1,3}(q) & a_{n-1,4}(q) & \cdots & a_{n-1,n-1}(q)
           \end{bmatrix}
 $$
 where
 $$
  a_{i,j}(q) = \begin{cases}
                \displaystyle { i \choose j }_{\!\!q} a_{i-j}(q), & \mbox{if } i \geq j; \\
                -1, & \mbox{if } i = j-1; \\
                 0, & \mbox{otherwise}
               \end{cases}
 $$
 where
 \begin{equation}\label{coeff-a}
  a_k(q) = \frac{q}{2q-1}\;(q^n-(1-q)^n)\,[n]_q!\, .
 \end{equation}
 Then we have the identity
 \begin{equation}\label{formula-Fx-det}
  d_n(q) = \det A_n(q) \, .
 \end{equation}
\end{theorem}
\begin{proof}
 Let $ b_n(q) = \det A_n(q) $.
 By expanding the determinant along the last column, we get the recurrence
 $$ b_{n+1}(q) = \sum_{k=0}^n { n \choose k }_{\!\!q} a_k(q) b_{n-k}(q) $$
 with initial value $ b_0(q) = 1 $.
 Hence, considering the $q$-exponential generating series
 $$
  a(q;t) = \sum_{n\geq0} a_n(q) \frac{t^n}{[n]_q!}
  \qquad\text{and}\qquad
  b(q;t) = \sum_{n\geq0} b_n(q) \frac{t^n}{[n]_q!} \, ,
 $$
 we have the $q$-differential equation
 $$ \DD_q b(q;t) = a(q;t)\, b(q;t) \, . $$
 If $ b(q;t) = D_q(t) $, then $ b_0(q) = d_0(q) = 1 $, as requested, and
 $$ a(q;t) = \frac{\DD_q b(q;t)}{b(q;t)} = \frac{\DD_q D_q(t)}{D_q(t)} \, . $$
 By series (\ref{series-derN}) and relation (\ref{EEqq}), we have
 \begin{align*}
  \DD_q D_q(t)
  &= \frac{D_q(qt)-D_q(t)}{(q-1)t} \\
  &= \frac{1}{(q-1)t}\left( \frac{E_q(qt)^{-1}}{1-qt} - \frac{E_q(t)^{-1}}{1-t} \right) \\
  &= \frac{1}{(q-1)t}\left( \frac{E_q(t)^{-1}}{(1-qt)(1+(q-1)t)} - \frac{E_q(t)^{-1}}{1-t} \right) \\
  &= \frac{qt\,E_q(t)^{-1}}{(1-t)(1-qt)(1+(q-1)t)},
 \end{align*}
which is 
 $$ \DD_q D_q(t) = \frac{qt}{(1-qt)(1+(q-1)t)}\;D_q(t) \, . $$
 Therefore, we have
 $$
  a(q;t) = \frac{qt}{(1-qt)(1+(q-1)t)}
  = \frac{q}{2q-1}\,\frac{1}{1-qt} - \frac{q}{2q-1}\,\frac{1}{1-(1-q)t}\, .
 $$
 This decomposition yields identity (\ref{coeff-a}),
 and, consequently, this proves identity (\ref{formula-Fx-det}).
\end{proof}

\section{Final remarks}

In the literature, there are also other $q$-analogues for the derangement numbers.
For instance, we have the $q$-derangement numbers \cite{GarsiaRemmel}
\begin{equation}\label{def-qderNN}
 D_n(q) = \sum_{k=0}^n { n \choose k }_{\!\!q} [n-k]_q!\, (-1)^k
\end{equation}
satisfying the recurrences
\begin{align}
 & D_{n+1}(q) = [n+1]_q\, D_n(q) + (-1)^{n+1} \label{rec-qderNN01} \\
 & D_{n+2}(q) = q\, [n+1]_q\, D_{n+1}(q) + [n+1]_q\, D_n(q) \label{rec-qderNN02}
\end{align}
with initial conditions $ D_0(q) = 1 $ and $ D_1(q) = 0 $.
Moreover, they have $q$-exponential generating series
$$ \sum_{n\geq0} D_n(q) \frac{t^n}{[n]_q!} = \frac{E_q(-t)}{1-t} \, . $$

The $q$-numbers $ d_n(q) $ and $ D_n(q) $ are not independent, as shown in the next theorem.
\begin{theorem}
 For every $ n \in \NN $, we have the relation
 \begin{equation}\label{dnqDnq}
  d_n(q^{-1}) = q^{-{ n \choose 2 }} D_n(q) \, .
 \end{equation}
 Moreover, we have the formulas
 \begin{align}
  & d_n(q) = \sum_{k=0}^n (-1)^{n-k}q^{{ n-k \choose 2 }}\frac{(q^{n-k+1};q)_k}{(1-q)^k}\label{qDqPoch}\\
  & D_n(q) = \sum_{k=0}^n (-1)^{n-k}\frac{(q^{n-k+1};q)_k}{(1-q)^k}\label{qDDqPoch}\, .
 \end{align}
\end{theorem}
\begin{proof}
 By formula (\ref{def-qderN}) and relations (\ref{qBinRel}), we have
 \begin{align*}
  d_n(q^{-1})
  &= \sum_{k=0}^n { n \choose k }_{\!\!q^{-1}} [n-k]_{q^{-1}}!\, (-1)^k q^{-{ k \choose 2 }} \\
  &= \sum_{k=0}^n { n \choose k }_{\!\!q} q^{-k(n-k)} [n-k]_q! q^{-{ n-k \choose 2 }}\, (-1)^k q^{-{ k \choose 2 }} \\
  &= q^{-{ n \choose 2 }} \sum_{k=0}^n { n \choose k }_{\!\!q} [n-k]_q!\, (-1)^k \, .
 \end{align*}
 By formula (\ref{def-qderNN}), this is relation (\ref{dnqDnq}).

 Since $ [n]_q! = \frac{(q;q)_n}{(1-q)^n} $, from definition (\ref{def-qderN}) we have
 $$
  d_n(q) = \sum_{k=0}^n \frac{[n]_q!}{[k]_q!}\, (-1)^k q^{{ k \choose 2 }}
         = \sum_{k=0}^n \frac{(-1)^k q^{{ k \choose 2 }}}{(1-q)^{n-k}}\,\frac{(q;q)_n}{(q;q)_k}
         = \sum_{k=0}^n \frac{(-1)^k q^{{ k \choose 2 }}}{(1-q)^{n-k}}\,(q^{k+1};q)_{n-k} \, .
 $$
 This is equivalent to identity (\ref{qDqPoch}).
 Similarly, formula (\ref{def-qderNN}) can be rewritten as formula (\ref{qDDqPoch}).
\end{proof}

We also have the following result.
\begin{theorem}
 We have the ordinary generating series
 \begin{align}
  & d(q;t) = \sum_{n\geq0} d_n(q)\,t^n =
    \sum_{k\geq0} \frac{(-1)^k q^{{ k+1 \choose 2 }}}{(1-q)^k}\,
    \frac{t^kQ(q;q^kt)}{\big(\frac{t}{1-q};q\big)_{k+1}} \label{qseriesD} \\
  & D(q;t) = \sum_{n\geq0} D_n(q)\,t^n =
    \sum_{k\geq0} \frac{(-1)^k q^{{ k+1 \choose 2 }}}{(1-q)^k}\,
    \frac{t^k}{(1+q^kt)\big(\frac{t}{1-q};q\big)_{k+1}} \label{qseriesDD}
 \end{align}
 where
 $$ Q(q;t) = \sum_{n\geq0} (-1)^n q^{{ n \choose 2 }}\, t^n \, . $$
\end{theorem}
\begin{proof}
 From recurrence (\ref{rec-qderN01}), we have
 $$
  \sum_{n\geq0} d_{n+1}(q) \, t^n =
  \sum_{n\geq0} \frac{1-q^{n+1}}{1-q}\, d_n(q) \, t^n +
  \sum_{n\geq0} (-1)^{n+1} q^{{ n+1 \choose 2 }} \, t^n,
 $$
which is 
 $$ \frac{d(q;t)-d_0(q)}{t} = \frac{1}{1-q} ( d(q;t ) - q d(q;qt) ) + \frac{Q(q;t)-1}{t}, $$
or
 $$ d(q;t) - 1 = \frac{t}{1-q} d(q;t) - \frac{qt}{1-q}\, d(q;qt) + Q(q;t) - 1, $$
or
 $$ \left( 1 - \frac{t}{1-q} \right) d(q;t) = Q(q;t) - \frac{qt}{1-q}\, d(q;qt) ,$$
 which is
 $$ d(q;t) = \frac{Q(q;t)}{1-\frac{t}{1-q}} - \frac{qt}{(1-q)\big(1-\frac{t}{1-q}\big)}\, d(q;qt)\, . $$
 By repeatedly applying this formula, we get
 \begin{align*}
  d(q;t) &=
  \sum_{k=0}^n \frac{(-1)^kq^{{ k+1 \choose 2 }}}{(1-q)^k}
  \frac{t^k\,Q(q;q^kt)}{\big(1-\frac{t}{1-q}\big)(1-\frac{qt}{1-q}\big)\cdots(1-\frac{q^kt}{1-q}\big)}  \\
  &\qquad\qquad + \frac{(-1)^{n+1}q^{{ n+2 \choose 2 }}}{(1-q)^{n+1}} \frac{t^{n+1}}
   {\big(1-\frac{t}{1-q}\big)(1-\frac{qt}{1-q}\big)\cdots(1-\frac{q^nt}{1-q}\big)}\, d(q;q^{n+1}t) \\
  &=
  \sum_{k=0}^n \frac{(-1)^kq^{{ k+1 \choose 2 }}}{(1-q)^k}\frac{t^k\,Q(q;q^kt)}{\big(\frac{t}{1-q};q\big)_{k+1}} +
  \frac{(-1)^{n+1}q^{{ n+2 \choose 2 }}}{(1-q)^{n+1}}\frac{t^{n+1}}{\big(\frac{t}{1-q};q\big)_{n+1}}\, d(q;q^{n+1}t) \, .
 \end{align*}
 Taking the limit for $ n $ tending to $ +\infty $, we obtain series (\ref{qseriesD}).

 Similarly, from recurrence (\ref{rec-qderNN01}), we have
 $$
  \sum_{n\geq0} D_{n+1}(q)\, t^n =
  \sum_{n\geq0} \frac{1-q^{n+1}}{1-q}\, D_n(q)\, t^n + \sum_{n\geq0} (-1)^{n+1} t^n,
 $$
which is 
 $$ \frac{D(q;t)-D_0(q)}{t} = \frac{1}{1-q} ( D(q;t ) - q D(q;qt) ) - \frac{1}{1+t}, $$
 or
 $$ \left(1-\frac{t}{1-q}\right) D(q;t) = \frac{1}{1+t} - \frac{qt}{1-q} D(q;qt) , $$
 or
 $$ D(q;t) = \frac{1}{(1+t)\big(1-\frac{t}{1-q}\big) } - \frac{qt}{(1-q)\big(1-\frac{t}{1-q}\big) } D(q;qt).  $$
 By repeatedly applying this formula, we get
 \begin{align*}
  D(q;t) &=
  \sum_{k=0}^n \frac{(-1)^kq^{{ k+1 \choose 2 }}}{(1-q)^k} \frac{t^k}
   {(1+q^kt)\big(1-\frac{t}{1-q}\big)(1-\frac{qt}{1-q}\big)\cdots(1-\frac{q^kt}{1-q}\big)}  \\
  &\qquad\qquad +
   \frac{(-1)^{n+1}q^{{ n+2 \choose 2 }}}{(1-q)^{n+1}}\frac{t^{n+1}}
   {\big(1-\frac{t}{1-q}\big)(1-\frac{qt}{1-q}\big)\cdots(1-\frac{q^nt}{1-q}\big)}\, D(q;q^{n+1}t) \\
  &=
  \sum_{k=0}^n \frac{(-1)^kq^{{ k+1 \choose 2 }}}{(1-q)^k}\frac{t^k}{(1+q^kt)\big(\frac{t}{1-q};q\big)_{k+1}}  \\
  &\qquad\qquad +
  \frac{(-1)^{n+1}q^{{ n+2 \choose 2 }}}{(1-q)^{n+1}}\frac{t^{n+1}}{\big(\frac{t}{1-q};q\big)_{n+1}}\, D(q;q^{n+1}t) \, .
 \end{align*}
 Taking the limit for $ n $ tending to $ +\infty $, we obtain series (\ref{qseriesDD}).
\end{proof}

\begin{thebibliography}{99}
 \bibitem{AlSalamCarlitz}
  W. A. Al-Salam and L. Carlitz,
  A $q$-analog of a formula of Toscano,
  \emph{Boll. Un. Mat. Ital.} (3) \textbf{12} (1957), 414--417.
 \bibitem{AlSalamCarlitzU}
  W. A. Al-Salam and L. Carlitz,
  Some orthogonal $q$-polynomials,
  \emph{Math. Nachr.} \textbf{30} (1965), 47-61.
 \bibitem{CFMunariniZ}
  S. Capparelli, M. M. Ferrari, E. Munarini, and N. Zagaglia Salvi,
  A generalization of the ``\emph{Probl\`eme des Rencontres}'',
  \emph{J. Integer Sequences} \textbf{21} (2018), 
  \href{https://cs.uwaterloo.ca/journals/JIS/VOL21/Munarini/muna8.html}{Article 18.2.8}.
 \bibitem{Carlitz}
  L. Carlitz,
  Some polynomials related to the theta functions,
  \emph{Ann. Mat. Pura Appl.} \textbf{41} (1955), 359--373.
 \bibitem{ChenRota}
  W. Y. C. Chen and G.-C. Rota,
  $q$-analogs of the inclusion-exclusion principle and permutations with restricted position,
  \emph{Discrete Math.} \textbf{104} (1992), 7--22.
 \bibitem{ChenSaadSun}
  W. Y. C. Chen, H. L. Saad, and L. H. Sun,
  An operator approach to the Al-Salam–Carlitz polynomials,
  \emph{J. Math. Phys.} \textbf{51} (2010), Paper 043502.
 \bibitem{ChenXia}
  W. Y. C. Chen and E. X. W. Xia,
  The ratio monotonicity of the $q$-derangement numbers,
  \emph{Discrete Math.} \textbf{311} (2011), 393--397.
 \bibitem{Chihara}
  T. S. Chihara,
  \emph{An Introduction to Orthogonal Polynomials},
  Gordon and Breach, 1978.
 \bibitem{MunariniCC}
  O. M. D'Antona and E. Munarini,
  A combinatorial interpretation of the connection constants for persistent sequences of polynomials,
  \emph{European J. Combin.} \textbf{26} (2005), 1105--1118.
 \bibitem{FerrariMunarini}
  M. M. Ferrari and E. Munarini,
  Decomposition of some Hankel matrices generated by the generalized rencontres polynomials,
  \emph{Linear Algebra Appl.} \textbf{567} (2019), 180-–201.
 \bibitem{GarsiaRemmel}
  A. M. Garsia and J. Remmel,
  A combinatorial interpretation of $q$-derangement and $q$-Laguerre numbers,
  \emph{Europ. J. Combin.} \textbf{1} (1980), 47--5.
 \bibitem{Gauss}
  C. F. Gauss,
  Summatio quarumdam serierum singularium,
  \emph{Comm. soc. reg. sci. Gottingensis rec.} \textbf{1} (1808), 147--186.
  Reprinted in Gauss's {\it Werke} \textbf{2} (1863), 9--45.
 \bibitem{GoldmanRota}
  J. Goldman and G.-C. Rota,
  The number of subspaces of a vector space,
  \emph{Recent Progress in Combinatorics} (Proc. Third Waterloo Conf. on Combinatorics, 1968)
  Academic Press, 1969, pp.~75--83.
 \bibitem{GoldmanRota70}
  J. Goldman and G.-C. Rota,
  On the foundations of combinatorial theory. IV. Finite vector spaces and Eulerian generating functions,
  \emph{Studies in Appl. Math.} \textbf{49} (1970), 239--258.
 \bibitem{Ismail}
  M. E. H. Ismail,
  \emph{Classical and Quantum Orthogonal Polynomials in One Variable},
  Cambridge University Press, 2005.
 \bibitem{Jackson}
  F. H. Jackson,
  A basic-sine and cosine with symbolical solutions of certain differential equations,
  \emph{Proc. Edinburgh Math. Soc.} \textbf{22} (1904), 28--39.
 \bibitem{Jackson1908}
  F. H. Jackson,
  On $q$-functions and a certain difference operator,
  \emph{Trans. Roy. Soc. Edin.} \textbf{46} (1908), 253--281.
 \bibitem{Jackson1910}
  F. H. Jackson,
  $q$-Difference equations,
  \emph{Am. J. Math.} \textbf{32} (1910), 305--314.
 \bibitem{Kim}
  D. Kim,
  On combinatorics of Al-Salam Carlitz polynomials,
  \emph{European J. Combin.} \textbf{18} (1997), 295--302.
 \bibitem{Muir}
  T. Muir,
  \emph{The Theory of Determinants in the Historical Order of Developement},
  Dover, 1960.
 \bibitem{MunariniSP}
  E. Munarini,
  Shifting property for Riordan, Sheffer and connection constants matrices,
  \emph{J. Integer Sequencesf} \textbf{20} (2017), 
  \href{https://cs.uwaterloo.ca/journals/JIS/VOL20/Munarini/muna4.html}{Article 17.8.2}.
 \bibitem{Munarini-qFiboSP}
  E. Munarini,
  Some $q$-binomial identities involving the generalized $q$-Fibonacci numbers,
  \emph{Integers} \textbf{18} (2018), Paper No.~A76.
 \bibitem{MunariniA}
  E. Munarini,
  Combinatorial identities for Appell polynomials,
  \emph{Appl. Anal. Discrete Math.} \textbf{12} (2018), 362--388.
 \bibitem{MunariniC}
  E. Munarini,
  Callan-like identities,
  \emph{Online J. Anal. Comb.} \textbf{14} (2019), Article \#06.
 \bibitem{MunariniO}
  E. Munarini,
  An operational approach to the generalized rencontres polynomials,
  \emph{Kragujevac J. Math.} \textbf{46} (2022), 461--469.
 \bibitem{NijenhuisSolowWilf}
  A. Nijenhuis, A. E. Solow, and H. S. Wilf,
  Bijective methods in the theory of finite vector spaces,
  \emph{J. Combin. Theory Ser. A} \textbf{37} (1984), 80--84.
 \bibitem{Roman}
  S. Roman,
  \emph{The Umbral Calculus},
  Academic Press, 1984.
 \bibitem{Sloane}
  N. J. A. Sloane et al.,
  \emph{The On-Line Encyclopedia of Integer Sequences}, 2020.   
  Available at \url{https://oeis.org/}.
 \bibitem{Szego}
  G. Szeg\H{o},
  \emph{Orthogonal Polynomials},
  Amer. Math. Soc. Colloquium Publication \textbf{23},
  Amer. Math. Soc., 1975.
 \bibitem{Ubriaco}
  M. R. Ubriaco,
  Time evolution in quantum mechanics on the quantum line,
  \emph{Phys. Lett.} A \textbf{163} (1992), 1--4.
 \bibitem{VeinDale}
  R. Vein and P. Dale,
  \emph{Determinants and Their Applications in Mathematical Physics},
  Springer-Verlag, 1999.
 \bibitem{Wachs}
  M. L. Wachs,
  On $q$-derangement numbers,
  \emph{Proc. Amer. Math. Soc.} \textbf{106} (1989), 273--278.
 \bibitem{Zhang}
  X.-D. Zhang,
  On the spiral property of the $q$-derangement numbers,
  \emph{Discrete Math.} \textbf{159} (1996), 295--298.
\end{thebibliography}

\bigskip
\hrule
\bigskip

\noindent 2010 {\it Mathematics Subject Classification}:
Primary 05A30;
Secondary 11B65, 05A19, 11B73, 33B10, 39A13.

\noindent \emph{Keywords: }
combinatorial sum, $q$-binomial sum,
$q$-derangement number, $q$-Stirling number, $q$-Bell number,
connection constant, $q$-exponential generating series.

\bigskip
\hrule
\bigskip

\noindent (Concerned with sequences
\seqnum{A000110} and \seqnum{A000166}.)

\bigskip
\hrule
\bigskip

\vspace*{+.1in}
\noindent
Received October 27 2019;
revised version received February 18 2020; March 11 2020.
Published in {\it Journal of Integer Sequences}, March 17 2020.

\bigskip
\hrule
\bigskip

\noindent
Return to
\htmladdnormallink{Journal of Integer Sequences home page}{http://www.cs.uwaterloo.ca/journals/JIS/}.
\vskip .1in

\end{document}
