Quotient, Remainder

The pair of orthogonal diagonal Latin squares, (ODLS), that make a (Graeco-Latin) magic square, are here called Q, (quotient), and R, (remainder). The magic square is made as:

                 M[r][c] = n x Q[r][c] + R[r][c] + 1,
 0 ≤ r,c < n

which for a SODLS is equivalent to:

                 M[r][c] = n x Q[r][c] + Q[c][r] + 1

How Many

The number of SODLS is 4 times the number of unique magic squares because 4 SODLS (aspects) make 4 aspects of the same magic square.

The nfr, (natural order first row), numbers were obtained by a backtracking program.

With the exception of order 9, all (nfr x n!) SODLS and magic squares were written to disk for analysis. For order 9, only nfr SODLS and associative and pandiagonal magic squares were written to disk, the others being counted, type checked, and discarded.

For orders 4, 5, and 7, all the numbers were determined by backtracking and confirmed by permutation of the nfr.

The orders 8 and 9 numbers were obtained by permutation of the nfr, and the associative numbers were checked by backtracking. Francis Gaspalou's order 8 number 1,152 is confirmed.


For SODLS the orientation, (aspect), has to be considered.

The four aspects of a SODLS that keep the diagonals in the same position, make four aspects of a magic square.

Doubly Self-Orthogonal

For some orders, the other four aspects, in which the positions of the forward and back diagonals are reversed, make four aspects of a different magic square.
Miguel Angel Amela refers to such a SODLS as a:

Doubly Self-Orthogonal Diagonal Latin Square (orthogonal to its transpose and its antitranspose)

The term "doubly self-orthogonal Latin square" was coined by Kim and Kumar.
Miguel has extended this to quadruply and sextuply self-orthogonal Latin squares. See 6-SOLS 9x9.pdf.

Here is an order 4 doubly SODLS example. The blue square aspects are made from the Q aspect and its transpose, (rotation about the blue diagonal):

M[r][c] = n x Q[r][c] + Q[c][r] + 1

The red square aspects are made from the Q aspect and its antitranspose, (rotation about the red diagonal):

M[r][c] = n x Q[r][c] + Q[n-1-c][n-1-r] + 1

All SODLS of order 4, 5, 7, and 8 are doubly self-orthogonal.

Singly Self-Orthogonal

For some other orders a SODLS may not be orthogonal to its antitranspose, (when superposed with the antitranspose, some symbol overlays are duplicated, and some are missing).

For order 9, some SODLS are doubly self-orthogonal and some are not. Of the 224,832 nfr, natural order first row, 28,608 are doubly SODLS and 196,224 are singly SODLS. These numbers are confirmed by Francis Gaspalou, (June, 2016).

There is no doubly SODLS of order 10. See Lu, Liu and Zhang


Program MagicSquaresSODLS uses Planck's "A-D method" to convert some associative SODLS to pandiagonal SODLS. This works for the associative SODLS made by the program. However, it does not work for all associative SODLS. It does not work for the order 16 associative SODLS, made by backtracking, that is included in the program.

For order 8, converting all 294,912 aspects of the 36,864 unique associative SODLS makes 172,032 pandiagonal SODLS, (21,504 unique). The rest, even though they do make pandiagonal complete magic squares, are not diagonal Latin squares. There are duplicated symbols on the forward diagonal. Example:

Program SODLS

SODLS are made with natural order first row 0 1 2 3 ... . All SODLS have been made up to order 9; some have been made of orders 10 and 11. With permutations, each SODLS can be converted into N! SODLS.

SSSODLS are made with natural order \diagonal 0 1 2 3 ... . All SSSODLS have been made up to order 9; some have been made of orders 11, 12, 13, 15, and 16. With permutations, each SSODLS can be converted into N! SODLS. Those that preserve center symmetry will be SSSODLS, (odd: 2x4x6x..x(N-1), even 2x4x6x..xN).

Program SODLS10

SODLS are made with natural order first row: 0 1 2 3 4 5 6 7 8 9.

Input is a text file containing either a \diagonal minus the starting 0 or a full order 10 SODLS.

input \diagonal

If input is a \diagonal, there is a prompt for input of a value for the second position of the /diagonal. The program will then make all the SODLS of that configuration, (i.e., with those values in those positions). Example:

There are 176 SODLS of this configuration. Of the 16 configurations that have been run, the number of SODLS ranges from 163 to 247, averaging 200. Each run requires from 4 to 7 days to complete on a 3.0 GHz PC.

All the valid \diagonals, (minus their starting 0), are provided in files SODLS10d2, SODLS10d3, SODLS10d4, SODLS10d5, SODLS10d6, SODLS10d7, SODLS10d8, SODLS10d9.
There are 16687 for each second value 2 .. 9; total 133496.

input SODLS

If input is a full SODLS, the program will make the remaining SODLS, if any, with that \diagonal and value in the second position of the /diagonal. This is intended for completing an interrupted run with a \diagonal input. Example:

This is the second last SODLS of this configuration so the program will make just the last one.