Maple Worksheets and Supporting Documentation

This page provides access to the principal Maple computations on which our article was based, and some supplementary material.

There are three kinds of computations: the geometrical ones based on inside-out Ehrhart theory with generating functions and quasipolynomial counting functions, those which enumerate and count the squares individually, and one oddball in which we calculate the number of squares by a complicated (but effective) formula.

We include two more Maple computations. One is for weak 3x3 squares, and the other is for a 2x3 Latin rectangle (not in the "Six little squares" paper).

### Geometrical solutions

#### LattE input files and results.

These files may be posted at a later time.

#### Maple files of computations based on the LattE output.

Each set begins with the same "front end" that sets up the generating function as a rational function, but then takes the computations in a different direction.

- The first set computes the quasipolynomial constituents via inside-out Ehrhart theory, and lists and analyzes their coefficients (except in the magic cases, which are simple).
*Magic squares by magic sum and by upper bound.*- Maple program gf-constituents.latte.m.mw
- View in PDF gf-constituents.latte.m.pdf
- In LaTex gf-constituents.latte.m.tex

*Semimagic squares counted by magic sum.*- Maple program gf-constituents.latte.sa.mw
- View in PDF gf-constituents.latte.sa.pdf
- In LaTex gf-constituents.latte.sa.tex

*Semimagic squares counted by upper bound.*- Maple program gf-constituents.latte.sc.mw
- View in PDF gf-constituents.latte.sc.pdf
- In LaTex gf-constituents.latte.sc.tex

*Magilatin squares counted by magic sum.*- Maple program gf-constituents.latte.mla.mw
- View in PDF gf-constituents.latte.mla.pdf
- In LaTex gf-constituents.latte.mla.tex

*Magilatin squares counted by upper bound.*- Maple program gf-constituents.latte.mlc.mw
- View in PDF gf-constituents.latte.mlc.pdf
- In LaTex gf-constituents.latte.mlc.tex

- The second set computes the generating functions out to a large number of terms, in fact up to term
_{enddegree}. Up to 10000 terms can be done quickly by the Maple program. The user can set the value of "enddegree". This set does not compute the quasipolynomials; instead, its output (which may be very long) lists the values of the sequence, which it obtains by series expansion of the rational generating function.

The programs with their output for "enddegree:=500" are also available as guides to correct use.*Magic squares by magic sum and by upper bound.*- Maple program with results up to t=100: gf-sequences.latte.m.mw
- View in PDF gf-sequences.latte.m.pdf
- In LaTex gf-sequences.latte.m.tex

*Semimagic squares counted by magic sum.*- Maple program gf-sequences.latte.sa.mw
- View in PDF gf-sequences.latte.sa.pdf
- In LaTex gf-sequences.latte.sa.tex
- Maple program with results up to t=500: gf-sequences.latte.sa-500.mw
- View in PDF gf-sequences.latte.sa-500.pdf
- In LaTex gf-sequences.latte.sa-500.tex

*Semimagic squares counted by upper bound.*- Maple program gf-sequences.latte.sc.mw
- View in PDF gf-sequences.latte.sc.pdf
- In LaTex gf-sequences.latte.sc.tex
- Maple program with results up to t=500: gf-sequences.latte.sc-500.mw
- View in PDF gf-sequences.latte.sc-500.pdf
- In LaTex gf-sequences.latte.sc-500.tex

*Magilatin squares counted by magic sum.*- Maple program gf-sequences.latte.mla.mw
- View in PDF gf-sequences.latte.mla.pdf
- In LaTex gf-sequences.latte.mla.tex
- Maple program with results up to t=500: gf-sequences.latte.mla-500.mw
- View in PDF gf-sequences.latte.mla-500.pdf
- In LaTex gf-sequences.latte.mla-500.tex

*Magilatin squares counted by upper bound.*- Maple program gf-sequences.latte.mlc.mw
- View in PDF gf-sequences.latte.mlc.pdf
- In LaTex gf-sequences.latte.mlc.tex
- Maple program with results up to t=500: gf-sequences.latte.mlc-500.mw
- View in PDF gf-sequences.latte.mlc-500.pdf
- In LaTex gf-sequences.latte.mlc-500.tex

- These files contain
**tables of values**in the form "t, term_{t}", one per line, for t from the initial positive term to t=10000. They are in the Online Encyclopedia of Integer Sequences (OEIS).*Magic squares by magic sum.*- The total number of squares with magic sum t=3n,
*M*_{a}(3n), for n up to 10000. Sequence A108578 in the OEIS. - The number of symmetry types of squares with magic sum t=3n,
*m*_{a}(3n), for n up to 10000. Sequence A108579 in the OEIS. - The number of reduced squares with magic sum t=3n,
*R*_{ma}(3n), for n up to 10000. Sequence A174256 in the OEIS. - The number of symmetry types of reduced squares with magic sum t=3n,
*r*_{ma}(3n), for n up to 10000. Sequence A174257 in the OEIS.

- The total number of squares with magic sum t=3n,
*Magic squares by upper bound.*- The total number of squares with upper bound t,
*M*_{c}(t), for t up to 10000. Sequence A108576 in the OEIS. - The number of symmetry types of squares with upper bound t,
*m*_{c}(t), for t up to 10000. Sequence A108577 in the OEIS. - The number of reduced squares with upper bound t=2n,
*R*_{mc}(2n), for n up to 10000. Sequence A174256 in the OEIS. (The same as reduced magic squares by magic sum 3n.) - The number of symmetry types of reduced squares with upper bound t=2n,
*r*_{mc}(2n), for n up to 10000. Sequence A174257 in the OEIS. (The same as reduced symmetry types by magic sum 3n.)

- The total number of squares with upper bound t,
*Semimagic squares counted by magic sum.*- The total number of squares,
*S*_{a}(t), for t up to 10000. Sequence A173547 in the OEIS. - The number of symmetry types of squares,
*s*_{a}(t), for t up to 10000. Sequence A173725 in the OEIS. - The number of reduced squares,
*R*_{sa}(t), for t up to 10000. Sequence A173728 in the OEIS. - The number of symmetry types of reduced squares,
*r*_{sa}(t), for t up to 10000. Sequence A173726 in the OEIS.

- The total number of squares,
*Semimagic squares counted by upper bound.*- The total number of squares,
*S*_{c}(t), for t up to 10000. Sequence A173546 in the OEIS. - The number of symmetry types of squares,
*s*_{c}(t), for t up to 10000. Sequence A173723 in the OEIS. - The number of reduced squares,
*R*_{sc}(t), for t up to 10000. Sequence A173727 in the OEIS. - The number of symmetry types of reduced squares,
*r*_{sc}(t), for t up to 10000. Sequence A173724 in the OEIS.

- The total number of squares,
*Magilatin squares counted by magic sum.*- The total number of squares,
*L*_{a}(t), for t up to 10000. Sequence A173549 in the OEIS. - The number of symmetry types of squares,
*l*_{a}(t), for t up to 10000. Sequence A173730 in the OEIS. - The number of reduced squares,
*R*_{mla}(t), for t up to 10000. Sequence A174020 in the OEIS. - The number of symmetry types of reduced squares,
*r*_{mla}(t), for t up to 10000. Sequence A174021 in the OEIS.

- The total number of squares,
*Magilatin squares counted by upper bound.*- The total number of squares,
*L*_{c}(t), for t up to 10000. Sequence A173548 in the OEIS. - The number of symmetry types of squares,
*l*_{c}(t), for t up to 10000. Sequence A173729 in the OEIS. - The number of reduced squares,
*R*_{mlc}(t), for t up to 10000. Sequence A174018 in the OEIS. - The number of symmetry types of reduced squares,
*r*_{mlc}(t), for t up to 10000. Sequence A174019 in the OEIS.

- The total number of squares,

- The third set computes the constituents and checks that they're correctly evaluated by using them to generate more than two full periods of values, which are compared with the coefficients of the generating series. These programs are written only for the magilatin computation, since that contains the semimagic computation as a sub-computation, so validating the former gives confidence also in the latter. The affine program computes the truncated constituents (period 120) and the correction constituents (period 21), whose difference gives the actual values (period gcd(21,120) = 840) of the affine magilatin count.
*Magilatin squares counted by magic sum.*- Maple program alone: gf-test-constituents.latte.mla.mw
- View in PDF gf-test-constituents.latte.mla.pdf
- In LaTex gf-test-constituents.latte.mla.tex
- Maple program with results: gf-test-constituents.latte.mla-2000.mw
- View in PDF gf-test-constituents.latte.mla-2000.pdf
- In LaTex gf-test-constituents.latte.mla-2000.tex

*Magilatin squares counted by upper bound.*- Maple program alone: gf-test-constituents.latte.mlc.mw
- View in PDF gf-test-constituents.latte.mlc.pdf
- In LaTex gf-test-constituents.latte.mlc.tex
- Maple program with results: gf-test-constituents.latte.mlc-1000.mw
- View in PDF gf-test-constituents.latte.mlc-1000.pdf
- In LaTex gf-test-constituents.latte.mlc-1000.tex

- The first set computes the quasipolynomial constituents via inside-out Ehrhart theory, and lists and analyzes their coefficients (except in the magic cases, which are simple).
### Direct enumeration

Maple files of computations and results.The Maple programs compute the numbers by individually generating and counting all squares. This is slow but the programs are simple and therefore trustworthy. The programs contain the generating functions found by the geometrical method and compare them with the direct counts, thereby confirming the correctness of the generating functions.

*Magic squares counted by magic sum or upper bound.*Maple programs count.ma.mws (by magic sum) and count.mc.mws (by upper bound). They count magic squares in a completely elementary and dependable way (generating one square of each symmetry type), up to high enough values of the magic sum to completely confirm the results of the Ehrhart method.*Semimagic squares counted by magic sum:*- Maple program count.sa100.mws. It counts semimagic squares in a completely elementary and dependable way (generating one square of each symmetry type), up to high enough values of the magic sum to give considerable confidence in the Ehrhart results, but it is a long way from a complete confirmation (which we estimate would take many millenia).
- Another Maple program count.sa3.sn.mws. It counts semimagic squares by magic sum, by direct enumeration of supernormalized squares and combining these numbers (by a simple formula) to get the number of all squares. (This program also prints the number of symmetry types, thus giving a long list of numbers.) The count is slow, though faster than the preceding program, so the results stop before 100.

*Semimagic squares counted by upper bound:*Maple program count.sc100.mws. It counts semimagic squares in a completely elementary and dependable way (generating one square of each symmetry type), up to high enough values of the bound (more than one full period of 60) to give considerable confidence in the Ehrhart results, but it is not a complete confirmation.*Magilatin squares counted by magic sum:*Maple program count.mla100.mws. It counts semimagic squares in a completely elementary and dependable way (generating every square), up to high enough values of the magic sum (sum 100) to give considerable confidence in the Ehrhart results, but it is far from perfect confirmation, which we estimate would take a million years, more or less, by this method.*Magilatin squares counted by upper bound:*Maple program count.mlc91.mws. It counts semimagic squares in a completely elementary and dependable way (generating every square), up to bound 91 (more than one full period of 60), giving additional confidence in the Ehrhart results; but it is not perfect confirmation, which we estimate might take a hundred thousand years by this method.

### Indirect counting

*Semimagic squares counted by magic sum:*Maple program count.sa3.formula.mw calculates the numbers of semimagic squares by magic sum, using a complicated formula, and finds all 840 constituent polynomials within a reasonable time.*A similar program,*Maple program count.sa3.formula-detailed.mw, is the same; but it also evaluates the period, finding that the period of the constituents with index not a multiple of 4 is a divisor of 420 (half the overall period).- Explanation of the complicated formula implemented in that Maple program. (Download PostScript file, 270 KB; PDF file, 110 KB.)

This method is complicated (and the formula took weeks to compute and verify) but we are confident it is correct because we have cross-checked small values and the principal constituent against the other methods.

### Weak semimagic

- We used a Maple program to find the number of weakly semimagic squares, i.e., without any distinctness requirement. This is easy to do by direct enumeration.
- The same Maple program s3weak.mws did the cubical and affine problems simultaneously.
- View in PDF s3weak.pdf
- In LaTex s3weak.tex

- We used a Maple program to find the number of weakly semimagic squares, i.e., without any distinctness requirement. This is easy to do by direct enumeration.
### Other magical counting problems

Up to the publication list

Return to my home page.