(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 1029484, 32331] NotebookOptionsPosition[ 971147, 30652] NotebookOutlinePosition[ 976576, 30798] CellTagsIndexPosition[ 975388, 30768] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Implementing the Lagarias geodesic multiple dimension continued fraction \ algorithm. \ \>", "Title"], Cell[TextData[{ "Simultaneous Diophantine approximation of (", Cell[BoxData[ FormBox[ SubscriptBox["\[Theta]", "1"], TraditionalForm]]], ",", Cell[BoxData[ FormBox[ SubscriptBox["\[Theta]", "2"], TraditionalForm]]], ",...,", Cell[BoxData[ FormBox[ SubscriptBox["\[Theta]", RowBox[{"n", "-", "1"}]], TraditionalForm]]], ") by (", Cell[BoxData[ FormBox[ SubscriptBox["p", "1"], TraditionalForm]]], "/q,", Cell[BoxData[ FormBox[ SubscriptBox["p", "2"], TraditionalForm]]], "/q,...", Cell[BoxData[ FormBox[ SubscriptBox["p", RowBox[{"n", "-", "1"}]], TraditionalForm]]], "/q) via Minkowski reduction of a lattice with final row \n(-", Cell[BoxData[ FormBox[ SubscriptBox["\[Theta]", "1"], TraditionalForm]]], ",-", Cell[BoxData[ FormBox[ SubscriptBox["\[Theta]", "2"], TraditionalForm]]], ",...,-", Cell[BoxData[ FormBox[ SubscriptBox["\[Theta]", RowBox[{"n", "-", "1"}]], TraditionalForm]]], ",t)." }], "Subtitle"], Cell[BoxData[ RowBox[{ RowBox[{"inprod", "[", RowBox[{"x_", ",", "y_", ",", "alpha_"}], "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"Drop", "[", RowBox[{"x", ",", RowBox[{"-", "1"}]}], "]"}], ".", RowBox[{"Drop", "[", RowBox[{"y", ",", RowBox[{"-", "1"}]}], "]"}]}], "+", RowBox[{"alpha", " ", RowBox[{"x", "[", RowBox[{"[", RowBox[{"-", "1"}], "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", RowBox[{"-", "1"}], "]"}], "]"}]}]}]}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"inprod", "::", "usage"}], "=", "\"\\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"inprod takes as input two lists x and y of numbers of \ common length n, and a positive real number alpha, and returns their inner \ product with respect to the weight (1,1,...1,alpha) where there are n-1 1's \ before the alpha.\"\>"], "Output", CellChangeTimes->{3.423399550097623*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"mygramschmidt", "[", RowBox[{"u_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"k", ",", "v", ",", "g", ",", "m", ",", "n"}], "}"}], ",", RowBox[{ RowBox[{"m", "=", RowBox[{"Length", "[", "u", "]"}]}], ";", RowBox[{"n", "=", RowBox[{"Length", "[", RowBox[{"u", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"m", "\[Equal]", "1"}], ",", RowBox[{"Return", "[", "u", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"v", "=", RowBox[{"u", "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", RowBox[{"g", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"#", "-", RowBox[{"projn", "[", RowBox[{"#", ",", "v", ",", "alpha"}], "]"}]}], ")"}], "&"}], ",", RowBox[{"Drop", "[", RowBox[{"u", ",", "1"}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Join", "[", RowBox[{ RowBox[{"{", "v", "}"}], ",", RowBox[{"mygramschmidt", "[", RowBox[{"g", ",", "alpha"}], "]"}]}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]"}]], "Input", InitializationCell->True, CellChangeTimes->{{3.4233988538136225`*^9, 3.4233989009386225`*^9}, { 3.4233989547016225`*^9, 3.4233989640136223`*^9}, 3.4233989951646223`*^9, { 3.4233990682336226`*^9, 3.4233991574386225`*^9}, {3.4233992963416224`*^9, 3.4233993878186226`*^9}, {3.4233994648326225`*^9, 3.423399466392623*^9}, { 3.423399660609623*^9, 3.423399660939623*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"mygramschmidt", "[", RowBox[{"u_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Orthogonalize", "[", RowBox[{"u", ",", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Drop", "[", RowBox[{"#1", ",", RowBox[{"-", "1"}]}], "]"}], ".", RowBox[{"Drop", "[", RowBox[{"#2", ",", RowBox[{"-", "1"}]}], "]"}]}], "+", RowBox[{"alpha", " ", RowBox[{"#1", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}], " ", RowBox[{"#2", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}]}]}], "&"}], ",", RowBox[{"Method", "\[Rule]", "\"\\""}]}], "]"}]}]], "CompatibilityInput", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"mygramschmidt", "::", "usage"}], "=", "\"\\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"mygramschmidt requires that the package \ LinearAlgebra`Orthogonalization` be loaded. It takes as input a list u of n \ lists of real numbers, each of length n, and a positive real number alpha, \ and executes the non-normalized Gram-Schmidt algorithm on u with respect to \ the inner product defined by `inprod'.\"\>"], "Output", CellChangeTimes->{3.4233995501246223`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"mygramschmidt", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "6"}], "}"}]}], "}"}], ",", RowBox[{"1", "/", "2"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["10", "19"], ",", FractionBox["1", "19"], ",", RowBox[{"-", FractionBox["8", "19"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1", "7"], ",", RowBox[{"-", FractionBox["2", "7"]}], ",", FractionBox["2", "7"]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233996679856224`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"w", "=", "%"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["10", "19"], ",", FractionBox["1", "19"], ",", RowBox[{"-", FractionBox["8", "19"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1", "7"], ",", RowBox[{"-", FractionBox["2", "7"]}], ",", FractionBox["2", "7"]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233996745516224`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"inprod", "[", RowBox[{ RowBox[{"w", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"w", "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"1", "/", "2"}]}], "]"}]], "Input"], Cell[BoxData["0"], "Output", CellChangeTimes->{3.423399677887623*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"myfloor", "[", "u_", "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"$MaxExtraPrecision", "=", "Infinity"}], "}"}], ",", RowBox[{"Floor", "[", "u", "]"}]}], "]"}]}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{"myfloor", "::", "usage"}], "=", "\"\\""}]}]], \ "Input", InitializationCell->True], Cell[BoxData["\<\"myfloor takes as input a real number, and returns the floor \ of that real number if it can. The extra precision parameter is temporarily \ set to infinity so as to ensure no wrong answers. This has the side effect \ that it will choke \\non any input that is an unrecognized integer, or that \ is so close to an integer that the machine exhausts its resources before \ resolving the difference, but in this notebook, it is given only inputs which \ are the sum of a rational, and the square root of a positive rational.\"\>"], \ "Output", CellChangeTimes->{3.4233995501476226`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"myceiling", "[", "u_", "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"$MaxExtraPrecision", "=", "Infinity"}], "}"}], ",", RowBox[{"Ceiling", "[", "u", "]"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"myceiling", "::", "usage"}], "=", "\"\\""}]}], "Input", InitializationCell->True], Cell[BoxData["\<\"myceiling is just like myfloor.\"\>"], "Output", CellChangeTimes->{3.423399550170623*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"feasiblekvals", "[", RowBox[{ "klist_", ",", "latticebasis_", ",", "qmatrix_", ",", "alpha_", ",", "rsquared_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "a", ",", "b", ",", "d", ",", "j", ",", "k", ",", "n", ",", "u", ",", "v", ",", "uu", ",", "uv", ",", "vv", ",", "x", ",", "z", ",", "zn", ",", "lams"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"d", "=", RowBox[{"Length", "[", "klist", "]"}]}], ";", RowBox[{"n", "=", RowBox[{"Length", "[", "latticebasis", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"{", RowBox[{"d", ",", "n"}], "}"}]}], "]"}], ";"}], "*)"}], RowBox[{"(*", RowBox[{"comment", " ", "this", " ", "out", " ", "later"}], "*)"}], "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"d", "\[GreaterEqual]", "n"}], ",", RowBox[{ RowBox[{"Print", "[", "\"\=n\>\"", "]"}], ";", RowBox[{"Return", "[", RowBox[{"{", "}"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"d", "\[Equal]", RowBox[{"n", "-", "1"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"u", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"klist", "[", RowBox[{"[", "j", "]"}], "]"}], " ", RowBox[{"latticebasis", "[", RowBox[{"[", "j", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"v", "=", RowBox[{"latticebasis", "[", RowBox[{"[", "n", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"uv", "=", RowBox[{"inprod", "[", RowBox[{"u", ",", "v", ",", "alpha"}], "]"}]}], ";", RowBox[{"uu", "=", RowBox[{"inprod", "[", RowBox[{"u", ",", "u", ",", "alpha"}], "]"}]}], ";", RowBox[{"vv", "=", RowBox[{"inprod", "[", RowBox[{"v", ",", "v", ",", "alpha"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"x", "=", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"uv", "^", "2"}], "+", RowBox[{"vv", RowBox[{"(", RowBox[{"rsquared", "-", "uu"}], ")"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"a", "=", RowBox[{"myceiling", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "uv"}], "-", "x"}], ")"}], "/", "vv"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"myfloor", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "uv"}], "+", "x"}], ")"}], "/", "vv"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"a", ">", "b"}], ",", RowBox[{"Return", "[", RowBox[{"{", "}"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"z", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Append", "[", RowBox[{"klist", ",", "k"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "a", ",", "b"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "z", "]"}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"klist", "\[Equal]", RowBox[{"{", "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"u", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", "n", "}"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"u", "=", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"klist", "[", RowBox[{"[", "j", "]"}], "]"}], RowBox[{"qmatrix", "[", RowBox[{"[", RowBox[{"j", ",", RowBox[{"d", "+", "2"}]}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "d"}], "}"}]}], "]"}]}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"v", "=", RowBox[{"qmatrix", "[", RowBox[{"[", RowBox[{ RowBox[{"d", "+", "1"}], ",", RowBox[{"d", "+", "2"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"uu", "=", RowBox[{"inprod", "[", RowBox[{"u", ",", "u", ",", "alpha"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"uv", "=", RowBox[{"inprod", "[", RowBox[{"u", ",", "v", ",", "alpha"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"vv", "=", RowBox[{"inprod", "[", RowBox[{"v", ",", "v", ",", "alpha"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"x", "=", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"uv", "^", "2"}], "+", RowBox[{"vv", RowBox[{"(", RowBox[{"rsquared", "-", "uu"}], ")"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"a", "=", RowBox[{"myceiling", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "uv"}], "-", "x"}], ")"}], "/", "vv"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"myfloor", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "uv"}], "+", "x"}], ")"}], "/", "vv"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"a", ">", "b"}], ",", RowBox[{"Return", "[", RowBox[{"{", "}"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"z", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Append", "[", RowBox[{"klist", ",", "k"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "a", ",", "b"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", "z"}]}], "\[IndentingNewLine]", "]"}]}]], "Input",\ InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"feasiblekvals", "::", "usage"}], "=", "\"\\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"feasiblekvals calls subroutines `myceiling', `myfloor', and \ `inprod'. feasiblekvals takes as input a list (called klist) of d<=n \ integers, a lattice basis (a list of n lists of n integers), a matrix giving \ information about the gramschmidt reduction of the lattice basis, a positive \ real number alpha which determines the inner product being used, and a \ positive real number rsquared. It returns a list of all coefficient vectors \ of length d+1 which could potentially be the initial d+1 entries of an \ n-entry integer vector s so that Sum[s[[j]] latticebasis[[j]],{j,1,n}] has \ norm^2 less than or equal to rsquared.\[IndentingNewLine]What is required is \ that the hyperplane through the partial sum up to depth d+1, and parallel to \ the remaining vectors of the latticebasis, cut the sphere of radius-squared \ equal to rsquared.\"\>"], "Output", CellChangeTimes->{3.4233995501936226`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"feasibleklists", "[", RowBox[{"latticebasis_", ",", "alpha_", ",", "rsquared_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"d", ",", "n", ",", "qmatrix", ",", "klistses"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"qmatrix", "=", RowBox[{"getqmatrix", "[", RowBox[{"latticebasis", ",", "alpha"}], "]"}]}], ";", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "qmatrix"}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", RowBox[{"d", "=", "1"}], ";", RowBox[{"n", "=", RowBox[{"Length", "[", "latticebasis", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"klistses", "=", RowBox[{"feasiblekvals", "[", RowBox[{ RowBox[{"{", "}"}], ",", "latticebasis", ",", "qmatrix", ",", "alpha", ",", "rsquared"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "klistses", ",", "\"\< \>\"", ",", "\"\\"", ",", "d"}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{"d", "<", "n"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"klistses", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"feasiblekvals", "[", RowBox[{ "#", ",", "latticebasis", ",", "qmatrix", ",", "alpha", ",", "rsquared"}], "]"}], "&"}], ",", "klistses"}], "]"}]}], ";", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "d", ",", "\"\< ,klistses=\>\"", ",", "klistses"}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", RowBox[{"klistses", "=", RowBox[{"Select", "[", RowBox[{"klistses", ",", RowBox[{ RowBox[{"(", RowBox[{"#", "\[NotEqual]", RowBox[{"{", "}"}]}], ")"}], "&"}]}], "]"}]}], ";", RowBox[{"klistses", "=", RowBox[{"Flatten", "[", RowBox[{"klistses", ",", "1"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"klistses", "\[Equal]", RowBox[{"{", "}"}]}], ",", RowBox[{"Return", "[", RowBox[{"{", "}"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "klistses", ",", "\"\< \>\"", ",", "\"\\"", ",", "d", ",", "\"\\"", ",", "n"}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", RowBox[{"d", "++"}]}]}], "]"}], ";", "\[IndentingNewLine]", "klistses"}]}], "]"}]}], "\[IndentingNewLine]"}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"feasibleklists", "::", "usage"}], "=", "\"\\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"feasibleklists calls the subroutines `getqmatrix' and \ 'feasiblekvals'. feasibleklists is essentially the Finke-Pohst algorithm. It \ takes as input a list of n linearly independent vectors of dimension n, a \ positive real number alpha, and another positive real number rsquared. It \ returns a list of all integer vectors s in Z^n so that Sum[s[[j]] \ latticebasis[[j]],{j,1,n}] has norm^2, with respect to the inner product \ inprod[#1,#2,alpha], less than or equal to rsquared.\"\>"], "Output", CellChangeTimes->{3.423399550215623*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"projn", "[", RowBox[{"u_", ",", "v_", ",", "alpha_"}], "]"}], ":=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"inprod", "[", RowBox[{"u", ",", "v", ",", "alpha"}], "]"}], "/", RowBox[{"inprod", "[", RowBox[{"v", ",", "v", ",", "alpha"}], "]"}]}], ")"}], "v"}]}]], "Input",\ InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"projn", "::", "usage"}], "=", "\"\\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"projn takes as input two vectors u and v, and a positive \ real number alpha, and returns the projection of u onto v with respect to the \ inner product inprod[#1,#2,alpha].\"\>"], "Output", CellChangeTimes->{3.423399550234623*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"latticebasis", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}]}], "}"}]}]], "Input",\ InitializationCell->True], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233995502516227`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"mynorm", "[", RowBox[{"u_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Sqrt", "[", RowBox[{"inprod", "[", RowBox[{"u", ",", "u", ",", "alpha"}], "]"}], "]"}]}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{"mynorm", "::", "usage"}], "=", "\"\\""}]}]], "Input", InitializationCell->True], Cell[BoxData["\<\"mynorm takes as input a vector u and a positive real number \ alpha, and returns a nonnegative real number which is the norm of u with \ respect to the inner product inprod[#1,#2,alpha].\"\>"], "Output", CellChangeTimes->{3.4233995502736225`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"projectit", "[", RowBox[{"v_", ",", "m_", ",", "latticebasis_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"j", ",", "n", ",", "g"}], "}"}], ",", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "latticebasis", "]"}]}], ";", RowBox[{"g", "=", RowBox[{"mygramschmidt", "[", RowBox[{ RowBox[{"Take", "[", RowBox[{"latticebasis", ",", RowBox[{"{", RowBox[{"m", ",", "n"}], "}"}]}], "]"}], ",", "alpha"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Sum", "[", RowBox[{ RowBox[{"projn", "[", RowBox[{"v", ",", RowBox[{"g", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "alpha"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"Length", "[", "g", "]"}]}], "}"}]}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "triggersumtime"}]], "Input"], Cell[BoxData["\<\"triggersumtime takes three inputs: a list s of n integers, \ a list b of n real vectors with n entries each, and a positive integer d from \ 1 to n. It returns Infinity, if the sum vector is always shorter than b sub \ d. It returns -1, if it is not shorter for small alpha. And it returns beta, \ the point at which the sum becomes shorter, otherwise.\"\>"], "Print", CellTags->"Info3263234855-4896218"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "triggertime"}]], "Input"], Cell[BoxData["\<\"triggertime takes as input two lists of n real numbers, and \ returns the positive real number alpha at which the norm of the first, with \ respect to mynorm[#,alpha], becomes less than that of the second. If there is \ no such alpha, it returns -1.\"\>"], "Print", CellTags->"Info3263234865-9050723"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"??", "triggertime"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData["\<\"triggertime takes as input two lists of n real numbers, and \ returns the positive real number alpha at which the norm of the first, with \ respect to mynorm[#,alpha], becomes less than that of the second. If there is \ no such alpha, it returns -1.\"\>"], "Print", CellTags->"Info3263234871-9807539"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"triggertime", "[", RowBox[{"b1_", ",", "b2_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "b1n", ",", "b2n", ",", "n", ",", "b1a", ",", "b2a", ",", "b1dot", ",", "b2dot"}], "}"}], ",", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "b1", "]"}]}], ";", RowBox[{"b1n", "=", RowBox[{"Abs", "[", RowBox[{ "b1", "\[LeftDoubleBracket]", "n", "\[RightDoubleBracket]"}], "]"}]}], ";", RowBox[{"b2n", "=", RowBox[{"Abs", "[", RowBox[{ "b2", "\[LeftDoubleBracket]", "n", "\[RightDoubleBracket]"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"b1n", ">", "b2n"}], ",", RowBox[{"Return", "[", RowBox[{"-", "1"}], "]"}]}], "]"}], ";", RowBox[{"b1a", "=", RowBox[{"Drop", "[", RowBox[{"b1", ",", RowBox[{"-", "1"}]}], "]"}]}], ";", RowBox[{"b2a", "=", RowBox[{"Drop", "[", RowBox[{"b2", ",", RowBox[{"-", "1"}]}], "]"}]}], ";", RowBox[{"b1dot", "=", RowBox[{"b1a", ".", "b1a"}]}], ";", RowBox[{"b2dot", "=", RowBox[{"b2a", ".", "b2a"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"b1dot", "\[LessEqual]", "b2dot"}], ",", RowBox[{"Return", "[", RowBox[{"-", "1"}], "]"}]}], "]"}], ";", FractionBox[ RowBox[{"b2dot", "-", "b1dot"}], RowBox[{ SuperscriptBox["b1n", "2"], "-", SuperscriptBox["b2n", "2"]}]]}]}], "]"}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["triggertime"], Editable->False]], "Print", CellTags->"Info3263234871-9807539"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"projectit", "::", "usage"}], "=", "\"\\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"projectit takes as input a vector v with n entries, an \ integer m from 1 to n, a list `latticebasis' of n vectors each of length n, \ and a positive real number alpha. It returns the projection of the given \ vector onto the subspace of R^n spanned by the lattice basis entries from m \ to n, inclusive.\"\>"], "Output", CellChangeTimes->{3.4233995502926226`*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"getqmatrix", "[", RowBox[{"latticebasis_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "n", "}"}], ",", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "latticebasis", "]"}]}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[GreaterEqual]", "k"}], ",", "0", ",", RowBox[{ RowBox[{"latticebasis", "[", RowBox[{"[", "j", "]"}], "]"}], "-", RowBox[{"projectit", "[", RowBox[{ RowBox[{"latticebasis", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "k", ",", "latticebasis", ",", "alpha"}], "]"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}]}]}], "]"}]}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"getqmatrix", "::", "usage"}], "=", "\"\=k these vectors are zero, so it \ returns instead just the number zero.\>\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"getqmatrix takes as input a list `latticebasis' of n \ vectors, and a positive real number alpha, and returns a list of vectors \ which are the projections of the jth lattice basis entry onto the orthogonal \ complement of the basis vectors from k to n. When j>=k these vectors are \ zero, so it returns instead just the number zero.\"\>"], "Output", CellChangeTimes->{3.4233995503136225`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"getqmatrix", "[", RowBox[{"latticebasis", ",", "alpha"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["5", "16"]}], ",", FractionBox["1", "16"], ",", RowBox[{"-", FractionBox["1", "8"]}], ",", FractionBox["3", "8"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["139", "365"]}], ",", FractionBox["20", "73"], ",", RowBox[{"-", FractionBox["39", "365"]}], ",", FractionBox["74", "365"]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["19", "128"]}], ",", FractionBox["23", "128"], ",", FractionBox["7", "64"], ",", RowBox[{"-", FractionBox["15", "64"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["38", "365"], ",", FractionBox["46", "73"], ",", RowBox[{"-", FractionBox["97", "365"]}], ",", RowBox[{"-", FractionBox["78", "365"]}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"getqmatrix", "[", RowBox[{"latticebasis", ",", RowBox[{"1", "/", "100"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["1", "62"]}], ",", FractionBox["1", "310"], ",", RowBox[{"-", FractionBox["1", "155"]}], ",", FractionBox["30", "31"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["1337", "3454"]}], ",", FractionBox["4217", "17270"], ",", FractionBox["283", "8635"], ",", FractionBox["510", "1727"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["115", "333"]}], ",", FractionBox["106", "333"], ",", RowBox[{"-", FractionBox["1", "37"]}], ",", FractionBox["100", "333"]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["331", "1727"]}], ",", FractionBox["215", "1727"], ",", FractionBox["35", "1727"], ",", RowBox[{"-", FractionBox["600", "1727"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["274", "4107"], ",", FractionBox["2396", "4107"], ",", RowBox[{"-", FractionBox["479", "1369"]}], ",", RowBox[{"-", FractionBox["1300", "4107"]}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ FractionBox["5855", "12321"], ",", FractionBox["10399", "12321"], ",", RowBox[{"-", FractionBox["932", "1369"]}], ",", FractionBox["700", "12321"]}], "}"}]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "Random"}]], "Input"], Cell[BoxData[ RowBox[{"\<\"Random[ ] gives a uniformly distributed pseudorandom Real in \ the range 0 to 1. Random[type, range] gives a pseudorandom number of the \ specified type, lying in the specified range. Possible types are: Integer, \ Real and Complex. The default range is 0 to 1. You can give the range {min, \ max} explicitly; a range specification of max is equivalent to {0, max}.\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], Active->True, BaseStyle->"RefGuideLink", ButtonData:>"Random"]}]], "Print", CellTags->"Info3262186062-5918003"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Det", "[", "lb", "]"}]], "Input"], Cell[BoxData[ RowBox[{"-", "1613488756992567684588279"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{"Timing", "[", RowBox[{"getqmatrix2", "[", RowBox[{"lb", ",", "alpha"}], "]"}], "]"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "Timing"}]], "Input"], Cell[BoxData[ RowBox[{"\<\"Timing[expr] evaluates expr, and returns a list of time used, \ together with the result obtained.\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], Active->True, BaseStyle->"RefGuideLink", ButtonData:>"Timing"]}]], "Print", CellTags->"Info3262186015-9446647"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"projectit", "[", RowBox[{ RowBox[{"latticebasis", "[", RowBox[{"[", "1", "]"}], "]"}], ",", "3", ",", "latticebasis", ",", "alpha"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ FractionBox["729", "512"], ",", FractionBox["923", "512"], ",", FractionBox["779", "256"], ",", FractionBox["973", "256"]}], "}"}]], "Output", CellChangeTimes->{3.4233997685636225`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"projectit", "[", RowBox[{ RowBox[{"latticebasis", "[", RowBox[{"[", "1", "]"}], "]"}], ",", "3", ",", "latticebasis", ",", "alpha"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ FractionBox["729", "512"], ",", FractionBox["923", "512"], ",", FractionBox["779", "256"], ",", FractionBox["973", "256"]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"latticebasis", "[", RowBox[{"[", "1", "]"}], "]"}], "-", "%"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"alpha", "=", RowBox[{"1", "/", "2"}]}]], "Input", InitializationCell->True], Cell[BoxData[ FractionBox["1", "2"]], "Output", CellChangeTimes->{3.4233995503306227`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gb", "=", RowBox[{"getqmatrix", "[", RowBox[{"latticebasis", ",", "alpha"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["5", "16"]}], ",", FractionBox["1", "16"], ",", RowBox[{"-", FractionBox["1", "8"]}], ",", FractionBox["3", "8"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["139", "365"]}], ",", FractionBox["20", "73"], ",", RowBox[{"-", FractionBox["39", "365"]}], ",", FractionBox["74", "365"]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["19", "128"]}], ",", FractionBox["23", "128"], ",", FractionBox["7", "64"], ",", RowBox[{"-", FractionBox["15", "64"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["38", "365"], ",", FractionBox["46", "73"], ",", RowBox[{"-", FractionBox["97", "365"]}], ",", RowBox[{"-", FractionBox["78", "365"]}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.423399787807623*^9, 3.4233998217846227`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gb", "=", RowBox[{"getqmatrix", "[", RowBox[{"latticebasis", ",", "alpha"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["5", "16"]}], ",", FractionBox["1", "16"], ",", RowBox[{"-", FractionBox["1", "8"]}], ",", FractionBox["3", "8"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["139", "365"]}], ",", FractionBox["20", "73"], ",", RowBox[{"-", FractionBox["39", "365"]}], ",", FractionBox["74", "365"]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["19", "128"]}], ",", FractionBox["23", "128"], ",", FractionBox["7", "64"], ",", RowBox[{"-", FractionBox["15", "64"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["38", "365"], ",", FractionBox["46", "73"], ",", RowBox[{"-", FractionBox["97", "365"]}], ",", RowBox[{"-", FractionBox["78", "365"]}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233998248496227`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gb", "=", RowBox[{"Flatten", "[", RowBox[{"gb", ",", "1"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["5", "16"]}], ",", FractionBox["1", "16"], ",", RowBox[{"-", FractionBox["1", "8"]}], ",", FractionBox["3", "8"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["139", "365"]}], ",", FractionBox["20", "73"], ",", RowBox[{"-", FractionBox["39", "365"]}], ",", FractionBox["74", "365"]}], "}"}], ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["19", "128"]}], ",", FractionBox["23", "128"], ",", FractionBox["7", "64"], ",", RowBox[{"-", FractionBox["15", "64"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["38", "365"], ",", FractionBox["46", "73"], ",", RowBox[{"-", FractionBox["97", "365"]}], ",", RowBox[{"-", FractionBox["78", "365"]}]}], "}"}], ",", "0", ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233998273486223`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gb", "=", RowBox[{"Select", "[", RowBox[{"gb", ",", RowBox[{ RowBox[{"ListQ", "[", "#", "]"}], "&"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["5", "16"]}], ",", FractionBox["1", "16"], ",", RowBox[{"-", FractionBox["1", "8"]}], ",", FractionBox["3", "8"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["139", "365"]}], ",", FractionBox["20", "73"], ",", RowBox[{"-", FractionBox["39", "365"]}], ",", FractionBox["74", "365"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["19", "128"]}], ",", FractionBox["23", "128"], ",", FractionBox["7", "64"], ",", RowBox[{"-", FractionBox["15", "64"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["38", "365"], ",", FractionBox["46", "73"], ",", RowBox[{"-", FractionBox["97", "365"]}], ",", RowBox[{"-", FractionBox["78", "365"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233998287276225`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"mynorm", "[", RowBox[{"#", ",", RowBox[{"1", "/", "2"}]}], "]"}], "&"}], ",", "gb"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ FractionBox[ SqrtBox["3"], "4"], ",", FractionBox[ SqrtBox[ FractionBox["123", "2"]], "16"], ",", RowBox[{"2", " ", SqrtBox[ FractionBox["23", "365"]]}], ",", FractionBox[ SqrtBox[ FractionBox["3", "2"]], "4"], ",", SqrtBox[ FractionBox["183", "365"]], ",", RowBox[{"16", " ", SqrtBox[ FractionBox["2", "365"]]}]}], "}"}]], "Output", CellChangeTimes->{3.4233997971456223`*^9, 3.4233998305876226`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"N", "[", "%", "]"}]], "Input", CellChangeTimes->{{3.4233998370536222`*^9, 3.4233998383886223`*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ "0.4330127018922193`", ",", "0.49013709816744133`", ",", "0.5020505896028288`", ",", "0.30618621784789724`", ",", "0.7080747580684533`", ",", "1.1843731363161685`"}], "}"}]], "Output", CellChangeTimes->{3.4233998394996223`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"N", "[", "%", "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ "0.4330127018922193`", ",", "0.49013709816744133`", ",", "0.5020505896028288`", ",", "0.30618621784789724`", ",", "0.7080747580684533`", ",", "1.1843731363161685`"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "mynorm"}]], "Input"], Cell["Global`mynorm", "Print", CellTags->"Info3262186361-6713443"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "inprod"}]], "Input"], Cell[CellGroupData[{ Cell["Global`inprod", "Print", CellTags->"Info3262186370-2627300"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"inprod", "[", RowBox[{"x_", ",", "y_", ",", "alpha_"}], "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"Drop", "[", RowBox[{"x", ",", RowBox[{"-", "1"}]}], "]"}], ".", RowBox[{"Drop", "[", RowBox[{"y", ",", RowBox[{"-", "1"}]}], "]"}]}], "+", RowBox[{"alpha", " ", RowBox[{"x", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}], " ", RowBox[{"y", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}]}]}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["inprod"], Editable->False]], "Print", CellTags->"Info3262186370-2627300"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"mygramschmidt", "[", RowBox[{ RowBox[{"Reverse", "[", RowBox[{"Take", "[", RowBox[{"latticebasis", ",", RowBox[{"{", RowBox[{"3", ",", "4"}], "}"}]}], "]"}], "]"}], ",", "alpha"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233998500996227`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"w3", ",", "w4"}], "}"}], "=", "%"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"b1", "=", RowBox[{"latticebasis", "[", RowBox[{"[", "1", "]"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"b1", "-", RowBox[{"projn", "[", RowBox[{"b1", ",", "w3", ",", "alpha"}], "]"}], "-", RowBox[{"projn", "[", RowBox[{"b1", ",", "w4", ",", "alpha"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}]], "Output"], Cell[BoxData["\<\"feasibleklists takes as input a list of n linearly \ independent vectors of dimension n, a positive real number alpha, and another \ positive real number rsquared. It returns a list of all integer vectors s in \ Z^n so that Sum[s[[j]] latticebasis[[j]],{j,1,n}] has norm^2, with respect to \ the inner product inprod[#1,#2,alpha], less than or equal to rsquared.\"\>"], \ "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"feasibleklists", "[", RowBox[{"latticebasis", ",", "alpha", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "4"}], ",", "2", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "3"}], ",", "0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "3"}], ",", "2", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "3"}], ",", "4", ",", RowBox[{"-", "3"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "3"}], ",", "5", ",", RowBox[{"-", "2"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", RowBox[{"-", "2"}], ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "2", ",", RowBox[{"-", "2"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "3", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "4", ",", RowBox[{"-", "2"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "4"}], ",", "2", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "2"}], ",", "2", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "2", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "4", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "6", ",", RowBox[{"-", "4"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "6"}], ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "4"}], ",", "3", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "2"}], ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "2", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "4", ",", RowBox[{"-", "3"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "6", ",", RowBox[{"-", "3"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "6"}], ",", "4", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "4"}], ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "2"}], ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", RowBox[{"-", "2"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", RowBox[{"-", "2"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", RowBox[{"-", "4"}], ",", "2", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", RowBox[{"-", "3"}], ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", RowBox[{"-", "2"}], ",", "2", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", RowBox[{"-", "5"}], ",", "2", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", RowBox[{"-", "4"}], ",", "3", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", RowBox[{"-", "2"}], ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", RowBox[{"-", "2"}], ",", "1", ",", RowBox[{"-", "1"}]}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4233998585066223`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "lastgcdok"}]], "Input"], Cell[BoxData["\<\"lastgcdok takes as input a list s of n integers. It returns \ the greatest integer d, so that gcd of s[[d]] through s[[n]] is 1. If there \ is no such d, it returns zero.\"\>"], "Print", CellTags->"Info3263235009-3054831"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"??", "lastgcdok"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData["\<\"lastgcdok takes as input a list s of n integers. It returns \ the greatest integer d, so that gcd of s[[d]] through s[[n]] is 1. If there \ is no such d, it returns zero.\"\>"], "Print", CellTags->"Info3263235019-6425488"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"lastgcdok", "[", "s_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"d", ",", "w"}], "}"}], ",", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "s", "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Abs", "[", RowBox[{ "s", "\[LeftDoubleBracket]", "n", "\[RightDoubleBracket]"}], "]"}], "==", "1"}], ",", RowBox[{"Return", "[", "n", "]"}]}], "]"}], ";", RowBox[{"d", "=", "n"}], ";", RowBox[{"w", "=", RowBox[{"s", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}]}], ";", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"w", "/.", "\[InvisibleSpace]", RowBox[{"List", "\[Rule]", "GCD"}]}], ")"}], "\[NotEqual]", "1"}], "&&", RowBox[{"d", "\[GreaterEqual]", "1"}]}], ",", RowBox[{ RowBox[{"d", "--"}], ";", RowBox[{"w", "=", RowBox[{"Take", "[", RowBox[{"s", ",", RowBox[{"{", RowBox[{"d", ",", "n"}], "}"}]}], "]"}]}]}]}], "]"}], ";", "d"}]}], "]"}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["lastgcdok"], Editable->False]], "Print", CellTags->"Info3263235019-6425488"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[BoxData["latticebasis"], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"mynorm", "[", RowBox[{"u_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Sqrt", "[", RowBox[{"inprod", "[", RowBox[{"u", ",", "u", ",", "alpha"}], "]"}], "]"}]}]], "Input"], Cell[BoxData[""], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"testks", "=", RowBox[{"feasiblekvals", "[", RowBox[{ RowBox[{"{", RowBox[{"-", "9"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["5", "16"]}], ",", FractionBox["1", "16"], ",", RowBox[{"-", FractionBox["1", "8"]}], ",", FractionBox["3", "8"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["139", "365"]}], ",", FractionBox["20", "73"], ",", RowBox[{"-", FractionBox["39", "365"]}], ",", FractionBox["74", "365"]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["19", "128"]}], ",", FractionBox["23", "128"], ",", FractionBox["7", "64"], ",", RowBox[{"-", FractionBox["15", "64"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["38", "365"], ",", FractionBox["46", "73"], ",", RowBox[{"-", FractionBox["97", "365"]}], ",", RowBox[{"-", FractionBox["78", "365"]}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]}], "}"}], ",", FractionBox["1", "2"], ",", "20"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "8"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "9"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "11"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "12"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "13"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.423399883175623*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"testks", "=", RowBox[{"feasiblekvals", "[", RowBox[{ RowBox[{"{", RowBox[{"-", "9"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["5", "16"]}], ",", FractionBox["1", "16"], ",", RowBox[{"-", FractionBox["1", "8"]}], ",", FractionBox["3", "8"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["217", "512"]}], ",", FractionBox["101", "512"], ",", RowBox[{"-", FractionBox["11", "256"]}], ",", FractionBox["51", "256"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["139", "365"]}], ",", FractionBox["20", "73"], ",", RowBox[{"-", FractionBox["39", "365"]}], ",", FractionBox["74", "365"]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["19", "128"]}], ",", FractionBox["23", "128"], ",", FractionBox["7", "64"], ",", RowBox[{"-", FractionBox["15", "64"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["38", "365"], ",", FractionBox["46", "73"], ",", RowBox[{"-", FractionBox["97", "365"]}], ",", RowBox[{"-", FractionBox["78", "365"]}]}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"{", RowBox[{ FractionBox["171", "365"], ",", FractionBox["61", "73"], ",", RowBox[{"-", FractionBox["254", "365"]}], ",", FractionBox["14", "365"]}], "}"}]}], "}"}]}], "}"}], ",", FractionBox["1", "2"], ",", "20"}], "]"}]}], "\[IndentingNewLine]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "8"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "9"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "11"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "12"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", "13"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"?", "validswitch"}], "\[IndentingNewLine]"}]], "Input"], Cell[CellGroupData[{ Cell["Global`validswitch", "Print", CellTags->"Info3263300426-9811810"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"validswitch", "[", RowBox[{"b_", ",", "i_", ",", "j_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"s", ",", "t", ",", "n"}], "}"}], ",", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "b", "]"}]}], ";", RowBox[{"s", "=", RowBox[{"mynorm", "[", RowBox[{ RowBox[{ "b", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], ",", "alpha"}], "]"}]}], ";", RowBox[{"t", "=", RowBox[{"mynorm", "[", RowBox[{ RowBox[{ "b", "\[LeftDoubleBracket]", "j", "\[RightDoubleBracket]"}], ",", "alpha"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"s", "<", "t"}], ",", RowBox[{"Return", "[", "False", "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"s", "==", "t"}], "&&", RowBox[{ RowBox[{"Abs", "[", RowBox[{"b", "\[LeftDoubleBracket]", RowBox[{"i", ",", "n"}], "\[RightDoubleBracket]"}], "]"}], "\[LessEqual]", RowBox[{"Abs", "[", RowBox[{"b", "\[LeftDoubleBracket]", RowBox[{"j", ",", "n"}], "\[RightDoubleBracket]"}], "]"}]}]}], ",", RowBox[{"Return", "[", "False", "]"}]}], "]"}], ";", "True"}]}], "]"}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["validswitch"], Editable->False]], "Print", CellTags->"Info3263300426-9811810"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"testvectors", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "k", "]"}], "]"}], RowBox[{"latticebasis", "[", RowBox[{"[", "k", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"Length", "[", "#", "]"}]}], "}"}]}], "]"}], "&"}], ",", "testks"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "9"}], ",", RowBox[{"-", "18"}], ",", RowBox[{"-", "27"}], ",", RowBox[{"-", "36"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "7"}], ",", RowBox[{"-", "15"}], ",", RowBox[{"-", "23"}], ",", RowBox[{"-", "31"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "5"}], ",", RowBox[{"-", "12"}], ",", RowBox[{"-", "19"}], ",", RowBox[{"-", "26"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "3"}], ",", RowBox[{"-", "9"}], ",", RowBox[{"-", "15"}], ",", RowBox[{"-", "21"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "6"}], ",", RowBox[{"-", "11"}], ",", RowBox[{"-", "16"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "3"}], ",", RowBox[{"-", "7"}], ",", RowBox[{"-", "11"}]}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "0", ",", RowBox[{"-", "3"}], ",", RowBox[{"-", "6"}]}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "3", ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"7", ",", "6", ",", "5", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"9", ",", "9", ",", "9", ",", "9"}], "}"}], ",", RowBox[{"{", RowBox[{"11", ",", "12", ",", "13", ",", "14"}], "}"}], ",", RowBox[{"{", RowBox[{"13", ",", "15", ",", "17", ",", "19"}], "}"}], ",", RowBox[{"{", RowBox[{"15", ",", "18", ",", "21", ",", "24"}], "}"}], ",", RowBox[{"{", RowBox[{"17", ",", "21", ",", "25", ",", "29"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "getqmatrix"}]], "Input"], Cell[BoxData["\<\"getqmatrix takes as input a list `latticebasis' of n \ vectors, and a positive real number alpha, and returns a list of vectors \ which are the projections of the jth lattice basis entry onto the orthogonal \ complement of the basis vectors from k to n. When j>=k these vectors are \ zero, so it returns instead just the number zero.\"\>"], "Print", CellTags->"Info3263300408-3630177"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"testprojns", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"#", "-", RowBox[{"projectit", "[", RowBox[{"#", ",", "3", ",", "latticebasis", ",", "alpha"}], "]"}]}], ")"}], "&"}], ",", "testvectors"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ FractionBox["1953", "512"], ",", RowBox[{"-", FractionBox["909", "512"]}], ",", FractionBox["99", "256"], ",", RowBox[{"-", FractionBox["459", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1877", "512"], ",", RowBox[{"-", FractionBox["817", "512"]}], ",", FractionBox["127", "256"], ",", RowBox[{"-", FractionBox["519", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1801", "512"], ",", RowBox[{"-", FractionBox["725", "512"]}], ",", FractionBox["155", "256"], ",", RowBox[{"-", FractionBox["579", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1725", "512"], ",", RowBox[{"-", FractionBox["633", "512"]}], ",", FractionBox["183", "256"], ",", RowBox[{"-", FractionBox["639", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1649", "512"], ",", RowBox[{"-", FractionBox["541", "512"]}], ",", FractionBox["211", "256"], ",", RowBox[{"-", FractionBox["699", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1573", "512"], ",", RowBox[{"-", FractionBox["449", "512"]}], ",", FractionBox["239", "256"], ",", RowBox[{"-", FractionBox["759", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1497", "512"], ",", RowBox[{"-", FractionBox["357", "512"]}], ",", FractionBox["267", "256"], ",", RowBox[{"-", FractionBox["819", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1421", "512"], ",", RowBox[{"-", FractionBox["265", "512"]}], ",", FractionBox["295", "256"], ",", RowBox[{"-", FractionBox["879", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1345", "512"], ",", RowBox[{"-", FractionBox["173", "512"]}], ",", FractionBox["323", "256"], ",", RowBox[{"-", FractionBox["939", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1269", "512"], ",", RowBox[{"-", FractionBox["81", "512"]}], ",", FractionBox["351", "256"], ",", RowBox[{"-", FractionBox["999", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1193", "512"], ",", FractionBox["11", "512"], ",", FractionBox["379", "256"], ",", RowBox[{"-", FractionBox["1059", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1117", "512"], ",", FractionBox["103", "512"], ",", FractionBox["407", "256"], ",", RowBox[{"-", FractionBox["1119", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["1041", "512"], ",", FractionBox["195", "512"], ",", FractionBox["435", "256"], ",", RowBox[{"-", FractionBox["1179", "256"]}]}], "}"}], ",", RowBox[{"{", RowBox[{ FractionBox["965", "512"], ",", FractionBox["287", "512"], ",", FractionBox["463", "256"], ",", RowBox[{"-", FractionBox["1239", "256"]}]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"N", "[", RowBox[{"mynorm", "[", RowBox[{"#", ",", "alpha"}], "]"}], "]"}], "&"}], ",", "%"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ "4.411233883506972`", ",", "4.276342990804175`", ",", "4.1596555596587566`", ",", "4.062740377503834`", ",", "3.98703955021768`", ",", "3.9337780027601963`", ",", "3.9038742775606896`", ",", "3.8978660026994256`", ",", "3.9158631711284295`", ",", "3.957538297351019`", ",", "4.022155438940668`", ",", "4.108632299804888`", ",", "4.215623841734459`", ",", "4.341613683297951`"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"feasiblekvals", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "4"}], ",", "2", ",", RowBox[{"-", "1"}]}], "}"}], ",", "latticebasis", ",", "qmatrix", ",", "alpha", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"-", "4"}], ",", "2", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "feasiblekvals"}]], "Input"], Cell[BoxData["\<\"feasiblekvals takes as input a list (called klist) of d<=n \ integers, a lattice basis (a list of n lists of n integers), a matrix giving \ information about the gramschmidt reduction of the lattice basis, a positive \ real number alpha which determines the inner product being used, and a \ positive real number rsquared. It returns a list of all coefficient vectors \ of length d+1 which could potentially be the initial d+1 entries of an \ n-entry integer vector s so that Sum[s[[j]] latticebasis[[j]],{j,1,n}] has \ norm^2 less than or equal to rsquared.\[IndentingNewLine]What is required is \ that the hyperplane through the partial sum up to depth d+1, and parallel to \ the remaining vectors of the latticebasis, cut the sphere of radius-squared \ equal to rsquared.\"\>"], "Print", CellTags->"Info3263713957-2194952"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"feasiblekvals", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "1", ",", RowBox[{"-", "1"}]}], "}"}], ",", "latticebasis", ",", "qmatrix", ",", "alpha", ",", "80"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"-", "2"}], ",", "1", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}], "}"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"esubi", "[", RowBox[{"k_", ",", "n_"}], "]"}], ":=", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"k", "-", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", "1", "}"}], ",", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"n", "-", "k"}], "}"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"esubi", "[", RowBox[{"1", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"esubi", "[", RowBox[{"4", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"esubi", "[", RowBox[{"2", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"gcdstepper", "[", RowBox[{"a_", ",", "b_", ",", "s_", ",", "n_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"g", ",", "p", ",", "q", ",", "k"}], "}"}], ",", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"a", "\[Equal]", "0"}], "&&", RowBox[{"b", "\[Equal]", "0"}]}], ",", RowBox[{ RowBox[{"{", RowBox[{"g", ",", RowBox[{"{", RowBox[{"p", ",", "q"}], "}"}]}], "}"}], "=", RowBox[{"{", RowBox[{"0", ",", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], "}"}]}], ",", RowBox[{ RowBox[{"{", RowBox[{"g", ",", RowBox[{"{", RowBox[{"p", ",", "q"}], "}"}]}], "}"}], "=", RowBox[{"ExtendedGCD", "[", RowBox[{"a", ",", "b"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"Join", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"esubi", "[", RowBox[{"k", ",", "n"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"s", "-", "1"}]}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"a", "\[Equal]", "0"}], "&&", RowBox[{"b", "\[Equal]", "0"}]}], ",", RowBox[{"{", RowBox[{"esubi", "[", RowBox[{"s", ",", "n"}], "]"}], "}"}], ",", RowBox[{"{", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"s", "-", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"q", ",", RowBox[{"-", "p"}]}], "}"}], ",", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"n", "-", "s", "-", "1"}], "}"}]}], "]"}]}], "]"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"a", "\[Equal]", "0"}], "&&", RowBox[{"b", "\[Equal]", "0"}]}], ",", RowBox[{"{", RowBox[{"esubi", "[", RowBox[{ RowBox[{"s", "+", "1"}], ",", "n"}], "]"}], "}"}], ",", RowBox[{"{", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"s", "-", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"a", "/", "g"}], ",", RowBox[{"b", "/", "g"}]}], "}"}], ",", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"n", "-", "s", "-", "1"}], "}"}]}], "]"}]}], "]"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"esubi", "[", RowBox[{"k", ",", "n"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"s", "+", "2"}], ",", "n"}], "}"}]}], "]"}]}], "]"}], ",", "g"}], "}"}]}]}], "]"}]}], "\[IndentingNewLine]"}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdstepper", "[", RowBox[{"0", ",", "0", ",", "\[IndentingNewLine]", "2", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1"}], "}"}]}], "}"}], ",", "0"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1"}], "}"}], ",", "2", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1"}], "}"}], ",", "2", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "6", ",", "10", ",", "15"}], "}"}], ",", "2", ",", "5"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "6", ",", "10", ",", "15"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "2"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "3", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Det", "[", "%", "]"}]], "Input"], Cell[BoxData[ RowBox[{"-", "1"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"gcdstepper", "::", "usage"}], "=", "\"\\""}]], \ "Input", InitializationCell->True], Cell[BoxData["\<\"gcdstepper is a utility subroutine for gcdmatrix. It takes \ as input four integers, a,b,s, and n. Here, s should be between 1 and n-1. \ It returns a two entry list. The first entry is an n by n invertible integer \ matrix that is mostly the identity, but with two rows in position s and s+1 \ based on the m and n for which am+bn=gcd. The second entry is the gcd of a \ and b.\"\>"], "Output", CellChangeTimes->{3.4233995503566227`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdstepper", "[", RowBox[{"6", ",", "10", ",", "5", ",", "6"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "0", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "0", ",", "3", ",", "5"}], "}"}]}], "}"}], ",", "2"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"6", ",", "10", ",", "15"}], "}"}], ".", RowBox[{"Inverse", "[", "%", "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"0", ",", "2", ",", "15"}], "}"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"gcdmatrix", "[", RowBox[{"s_", ",", "d_", ",", "n_"}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "m", ",", "t", ",", "u", ",", "w", ",", "g", ",", "x", ",", "y"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "=", RowBox[{"IdentityMatrix", "[", "n", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"t", "=", "d"}], ";", "\[IndentingNewLine]", RowBox[{"g", "=", RowBox[{"s", "[", RowBox[{"[", "t", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", "\[IndentingNewLine]", "\t", RowBox[{ RowBox[{"t", "\[LessEqual]", RowBox[{"n", "-", "1"}]}], ",", "\[IndentingNewLine]", "\t\t", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"u", ",", "g"}], "}"}], "=", RowBox[{"gcdstepper", "[", RowBox[{"g", ",", RowBox[{"s", "[", RowBox[{"[", RowBox[{"t", "+", "1"}], "]"}], "]"}], ",", "t", ",", "n"}], "]"}]}], ";", "\[IndentingNewLine]", "\t\t", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "u", ",", "\"\<,\>\"", ",", "\"\\"", ",", "g"}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", "\t\t", RowBox[{"m", "=", RowBox[{"u", ".", "m"}]}], ";", RowBox[{"t", "++"}]}]}], "\[IndentingNewLine]", "\t", "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"d", "<", "n"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"x", "=", RowBox[{ RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"esubi", "[", RowBox[{"k", ",", "n"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"d", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"esubi", "[", RowBox[{"n", ",", "n"}], "]"}], "}"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"esubi", "[", RowBox[{"k", ",", "n"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"d", "+", "1"}], ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"esubi", "[", RowBox[{"d", ",", "n"}], "]"}], "}"}]}], "]"}], ".", "m"}]}], ";", "\[IndentingNewLine]", RowBox[{"y", "=", RowBox[{"Join", "[", RowBox[{ RowBox[{"Take", "[", RowBox[{"x", ",", RowBox[{"d", "-", "1"}]}], "]"}], ",", RowBox[{"{", RowBox[{"Join", "[", RowBox[{ RowBox[{"Take", "[", RowBox[{"s", ",", RowBox[{"d", "-", "1"}]}], "]"}], ",", RowBox[{"Take", "[", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "d", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"d", ",", "n"}], "}"}]}], "]"}]}], "]"}], "}"}], ",", RowBox[{"Take", "[", RowBox[{"x", ",", RowBox[{"{", RowBox[{ RowBox[{"d", "+", "1"}], ",", "n"}], "}"}]}], "]"}]}], "]"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"d", "\[Equal]", "n"}], ",", RowBox[{"y", "=", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"esubi", "[", RowBox[{"k", ",", "n"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", "s", "}"}]}], "]"}]}]}], "]"}], ";", "y"}]}], "]"}]}], "\[IndentingNewLine]"}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", "2", ",", "5"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "7"}], ",", RowBox[{"-", "7"}], ",", RowBox[{"-", "2"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", "4", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "7"}], ",", RowBox[{"-", "7"}], ",", RowBox[{"-", "2"}], ",", RowBox[{"-", "1"}]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Det", "[", "%", "]"}]], "Input"], Cell[BoxData[ RowBox[{"-", "1"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"\[IndentingNewLine]", RowBox[{ RowBox[{"gcdmatrix", "::", "usage"}], "=", "\"\\""}]}]], \ "Input", InitializationCell->True], Cell[BoxData["\<\"gcdmatrix calls subroutine `gcdstepper'. gcdmatrix takes as \ input a list s of integers,which should be collectively though not \ necessarily pairwise,relatively prime,and a position d,or integer from 1 to \ n,indicating that the gcd of the entries from that point on,is 1. It returns \ a matrix which has the list as its dth row,and is like the identity matrix \ for rows before d,and has integer entries and determinant 1. This matrix can \ be used to update a lattice basis,and will give a new lattice basis.\"\>"], \ "Output", CellChangeTimes->{3.423399550380623*^9}] }, Open ]], Cell["gcdstepper is a subroutine for getmatrix. ", "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"3", ",", "2", ",", "1"}], "}"}], ",", "3", ",", "3"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell["\<\ gcdmatrix takes as input a list of integers, which should be collectively \ though not necessarily pairwise, relatively prime, and a position, or integer \ from 1 to n, indicating that the gcd of the entries from that point on, is 1. \ It returns a matrix which has the list as its sth row, and is like the \ identity matrix for rows before s, and has integer entries and determinant 1. \ This matrix can be used to update a lattice basis, and will give a new \ lattice basis. \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1"}], "}"}], ",", "4", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1"}], "}"}], ",", "2", ",", "4"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", "1", ",", "3"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"6", ",", "10", ",", "15"}], "}"}], ",", "1", ",", "3"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"6", ",", "10", ",", "15"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "2"}], ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"7", ",", "3", ",", "20", ",", "36", ",", "14", ",", "21"}], "}"}], ",", "3", ",", "6"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "20", ",", "36", ",", "14", ",", "21"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "5", ",", "9", ",", "3", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "10", ",", "18", ",", "7", ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "2"}], ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0", ",", "1"}], "}"}], ",", "2", ",", "5"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", RowBox[{"-", "1"}], ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", RowBox[{"-", "1"}], ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"gcdmatrix", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", "1", ",", "3"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"MatrixForm", "[", "%", "]"}]], "Input"], Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"1", "0", "0", "0", "0", "0"}, {"0", "1", "0", "0", "0", "0"}, {"0", "0", "20", "36", "14", "21"}, {"0", "0", "5", "9", "3", "0"}, {"0", "0", "10", "18", "7", "10"}, {"0", "0", RowBox[{"-", "1"}], RowBox[{"-", "2"}], "0", "0"} }], "\[NoBreak]", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Det", "[", "%", "]"}]], "Input"], Cell[BoxData[ RowBox[{"-", "1"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Det", "[", "%", "]"}]], "Input"], Cell[BoxData["1"], "Output"] }, Open ]], Cell[BoxData["\[IndentingNewLine]"], "Input"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"whenswitch", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"un1,un2=\"\>", "\[InvisibleSpace]", RowBox[{"{", RowBox[{"5", ",", "13"}], "}"}]}], SequenceForm["un1,un2=", {5, 13}], Editable->False]], "Print"], Cell[BoxData[ RowBox[{"-", "1"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"whenswitch", "[", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"un1,un2=\"\>", "\[InvisibleSpace]", RowBox[{"{", RowBox[{"13", ",", "5"}], "}"}]}], SequenceForm["un1,un2=", {13, 5}], Editable->False]], "Print"], Cell[BoxData["2"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"whenswitch", "[", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "1"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"un1,un2=\"\>", "\[InvisibleSpace]", RowBox[{"{", RowBox[{"13", ",", "5"}], "}"}]}], SequenceForm["un1,un2=", {13, 5}], Editable->False]], "Print"], Cell[BoxData["2"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"cb", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"1", "/", "2"}]}], "]"}]], "Input"], Cell[BoxData["True"], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"cb", "[", RowBox[{"b1_", ",", "b2_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"u1", ",", "v1", ",", "u2", ",", "v2", ",", "n1", ",", "n2"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"cb", " ", "means", " ", "comes", " ", "before"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"u1", "=", RowBox[{"Drop", "[", RowBox[{"b1", ",", RowBox[{"-", "1"}]}], "]"}]}], ";", RowBox[{"v1", "=", RowBox[{"b1", "[", RowBox[{"[", RowBox[{"-", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"u2", "=", RowBox[{"Drop", "[", RowBox[{"b2", ",", RowBox[{"-", "1"}]}], "]"}]}], ";", RowBox[{"v2", "=", RowBox[{"b2", "[", RowBox[{"[", RowBox[{"-", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"n1", "=", RowBox[{ RowBox[{"u1", ".", "u1"}], "+", RowBox[{"alpha", " ", RowBox[{"v1", "^", "2"}]}]}]}], ";", RowBox[{"n2", "=", RowBox[{ RowBox[{"u2", ".", "u2"}], "+", RowBox[{"alpha", " ", RowBox[{"v2", "^", "2"}]}]}]}], ";", "\n", RowBox[{"If", "[", RowBox[{ RowBox[{"n1", "<", "n2"}], ",", RowBox[{"Return", "[", "True", "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"n1", "==", "n2"}], "&&", RowBox[{ RowBox[{"v1", "^", "2"}], ">", RowBox[{"v2", "^", "2"}]}]}], ",", RowBox[{"Return", "[", "True", "]"}]}], "]"}], ";", "\n", "False"}]}], "]"}]}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"cb", "::", "usage"}], "=", "\"\\""}], "\[IndentingNewLine]"}]], "Input", InitializationCell->True], Cell[BoxData["\<\"cb takes as input two vectors and a positive real number \ alpha. It basically decides whether the first vector is shorter than the \ second with respect to the alpha-norm, but if there is a tie, it decides in \ favor of that vector which will be shorter once alpha is reduced. If that, \ too, is a tie, it says False.\"\>"], "Output", CellChangeTimes->{3.423399550401623*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"cb", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"1", "/", "2"}]}], "]"}]], "Input"], Cell[BoxData["True"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "Sort"}]], "Input"], Cell[BoxData[ RowBox[{"\<\"Sort[list] sorts the elements of list into canonical order. \ Sort[list, p] sorts using the ordering function p.\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], Active->True, BaseStyle->"RefGuideLink", ButtonData:>"Sort"]}]], "Print", CellTags->"Info3262768187-8916970"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{"Sort", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{ RowBox[{"cb", "[", RowBox[{"#1", ",", "#2", ",", RowBox[{"1", "/", "n"}]}], "]"}], "&"}]}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "12"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "4", ",", "1"}], "}"}]}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"basissorter", "[", RowBox[{"b_", ",", "m_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"permmatrix", ",", "permn", ",", "bb", ",", "k", ",", "n"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"n", "=", RowBox[{"Length", "[", "b", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"bb", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"b", "[", RowBox[{"[", "k", "]"}], "]"}], ",", "k"}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "bb"}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", RowBox[{"bb", "=", RowBox[{"Sort", "[", RowBox[{"bb", ",", RowBox[{ RowBox[{"cb", "[", RowBox[{ RowBox[{"#1", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"#2", "[", RowBox[{"[", "1", "]"}], "]"}], ",", "alpha"}], "]"}], "&"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"permn", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}], "&"}], ",", "bb"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"permmatrix", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"esubi", "[", RowBox[{ RowBox[{"permn", "[", RowBox[{"[", "k", "]"}], "]"}], ",", "n"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "n"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}], "&"}], ",", "bb"}], "]"}], ",", RowBox[{"permmatrix", ".", "m"}], ",", "alpha"}], "}"}]}]}], "]"}]}], "\[IndentingNewLine]"}]], "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"basissorter", "::", "usage"}], "=", "\"\\""}]], "Input", InitializationCell->True], Cell[BoxData["\<\"basissorter calls the subroutines `esubi' and `cb'. \ basissorter takes as input a list b of n real vectors, an integer matrix m, \ and a positive real number alpha. It finds a permutation matrix which sorts \ the vectors of b with respect to the alpha norm, and uses the tiebreaker \ built into the function `cb'. It returns a list with three entries: {the \ sorted list, the product of the permutation with m, and alpha}. \"\>"], \ "Output", CellChangeTimes->{3.423399550427623*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"basissorter", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}]}], "}"}], ",", RowBox[{"IdentityMatrix", "[", "3", "]"}], ",", RowBox[{"1", "/", "3"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "1"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], "}"}], ",", FractionBox["1", "3"]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"cb", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1", ",", "5"}], "}"}], ",", RowBox[{"1", "/", "100"}]}], "]"}]], "Input"], Cell[BoxData["False"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"basissorter", "[", RowBox[{"latticebasis", ",", RowBox[{"IdentityMatrix", "[", "4", "]"}], ",", "1"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1"}], "}"}]}], "}"}], ",", "1"}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"basissorter", "[", RowBox[{ RowBox[{"Reverse", "[", "latticebasis", "]"}], ",", RowBox[{"IdentityMatrix", "[", "4", "]"}], ",", RowBox[{"1", "/", "2"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "5", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "5", ",", "9", ",", "11"}], "}"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0", ",", "0"}], "}"}]}], "}"}], ",", FractionBox["1", "2"]}], "}"}]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"lastgcdok", "[", RowBox[{"{", RowBox[{"5", ",", "6", ",", "8"}], "}"}], "]"}]], "Input"], Cell[BoxData["1"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"lastgcdok", "[", RowBox[{"{", RowBox[{"5", ",", "10", ",", "15"}], "}"}], "]"}]], "Input"], Cell[BoxData["0"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"lastgcdok", "[", RowBox[{"{", RowBox[{"6", ",", "7", ",", "8"}], "}"}], "]"}]], "Input"], Cell[BoxData["2"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"lastgcdok", "[", RowBox[{"{", RowBox[{"3", ",", "2", ",", "1"}], "}"}], "]"}]], "Input"], Cell[BoxData["3"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"lastgcdok", "[", RowBox[{"{", RowBox[{"0", ",", "0", ",", "0"}], "}"}], "]"}]], "Input"], Cell[BoxData["0"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "inprod"}]], "Input"], Cell[CellGroupData[{ Cell["Global`inprod", "Print", CellTags->"Info3262776734-1476812"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"inprod", "[", RowBox[{"x_", ",", "y_", ",", "alpha_"}], "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"Drop", "[", RowBox[{"x", ",", RowBox[{"-", "1"}]}], "]"}], ".", RowBox[{"Drop", "[", RowBox[{"y", ",", RowBox[{"-", "1"}]}], "]"}]}], "+", RowBox[{"alpha", " ", RowBox[{"x", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}], " ", RowBox[{"y", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}]}]}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["inprod"], Editable->False]], "Print", CellTags->"Info3262776734-1476812"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "cb"}]], "Input"], Cell[CellGroupData[{ Cell["Global`cb", "Print", CellTags->"Info3262776918-4645885"], Cell[BoxData[ InterpretationBox[GridBox[{ {GridBox[{ { RowBox[{ RowBox[{"cb", "[", RowBox[{"b1_", ",", "b2_", ",", "alpha_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "u1", ",", "v1", ",", "u2", ",", "v2", ",", "n1", ",", "n2"}], "}"}], ",", RowBox[{ RowBox[{"u1", "=", RowBox[{"Drop", "[", RowBox[{"b1", ",", RowBox[{"-", "1"}]}], "]"}]}], ";", RowBox[{"v1", "=", RowBox[{"b1", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}]}], ";", RowBox[{"u2", "=", RowBox[{"Drop", "[", RowBox[{"b2", ",", RowBox[{"-", "1"}]}], "]"}]}], ";", RowBox[{"v2", "=", RowBox[{"b2", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}]}], ";", RowBox[{"n1", "=", RowBox[{ RowBox[{"u1", ".", "u1"}], "+", RowBox[{"alpha", " ", SuperscriptBox["v1", "2"]}]}]}], ";", RowBox[{"n2", "=", RowBox[{ RowBox[{"u2", ".", "u2"}], "+", RowBox[{"alpha", " ", SuperscriptBox["v2", "2"]}]}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"n1", "<", "n2"}], ",", RowBox[{"Return", "[", "True", "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"n1", "==", "n2"}], "&&", RowBox[{ SuperscriptBox["v1", "2"], ">", SuperscriptBox["v2", "2"]}]}], ",", RowBox[{"Return", "[", "True", "]"}]}], "]"}], ";", "False"}]}], "]"}]}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxItemSize->{"Columns" -> {{ Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}]} }, BaselinePosition->{Baseline, {1, 1}}, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], Definition["cb"