(* :Author: Christopher Moretti *) (* :Summary: ModularDisplay[formula,a,b,n] creates a color-coded table of the values of - formula- with respect to the variables a and b modulo n. (with legend). Black is always 0, and white is always 1.*) (* :History: Version 1.1 by Christopher Moretti, 1998 *) ModularDisplay[form_,a_,b_,n_]:= Block[{i,j,w}, Show[Graphics[Flatten[Table[ Which[Mod[(w=form/.{a->i,b->j}),n]==0, {GrayLevel[0],Polygon[{{i,n-j-1},{i+1,n-j-1},{i+1,n-j},{i,n-j}}]},Mod[(w=form/.{a->i,b->j}),n]==1, {GrayLevel[1],Polygon[{{i,n-j-1},{i+1,n-j-1},{i+1,n-j},{i,n-j}}]},True, {Hue[Mod[(w=form/.{a->i,b->j}),n]/n], Rectangle[{i,n-j},{i+1,n-(j+1)}]}],{i,n-1,0,-1},{j,n-1,0,-1}]]],Graphics[Table[ Text[i,{i+.5,n+.5}],{i,0,n-1}]], Graphics[Table[ Text[n-i-1,{-.5,i+.5}],{i,0,n-1}]],Graphics[Flatten[{ Table[{Hue[j/n],Rectangle[{n+2,n-j},{n+3,n-(j+1)}]},{j,n-1, 2,-1}],{GrayLevel[0], Polygon[{{n+2,n} ,{n+2,n-1},{n+3,n-1},{n+3,n}}]}}]],Graphics[Table[ Text[n-i-1,{n+3.5,i+.5}],{i,0,n-1}]],AspectRatio->Automatic]]