“Lucky fool” 22 matrix multiplication: finding all 100 possible pairs with Wolfram Language​
​By Rauan Kaldybayev 
Okay, math meme page admins. Here is a pool of “lucky fool” matrix multiplication pairs where you can draw content from.

Question

On the Internet, you might have seen jokes of the type “I’ve invented an easy way to multiply matrices:
a
b
c
d
·
a'
b'
c'
d'
=
ab
bb'
cc'
dd'
. Here is an example:

3
4
8
7
·
7
2
4
9
 = 
37
42
84
79

. Don’t trust me? Here is another one:

9
6
3
2
·
9
6
3
2
 = 
99
66
33
22

.” I first saw it in this Facebook post:
Are there any other pairs of matrices that follow this pattern, and can we find all of them? It turns out that the answer is yes, and the derivation is rater simple.

Answer

What we are looking for is a pair of matrices whose entries are digits and whose product can be computed by simply “adding” their entries. Symbolically, we can write the criterion as
a
b
c
d
a'
b'
c'
d'
=
10a+a'
10b+b'
10c+c'
10d+d'
where
a,b,c,d,a',b',c',d'
are integers between 1 and 9. This criterion is the constraint that the two matrices must satisfy in order to form a “lucky fool” pair. The criterion can be decomposed into four scalar equations:
aa'+bc'=10a+a'​​ab'+bd'=10b+b'​​ca'+dc'=10c+c'​​ab'+dd'=10d+d'
Now, one way to find the “lucky fool” pairs would be to simply iterate through all possible values of the entries. However, a much faster way to solve the problem is by using the four equations to determine
a',b',c',d'
in terms of
a,b,c,d
and then iterate through all possible values of
a,b,c,d
. And instead of solving the equations the “stone age” way, it is convenient to write them in matrix notation:
MM'=10M+M'
Here
M=
a
b
c
d
,
M'=
a'
b'
c'
d'
. We can re-write this matrix equation as
(M-I)M'=10M
or
M'=10
-1
(M-I)
M
where
I=
1
0
0
1

is the 22 identity matrix and
-1
A
denotes the inverse of
A
. We can use this formula to write a Wolfram Language function to find
M'
given
M
:
In[]:=
findMprime[M_] := 10 InverseM - 
1
0
0
1
 . M;
Now, we know that the entries of
M'
cannot be anything: they must be digits, or, in other words, integers between 1 and 9.
In[]:=
checkMprime[Mp_] := AllTrue[Flatten@Mp, Function[n, IntegerQ[n] && (1 ≤ n ≤ 9)]];
Now, we need to enumerate through all possible values of
M
.
In[]:=
possibleM[] := FlattenTable​​
a
b
c
d
,​​ {a, 1, 9}, {b, 1, 9}, {c, 1, 9}, {d, 1, 9}​​ , 3;
What is left is to display the matrices that form “lucky fool” pairs:
In[]:=
displayMandMprime[M_, Mp_] := Row[{MatrixForm@M, "·", MatrixForm@Mp, " = ", MatrixForm[M . Mp]}];
The function displayMandMprime takes in
M
and
M'
as arguments and displays them in the form
M·M'=P
. For example, displayMandMprime[

2
2
6
3

,

8
2
6
9

] returns

2
2
6
3
·
8
2
6
9
=
28
22
66
39

.
Having defined all the necessary functions, we can iterate through the possible values of
M
, pick those that produce a “lucky fool” pair, and then display the pairs we’ve found:
In[]:=
Table[​​ With[{Mprime = findMprime[M]}, If[checkMprime[Mprime], displayMandMprime[M, Mprime], Nothing]],​​ {M, possibleM[]}​​] // Quiet
Out[]=
In total, there are 100 such pairs:
In[]:=
Length[%]
Out[]=
100