Mathematical workbench

Square laboratory

Control an arbitrary square through E, x, and y, or obtain these coordinates from a parametric family.

Yellow–brown

ABCDG

E19 009x−1 320y7 560
Matrix 3 × 3 · valuesΣ = 57 027
A17 689
B27 889
C11 449
D12 769
E19 009
F25 249
G26 569
H10 129
J20 329

a brick-red frame marks a value that is a perfect square

Magic invariantall 8 line sums agree
Declared maskABCDG · confirmed
Actual result5/9 squares
Nondegeneracy9 pairwise-distinct entries

Family ABCDG

Theorem and complete proof

General theory of the 4/9 and 5/9 orbits

Statement

Under the assumptions below, the formulas define an integral magic square of order 3 in which at least all 5 cells of the ABCDG mask are squares of integers. Other cells are allowed to be squares as well.

{A,B,C,D,G}{P:MP(E,x,y)=rP2}\{A,B,C,D,G\}\subseteq\{P:\mathcal M_P(E,x,y)=r_P^2\}

The parameters a, b, c, and d are arbitrary integers. Every auxiliary root introduced below is therefore integral.

Initial system and elimination of E, x, y

For every marked cell, introduce an integral root and substitute the corresponding Magic3 linear form. This gives the system:

{E+x=qA2,Ex+y=qB2,Ey=qC2,Exy=qD2,E+y=qG2.\left\{\begin{aligned}E+x&=q_A^2,\\E-x+y&=q_B^2,\\E-y&=q_C^2,\\E-x-y&=q_D^2,\\E+y&=q_G^2.\end{aligned}\right.

The coefficient matrix of E, x, and y has rank 3. Eliminating them therefore leaves 2 independent homogeneous quadratic equations in the roots. The equations are derived and parametrized below.

Derivation of the root parametrization

Introduce the following auxiliary integers:

r=a2+2ab+b2,s=a2+b2,u=a2+2abb2,r2+u2=2s2r=-a^2+2ab+b^2,\quad s=a^2+b^2,\quad u=a^2+2ab-b^2,\quad r^2+u^2=2s^2K=2r2s2,P=Kc2d2,Q=2ucdK=2r^2-s^2,\qquad P=Kc^2-d^2,\qquad Q=2ucdα=u(Kc2+d2),β=PrQs,γ=Ps+Qr,δ=Pr+Qs,η=QrPs\alpha=u(Kc^2+d^2),\quad\beta=Pr-Qs,\quad\gamma=Ps+Qr,\quad\delta=Pr+Qs,\quad\eta=Qr-PsE=P2s2+Q2r2E=P^2s^2+Q^2r^2

Define the declared cell values as the following explicit squares:

(A,B,C,D,G)=(α2,β2,γ2,δ2,η2)(A,B,C,D,G)=(\alpha^2,\beta^2,\gamma^2,\delta^2,\eta^2)

The yellow relation comes from two Gaussian rotations. For the brown relation, the quadric residual is reduced step by step to α² as displayed below. The final formula also proves that the chosen E reconstructs C and G without division.

β2+γ2=δ2+η2=(P2+Q2)(r2+s2)\beta^2+\gamma^2=\delta^2+\eta^2=(P^2+Q^2)(r^2+s^2)γ2+3η22β2=2[P2(2s2r2)+Q2(2r2s2)]\gamma^2+3\eta^2-2\beta^2=2\left[P^2(2s^2-r^2)+Q^2(2r^2-s^2)\right]2s2r2=u2,2r2s2=K2s^2-r^2=u^2,\qquad 2r^2-s^2=Ku2P2+KQ2=u2(Kc2+d2)2=α2u^2P^2+KQ^2=u^2(Kc^2+d^2)^2=\alpha^22A+2B=C+3G,B+C=D+G2A+2B=C+3G,\qquad B+C=D+GC+G=γ2+η2=2(P2s2+Q2r2)=2EC+G=\gamma^2+\eta^2=2(P^2s^2+Q^2r^2)=2E

An auxiliary red conic introduces r, s, u. After substitution into the brown quadric, the coefficient of the second pair becomes K=2r²−s². The pair P=Kc²−d², Q=2ucd parametrizes the resulting weighted conic; two Gaussian rotations then give β, γ, δ, η. The displayed chain of equalities solves both quadrics and reconstructs E without division.

Reconstruction of the magic square

Use the standard three-coordinate form:

M(E,x,y)=(E+xEx+yEyExyEE+x+yE+yE+xyEx)\mathcal M(E,x,y)=\begin{pmatrix} E+x & E-x+y & E-y\\ E-x-y & E & E+x+y\\ E+y & E+x-y & E-x \end{pmatrix}

Set the coordinates equal to the following linear combination of the square values already constructed:

(E,x,y)=(E,AE,GE)(E,x,y)=(E,\,A-E,\,G-E)

The general linear lemma is applied directly: when the selected cell-form matrix has rank 3, its value vector lies in the image exactly when every vector in the left kernel annihilates it. The left kernel has dimension one for four cells and two for five cells. The colored identities above form precisely such a basis, while the displayed formulas for E, x, and y give the unique preimage.

LS(E,x,y)T=(qP2)PS,kerLST=R1,,R2L_S(E,x,y)^T=(q_P^2)_{P\in S},\qquad \ker L_S^T=\langle R_1,\ldots,R_{2}\rangle

Now substitute the coordinates into the nine Magic3 linear forms. Therefore

πABCDG ⁣(M(E,x,y))=(A,B,C,D,G){n2:nZ}5\pi_{ABCDG}\!\left(\mathcal M(E,x,y)\right)=(A,B,C,D,G)\in\{n^2:n\in\mathbb Z\}^{5}

By the Magic3 form itself, every row, every column, and both diagonals sum to 3E. We have therefore obtained the required family of magic squares with square-valued mask ABCDG. This proves the claim.

Color lemmas used in this proof

Yellow equality of two sums of squares

B+C=D+GB+C=D+G

A yellow four-cell support comes from composition of the Gaussian norm and gives an equality between two pairwise cell sums.

u=ac+bd,v=adbc,w=acbd,z=ad+bcu=ac+bd,\quad v=ad-bc,\quad w=ac-bd,\quad z=ad+bcu2+v2=w2+z2=(a2+b2)(c2+d2)u^2+v^2=w^2+z^2=(a^2+b^2)(c^2+d^2)(U,V,W,Z)=(u2,v2,w2,z2)U+V=W+Z(U,V,W,Z)=(u^2,v^2,w^2,z^2)\Longrightarrow U+V=W+Z

In this mask, the lemma variables are replaced by cells B, C, D, G; its conclusion is exactly the cell relation displayed above.

General statement and proof

Weighted brown conic

2A+2B=C+3G2A+2B=C+3G

The brown support ABCG satisfies a separate weighted relation; the ABCDG family combines it with a yellow norm relation.

2A+2B=C+3G2A+2B=C+3GA=a2,B=b2,C=c2,G=g2A=a^2,\quad B=b^2,\quad C=c^2,\quad G=g^22a2+2b2c23g2=02a^2+2b^2-c^2-3g^2=0

In this mask, the lemma variables are replaced by cells A, B, C, G; its conclusion is exactly the cell relation displayed above.

General statement and proof

The globally complete ABCDG algorithm

The polynomial formula in the preceding section constructs an explicit infinite subfamily. Enumerating every rational solution uses a different presentation of the same surface: a conic bundle over the projective line.

1. The global base

Let a,b,c,d,g be rational signed roots of the entries A,B,C,D,G. The two cell relations are

b2+c2=d2+g2,2a2+2b2=c2+3g2.b^2+c^2=d^2+g^2,\qquad 2a^2+2b^2=c^2+3g^2.

The first quadric is equivalent to det M=0 for the following matrix. At a projective point M cannot vanish: that would give b=c=d=g=0, and the second quadric would then give a=0. Thus M has rank one everywhere and a unique rational row direction [r:s].

M=(b+dc+gcgdb)=2(rPrQsPsQ).M=\begin{pmatrix}b+d&c+g\\c-g&d-b\end{pmatrix} =2\begin{pmatrix}rP&rQ\\sP&sQ\end{pmatrix}.

The corresponding fiber coordinates P,Q recover all four roots of the yellow quadric:

b=rPsQ,c=sP+rQ,d=rP+sQ,g=rQsP.\begin{aligned} b&=rP-sQ,&c&=sP+rQ,\\ d&=rP+sQ,&g&=rQ-sP. \end{aligned}

After substitution, the second quadric becomes the fiber conic

Cr,s:a2=(2s2r2)P2+(2r2s2)Q2.C_{r,s}:\quad a^2=(2s^2-r^2)P^2+(2r^2-s^2)Q^2.

2. Exact solution of every fiber

For a primitive representative [r:s], both conic coefficients are nonzero: vanishing would require a rational value of √2. Every fiber is therefore a smooth projective conic. Rational solubility of a ternary quadratic form over Q is decidable. The implementation returns either a rational point O or an exact local obstruction; a fiber is skipped only in the latter case.

Let F(X)=x²−(2s²−r²)y²−(2r²−s²)z² and let B be the bilinear form associated with F. Choose a coordinate j with Oⱼ≠0 and a vector U on the line Uⱼ=0. Then

X=F(U)O+2B(O,U)U,F(X)=F(U)2F(O)=0.X=-F(U)O+2B(O,U)U,\qquad F(X)=F(U)^2F(O)=0.

Points [m:n] of the projective line give all directions U. Conversely, for X≠O take U=OⱼX−XⱼO; the unique tangent direction returns X=O. Hence the formula parametrizes the entire soluble fiber, not merely an open chart.

3. Complete fair enumeration

Projective pairs are enumerated by primitive integer representatives of height h([x:y])=max(|x|,|y|). An ordinary nested loop would remain forever on the first infinite fiber, so the base and fiber-parameter heights are dovetailed:

h([r:s])+h([m:n])1=H.h([r:s])+h([m:n])-1=H.

At step H, every pair with this height sum is processed. Thus every pair of rational parameters and every rational point of the surface appears after finitely many steps. The result is normalized to a primitive signed projective integer vector.

4. Explicit inverse

For a given nonzero point, the base direction is read from a nonzero column of M:

[r:s]={[b+d:cg],(b+d,cg)(0,0),[c+g:db],otherwise.[r:s]= \begin{cases} [b+d:c-g],&(b+d,c-g)\ne(0,0),\\ [c+g:d-b],&\text{otherwise}. \end{cases}

After canonical normalization of [r:s], the fiber coordinates are

(P,Q)={(b+d2r,c+g2r),r0,(cg2s,db2s),r=0.(P,Q)= \begin{cases} \left(\dfrac{b+d}{2r},\dfrac{c+g}{2r}\right),&r\ne0,\\[6pt] \left(\dfrac{c-g}{2s},\dfrac{d-b}{2s}\right),&r=0. \end{cases}

The inverse projection on the recovered conic then reconstructs [m:n]. This finite construction applies to every rational point and is therefore a constructive proof of surjectivity.

5. Magic squares and the scope of the theorem

Among the finitely many signed lifts, retain the representative with nonnegative roots. The other four entries are recovered linearly; when necessary, multiplying the roots by 2 clears the denominator and multiplies every entry by 4. Positivity, pairwise distinctness, and the condition that exactly ABCDG are squares are decided by exact filters. The filtered iterator therefore reaches every normal exact ABCDG square and emits no extraneous square.

The result establishes global algorithmic completeness. It does not provide one surjective rational formula, a finite rational atlas, or a height-optimal enumeration.

Coverage completeness

Status: complete coverage. Completeness here refers to rational root vectors; integral representatives are obtained by clearing denominators and applying a common scale.

Broadest guaranteed subset

Every rational signed root vector (a,b,c,d,g) satisfying the two ABCDG quadrics, including the zero vector. Completeness is achieved by an effective conic-bundle algorithm; the polynomial formula displayed above remains a convenient subfamily of this complete set.

b2+c2=d2+g2,2a2+2b2=c2+3g2b^2+c^2=d^2+g^2,\qquad 2a^2+2b^2=c^2+3g^2(b+dc+gcgdb)=2(rPrQsPsQ)\begin{pmatrix}b+d&c+g\\c-g&d-b\end{pmatrix}=2\begin{pmatrix}rP&rQ\\sP&sQ\end{pmatrix}a2=(2s2r2)P2+(2r2s2)Q2a^2=(2s^2-r^2)P^2+(2r^2-s^2)Q^2h([r:s])+h([m:n])1=Hh([r:s])+h([m:n])-1=H

Inverse construction

At a nonzero point the matrix has rank one and a unique rational row direction [r:s]. Recover it as [b+d:c−g] when the first column is nonzero and as [c+g:d−b] otherwise. Then recover P,Q linearly, and the inverse projection on the corresponding conic returns the unique parameter [m:n]. Thus every rational point has a finite explicit inverse.

What remains outside the guarantee

No rational points lie outside the algorithm. A base with an empty conic is skipped only after the local-global problem for its ternary quadratic form has been decided exactly. The theorem does not assert the existence of one surjective rational formula, a finite rational atlas, or a height-optimal ordering.

Exc(AABCDG)=\operatorname{Exc}(\mathcal A_{ABCDG})=\varnothing

Global completeness of ABCDG is proved in the effective algorithmic sense: soundness, surjectivity, and finite reachability of every rational point are established separately.

This text agrees with a universal polynomial certificate in proof-core.yellow_brown_abcdg_square_mask