Saw below entertaining matrix multiplication examples.

enter image description here

Obviously they are just coincidences. But I am curious when does below hold?

\begin{equation} \begin{pmatrix} a_1 & b_1 \\ c_1 & d_1 \end{pmatrix} \times \begin{pmatrix} a_2 & b_2 \\ c_2 & d_2 \end{pmatrix} = \begin{pmatrix} \overline{a_1 a_2} & \overline{b_1 b_2} \\ \overline{c_1 c_2} & \overline{d_1 d_2} \end{pmatrix} \end{equation}

here $\overline{a_1 a_2}$ means gluing the integers together, not multiplications.. assuming we are working on integer matrices.

  • 8
    $\begingroup$ One instance of this is a "vampire matrix" where the matrices being multiplied are the same. For example, $$ \pmatrix{3 & 4\\6 & 8} \cdot \pmatrix{3 & 4\\6 & 8} = \pmatrix{33 & 44\\66 & 88}. $$ Matt Parker has a nice youtube video about these. $\endgroup$ Jan 18, 2021 at 15:23
  • 7
    $\begingroup$ Don't know if it will help, but "concatenate" is a technical term we use in programming to refer to "gluing" the integers together. I believe it is used in the mathematics of languages as well. $\endgroup$
    – Cort Ammon
    Jan 19, 2021 at 0:12
  • $\begingroup$ Agree that searchability would be improved if we substitute "concatenation" for "glues" in the title and post. $\endgroup$ Jan 19, 2021 at 7:07

3 Answers 3


Let $A$ denote the first matrix in the product, and let $B$ denote the second. I will consider only the case in which the entries of $B$ have one digit.

In this case, the "gluing" property of this matrix multiplication can be written as $$ AB = 10A + B. $$ Note that this equation can be rearranged into $$ AB - 10 A - B + 10I = 10I \implies\\ (A - I)(B - 10 I)= 10 I, $$ where $I$ denotes the identity matrix. Now, suppose that we select a matrix $B$ and we want a corresponding matrix $A$. We have $$ (A - I)(B - 10 I) = 10 I \implies\\ A = 10(B - 10 I)^{-1} + I. $$ Note that this equation only has a solution if $\det(B - 10 I) \neq 0$. Now, a question remains: how do we ensure that $10 (B - 10 I)^{-1}$ is an integer matrix? As it turns out, this will hold for a given integer matrix $B$ if and only if the determinant of $B - 10 I$ divides $10$.

In fact, we can generate pairs of matrices with non-negative integer entries that have the gluing property via the following steps:

  • Find a matrix $C$ whose diagonal entries satisfy $-10 \leq c_{ii} \leq -1$ and whose off-diagonal entries are a single digit positive number such that the determinant of $C$ is either $-1$, $-2$, $-5$, or $-10$.
  • Take $B = 10 I + C$ and $A = 10C^{-1} + I$.

For example, the matrix $$ C = \pmatrix{-4 & 3\\7 &-4} $$ has determinant $16 - 21 = -5$, which divides $10$. The corresponding matrix $B$ is $$ B = 10 I + \pmatrix{-4 & 3\\7 &-4} = \pmatrix{6&3\\7&6}. $$ The associated matrix $A$ is $$ 10C^{-1} + I = \frac{10}{-5} \cdot \pmatrix{-4 & -3\\-7 & -4} + \pmatrix{1&0\\0&1} = \pmatrix{9 & 6\\14 & 9}. $$ If we compute the product, we indeed find that $$ \pmatrix{\color{blue}{9} & \color{blue}{6}\\ \color{blue}{14} & \color{blue}{9}} \cdot \pmatrix{\color{green}{6} & \color{green}{3}\\ \color{green}{7} & \color{green}{6}} = \pmatrix{\color{blue}{9}\color{green}{6} & \color{blue}{6}\color{green}{3}\\ \color{blue}{14}\color{green}{7} & \color{blue}{9}\color{green}{6}}. $$

An interesting phenomenon: if $B$ is a single digit matrix for which there exists an $A,B$ pair with this "gluing" property, we will have $A = B$ if and only if $B$ is a "vampire matrix" (cf. my comment on the question), which holds if and only if $B$ has eigenvalues $0,11$, which holds if and only if $C = B - 10 I$ has eigenvalues $-10,1$, which holds if and only if $C$ has determinant $-10$ and trace $-9$.

  • $\begingroup$ This is really a great fun (matrix-algebra has been many years a favourite for me). (+1) and I would like to give more... $\endgroup$ Jan 18, 2021 at 21:25
  • $\begingroup$ @GottfriedHelms Thank you, I am glad you enjoyed it! $\endgroup$ Jan 18, 2021 at 22:45

Call the two matrices (in blue and in green respectively) $A$ and $B$. Assuming for simplicity that we want $B$ to consist of single digits only, we can write the property we're looking for as a matrix equation: $AB = 10A + B$.

Moving everything to one side, we can add a fourth term to make things easier to factor: $AB - 10A - B + 10I = 10I$. This can be written as $(A - I)(B - 10I) = 10 I$. So, in terms of $B$, we have $$A = 10(B - 10 I)^{-1} + I.$$ This gives us a formula for $A$ no matter which $B$ we pick, though out of $10^4$ possibilities for $B$, my computer only found $429$ for which $A$ consists of nonnegative integers.


Your question is quite interesting!

So, let's calculate: first, how can we write $\overline{a_1a_2}$? In fact, $a_1$ and $a_2$ are simply, as you said, "glued" together. So, we simply have $\overline{a_1a_2} = 10a_1+a_2$.

Now, let's re-write your equation using this result:

$$\begin{pmatrix} a_1 & b_1 \\ c_1 & d_1 \end{pmatrix} \times \begin{pmatrix} a_2 & b_2 \\ c_2 & d_2 \end{pmatrix} = \begin{pmatrix} \overline{a_1 a_2} & \overline{b_1 b_2} \\ \overline{c_1 c_2} & \overline{d_1 d_2} \end{pmatrix} = \begin{pmatrix} 10a_1+a_2 & 10b_1+b_2 \\ 10c_1+c_2 & 10d_1+d_2 \end{pmatrix}$$

Now, let's name this "equation" $(E)$ with every number being an integer. Then, by calculating the product, we have $$(E) \iff \begin{pmatrix} a_1a_2 + b_1c_2 & a_1b_2 + b_1d_2\\ c_1a_2 + d_1c_2 & c_1b_2 + d_1d_2 \end{pmatrix} = \begin{pmatrix} 10a_1+a_2 & 10b_1+b_2 \\ 10c_1+c_2 & 10d_1+d_2 \end{pmatrix}$$

Finally, we are able to identify the coefficients and get a system of equations: $$\boxed{(E) \iff \begin{cases} a_1a_2+b_1c_2 = 10a_1+a_2\\ c_1a_2+d_1c_2 = 10c_1+c_2 \\ a_1b_2+b_1d_2 = 10b_1+b_2\\ c_1b_2 + d_1d_2 = 10d_1+d_2 \end{cases}}$$

Now that we got this system, you can notice that there are only 4 equations for a total of 8 unknowns. So 4 of them will have to be fixed, then they'll give you the 4 other. Now it's up to you to find "groups" of integers that work!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .