A Hadamard matrix is a square matrix with all entries equal to +1 or -1, with its rows mutually orthogonal. Half of the corresponding pairs of entries in any two rows have the same sign and half have the opposite sign. It is conjectured that a Hadamard matrix of order n exists for all integers divisible by 4.
This notebook reconstructs the Hadamard matrix of order 668 announced in 2026 by Levent Alpöge, Philippe Voinov, and Saul Reynolds-Haertle, with assistance from Claude. Until the announcement, it was unknown if order 668 had a solution.
The matrix is reconstructed as four 167-element cyclic parts. Each part has one fixed distinguished coordinate, so only its other 166 signs are stored. The final permutation groups each distinguished coordinate with its 166 companions.
First, we need the cyclic parts:
s={"+++-+-+-+-+--+--+++-++----++--+----+-----+++---++-+---+++++++-+--+-+-+--++-+--+--+----+-+-+-+-++-++---+--++++--++-++++-+++++--+---++-+---+++++++++--+-+-+--++-+--+--+-","+++-----+++++---++--+-+-+-+--+---+-+-++-++-+-++++++-++-++-+--+-+--+-+--+---+---+++++++-----+++++---++--+-+-+-+--+---+-+-++-+--++------+--+--+-++-++++-+-++-+++-+++----","---+++---++----+++-++----+---+--+-++++++++-+++-+++-++-----+++-++++--+-+++--+-+-++++---+++---++----+++-++----+---+--+-+++++++-++--+---+--+++++---+----++-+---++-+-+----","-+-+--++---+---++--+--+++-+--++--+-++++++++---++++++--++-+---+-++-++++--++-+-+++----+-+--++---+---++--+---++-+--++--+-++++++--+++------++--+-+++-+--+----++--+-+---+++"};
And then the code to put it together:
n=166;{a,b,c,d}=(Characters/@s)/.{"+"->1,"-"->-1};l[x_]:=Map[RotateLeft[x,#]&,Range[0,n-1]];r[x_]:=Map[RotateRight[x,#]&,Range[0,n-1]];t[x_]:=RotateLeft[Reverse[x]];k={{-1,1,1,-1},{1,-1,1,-1},{1,1,-1,-1},{-1,-1,-1,-1}};tb={{-1,-1,-1,1},{-1,-1,1,-1},{-1,1,-1,-1},{1,-1,-1,-1}};lb={{1,1,1,-1},{-1,-1,1,-1},{-1,1,-1,-1},{1,-1,-1,-1}};expandRow[x_]:=Flatten[Map[ConstantArray[#,n]&,x]];top=Join[k,Map[expandRow,tb],2];left=Join@@Map[ConstantArray[#,n]&,lb];core=ArrayFlatten[{{r[a],l[b],l[c],l[d]},{l[-b],r[a],l[t[d]],l[-t[c]]},{l[-c],l[-t[d]],r[a],l[t[b]]},{l[-d],l[t[c]],l[-t[b]],r[a]}}];h0=Developer`ToPackedArray[Join[top,Join[left,core,2]]];p=Flatten[Table[Join[{i},Range[5+(i-1)n,4+in]],{i,4}]];h=Developer`ToPackedArray[h0[[p,p]]];Clear[a,b,c,d,core,h0,k,l,lb,left,n,p,r,s,t,tb,top];
Now we have the order 668 solution.
In[]:=
gram = h . Transpose[h];
{Dimensions[h], Union[Flatten[h]],
gram == 668 IdentityMatrix[668],
Max[Abs[gram - 668 IdentityMatrix[668]]]}
{Dimensions[h], Union[Flatten[h]],
gram == 668 IdentityMatrix[668],
Max[Abs[gram - 668 IdentityMatrix[668]]]}
Out[]=
{{668,668},{-1,1},True,0}
In the matrix, black is 1 and white is -1.
In[]:=
Rasterize[ArrayPlot[(h+1)/2,ImageSize->2672,Frame->False,PixelConstrained->True]]
Here, you can look at smaller Hadamard Matrices:
In[]:=
ResourceData["Demonstration: Small Hadamard Matrices"]
Out[]=
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Hadamard matrix of order 668
by Ed Pegg
Wolfram Community, STAFF PICKS, September 19, 2026
https://community.wolfram.com/t/28083
by Ed Pegg
Wolfram Community, STAFF PICKS, September 19, 2026
https://community.wolfram.com/t/28083

