#### Abstract

We convert a classical magic cube of order 4, which is an arrangement of , to a cube of order 4 whose entries belong to . By using finite-dimensional vector spaces over the field , we introduce the notion of affine magic cubes and study their properties. The obtained results can be applied to describe some features of various types of magic cubes of order 4.

#### 1. Introduction

A magic cube of order is an arrangement of the numbers in an cube in which the entries in each row, column, pillar, and triagonal sum to the same number. In 1650, Pierre de Fermat found a cube of order 4 which is almost magic but its four triagonals failed to have the same sum. This type of cube is called semi-magic. Joseph Sauveur later in 1710, published a cube of order 5 with all correct triagonal sums, however, it is still not magic because most orthogonal lines sum incorrectly. The first published magic cube we have been able to locate was published in Germany in 1898 by Hermann Schubert [1]. The appearance of magic cubes has subsequently been found by many mathematicians, for example, other well-known magic cubes are found by Hermann Weidemann and John Hendricks.

Appearing as a 3-dimensional shape, a magic cube is more complicated to study than a magic square. This leads to a study on magic cubes by transferring them to magic squares first, e.g., Allan Adler and Shuo-Yen Robert Li in [2] demonstrated a method for transforming a magic cube of order into a magic square of order .

In our work, we transform a magic cube of order 4 into a magic square of order 8 and study the relations between magic cubes and linear algebra. Motivated by John Henrich in [3] where he introduced an affine magic square of order 4, we introduce the notion of affine magic cubes of order 4 and study their properties. Moreover, we show that the famous magic cubes by Hermann Schubert, Hermann Weidemann, and John Hendricks are affine. Their different features are also discussed.

#### 2. Preliminary

In this section, the definitions of affine subspaces and affine transformations are given. We also introduce the definitions of magic cubes and their special kinds and provide some examples.

##### 2.1. Affine Subspaces and Affine Functions

*Definition 1 (see [4]). *Let be a finite-dimensional vector space over a field . For a vector in and a subspace of , the set is called an *affine subspace* of .

*Definition 2 (see [4]). *Let be a finite-dimensional vector space over a field . We say that a function is an *affine function* if there are a linear functional and a constant such that for all . Here, the linear functional and the constant with respect to are unique.

From the above definitions, an affine subspace of needs not to be a subspace of , and an affine function does not need to be a linear functional.

*Example 1. *Let be the field and let be the vector space over , i.e., . The set is not a subspace of . However, it is an affine subspace of because is the translation of the subspace . The constant function is not a linear functional but is an affine function when the corresponding is the zero linear functional and .

*Example 2. *Let be a field and scalars in . Let be the function defined byClearly, is a linear function. For any , the function is not a linear functional, but it is an affine function.

##### 2.2. Magic Cubes

*Definition 3. *For , a *cube of order n* is an cube of numbers. In a cube of order , a *row* is a set of numbers on a horizontal line from left to right or right to left. A *column* is a set of numbers on a line from back to front or front to back. A *pillar* is a set of numbers on a vertical line from top to bottom or bottom to top. A *face diagonal* is a diagonal on one of the faces of a cube. The *main triagonal* is a set of numbers on a line from a corner of a cube, though the center of the cube, toward the opposite corner. A *bent triagonal* is a set of numbers on a line from a corner of a cube, through the center of the cube, and then toward the other corners different from the opposite corner. A *broken triagonal* is a set of numbers that follow a line parallel to the main triagonal of a cube and continues on the corresponding point of an opposite face whenever it reaches the face of the cube.

Note that a broken triagonal may consist of 2 or 3 segments. For , a cube of the order has rows, columns, pillars, and 4 main triagonals.

*Definition 4. *A *magic cube of order * is an cube of numbers such that the sums of the numbers on each row, each column, each pillar, and each of the main triagonals are equal to the same number called a *magic sum*.

In this paper, all entries in a cube are thought of as natural numbers where each number is used only once. Then, the magic sum of a magic cube of order becomes .

*Example 3. *In Figure 1, there are 4 rows , 4 columns , 4 pillars , and 4 main triagonals .

*Example 4. *From Figure 2, this cube is a magic cube of order 3, and there are 9 rows, 9 columns, 9 pillars, and 4 main triagonals. The sum of the numbers in any row, column, and pillar is 42 (for example, row: , column: , and pillar: ). The sum along each of the main triagonals is also 42 . However, the sum along every face diagonal is not necessary to be the same as the magic sum (for example, ). Examples of bent triagonals are , and . The sum along each bent triagonal is not required to be the same as the magic sum.

The above example shows that the sum of entries on some lines of a magic cube needs not be the same as the magic sum, for example, on bent triagonals or broken triagonals. This leads to a study of specific types of magic cubes. We shall give definitions of the types discussed in this work.

*Definition 5. *A *bent triagonal* magic cube is a magic cube such that the sum of all entries in each bent triagonal equals the magic sum. A *pantriagonal* magic cube is a magic cube such that the sum of all entries in each broken triagonal equals the magic sum.

*Example 5. *It is clear that the cube of order 3 in example 4 is not pantriagonal. In fact, the smallest pantriagonal magic cube possible is of order 4.

*Definition 6. *A *semi-pantriagonal* magic cube of order is a magic cube of order such that the sum of all entries in each 2-segment broken triagonals which each segment contains cells when is even and cells (the center cell is added) or cells (the center cell is subtracted) when is odd equals the magic sum.

*Example 6. *From Figure 2, the sum of all entries in each 2-segment broken triagonals in which each segment contains cells when the center cell is subtracted equals the magic sum. In fact, . Clearly, the sum of all entries in each 2-segment broken triagonals which each segment contains cell when the center cell is added also equals the magic sum because they are main triagonals in this case.

Clearly, all pantriagonal magic cubes are semi-pantriagonal. In a cube of order 4, there are 12 broken triagonals that consist of 2-segments where each segment contains 2 cells.

*Definition 7. *An *associated* magic cube of order is a magic cube of order such that every pair on the opposite sides of the center of the cube sums to the same number.

*Example 7. *The cube of order 3 in example 4 is associated because .

*Definition 8. *A *compact* magic cube of order is a magic cube of order such that every , or block, parallel to the side of the cube, sums to the magic sum.

*Example 8. *The cube of or order 3 in example 4 is not compact because .

#### 3. Magic Cubes of Order 4

We first consider a cube of order 4 whose entries belong to . The points on each row (left to right), each column (back to front), and each horizontal plane (top to bottom), starting with 0 by using base-2 notation, are placed accordingly (see Figure 3). In [2], Alder and Li showed that one can transform a magic cube of order into a magic square of order by taking the rows of the cube one at a time and using them to fill up the square. Figure 4 is the resulting square of order 8 converted from the cube of order 4 when each pair of adjacent rows (no repeated row used) of the cube of Figure 3 is put into one row of the square.

#### 4. Affine Magic Cubes of Order 4

On the finite-dimensional vector space over , there are elements in and with the standard basis . From Figure 3, we observe that the first pillar is , the first column is , the first row is , and the main triagonal is . The following subspaces of and their parallel affine subspaces in Figure 3 are noticed:(1) and the affine subspaces parallel to it correspond to each pillar.(2) and the affine subspaces parallel to it correspond to each column.(3) and the affine subspaces parallel to it correspond to each row.(4) and the affine subspaces parallel to it correspond to 4 main triagonals and 12 broken triagonals consisting of 2-segments where each segment containing 2 cells.(5) and the affine subspaces parallel to them correspond to 2-segment and 3-segment broken triagonals.(6) and the affine subspaces parallel to it correspond to each pair on the opposite sides of the center of the cube.(7) and the affine subspaces parallel to them correspond to , , or block, parallel to the sides of the cube.(8) and the affine subspaces parallel to them correspond to all bent triagonals in the cube.

Let be the dual basis of . Then, is 1 if and 0 otherwise. Moreover, for any linear functional , there exist such that . In [5], Henrich mentioned that each linear functional on either is constant or takes the values 0 and 1 equally often. The following proposition is an analogous result for nonzero linear functionals on :

Proposition 1. *Let ** be a linear functional on ** with values in ** and ** a subspace of ** which is not contained in the null space of ** . Then, on any affine subspace parallel to ** , the functional ** takes the values 0 and 1 equally often.*

*Proof. *Let be an affine subspace parallel to . Then, there exists a vector such that . Let and . Since is not in the null space of , there is such that . Then, and . Case 1: If , then , and hence . Define a map by for all . Note that for all , , and , hence . It is easy to see that is injective. To show that is surjective, let . Then, such that , and hence . Also, we have . Thus, is surjective and hence bijective. Case 2: If , then , and hence . Define a map by for all . Note that for all , and , hence . It is easy to see that is injective. To show that is surjective, let . Then, such that , and hence . Also, we have . Thus, is surjective and hence bijective.Since and are finite, the number of elements in must be equal to the number of elements in from both cases. Therefore, takes the values 0 and 1 equally often on .

*Definition 9. *Let be affine functions on with values in . The map from to given byis an *affine cube*.

In the discussion of a particular affine cube , we shall denote the linear part of by .

*Definition 10. *Let be affine functions on with values in , and let be the affine cube from to determined by all . Let be a subspace of . Then, is *magic* for if each linear functional of is nonzero on for all .

Proposition 2. *Let ** be affine functions on ** with values in ** , and let ** be a subspace of ** . Then, ** is magic for the affine cube ** determined by all ** if and only if ** has uniform sums on the affine subspaces parallel to ** .*

*Proof. *Let be a subspace of with dimension . Suppose is magic. Let be an affine subspace parallel to . By Proposition 1, each linear functional takes the values 0 and 1 each times on . Since each affine function is either or , takes the values 0 and 1 each times on . Thus, the sum in of over is . Hence, we have that the sum of over isTo prove the converse, suppose is not magic. Let be the smallest index such that is zero on . Since is nonzero on , there exists a vector such that . Set . If , then the sum in of over is 0 but the sum in of over is . Then, the sum of over is 0 and the sum of over is . This implies the sum of over is less than the sum of over because the sum in of is between 0 and and for all . On the other hand, we can show that if , the sum of over is greater than the sum of over .

*Definition 11. *Let *V*_{1}, *V*_{2},…,*V*_{6} be affine functions on with values in and let be the affine cube from to determined by all . Then, is *nonsingular* if are linearly independent.

Proposition 3. *Let **V*_{1}, *V*_{2},…,*V*_{6}*, be affine functions on**with values in**. If the affine cube **from**to**determined by all**is nonsingular, then the values of**are exactly**with no omissions or duplications.*

*Proof. *Since 64 for . Since there are 64 elements in , it is sufficient to show that has a nonrepeating value. Suppose and are elements of such that . Then for and hence for . However, is nonsingular implies that are linearly independent, and therefore, span . Let be the dual basis of for . Then, and for some for . Since for , we have for . It follows that .

Analogously to the affine magic squares, we will give the definition of affine magic cubes of order 4. Since we only study the magic cube of order 4, we shall omit “of order 4” for convenience.

*Definition 12. *An *affine magic cube* is an affine cube that is nonsingular and of which the subspaces , and are magic.

In [3], it is shown that an affine magic square is quasi-pandiagonal or pandiagonal. The following theorem is the analog for affine magic cubes.

Theorem 1. * Let be an affine magic cube. Then*(1)

*(2)*

*is semi-pantriagonal.*

*is pantriagonal if and only if*,*and**are magic.**Proof. *Let , be affine functions on with values in which determine . Let be the affine cube from to determined by . Suppose is an affine magic cube. This implies the subspaces , and are magic. By Proposition 2, has uniform sums on the affine subspaces parallel to , and . Note that the subspace corresponds to the first pillar of , and the affine subspaces parallel to it correspond to the other pillars. Likewise, corresponds to the first column of , and the affine subspaces parallel to it correspond to the other columns. Moreover, corresponds to the first row of , and the affine subspaces parallel to it correspond to the other rows. Finally, corresponds to the main triagonal of , and the affine subspaces parallel to it correspond to the 4 main triagonals and 12 broken triagonals consist of 2-segments where each segment containing 2 cells of . Thus, is semi-pantriagonal. By Proposition 2, the subspaces , and are all magic if and only if has uniform sums on the affine subspaces parallel to and which correspond to 2-segment and 3-segment broken triagonals, i.e., is pantriagonal by definition.

The following results follow directly from Proposition 2 and the definitions of associated, compact, and bent triagonal magic cubes.

Theorem 2. * Let be an affine magic cube. Then*(1)

*(2)*

*is associated if and only if**is magic.**(3)*

*is compact if and only if**and**are magic.*

*is bent triagonal if and only if**and**are magic.*#### 5. Applications

The results we have derived in this work can be applied to study some features of magic cubes. In this section, we will discuss some well-known magic cubes of order 4 by applying our results to these affine magic cubes.

##### 5.1. Hermann Schubert’s Magic Cube

The following magic cube of order 4 was published by Hermann Schubert in Germany in 1898 [1]. It is the first published magic cube of order 4 by the now-accepted rules.

By subtracting 1 from each number in Figure 5 and writing them in base 2, we obtain the magic cube on as in Figure 6. Next, we would like to find affine functions , and which define Figure 6. Since 000000 needs to be matched with 000000, the following can be derived:

Hence, the affine functions must be in the following forms:where, is the linear part of for . Note that in this case is a linear functional for . To find linear parts , and , we consider mappings of basis elements , and of in Table 1.

Thus, the values of , and of the basis are as in Table 2.

Hence, the affine functions which determine Figure 6 are

and the corresponding number is . Note that is an affine function, and the linear part of each are as follows:

It is easy to see that , and are linearly independent. Thus, is nonsingular. Since each is nonzero on the subspaces and , and are magic. Therefore, Schubert’s cube is an affine magic cube, and hence semi-pantriagonal. This cube is also associated because is magic. However, it is not pantriagonal, not compact, and also not bent triagonal because the subspaces and are not magic.

##### 5.2. Hermann Weidemann’s Magic Cube

The following magic cube of order 4 by Hermann Weidemann was first published in 1922 [5].

To find the affine functions , and , which define the Modified Weidemann, obtained by subtracting one from each number in Figure 7 and writing them in base 2, we observe that 000000 needs to map to 011000. Thus,

Hence, the affine functions must be in the following forms:where, is the linear part of , for . Note that and are not linear in this case. To find linear parts , and , we consider mappings of basis elements , and of in Table 3.

Hence, the affine functions which determine the Modified Weidemann are

and the corresponding number is . Note that is an affine function and the linear part of each are as follows:

It is easy to see that , and are linearly independent. Thus, is nonsingular. Since each is nonzero on the subspaces and , and are magic. Therefore, Weidemann’s cube is an affine magic cube and hence semi-pantriagonal. However, it is not pantriagonal, not associated, not compact, and also not bent triagonal because the subspaces are not magic.

##### 5.3. John Hendricks 1972's Magic Cube

John Hendricks published this cube in 1972 when he introduced pantriagonal magic cubes [6].

The affine functions which determine the Modified Hendricks 1972 obtained by subtracting one from each number in Figure 8 and writing them in base 2 are

and the corresponding number is . Note that is an affine function. In this case, we have that is a linear function for . Since , and are linearly independent, is nonsingular. It is easy to see that , and are magic. Thus, Hendrick 1972's cube is an affine magic cube and hence semi-pantriagonal. It is pantriagonal and also compact because and are magic. However, it is neither bent triagonal nor associated because and are not magic.

##### 5.4. John Hendricks 1999's Magic Cube

In this last example, we consider the magic cube by John Hendricks appearance in his 1999 book [7]. It has the unique feature of containing bent triagonals.

The affine functions which determine the Modified Hendricks 1999 obtained by subtracting one from each number in Figure 9 and writing them in base 2 are

and the corresponding number is . Note that is an affine function and the linear part of each are as follows:

Then , and are linearly independent, and so is nonsingular. Since , and are magic, Hendrick 1999s cube is an affine magic cube and hence semi-pantriagonal. It is bent triagonal because ,

and are magic. However, it is not pantriagonal, not associated, and also not compact because are not magic.

#### Data Availability

No data were used to support this study.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.

#### Acknowledgments

This study was partially supported by Faculty of Science, Srinakharinwirot University Grant #204/2565.