PreCalc Final Project

Matrices and the Lights Out Puzzle

Interactive!

Operation: \( f(X)=\) \(...\)


\(O\) \(=\begin{bmatrix} 0 & -1 & 0\\ -1 & -1 & -1\\ 0 & -1 & 0 \end{bmatrix}\)

\(U\) \(=\begin{bmatrix} 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0 \end{bmatrix}\)

\(L\) \(=\begin{bmatrix} 0 & 0 & 0\\ 1 & 0 & 0\\ 0 & 1 & 0 \end{bmatrix}\)


My project was about recreating the "Lights Out" Puzzle in a way that could be represented extremely easily through mathematics.

There are only a few main components of \(f(X)\)

\(O\) represents the matrix responsible for the basic operation that is done when you click on one of the squares. In this puzzle, clicking on a square will result in that one changing its state (on->off, off->on) and also changing the adjacent squares' states. There are only two states in this puzzle: on and off. Numerically, these two states can be represented numerically as 0 (to represent the off state) and 1 (to represent the on state).
\(O=\begin{bmatrix} 0 & -1 & 0\\ -1 & -1 & -1\\ 0 & -1 & 0 \end{bmatrix}\)
If \(X_{2,2}\) was the square you clicked on, then adding \(O\) to \(X\) would properly do that operation. For example, \[O+X=\begin{bmatrix} 0 & -1 & 0\\ -1 & -1 & -1\\ 0 & -1 & 0 \end{bmatrix}+\begin{bmatrix} 0 & 0 & 1\\ 1 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix}=\begin{bmatrix} 0 & -1 & 1\\ 0 & 0 & -1\\ 0 & -1 & 1 \end{bmatrix}\] And now take the absolute value
\[\begin{bmatrix} 0 & -1 & 1\\ 0 & 0 & -1\\ 0 & -1 & 1 \end{bmatrix}^{abs}=\begin{bmatrix} 0 & 1 & 1\\ 0 & 0 & 1\\ 0 & 1 & 1 \end{bmatrix}\]

\(\longrightarrow\)

However, \(O\) has to be changed in order to do the operations for the other squares. This is achievable by using shift matrices. One other alternative could have been to use rotation matrices, but you would need to develop a new strategy for puzzles that are larger than a 3x3 matrix. Creating nine different versions of the operation matrix \(O\) to fit each of the different positions would become very tedious. Instead, the most efficient and simple solution is to use shift matrices to "translate" the operation matrix. That way, there would be no need to individually write every possibility.

\(U\) and \(L\) are both shift matrices. \(U\) is the upper shift matrix, meaning that it is equal to the identity matrix but already translated up by one. \(L\) is the lower shift matrix, which is pretty much the same as the upper shift matrix but going one down instead. Here is how they work: For example, \[M = \begin{bmatrix} 0 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0 \end{bmatrix}\] \[U \times M \times L = \begin{bmatrix} 0 & 1 & 0\\ 0 & 0 & 1\\ 0 & 0 & 0 \end{bmatrix} \times \begin{bmatrix} 0 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0 \end{bmatrix} \times \begin{bmatrix} 0 & 0 & 0\\ 1 & 0 & 0\\ 0 & 1 & 0 \end{bmatrix}= \begin{bmatrix} 1 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 0 \end{bmatrix}\] M is translated one row up \(U \times M\) and then M is translated one column to the left \(M \times L\).
Now, try that with the operation matrix \(O\).

\(O\) Before

\(O\) After

This shows that the lights out puzzle can be recreated purely in mathematics in a simple and easy to understand way.



Created by Tomas De Jesus