TITLE: Is it possible to compute factorials by converting to matrix multiplications?
QUESTION [6 upvotes]: An $n$-th term of the Fibonacci sequence can be computed by a nice trick by converting the recurrence relation in a matrix form. Then we compute $M^n$ in $O(\log n)$ steps using exponentiation by squaring.
Would it be possible to use such a trick to compute factorials? If not, can it be proved? I figured out how to compute any polynomial in $n$ using this approach, but for factorials I wasn't able to express the factorial's recurrence relation as a linear transformation.

REPLY [3 votes]: Well, this is probably not the answer you are looking for, but it might be interesting.
Let $D_k$ be the $k \times k$ matrix with zeros everywhere except on the superdiagonal, where it has the values $1, 2, \dots, k - 1$. Then the factorial $(k-1)!$ is equal to the first element in the vector
$$D_k^{k-1} e_k$$
where $e_k$ is the unit vector with a one at position $k$. Equivalently, the element at position $(1,k)$ in $D_k^{k-1}$ is $(k-1)!$.
Example
$$D_5 = \left(
\begin{array}{ccccc}
 0 & 1 & 0 & 0 & 0 \\
 0 & 0 & 2 & 0 & 0 \\
 0 & 0 & 0 & 3 & 0 \\
 0 & 0 & 0 & 0 & 4 \\
 0 & 0 & 0 & 0 & 0
\end{array}
\right)$$
$$D_5^4 = \left(
\begin{array}{ccccc}
 0 & 0 & 0 & 0 & 24 \\
 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0
\end{array}
\right)$$
Explanation
The matrix $D_k$ acts on the space of polynomials of degree $\leq k$ as differentiation. Then one can use the following characterization of the factorial:
$$n!= \frac{d^n}{dx^n} x^n$$
and get the result above.
Observations
The matrix $D_k$ can also be used to generate an upper triangular Pascal matrix $U_k$ through $U_k = e^{D_k}$, using the matrix exponential.
A closer look at $D_k$
When you put $D_k$ on Jordan normal form. For example with $D_5$ above you get $D_5 = S^{-1}JS$:
$$D_5 = \underbrace{\left(
\begin{array}{ccccc}
 1 & 0 & 0 & 0 & 0 \\
 0 & 1 & 0 & 0 & 0 \\
 0 & 0 & 2 & 0 & 0 \\
 0 & 0 & 0 & 6 & 0 \\
 0 & 0 & 0 & 0 & 24
\end{array}
\right)}_{=S^{-1}}
\underbrace{\left(
\begin{array}{ccccc}
 0 & 1 & 0 & 0 & 0 \\
 0 & 0 & 1 & 0 & 0 \\
 0 & 0 & 0 & 1 & 0 \\
 0 & 0 & 0 & 0 & 1 \\
 0 & 0 & 0 & 0 & 0
\end{array}
\right)}_{=J}
\underbrace{
\left(
\begin{array}{ccccc}
 1 & 0 & 0 & 0 & 0 \\
 0 & 1 & 0 & 0 & 0 \\
 0 & 0 & \frac{1}{2} & 0 & 0 \\
 0 & 0 & 0 & \frac{1}{6} & 0 \\
 0 & 0 & 0 & 0 & \frac{1}{24}
\end{array}
\right)}_{=S}
$$
where $J$ is one big Jordan block (which is not surprising since $D_k$ is nilpotent), and $S^{-1}$ is a diagonal matrix with factorials on the diagonal!
Investigating this a little but further reveals that this is not so strange. $D_k$ has only one eigenvalue, namely 0, with algebraic multiplity $k$ and geometric multiplicity 1. The eigenvector belonging to this eigenvalue is $e_1$.
When we put something on Jordan normal form, we use generalized eigenvectors, which are vectors $v$ that satisfy $(D_k - \lambda I)^n v = 0$ for some $k$. In our case $\lambda = 0$, so we just look at $D_k^n v = 0$. This gives us that $e_k$ is a generalized eigenvector. Remember our original formulation?
$$D_k^{k-1}e_k = (k-1)! e_1$$
which explains why we have factorials in $S^{-1}$.