# How could we define the factorial of a matrix?

Suppose I have a square matrix $\mathsf{A}$ with $\det \mathsf{A}\neq 0$.

How could we define the following operation?

Maybe we could make some simple example, admitted it makes any sense, with

For any holomorphic function $$GG$$, we can define a corresponding matrix function $$˜G\tilde{G}$$ via (a formal version of) the Cauchy Integral Formula: We set
$$˜G(B):=12πi∮CG(z)(zI−B)−1dz,\tilde{G}(B) := \frac{1}{2 \pi i} \oint_C G(z) (z I - B)^{-1} \, dz ,$$
where $$CC$$ is an (arbitrary) anticlockwise curve that encloses (once each) the eigenvalues of the (square) matrix $$BB$$. Note that the condition on $$CC$$ means that restrictions on the domain of $$GG$$ determine restrictions on the domain of $$˜G\tilde{G}$$.

So, we could make sense of the factorial of a matrix if we had a holomorphic function that restricted to the factorial function $$n↦n!n \mapsto n!$$ on nonnegative integers. Fortunately, there is such a function: The function $$F:z↦Γ(z+1),F: z \mapsto \Gamma(z + 1),$$ where $$Γ\Gamma$$ denotes the Gamma function, satisfies $$F(n)=n!F(n) = n!$$ for nonnegative integers $$nn$$. (There is a sense in which $$FF$$ is the best possible function extending the factorial function, but notice the target of that link really just discusses the real Gamma function, which our $$Γ\Gamma$$ preferentially extends.) Thus, we may define factorial of a (square) matrix $$BB$$ by substituting the second display equation above into the first:
$$B!:=˜F(B)=12πi∮CΓ(z+1)(zI−B)−1dz.\color{#df0000}{\boxed{B! := \tilde{F}(B) = \frac{1}{2 \pi i} \oint_C \Gamma(z + 1) (z I - B)^{-1} \, dz}} .$$

The (scalar) Cauchy Integral Formula shows that this formulation has the obviously desirable property that for scalar matrices it recovers the usual factorial, or more precisely, that $$(n)!=(n!)\pmatrix{n}! = \pmatrix{n!}$$ (for nonnegative integers $$nn$$).

Alternatively, one could define a matrix function $$˜G\tilde G$$ (and in particular define $$B!B!$$) by evaluating formally the power series $$∑∞i=0ak(z−z0)k\sum_{i = 0}^{\infty} a_k (z - z_0)^k$$ for $$GG$$ about some point $$z0z_0$$, that is, declaring $$˜G(B):=∑∞i=0ak(B−z0I)k\tilde G(B) := \sum_{i = 0}^{\infty} a_k (B - z_0 I)^k$$, but in general this definition is more restrictive than the Cauchy Integral Formula definition, simply because the power series need not converge everywhere (where it does converge, it converges to the value given by the integral formula). Indeed, we cannot use a power series for $$FF$$ to evaluate $$A!A!$$ directly for our particular $$AA$$: The function $$FF$$ has a pole on the line segment in $$C\Bbb C$$ with endpoints the eigenvalues of $$AA$$, so there is no open disk in the domain of $$FF$$ containing all of the eigenvalues of $$AA$$, and hence there is no basepoint $$z0z_0$$ for which the series for $$˜F\tilde F$$ converges at $$AA$$.

We can define $$˜G\tilde G$$ in yet another way, which coincides appropriately with the above definitions but which is more amenable to explicit computation: If $$BB$$ is diagonalizable, so that we can decompose $$B=P(λ1⋱λn)P−1,B = P \pmatrix{\lambda_1 & & \\ & \ddots & \\ & & \lambda_n} P^{-1} ,$$
for eigenvalues $$λa\lambda_a$$ of $$BB$$ and some matrix $$PP$$, we define
$$˜G(B):=P(G(λ1)⋱G(λn))P−1.\tilde{G}(B) := P \pmatrix{G(\lambda_1) & & \\ & \ddots & \\ & & G(\lambda_n)} P^{-1} .$$ Indeed, by substituting and rearranging, we can see that this coincides, at least formally, with the power series characterization. There is a similar but more complicated formula for nondiagonalizable $$BB$$ that I won’t write out here but which is given in the Wikipedia article Matrix function.

Example The given matrix $$AA$$ has distinct eigenvalues $$λ±=1±√6\lambda_{\pm} = 1 \pm \sqrt{6}$$, and so can be diagonalized as $$P(1−√6001+√6)P−1;P \pmatrix{1 - \sqrt{6} & 0 \\ 0 & 1 + \sqrt{6}} P^{-1} ;$$ indeed, we can take $$P=(1212−1√61√6).P = \pmatrix{\tfrac{1}{2} & \tfrac{1}{2} \\ -\frac{1}{\sqrt{6}} & \frac{1}{\sqrt{6}}}.$$

Now, $$F(\lambda_{\pm}) = \Gamma(\lambda_{\pm} + 1) = \Gamma (2 {\pm} \sqrt{6}),F(\lambda_{\pm}) = \Gamma(\lambda_{\pm} + 1) = \Gamma (2 {\pm} \sqrt{6}),$$
and putting this all together gives that
\begin{align*}\pmatrix{1 & 3 \\ 2 & 1} ! = \bar{F}(A) &= P \pmatrix{F(\lambda_-) & 0 \\ 0 & F(\lambda_+)} P^{-1} \\ &= \pmatrix{\tfrac{1}{2} & \tfrac{1}{2} \\ -\frac{1}{\sqrt{6}} & \frac{1}{\sqrt{6}}} \pmatrix{\Gamma (2 – \sqrt{6}) & 0 \\ 0 & \Gamma (2 + \sqrt{6})} \pmatrix{1 & -\frac{\sqrt{3}}{\sqrt{2}} \\ 1 & \frac{\sqrt{3}}{\sqrt{2}}} .\end{align*}\begin{align*}\pmatrix{1 & 3 \\ 2 & 1} ! = \bar{F}(A) &= P \pmatrix{F(\lambda_-) & 0 \\ 0 & F(\lambda_+)} P^{-1} \\ &= \pmatrix{\tfrac{1}{2} & \tfrac{1}{2} \\ -\frac{1}{\sqrt{6}} & \frac{1}{\sqrt{6}}} \pmatrix{\Gamma (2 - \sqrt{6}) & 0 \\ 0 & \Gamma (2 + \sqrt{6})} \pmatrix{1 & -\frac{\sqrt{3}}{\sqrt{2}} \\ 1 & \frac{\sqrt{3}}{\sqrt{2}}} .\end{align*}
Multiplying this out gives
$$\color{#df0000}{\boxed{\pmatrix{1 & 3 \\ 2 & 1} ! = \pmatrix{\frac{1}{2} \alpha_+ & \frac{\sqrt{3}}{2 \sqrt{2}} \alpha_- \\ \frac{1}{\sqrt{6}} \alpha_- & \frac{1}{2} \alpha_+}}} ,\color{#df0000}{\boxed{\pmatrix{1 & 3 \\ 2 & 1} ! = \pmatrix{\frac{1}{2} \alpha_+ & \frac{\sqrt{3}}{2 \sqrt{2}} \alpha_- \\ \frac{1}{\sqrt{6}} \alpha_- & \frac{1}{2} \alpha_+}}} ,$$
where $$\color{#df0000}{\alpha_{\pm} = \Gamma(2 + \sqrt{6}) \pm \Gamma(2 – \sqrt{6})}. \color{#df0000}{\alpha_{\pm} = \Gamma(2 + \sqrt{6}) \pm \Gamma(2 - \sqrt{6})}.$$

It’s perhaps not very illuminating, but $$A!A!$$ has numerical value
$$\pmatrix{1 & 3 \\ 2 & 1}! \approx \pmatrix{3.62744 & 8.84231 \\ 5.89488 & 3.62744} . \pmatrix{1 & 3 \\ 2 & 1}! \approx \pmatrix{3.62744 & 8.84231 \\ 5.89488 & 3.62744} .$$

To carry out these computations, one can use Maple’s built-in MatrixFunction routine (it requires the LinearAlgebra package) to write a function that computes the factorial of any matrix:

MatrixFactorial := X -> LinearAlgebra:-MatrixFunction(X, GAMMA(z + 1), z);


To evaluate, for example, $$A!A!$$, we then need only run the following:

A := Matrix([[1, 3], [2, 1]]);
MatrixFactorial(A);


(NB executing this code returns an expression for $$A!A!$$ different from the one above: Their values can be seen to coincide using the the reflection formula $$-z \Gamma(z) \Gamma(-z) = \frac{\pi}{\sin \pi z} .-z \Gamma(z) \Gamma(-z) = \frac{\pi}{\sin \pi z} .$$ We can further simplify the expression using the identity $$\Gamma(z + 1) = z \Gamma(z)\Gamma(z + 1) = z \Gamma(z)$$ extending the factorial identity $$(n + 1)! = (n + 1) \cdot n!(n + 1)! = (n + 1) \cdot n!$$ to write $$\Gamma(2 \pm \sqrt{6}) = (6 \pm \sqrt{6}) \Gamma(\pm \sqrt{6})\Gamma(2 \pm \sqrt{6}) = (6 \pm \sqrt{6}) \Gamma(\pm \sqrt{6})$$ and so write the entries as expressions algebraic in $$\pi\pi$$, $$\sin(\pi \sqrt{6})\sin(\pi \sqrt{6})$$, and $$\Gamma(\sqrt{6})\Gamma(\sqrt{6})$$ alone. One can compel Maple to carry out these substitutions by executing simplify(map(expand, %)); immediately after executing the previous code.) To compute the numerical value, we need only execute evalf(%); immediately after the previous code.

By the way, we need not have that $$\det B \neq 0\det B \neq 0$$ in order to define $$B!B!$$. In fact, proceeding as above we find that the factorial of the (already diagonal) zero matrix is the identity matrix: $$0! = \pmatrix{\Gamma(1) \\ & \ddots \\ & & \Gamma(1)} = I .0! = \pmatrix{\Gamma(1) \\ & \ddots \\ & & \Gamma(1)} = I .$$ Likewise using the formula for nondiagonalizable matrices referenced above together with a special identity gives that the factorial of the $$2 \times 22 \times 2$$ Jordan block of eigenvalue $$00$$ is, somewhat amusingly,
$$\pmatrix{0 & 1\\0 & 0} ! = \pmatrix{1 & -\gamma \\ 0 & 1} ,\pmatrix{0 & 1\\0 & 0} ! = \pmatrix{1 & -\gamma \\ 0 & 1} ,$$ where $$\gamma\gamma$$ is the Euler-Mascheroni constant.