## What is a magic cube?

A magic cube is the 3-dimensional equivalent of a magic square, that is, a number of integers arranged in a n x n x n pattern such that the sum of the numbers on each row, each column, each pillar and the four main space diagonals is equal to a single number, the so-called magic constant of the cube. It can be shown that if a magic cube consists of the numbers 1, 2, ..., n3, then it has magic constant S = 0.5n (n2 + 1) , where n is the order of the cube. You can view Abiyev Balanced Cube of any degree using the program below.

Input order of Balanced (Magic) Cube:

## What is a Latin Square?

A Latin square is an arrangement of m variables, x1, x2, …, xm into m rows and m columns such that no row and no column contains any of the variables twice. Magic number of Latin squares is equal to Sn = 0.5n (n-1). Latin squares are used in the design experiments, tournament scheduling, and constructing magic squares and cubes.
In order to write a magic square, 2 Latin squares need to be used. A cube can be divided into n squares horizontally (and 2 types of vertically). Hence, in order to write the n squares in a magic cube, 3 Latin squares need to be used. The number in each of the cells in the magic cube is found using the following formula: mk= Ak(i, j)n2 + Bk(i, j)n + Ck(i, j) + a0, where Ak, Bk and Ck are the numbers in cell (i, j) of A, B, C Latin squares, respectively, of k-th square, a0 is the initial number and n is the order of the magic cube.
Thus, the main problem in obtaining a magic cube is writing the Latin squares. Abiyev's algorithm, unlike the algorithms created by other scientists, allows to write colored balanced cubes using any numbers.
Note that, since the graphed algorithm Abiyev created in order to write a Balanced Square is too complicated for cubes, the Latin squares are used to write a Balanced Square.

## Examples of Balanced Cubes

Abiyev wrote a colored Balanced Square of 5002nd order and a colored Balanced Cube of 1001st order as an example. With the constants a0 = √3, b = π, c = e, d = 3 + 4i proposed by Prof. Aghajan Abiyev, a Balanced Cube of 7th order has been written. Here, the magic constant S is S=[√3 + 3 π + 3e + (3 + 4i)].