# SODLS Construction Methods

#### Self-orthogonal Diagonal Latin Squares ## Odd

### Small Orders

#### Backtracking

Orders 5, 7, 9, 11, 13, 15 SODLS for associative magic squares can be made by a backtracking program.
Examples: .xlsx  ### Composite

Orders 25 (5 5s), 35 (5 7s) (7 5s), 45 (5 9s) (9 5s), 49 (7 7s), 55 (5 11s) (11 5s), etc.
For some orders, the magic squares can be associative, pandiagonal, or ultramagic.

Example, order 25 (5 5s) associative: .xlsx  ### Centers 5, 7, 9, 11

Made for orders from 17 to 45: See method and examples for center 4 for even orders.

Example, order 17: .xlsx  Example, order 31: .xlsx  ## Odd - Not Multiple of 3

### Shift Left 2

Orders 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, etc.

Let N be the order of the SODLS Q.

• Fill row 0: for pandiagonal, with natural order; for ultramagic, with "(N-column) % N".
• For other rows, start with the last 2 numbers of the previous row.

Make other associative by swapping rows/columns of ultramagic.

Example, orders 5, 7, 11, 13 ultramagic: .xlsx  ### x ks+1

Some orders: 17 (4 4s+1), 29 (4 7s+1) (7 4s+1), 49 (4 12s+1) (12 4s+1), etc.

See method and examples for x ks+1 for odd multiple of 3. ## Odd - Multiple of 3

### x 5s+4

Orders 39 (7 5s+4), 69 (13 5s+4), 129 (25 5s+4), 159 (31 5s+4), 249 (49 5s+4), etc.

Let N be the order of the SODLS Q, nB = x, nA = 5, n = N-4.

• Make a composite SODLS of nB subsquares A, (ultramagic order 5), where nB × 5 = n.
• Add 4 rows and 4 columns after the middle A.
• Let u be the number of the first added row; increase SODLS numbers ≥ u by 4.
• On one diagonal parallel to the main /diagonal, replace numbers on 2 diagonals of subsquare A by u+1, u.
On another parallel diagonal, replace numbers on 2 diagonals of subsquare A by u+3, u+2.
• Put the displaced numbers into the corresponding new rows and columns.
• Put an order 4 SODLS with u added to all its numbers at Q[u][u].
• Move the first 2 new rows up 5 rows and move the first 2 new columns left 5 columns.

Example, order 39 (7 5s+4), N = 39, nB = 7, n = N-4 = 35: .xlsx

• Make a composite SODLS of 7 subsquares of order 5, (7 × 5 = 35).
• Add 4 new rows at row 20 and 4 new columns at column 20.
• Increase SODLS numbers ≥ 20 by 4.
• On one diagonal parallel to the main /diagonal, replace numbers on 2 diagonals of subsquare A by 21 20.
On another parallel diagonal, replace numbers on 2 diagonals of subsquare A by 23 22.
• Put the displaced numbers into the corresponding new rows and columns.
For example,12 14 and 7 9 in the new rows at column 0; 35 36 and 16 17 in the new columns at row 0.
• Put an order 4 SODLS with 20 added to all its numbers at Q.
Note that this order 4 SODLS is split into 4 2×2 pieces by the next step.
• Move the new rows 20,21 up to 15,16 and move the new columns 20,21 left to 15,16.  ### x ks+1

Orders 21 (5 4s+1), 33 (4 8s+1), 51 (5 10s+1), 57 (4 14s+1), 69 (4 17s+1), 93 (4 23s+1), etc.

Let N be the order of the SODLS Q, nB = x, nA = k, n = N-1.

• Make a composite SODLS of nB subsquares A of order nA, where nB x nA = n.
Use natural order main \diagonal for the nA and nB.
• Add 1 row and 1 column in the middle for even nB; after the middle A for odd nB.
• Let u be the number of the added row; increase SODLS numbers ≥ u by 1.
• On the main \diagonal, replace each nA subsquare A by numbers from an order nA+1 SODLS.
• In A, replace the number nA by u; add Q[R][R], where R is the first row of A to the other numbers.
Put the row nA numbers in the new row; put the column nA numbers in the new column.
• Put number u at the intersection of the new row and new column, Q[u][u].

Example, order 21, N = 21, nB = 5, nA = 4, n = N-1 = 20: .xlsx

• Make a composite SODLS of 5 subsquares A of order 4, (5 × 4 = 20).
• Add 1 row and 1 column after the third A.
• The number of the added row, (column), u = 12; increase SODLS numbers ≥ 12 by 1.
• On the main \diagonal, replace each 4×4 subsquare A by numbers from an order 5 SODLS.
• In A, replace the number 4 by 12; add Q[R][R], where R is the first row of A to the other numbers.
Add 0 to numbers of the first A, 4 to numbers of the second A, etc.
Put the row 4 numbers in row 12, (3 2 1 0 for the first A);
put the column 4 numbers in column 12, (1 3 0 2 for the first A).
• Put number 12 at Q. Example, order 33: .xlsx  ### x ks+k/2

Orders 27 (5 5s+2), 57 (11 5s+2), 87 (17 5s+2), 93 (5 17s+8), 573 (15 37s+18), etc.

See method for x ks+k/2 for singly even orders.
Example, order 27: .xlsx  ### x ks+c

For c=4, 8, 10, 12, 14, 16: orders 39 (5 7s+4), 69 (5 13s+4), 87 (11 7s+10), 93 (5 17s+ 8), etc.

See method and example for x ks+c for order 24.
Example, order 39: .xlsx Note: The c values can be increased by two's if needed for bigger orders. For orders up to 25,000 only order 22,623 required a value bigger than 10. ## Even

### Composite

Orders 16 (4 4s), 20 (4 5s) (5 4s), 28 (4 7s) (7 4s), 32 (4 8s) (8 4s), 36 (4 9s) (9 4s),
40 (4 10s) (5 8s) (8 5s) (10 4s), 50 (5 10s) (10 5s), etc.
For some orders, the magic squares can be associative, pandiagonal, or ultramagic.

Example, order 16 (4 4s) pandiagonal: .xlsx  ### Centers 4, 8, 10, 12

Made for orders from 16 to 48: Make from Latin square: LS.xlsx SODLS.xlsx  Consider the Latin square as divided into:

• a lower right order 4 SODLS of the biggest numbers, (W X Y Z).
• rows left of the order 4 SODLS.
• columns above the order 4 SODLS.
• an upper left order N-4 sub-square with natural \diagonal, (A0..Ad).
• wrap-around diagonals, parallel to A0..Ad.

Fill diagonals in the N-4 sub-square. Four are filled with the biggest numbers;

• One occurrence of each number in each row and each column.
• Each number meets 0 at most once in the transposed position.
• Fill the diagonal starting at column (N-4)/2, (D0..Dd). This becomes the /diagonal of the SODLS.
• Fill 4 diagonals with the biggest numbers, (W X Y Z). The diagonals may be randomly selected and in any order except that one diagonal may not occupy the transpose diagonal of any of the others. For, example X..X may not occupy w0..wd.
• Fill the transpose diagonals, (w0..wd x0..xd y0..yd z0..zd).
• Fill the rest of the diagonals (B0..Bd b0..bd C0..Cd c0..cd).

Similarly, fill the columns above and the rows left of the order 4 SODLS.

Convert the Latin square to a SODLS:

• Move the right 4 columns and the bottom 4 rows to the center.
• Reverse the right (N-4)/2 columns.
• Invert the bottom (N-4)/2 rows.

The middle 4 rows and/or columns may be permuted as appropriate to make other SODLS. Optionally, the results may be converted to natural \diagonal.

A computer program quickly makes hundreds of thousands for order 18; for order 30, the algorithm has to be tweaked to make a hundred.

Example, order 18: .xlsx nd.xlsx  Example, order 30: .xlsx  Example, order 32: .xlsx  ## Doubly Even

### Small Orders

#### Backtracking

Orders 4, 8, 12, 16 SODLS for associative magic squares can be made by a bactracking program. SODLS for pandiagonal magic squares can be made from some of these by Planck's A-D method.
Example for orders 4, 8, 12: .xlsx  ### Order 24

#### x 5s+4

General method: Let N be the order of the SODLS Q, nB = x, n = N-4.

• Make a composite SODLS of nB subsquares A, (ultramagic order 5), where nB × 5 = n.
• Add 4 rows and 4 columns in the middle.
• Let u be the number of the first added row; increase SODLS numbers ≥ u by 4.
• On the main \diagonal replace numbers on 2 diagonals of each subsquare by u+1, u;
on the main /diagonal replace numbers on 2 diagonals of each subsquare by u+3, u+2;
The 2 diagonals to use are shown in the example below.
(Note the difference for the /diagonal versus the \diagonal,
and for the bottom half of the /diagonal versus the top.)
• Move the displaced numbers into the new rows and columns.
• Put an order 4 SODLS with u added to all its numbers at Q[u][u].
• Make a composite SODLS of 4 subsquares of order 5, (4 × 5 = 20).
• Add 4 rows and 4 columns in the middle.
• The first added row u = 10; increase SODLS numbers ≥ 10 by 4.
• On the main \diagonal replace numbers on 2 diagonals of each subsquare by 11 10.
On the main /diagonal replace numbers on 2 diagonals of each subsquare by 13 12.
• Move the displaced numbers into the new rows and columns.
For example, these are numbers 2  4 14  16 in column 0 of the new rows 10..13;
numbers 1  2 7  8 in row 0 of new columns 10..13.
• Put an order 4 SODLS with 10 added to all its numbers at Q. #### x ks+c

General method: Let N be the order of the SODLS Q, nB = x, nA = k, n = N-c.

• Make a composite SODLS of nB subsquares A of order nA, where nB × nA = n.
Use natural order main \diagonal for A; use odd, not multiple of 3, ultramagic for order nB.
• Add c rows and c columns after the middle A.
• Let u be the number of the first added row; increase SODLS numbers ≥ u by c.
• On each of c diagonals parallel to the main /diagonal,
replace each subsquare A by numbers from an order nA+1 SODLS.
• Let U be u for one such diagonal, u+1 for another, etc.
• In A, replace the number nA by U; add Q[R][C], where R is the first row and C is the first column of A, to the other numbers.
Put the row nA numbers in the new row; put the column nA numbers in the new column.
• Put an order c SODLS with u added to all its numbers at Q[u][u].
• Move the first c/2 rows up nA rows and move the first c/2 columns left nA columns.

Example, order 24, N = 24, nB = 5, nA = 4, c = 4, n = N-4 = 20: .xlsx

• Make a composite SODLS of 5 subsquares of order 4, (5 × 4 = 20).
• Add 4 rows and 4 columns after the middle 4 starting at Q.
(Note: 2 of these rows will be moved up and 2 columns moved left later.)
• The number of the first added row is 12; increase SODLS numbers ≥ 12 by 4.
• On each of 4 diagonals parallel to the main /diagonal,
replace each 4×4 subsquare A by numbers from an order 5 SODLS.
• Let U have the values 12, 13, 14, and 15 for the 4 diagonals.
• In A on the first diagonal, replace the number 4 by 12.
Add Q = 0 to the other numbers of the first A, add Q = 16 to the other numbers of the second A, and so on.
Put the row 4 numbers in the new row, (3 2 1 0 for the A at Q).
Put the column 4 numbers in the new column, (1 3 0 2 for the A at Q).
Don't put number A anywhere, (it will be in the added order 4 SODLS).
Proceed similarly for the second, third, and fourth diagonals.
• Put an order 4 SODLS with 12 added to all its numbers at Q.
Note that this order 4 SODLS is split into 4 2×2 pieces by the next step.
• Move the new rows 12,13 up to 8,9 and move the new columns 12,13 left to 8,9.  ### x ks+1

Some orders: 36 (5 7s+1), 56 (5 11s+1), 64 (7 9s+1) (9 7s+1), etc.

See method and examples for x ks+1 for odd multiple of 3. ## Singly Even

### Center 4

Order 14.

Fill the center with a 4×4 SODLS of the middle numbers.
In each of the corners:

• Fill the main diagonals as shown below.
• Fill each of four diagonals with a middle number, as shown below.

Fill the remaining cells of the first row and use a backtracking program to complete the square.
.xlsx  Orders 18, 22, 26, 30.

Fill the center with a 4×4 SODLS of the middle numbers.
Consider the rest of the SODLS as divided into:

• rows left of the 4×4; rows right of the 4×4
• columns above the 4×4; columns below the 4×4
• top left corner, wrap-around diagonals, parallel to the main \diagonal
• bottom right corner, wrap-around diagonals, parallel to the main \diagonal
• top right corner, wrap-around diagonals, parallel to the main /diagonal
• bottom left corner, wrap-around diagonals, parallel to the main /diagonal

In each of the corners:

• Fill the main diagonals as shown below.
• Fill each of two diagonals with a middle number, as shown below.

Fill the rest of the diagonals with numbers either all smaller or all bigger than the middle numbers.

• Put the numbers in natural order, increasing or decreasing, with wrap-around.
• In top columns and top left and right diagonals, put small numbers in increasing order from the top; put big numbers in decreasing order.
• In bottom columns and bottom left and right diagonals, put small numbers in decreasing order from the middle; put big numbers in increasing order.
• In left rows, put small numbers in increasing order from the left; put big numbers in decreasing order.
• In right rows, put small numbers in decreasing order from the left; put big numbers in increasing order.
• In top columns, put sequence small, big, small, small.
• In left rows, put sequence small, big, big, small.

A backtracking program was used to make SODLS with this specification.
For order 18, millions are made in a day; for order 30, the algorithm has to be tweaked to make even one. This algorithm will not make SODLS for doubly even orders, because, for example, in the upper left quarter the middle diagonal wraps around to its own transpose position.

Example, order 18: .xlsx Example, order 30: .xlsx ### x 5s+4

Orders 54 (10 5s+4), 74 (14 5s+4), 94 (18 5s+4), 114 (22 5s+4), 134 (26 5s+4), etc.

See method and example for x 5s+4 for order 24. ### x 8s+2

Orders 34 (4 8s+2), 42 (5 8s+2), 58 (7 8s+2), 66 (8 8s+2), 82 (10 8s+2), 90 (11 8s+2), etc.

Let N be the order of the SODLS Q, nB = x, n = N-2.

• Make a composite SODLS of nB subsquares A of order 8, where nB × 8 = n.
Use natural order main \diagonal for A and the order nB.
• Add 2 rows and columns in the middle for even nB; after the middle A for odd nB.
• Let u be the number of the first added row; increase SODLS numbers ≥ u by 2.
• Let A' be the subsquare on the main \diagonal immediately following the added rows, columns.
• In the other subsquares with the same numbers as A', replace the first 2 numbers with the new row numbers;
replace the matching numbers in all the rows of these subsquares.
• Move the replaced numbers to the subsquare on the main \diagonal as shown below.
Finally, put the numbers displaced from that subsquare into the new rows, columns.
• Replace subsquare A' on the main \diagonal with an order 8+2=10 SODLS, (adding A to all numbers).
Note that the numbers of the order 10 included in the program have been specially permuted to place the correct numbers on the main /diagonal of Q.
• For odd nB, move row u up 8 rows and move column u left 8 columns.

Example, order 34, (4 8s+2), N = 34, nB = 4, n = N-2 = 32: .xlsx

• Make a composite SODLS of 4 subsquares of order 8.
• Add 2 rows and columns in the middle.
• The first added row is 16; increase SODLS numbers ≥ 16 by 2.
• Let A' be the subsquare on the main \diagonal at Q.
(Note: this subsquare will be replaced below.)
• In the other subsquares with the same numbers as A', replace 18 21 with the the new row numbers, 16  17.
• Move the replaced numbers 18 and 21 to the subsquare on the main \diagonal.
Finally, put the displaced numbers into the new rows, columns as shown.
For example, these are numbers 5  4 in column 0 of the new rows 16, 17;
numbers 3  6 in row 0 of new columns 16, 17.
• Replace subsquare A' on the main \diagonal with the order 10 SODLS, (adding 16 to all numbers).  ### x ks+1

Some orders: 46 (5 9s+1), 50 (7 7s+1), 66 (5 13s+1), 78 (7 11s+1), 86 (5 17s+1), etc.

See method and examples for x ks+1 for odd multiple of 3. ### x ks+k/2

Orders 22 (4 5s+2), 38 (5 7s+3), 62 (12 5s+2), 66 (9 7s+3), 82 (16 5s+2), 94 (13 7s+3), etc.

Let N be the order of the SODLS Q, nB = x, nA = k, n = N-k/2

• Make a composite SODLS of nB subsquares A of order nA, where nB × nA = n.
Use odd, not multiple of 3, ultramagic for A; use natural order main \diagonal for order nB.
• Add k/2 rows and columns in the middle for even nB; after the middle A for odd nB.
• Let u be the number of the first added row; increase SODLS numbers ≥ u by k/2.
• Let A' be the subsquare on the main \diagonal immediately preceding the added rows, columns.
• In the other subsquares with the same numbers as A', replace the first k/2 numbers with the new row numbers;
replace the matching numbers in all the rows of these subsquares.
• Move the replaced numbers to the subsquare on the main \diagonal as shown below.
Finally, put the numbers displaced from that subsquare into the new rows, columns.
• Replace subsquare A' on the main \diagonal with an order nA+k/2 SODLS, (adding A to all numbers).

Example, order 22, (4 5s+2), N = 22, nB = 4, nA = 5, n = N-5/2 = 22-2 = 20: .xlsx

• Make a composite SODLS of 4 subsquares of order 5, (4 × 5 = 20).
• Add 2 rows and columns in the middle.
• The first new row is 10; increase SODLS numbers ≥ 10 by 2.
• Let A' be the subsquare on the main \diagonal at Q.
• In the other subsquares with the same numbers as A', replace numbers 5, 9 with the new row numbers, 10 11.
• Move the replaced numbers  9  5 to the subsquare on the main \diagonal.
Finally, put the numbers displaced from that subsquare into the new rows, columns.
For example, these are numbers 4  2 in column 0 ot the new rows 10 and 11; numbers 2  1 in row 0 of new columns 10 and 11.
• Replace subsquare A' on the main \diagonal with an order 7 SODLS, (adding 5 to all numbers). Example, order 38: .xlsx  ### x ks+c

For c=4, 8, 10, 12, 14, 16: orders 54 (5 10s+4) (11 4s+10), 62 (13 4s+10), 74 (5 14s+4), 78 (17 4s+10), 86 (19 4s+10), 94 (5 18s+4), 98 (11 8s+10), 250 (11 22s+8), etc. See note.

See method and example for x ks+c for order 24. 