(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 12.2' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 50641, 1216] NotebookOptionsPosition[ 47971, 1175] NotebookOutlinePosition[ 48466, 1193] CellTagsIndexPosition[ 48423, 1190] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{"pivots", "[", "A_", "]"}], ":=", RowBox[{"Flatten", "[", RowBox[{ RowBox[{"FirstPosition", "[", "1", "]"}], "/@", RowBox[{"Transpose", "[", "A", "]"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.831194837404834*^9, 3.8311948924696903`*^9}, { 3.831194930347896*^9, 3.831194932848599*^9}}, CellLabel->"In[1]:=",ExpressionUUID->"e1bc883b-2413-4a7d-abe0-4a19eb3f78fd"], Cell[BoxData[ RowBox[{ RowBox[{"pMatrix", "[", "n_", "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Which", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"i", "\[Equal]", "2"}], "&&", RowBox[{"j", "\[Equal]", "1"}]}], "||", RowBox[{ RowBox[{"i", "\[Equal]", "1"}], "&&", RowBox[{"j", "\[Equal]", "2"}]}]}], ",", RowBox[{ RowBox[{"-", "1"}], "/", "2"}], ",", RowBox[{ RowBox[{"i", "\[Equal]", "j"}], "&&", RowBox[{"i", ">", "2"}]}], ",", "1", ",", "True", ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", " ", "n"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "n"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.831107414093502*^9, 3.83110748040809*^9}, { 3.831107557920609*^9, 3.8311075805621977`*^9}, {3.8311076270925627`*^9, 3.831107722019619*^9}, {3.83468833600141*^9, 3.8346883410498962`*^9}}, CellLabel->"In[2]:=",ExpressionUUID->"025b5df5-f2a6-4cee-a294-e76ee16e74d4"], Cell[BoxData[ RowBox[{ RowBox[{"gramMatrix", "[", "W_", "]"}], ":=", RowBox[{"Simplify", "[", RowBox[{ RowBox[{"Transpose", "[", "W", "]"}], ".", RowBox[{"pMatrix", "[", RowBox[{"Length", "[", "W", "]"}], "]"}], ".", "W"}], "]"}]}]], "Input", CellChangeTimes->{{3.831107486071478*^9, 3.831107546093779*^9}, { 3.831109392242589*^9, 3.831109394639595*^9}, {3.831110190169511*^9, 3.831110193792735*^9}}, CellLabel->"In[3]:=",ExpressionUUID->"54cc4a6c-be37-4091-ac21-3dfd11eb53ea"], Cell[BoxData[ RowBox[{ RowBox[{"linearRelationsMatrix", "[", "G_", "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"RowReduce", "[", "G", "]"}], "[", RowBox[{"[", RowBox[{"1", ";;", RowBox[{"MatrixRank", "[", "G", "]"}]}], "]"}], "]"}], "//", "Transpose"}]}]], "Input", CellChangeTimes->{{3.831109396818718*^9, 3.831109426888632*^9}}, CellLabel->"In[4]:=",ExpressionUUID->"d3298122-6e10-4115-8e61-a949acba4e08"], Cell[BoxData[ RowBox[{ RowBox[{"linearRelations", "[", "L_", "]"}], ":=", RowBox[{"Select", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Equal", "[", RowBox[{ SubscriptBox["b", "i"], ",", RowBox[{ RowBox[{"L", "[", RowBox[{"[", "i", "]"}], "]"}], ".", RowBox[{"Table", "[", RowBox[{ SubscriptBox["b", "i"], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"pivots", "[", "L", "]"}]}], "}"}]}], "]"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "L", "]"}]}], "}"}]}], "]"}], ",", RowBox[{ RowBox[{"Not", "[", RowBox[{"BooleanQ", "[", "#", "]"}], "]"}], "&"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.831109446192391*^9, 3.831109495064299*^9}, { 3.8311095335606937`*^9, 3.831109534992022*^9}, {3.831109584393684*^9, 3.831109833956565*^9}, {3.8311098747139893`*^9, 3.8311099163122053`*^9}, { 3.831110035487195*^9, 3.83111004405739*^9}, {3.831110077358601*^9, 3.831110081551445*^9}, {3.831194643897842*^9, 3.8311946492229443`*^9}, { 3.831194680087949*^9, 3.831194680680228*^9}, {3.831194956352386*^9, 3.831195002875142*^9}, {3.831205178380069*^9, 3.831205187846324*^9}, 3.834688343633176*^9}, CellLabel->"In[5]:=",ExpressionUUID->"4e2a5664-aeb5-4dfb-88fb-7e7839ba2141"], Cell[BoxData[ RowBox[{ RowBox[{"linearRelationsFromW", "=", RowBox[{ "linearRelations", "@*", "linearRelationsMatrix", "@*", "gramMatrix"}]}], ";"}]], "Input", CellChangeTimes->{{3.831110103314905*^9, 3.831110162272215*^9}, 3.831206070230084*^9}, CellLabel->"In[6]:=",ExpressionUUID->"c9a1b25a-8cb3-40d1-ac83-1d2405398934"], Cell[BoxData[ RowBox[{ RowBox[{"inverseLinearRelations", "[", "G_", "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[Equal]", "#"}], ",", "1", ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", RowBox[{"G", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}]}], "}"}]}], "]"}], "&"}], "/@", RowBox[{"Flatten", "[", RowBox[{ RowBox[{ RowBox[{"FirstPosition", "[", RowBox[{"#", ",", "1"}], "]"}], "&"}], "/@", RowBox[{"(", RowBox[{ RowBox[{"RowReduce", "[", "G", "]"}], "//", RowBox[{"Select", "[", RowBox[{ RowBox[{"Not", "[", RowBox[{"AllTrue", "[", RowBox[{"#", ",", RowBox[{ RowBox[{"#", "\[Equal]", "0"}], "&"}]}], "]"}], "]"}], "&"}], "]"}]}], ")"}]}], "]"}]}]}]], "Input", CellChangeTimes->{{3.831194278291965*^9, 3.831194298458626*^9}, 3.831195204231324*^9}, CellLabel->"In[7]:=",ExpressionUUID->"30b57c08-a123-4e7d-9b0a-b512fcfecee8"], Cell[BoxData[ RowBox[{ RowBox[{"quadraticFormMatrix", "[", RowBox[{"G_", ",", "L_"}], "]"}], ":=", RowBox[{"Inverse", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"G", "[", RowBox[{"[", RowBox[{"i", ",", " ", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"pivots", "[", "L", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"pivots", "[", "L", "]"}]}], "}"}]}], "]"}], "]"}]}]], "Input",\ CellChangeTimes->{{3.831195055004586*^9, 3.83119507699967*^9}, { 3.831195107195753*^9, 3.831195121990181*^9}, {3.831195208095559*^9, 3.831195214781535*^9}}, CellLabel->"In[8]:=",ExpressionUUID->"e30807a9-5381-4ad1-b9fd-a6a877ae69fe"], Cell[BoxData[ RowBox[{ RowBox[{"quadraticForm", "[", RowBox[{"Q_", ",", "L_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"v", "=", RowBox[{"Table", "[", RowBox[{ SubscriptBox["b", "i"], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"pivots", "[", "L", "]"}]}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"Simplify", "[", RowBox[{ RowBox[{"v", ".", "Q", ".", "v"}], "\[Equal]", "0"}], "]"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.831195241841057*^9, 3.831195289590564*^9}}, CellLabel->"In[9]:=",ExpressionUUID->"d1264330-efcb-4ca7-a1c2-f6744f28eebe"], Cell[BoxData[ RowBox[{ RowBox[{"quadform", "[", "W_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"G", "=", RowBox[{"gramMatrix", "[", "W", "]"}]}], "}"}], ",", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"L", "=", RowBox[{"linearRelationsMatrix", "[", "G", "]"}]}], "}"}], ",", RowBox[{"quadraticForm", "[", RowBox[{ RowBox[{"quadraticFormMatrix", "[", RowBox[{"G", ",", "L"}], "]"}], ",", "L"}], "]"}]}], "]"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.831195337159152*^9, 3.831195396279203*^9}}, CellLabel->"In[10]:=",ExpressionUUID->"efd0e321-9f31-4641-bf42-f73e16044635"], Cell[BoxData[ RowBox[{ RowBox[{"quadformFromG", "[", "G_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"L", "=", RowBox[{"linearRelationsMatrix", "[", "G", "]"}]}], "}"}], ",", RowBox[{"quadraticForm", "[", RowBox[{ RowBox[{"quadraticFormMatrix", "[", RowBox[{"G", ",", "L"}], "]"}], ",", "L"}], "]"}]}], "]"}]}]], "Input",\ CellChangeTimes->{{3.8312049925958433`*^9, 3.8312050200596113`*^9}}, CellLabel->"In[11]:=",ExpressionUUID->"810323e6-91cb-44f2-ad55-323fbec422eb"], Cell[BoxData[ RowBox[{ RowBox[{"graphFromG", "[", "G_", "]"}], ":=", RowBox[{"PlanarGraph", "[", RowBox[{"AdjacencyGraph", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"#", "\[Equal]", RowBox[{"-", "1"}]}], ",", "1", ",", "0"}], "]"}], "&"}], "/@", "#"}], "&"}], "/@", "G"}], ",", RowBox[{"VertexLabels", "\[Rule]", "\"\\""}]}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.8315843493182087`*^9, 3.831584372878718*^9}, { 3.831584545556731*^9, 3.831584563248426*^9}}, CellLabel->"In[12]:=",ExpressionUUID->"948959db-c926-4458-9e45-ef7f3fb99ba5"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"nextCandidate", "[", RowBox[{"s_", ",", "t_", ",", "adj_"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"length", ",", "pos"}], "}"}], ",", RowBox[{ RowBox[{"length", "=", RowBox[{"Length", "[", "adj", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"pos", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Position", "[", RowBox[{"adj", ",", "s"}], "]"}], "[", RowBox[{"[", RowBox[{"1", ",", "1"}], "]"}], "]"}], "+", "1"}], ",", "length", ",", "1"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"t", ",", RowBox[{"adj", "[", RowBox[{"[", "pos", "]"}], "]"}]}], "}"}]}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{3.831210886725911*^9}, CellLabel->"In[13]:=",ExpressionUUID->"e7b8a43b-0fbc-4073-928d-10a091e21dd7"], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"FindFace", "[", RowBox[{"g_", "?", "PlanarGraphQ"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", "emb", "}"}], ",", RowBox[{ RowBox[{"emb", "=", RowBox[{"GraphEmbedding", "[", RowBox[{"g", ",", "\"\\""}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"FindFace", "[", RowBox[{"g", ",", "emb"}], "]"}]}]}], "]"}]}], ";"}], "\n"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"FindFace", "[", RowBox[{ RowBox[{"g_", "?", "PlanarGraphQ"}], ",", "emb_"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{ "m", ",", "orderings", ",", "pAdj", ",", "rightF", ",", "s", ",", "t", ",", "initial", ",", "face"}], "}"}], ",", RowBox[{ RowBox[{"m", "=", RowBox[{"AdjacencyMatrix", "[", "g", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"pAdj", "[", "v", "]"}], "=", RowBox[{"SortBy", "[", RowBox[{ RowBox[{"Pick", "[", RowBox[{ RowBox[{"VertexList", "[", "g", "]"}], ",", RowBox[{"m", "[", RowBox[{"[", "v", "]"}], "]"}], ",", "1"}], "]"}], ",", RowBox[{ RowBox[{"ArcTan", "@@", RowBox[{"(", RowBox[{ RowBox[{"emb", "[", RowBox[{"[", "v", "]"}], "]"}], "-", RowBox[{"emb", "[", RowBox[{"[", "#", "]"}], "]"}]}], ")"}]}], "&"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"v", ",", RowBox[{"VertexList", "[", "g", "]"}]}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"rightF", "[", "_", "]"}], ":=", "False"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"Reap", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"!", RowBox[{"rightF", "[", "e", "]"}]}], ",", RowBox[{ RowBox[{"s", "=", RowBox[{"e", "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"t", "=", RowBox[{"e", "[", RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"initial", "=", "s"}], ";", "\[IndentingNewLine]", RowBox[{"face", "=", RowBox[{"{", "s", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{"t", "=!=", "initial"}], ",", RowBox[{ RowBox[{ RowBox[{"rightF", "[", RowBox[{"UndirectedEdge", "[", RowBox[{"s", ",", "t"}], "]"}], "]"}], "=", "True"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"s", ",", "t"}], "}"}], "=", RowBox[{"nextCandidate", "[", RowBox[{"s", ",", "t", ",", RowBox[{"pAdj", "[", "t", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"face", "=", RowBox[{"Join", "[", RowBox[{"face", ",", RowBox[{"{", "s", "}"}]}], "]"}]}], ";"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Sow", "[", "face", "]"}], ";"}]}], "]"}], ",", RowBox[{"{", RowBox[{"e", ",", RowBox[{"EdgeList", "[", "g", "]"}]}], "}"}]}], "]"}], "]"}], "[", RowBox[{"[", RowBox[{"2", ",", "1"}], "]"}], "]"}]}]}], "]"}]}]}], "Input", CellChangeTimes->{{3.8312108953940573`*^9, 3.831210895411563*^9}, 3.8312119634327393`*^9, 3.831542420732052*^9, {3.834688353349917*^9, 3.8346883534550037`*^9}}, CellLabel->"In[14]:=",ExpressionUUID->"5cb4f612-3c02-42ac-ad57-4fb2daf3366b"], Cell[BoxData[ RowBox[{ RowBox[{"findGenerators", "[", RowBox[{"faces_", ",", "vertices_", ",", "G_"}], "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{ "face", ",", "otherVertex", ",", "verticesOnFace", ",", "allVertices", ",", "Gp", ",", "P", ",", "Gnew", ",", "L", ",", "Q", ",", "Qform", ",", "sol1", ",", "sol2", ",", "sols", ",", "coeff", ",", "coeffTable", ",", "small", ",", "Li", ",", "P2"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"face", "=", RowBox[{"faces", "[", RowBox[{"[", "i", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"verticesOnFace", "=", RowBox[{"Sort", "[", RowBox[{"RandomSample", "[", RowBox[{"face", ",", "3"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"otherVertex", "=", RowBox[{"RandomChoice", "[", RowBox[{"Select", "[", RowBox[{"vertices", ",", RowBox[{ RowBox[{"Not", "[", RowBox[{"MemberQ", "[", RowBox[{"face", ",", "#"}], "]"}], "]"}], "&"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"allVertices", "=", RowBox[{"Append", "[", RowBox[{"verticesOnFace", ",", "otherVertex"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"P", "=", RowBox[{"Transpose", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"IdentityMatrix", "[", RowBox[{"Length", "[", "vertices", "]"}], "]"}], "[", RowBox[{"[", "#", "]"}], "]"}], "&"}], "/@", RowBox[{"DeleteDuplicates", "[", RowBox[{"Join", "[", RowBox[{"allVertices", ",", "vertices"}], "]"}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Gnew", "=", RowBox[{ RowBox[{"Transpose", "[", "P", "]"}], ".", "G", ".", "P"}]}], ";", "\[IndentingNewLine]", RowBox[{"L", "=", RowBox[{"linearRelationsMatrix", "[", "Gnew", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Gp", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"G", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "allVertices"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "allVertices"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Q", "=", RowBox[{"Inverse", "[", "Gp", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Qform", "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"#", ".", "Q", ".", "#"}], "&"}], "[", RowBox[{"Table", "[", RowBox[{ SubscriptBox["b", "j"], ",", RowBox[{"{", RowBox[{"j", ",", "allVertices"}], "}"}]}], "]"}], "]"}], ")"}], "\[Equal]", "0"}]}], ";", "\[IndentingNewLine]", RowBox[{"sols", "=", RowBox[{"Expand", "[", RowBox[{"FullSimplify", "[", RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], "&"}], "/@", RowBox[{"Solve", "[", RowBox[{"Qform", ",", SubscriptBox["b", "otherVertex"]}], "]"}]}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"coeff", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"sols", "/.", RowBox[{"Table", "[", RowBox[{ RowBox[{ SubscriptBox["b", "i"], "\[Rule]", RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[Equal]", "curr"}], ",", "1", ",", "0"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "allVertices"}], "}"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"curr", ",", "allVertices"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"small", "=", RowBox[{"IdentityMatrix", "[", RowBox[{"Length", "[", "allVertices", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"small", "[", RowBox[{"[", RowBox[{"-", "1"}], "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[Equal]", "4"}], ",", RowBox[{"-", "1"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"verticesOnFace", ",", RowBox[{"allVertices", "[", RowBox[{"[", "j", "]"}], "]"}]}], "]"}], ",", RowBox[{"coeff", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "0"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"Length", "[", "allVertices", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Li", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[Equal]", "k"}], ",", "1", ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"Length", "[", "vertices", "]"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "allVertices"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"P2", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[Equal]", "k"}], ",", "1", ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"Length", "[", "vertices", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"DeleteDuplicates", "[", RowBox[{"Join", "[", RowBox[{"allVertices", ",", "vertices"}], "]"}], "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"P2", ".", "L", ".", "small", ".", "Li"}]}]}], "\[IndentingNewLine]", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "faces", "]"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.831211980673108*^9, 3.831212009547978*^9}, { 3.831212047936781*^9, 3.831212064698745*^9}, {3.831212136824675*^9, 3.8312121924739923`*^9}, {3.83121282873549*^9, 3.831212895555662*^9}, { 3.8312129593096933`*^9, 3.831213052703521*^9}, {3.8312133826923237`*^9, 3.831213512078041*^9}, {3.831213579312004*^9, 3.831213607562201*^9}, { 3.8312136458477*^9, 3.8312136689119587`*^9}, {3.831213699813815*^9, 3.831213723704392*^9}, {3.8312138140717983`*^9, 3.831213889152441*^9}, { 3.831213941035733*^9, 3.831213957988277*^9}, {3.831213991504438*^9, 3.831214049771612*^9}, {3.8312142057843103`*^9, 3.831214227198838*^9}, { 3.8313934326708517`*^9, 3.83139343995124*^9}, {3.831393489506013*^9, 3.831393506386162*^9}, {3.831393555227632*^9, 3.8313935602186413`*^9}, { 3.8313936045286083`*^9, 3.83139367389612*^9}, {3.831393815407503*^9, 3.8313939935486803`*^9}, {3.83139404462208*^9, 3.831394092415612*^9}, { 3.831394131767799*^9, 3.831394217388193*^9}, {3.831394341420259*^9, 3.831394342312114*^9}, {3.83139445920255*^9, 3.8313945442248793`*^9}, { 3.8313945973518257`*^9, 3.831394680082652*^9}, {3.8313947347981873`*^9, 3.831394898892132*^9}, {3.83139493417336*^9, 3.831395053557044*^9}, { 3.831395100567893*^9, 3.83139518418989*^9}, {3.831395217466712*^9, 3.831395241186327*^9}, {3.831395355721635*^9, 3.8313954066678057`*^9}, { 3.831395475153723*^9, 3.831395516960009*^9}, {3.83139559485061*^9, 3.8313956385922327`*^9}, {3.831395769312038*^9, 3.8313958340021877`*^9}, { 3.831395865647847*^9, 3.83139610784988*^9}, {3.831396182381921*^9, 3.831396202527211*^9}, {3.8313962730948772`*^9, 3.8313963875560293`*^9}, { 3.831396427697093*^9, 3.8313965616329517`*^9}, {3.831396608167254*^9, 3.83139664360338*^9}, {3.83139670106045*^9, 3.8313967846470547`*^9}, { 3.8313968308609743`*^9, 3.8313969389717007`*^9}, 3.831396972519156*^9, { 3.831397018773802*^9, 3.831397020188629*^9}, {3.831397062011731*^9, 3.831397076917077*^9}, {3.8313971287749977`*^9, 3.8313971288803463`*^9}, { 3.831397158974574*^9, 3.831397164029716*^9}, {3.831451905653893*^9, 3.831451941106399*^9}, {3.8314519809069433`*^9, 3.831452094855884*^9}, { 3.831542443369563*^9, 3.83154246854852*^9}, {3.831542595276044*^9, 3.8315426013894053`*^9}, {3.831542828964487*^9, 3.831542862477805*^9}, 3.8315429215303297`*^9, {3.831543065147149*^9, 3.831543089933201*^9}, { 3.8315431288434877`*^9, 3.831543129636121*^9}, {3.83154323687431*^9, 3.831543260658288*^9}, {3.831543295045744*^9, 3.831543299689423*^9}, 3.831543486496207*^9, {3.831543653211835*^9, 3.831543654095707*^9}, { 3.831544292671633*^9, 3.8315442949499702`*^9}, {3.831544329733664*^9, 3.831544394563963*^9}, {3.831544636528879*^9, 3.831544663053648*^9}, 3.831544723323721*^9, 3.831546276666531*^9, {3.8315463223978786`*^9, 3.831546322569023*^9}, {3.831546446056045*^9, 3.83154644840313*^9}, { 3.8315465437277803`*^9, 3.8315465842454453`*^9}, {3.8315466426699533`*^9, 3.831546646606488*^9}, {3.831546727818715*^9, 3.831546788772341*^9}, { 3.831546839246593*^9, 3.8315468396090813`*^9}, {3.83154706753721*^9, 3.8315471373421164`*^9}, {3.831549700570283*^9, 3.831549703647592*^9}, { 3.8315497447736797`*^9, 3.831549761864801*^9}, {3.831549996792459*^9, 3.831550026202232*^9}, {3.831550732962453*^9, 3.831550735264537*^9}, { 3.8315509704443493`*^9, 3.8315509727254343`*^9}, {3.831551320669722*^9, 3.831551407002722*^9}, 3.831551438305327*^9, {3.8315518862869797`*^9, 3.831551891551553*^9}, {3.831552338431473*^9, 3.8315523578513947`*^9}, { 3.8315524412649384`*^9, 3.831552441791979*^9}, {3.831552847687746*^9, 3.8315528556641293`*^9}, {3.83172514482829*^9, 3.831725228085017*^9}, { 3.831725320892393*^9, 3.8317253386411657`*^9}, {3.8317254340311728`*^9, 3.831725440268997*^9}, {3.8317255156810293`*^9, 3.8317256205301943`*^9}, { 3.831725829008904*^9, 3.831725851322979*^9}, {3.831726730605854*^9, 3.8317267923612432`*^9}, 3.833968804473505*^9}, CellLabel->"In[16]:=",ExpressionUUID->"df61872a-1e93-4b2b-ad66-1c8fee203402"], Cell[BoxData[ RowBox[{ RowBox[{"findGeneratorsN", "[", RowBox[{"faces_", ",", "vertices_", ",", "G_"}], "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{ "face", ",", "otherVertex", ",", "verticesOnFace", ",", "allVertices", ",", "Gp", ",", "P", ",", "Gnew", ",", "L", ",", "Q", ",", "Qform", ",", "sol1", ",", "sol2", ",", "sols", ",", "coeff", ",", "coeffTable", ",", "small", ",", "Li", ",", "P2"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"face", "=", RowBox[{ "faces", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}]}], ";", "\[IndentingNewLine]", RowBox[{"verticesOnFace", "=", RowBox[{"Sort", "[", RowBox[{"RandomSample", "[", RowBox[{"face", ",", "3"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"otherVertex", "=", RowBox[{"RandomChoice", "[", RowBox[{"Select", "[", RowBox[{"vertices", ",", RowBox[{ RowBox[{"Not", "[", RowBox[{"MemberQ", "[", RowBox[{"face", ",", "#"}], "]"}], "]"}], "&"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"allVertices", "=", RowBox[{"Append", "[", RowBox[{"verticesOnFace", ",", "otherVertex"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"P", "=", RowBox[{"Transpose", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"IdentityMatrix", "[", RowBox[{"Length", "[", "vertices", "]"}], "]"}], "\[LeftDoubleBracket]", "#", "\[RightDoubleBracket]"}], "&"}], "/@", RowBox[{"DeleteDuplicates", "[", RowBox[{"Join", "[", RowBox[{"allVertices", ",", "vertices"}], "]"}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Gnew", "=", RowBox[{ RowBox[{"Transpose", "[", "P", "]"}], ".", "G", ".", "P"}]}], ";", "\[IndentingNewLine]", RowBox[{"L", "=", RowBox[{"linearRelationsMatrix", "[", "Gnew", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Gp", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"G", "\[LeftDoubleBracket]", RowBox[{"i", ",", "j"}], "\[RightDoubleBracket]"}], ",", RowBox[{"{", RowBox[{"i", ",", "allVertices"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "allVertices"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Q", "=", RowBox[{"Inverse", "[", "Gp", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Qform", "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"#", ".", "Q", ".", "#"}], "&"}], "[", RowBox[{"Table", "[", RowBox[{ SubscriptBox["b", "j"], ",", RowBox[{"{", RowBox[{"j", ",", "allVertices"}], "}"}]}], "]"}], "]"}], ")"}], "\[Equal]", "0"}]}], ";", "\[IndentingNewLine]", RowBox[{"sols", "=", RowBox[{"Expand", "[", RowBox[{"FullSimplify", "[", RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ "#", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], "&"}], "/@", RowBox[{"NSolve", "[", RowBox[{"Qform", ",", SubscriptBox["b", "otherVertex"]}], "]"}]}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"coeff", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"sols", "/.", RowBox[{"Table", "[", RowBox[{ RowBox[{ SubscriptBox["b", "i"], "\[Rule]", RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[Equal]", "curr"}], ",", "1", ",", "0"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "allVertices"}], "}"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"curr", ",", "allVertices"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"small", "=", RowBox[{"IdentityMatrix", "[", RowBox[{"Length", "[", "allVertices", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"small", "\[LeftDoubleBracket]", RowBox[{"-", "1"}], "\[RightDoubleBracket]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[Equal]", "4"}], ",", RowBox[{"-", "1"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"verticesOnFace", ",", RowBox[{ "allVertices", "\[LeftDoubleBracket]", "j", "\[RightDoubleBracket]"}]}], "]"}], ",", RowBox[{ "coeff", "\[LeftDoubleBracket]", "j", "\[RightDoubleBracket]"}], ",", "0"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"Length", "[", "allVertices", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Li", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[Equal]", "k"}], ",", "1", ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"Length", "[", "vertices", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", "allVertices"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"P2", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"j", "\[Equal]", "k"}], ",", "1", ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"Length", "[", "vertices", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"DeleteDuplicates", "[", RowBox[{"Join", "[", RowBox[{"allVertices", ",", "vertices"}], "]"}], "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"P2", ".", "L", ".", "small", ".", "Li"}]}]}], "\[IndentingNewLine]", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "faces", "]"}]}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.833981987629899*^9, 3.83398199939977*^9}, { 3.834688227481195*^9, 3.834688274556583*^9}, {3.83468883312962*^9, 3.834688836641605*^9}, {3.834688881355237*^9, 3.834688884801515*^9}, { 3.8346889307534027`*^9, 3.834689029259427*^9}, {3.834689161206604*^9, 3.8346891613731537`*^9}}, CellLabel->"In[17]:=",ExpressionUUID->"dab3b84f-3f49-42e4-9bc4-79cb6408f946"], Cell[BoxData[ RowBox[{ RowBox[{"findGeneratorsFromG", "[", "G_", "]"}], ":=", RowBox[{"findGeneratorsN", "[", RowBox[{ RowBox[{"FindFace", "[", RowBox[{"PlanarGraph", "[", RowBox[{"AdjacencyGraph", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"#", "\[Equal]", RowBox[{"-", "1"}]}], ",", "1", ",", "0"}], "]"}], "&"}], "/@", "#"}], "&"}], "/@", "G"}], ",", RowBox[{"VertexLabels", "\[Rule]", "\"\\""}]}], "]"}], "]"}], "]"}], ",", RowBox[{"Range", "[", RowBox[{"Length", "[", "G", "]"}], "]"}], ",", "G"}], "]"}]}]], "Input", CellChangeTimes->{{3.831554845925479*^9, 3.8315548977219877`*^9}, 3.833982029038528*^9}, CellLabel->"In[18]:=",ExpressionUUID->"bd52b017-bd99-4bdf-9126-b7c62804c9f2"], Cell[BoxData[ RowBox[{ RowBox[{"search", "[", RowBox[{ "generators_", ",", "current_", ",", "lastgen_", ",", "upperBound_", ",", "faces_"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"totals", ",", "invalid"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"invalid", "[", RowBox[{"\[Sigma]_", ",", "face_"}], "]"}], ":=", RowBox[{ RowBox[{"\[Sigma]", "\[Equal]", "lastgen"}], "||", RowBox[{"AllTrue", "[", RowBox[{ RowBox[{"Delete", "[", RowBox[{ RowBox[{"\[Sigma]", ".", "current"}], ",", RowBox[{ RowBox[{ RowBox[{"{", "#", "}"}], "&"}], "/@", "face"}]}], "]"}], ",", RowBox[{ RowBox[{"#", ">", "upperBound"}], "&"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"totals", "[", "i_", "]"}], ":=", RowBox[{"If", "[", RowBox[{ RowBox[{"invalid", "[", RowBox[{ RowBox[{ "generators", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], ",", RowBox[{ "faces", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}]}], "]"}], ",", "0", ",", RowBox[{ RowBox[{"Length", "[", "current", "]"}], "-", RowBox[{"Length", "[", RowBox[{ "faces", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], "]"}], "-", RowBox[{"Length", "[", RowBox[{"Select", "[", RowBox[{ RowBox[{"Delete", "[", RowBox[{ RowBox[{ RowBox[{ "generators", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], ".", "current"}], ",", RowBox[{ RowBox[{ RowBox[{"{", "#", "}"}], "&"}], "/@", RowBox[{ "faces", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}]}]}], "]"}], ",", RowBox[{ RowBox[{"#", ">", "upperBound"}], "&"}]}], "]"}], "]"}], "+", RowBox[{"search", "[", RowBox[{"generators", ",", RowBox[{ RowBox[{ "generators", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], ".", "current"}], ",", RowBox[{ "generators", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], ",", "upperBound", ",", "faces"}], "]"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Total", "[", RowBox[{"totals", "/@", RowBox[{"Range", "[", RowBox[{"Length", "[", "generators", "]"}], "]"}]}], "]"}]}]}], "]"}]}]], "Input", CellChangeTimes->{{3.831585478390266*^9, 3.831585832096991*^9}, { 3.831585873047202*^9, 3.831585884320414*^9}, {3.8315859333563128`*^9, 3.83158598633525*^9}, {3.831586158378029*^9, 3.831586222152265*^9}, { 3.831586295582384*^9, 3.831586377705759*^9}, {3.8315864822120523`*^9, 3.831586554779951*^9}, {3.8315866296308203`*^9, 3.831586667667411*^9}, { 3.831586741340292*^9, 3.831586755993217*^9}, {3.831592107164525*^9, 3.831592113959847*^9}, {3.831592169716857*^9, 3.831592280561895*^9}, { 3.831593557409717*^9, 3.8315935576894217`*^9}, {3.831593848468913*^9, 3.8315939374159*^9}, {3.831593976921562*^9, 3.831594001541377*^9}, { 3.8315940487580757`*^9, 3.8315940927666388`*^9}, {3.831594365932665*^9, 3.831594522762847*^9}, {3.831594614138864*^9, 3.831594754985476*^9}, { 3.8315949767507057`*^9, 3.831594980589171*^9}, {3.8316319386522493`*^9, 3.8316319392747498`*^9}, {3.831641985178143*^9, 3.831642038615139*^9}, 3.8316436263727818`*^9, {3.831643663092218*^9, 3.8316436694418087`*^9}, { 3.831643837833714*^9, 3.831643845617309*^9}, {3.8316438865181704`*^9, 3.831643933219273*^9}, {3.831643991735036*^9, 3.831644005728479*^9}, { 3.831718518985198*^9, 3.831718538584508*^9}, {3.831718573982415*^9, 3.831718579591817*^9}, {3.831718638646072*^9, 3.83171867240186*^9}, { 3.8317201135527287`*^9, 3.831720118218873*^9}, {3.831720321587966*^9, 3.831720325967662*^9}, {3.831721027895946*^9, 3.831721065838575*^9}, { 3.831721143231716*^9, 3.831721181846493*^9}, {3.831721396838306*^9, 3.83172139923806*^9}, {3.831721668116399*^9, 3.831721676695764*^9}, { 3.831723288861394*^9, 3.831723291074202*^9}, {3.83172431511852*^9, 3.831724317665661*^9}, 3.833891293020659*^9, {3.834269383514792*^9, 3.834269386321598*^9}, {3.834269487189498*^9, 3.8342694873961067`*^9}, { 3.834270103611849*^9, 3.834270107267815*^9}, {3.834270430339264*^9, 3.834270430502697*^9}, {3.834271267146653*^9, 3.834271275112032*^9}, { 3.834351949243196*^9, 3.834351950526677*^9}, {3.834352089916841*^9, 3.834352127810135*^9}, {3.8346566614593353`*^9, 3.8346566626212893`*^9}, { 3.834656744290606*^9, 3.8346567586616583`*^9}, {3.834659006866577*^9, 3.834659016440263*^9}, {3.8346706664345417`*^9, 3.834670668758758*^9}, { 3.834671395332242*^9, 3.83467148748079*^9}, {3.834671580308955*^9, 3.834671642730775*^9}, {3.834671988628789*^9, 3.834671991147118*^9}, { 3.83467255246567*^9, 3.8346725653260603`*^9}}, CellLabel->"In[19]:=",ExpressionUUID->"4186f080-27d0-474f-9433-7cdeb3a7a49d"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"$RecursionLimit", "=", "16384"}]], "Input", CellChangeTimes->{{3.833893222127377*^9, 3.833893227672316*^9}, { 3.83397931096562*^9, 3.833979311902438*^9}, {3.833982525256192*^9, 3.833982529177711*^9}, {3.833982918567665*^9, 3.8339829240001698`*^9}}, CellLabel->"In[20]:=",ExpressionUUID->"a546161f-063b-4b38-811b-1f5d9ac28696"], Cell[BoxData["16384"], "Output", CellChangeTimes->{ 3.8338932281018763`*^9, 3.8339758669967527`*^9, 3.833979312227579*^9, 3.833979916481537*^9, 3.833980236024199*^9, 3.833980842837739*^9, 3.83398098522823*^9, 3.833981016536418*^9, {3.83398252603516*^9, 3.833982529689131*^9}, {3.8339829193261623`*^9, 3.8339829508363667`*^9}, 3.8339830049394903`*^9, 3.833985185839014*^9, {3.833985309697896*^9, 3.833985324982264*^9}, {3.8339855257030573`*^9, 3.8339855467146*^9}, 3.833989922637932*^9, 3.833990186870085*^9, 3.833993648764943*^9, { 3.83399468620287*^9, 3.8339947024536467`*^9}, 3.833995688332788*^9, { 3.833997659712306*^9, 3.833997676964181*^9}, {3.83399771946511*^9, 3.833997735813401*^9}, 3.833997886970297*^9, 3.833998804781659*^9, 3.833998949886093*^9, 3.833999546282991*^9, 3.834002950053997*^9, 3.834008369614998*^9, 3.834008404771652*^9, 3.834012063580451*^9, { 3.8340125211494923`*^9, 3.834012544564479*^9}, {3.834012632134491*^9, 3.834012669541378*^9}, {3.8340129486241903`*^9, 3.834012994884214*^9}, 3.834013025749654*^9, {3.8340516513410587`*^9, 3.834051710003538*^9}, 3.834061107105874*^9, {3.834061368190651*^9, 3.8340614192869053`*^9}, { 3.8340617843815823`*^9, 3.834061797970849*^9}, {3.834065075805954*^9, 3.834065147762154*^9}, {3.8340672561763277`*^9, 3.834067310718713*^9}, { 3.834069699109585*^9, 3.834069709702557*^9}, 3.834092717521625*^9, 3.834097171624065*^9, 3.8341343872984047`*^9, 3.834142620775568*^9, 3.834145530968349*^9, 3.834146073235483*^9, 3.8341809139458323`*^9, 3.834269357761674*^9, 3.8342693933710947`*^9, 3.834269448502894*^9, 3.834269494050521*^9, {3.8342695663389606`*^9, 3.8342696026888247`*^9}, 3.8342701160872383`*^9, 3.834270161194154*^9, 3.834270438333136*^9, 3.834270555594716*^9, {3.834271103264781*^9, 3.834271120536076*^9}, 3.834271489584754*^9, 3.834271596271693*^9, 3.834272147258156*^9, 3.834351698339382*^9, {3.834351996635762*^9, 3.834352017390819*^9}, 3.834363957483852*^9, {3.834364187716065*^9, 3.834364198004562*^9}, 3.8344822107164927`*^9, 3.83456973372355*^9, 3.834575082919744*^9, 3.834577447902966*^9, 3.8345890154068213`*^9, 3.834619110878572*^9, { 3.834619146500414*^9, 3.834619200887533*^9}, 3.834620064417549*^9, 3.834622032092245*^9, 3.8346548822352743`*^9, 3.834654946056427*^9, { 3.8346646221002398`*^9, 3.8346646607444057`*^9}, 3.834666963392949*^9, 3.8346675010015087`*^9, 3.83467065066402*^9, 3.834670688395502*^9, 3.834670724619562*^9, 3.8346707922130203`*^9, 3.834672572650928*^9, { 3.834672606536978*^9, 3.834672633714957*^9}, 3.834688011488668*^9, 3.834741745404797*^9}, CellLabel->"Out[20]=",ExpressionUUID->"4556071e-a1ae-4f56-bd89-317072a8ba00"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"fractalDimensionFromG", "[", RowBox[{"G_", ",", "max_", ",", "delta_", ",", "root_"}], "]"}], ":=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{ "xs", ",", "ys", ",", "data", ",", "graph", ",", "faces", ",", "sigmas", ",", "nlm", ",", "params"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"xs", "=", RowBox[{"Range", "[", RowBox[{"delta", ",", "max", ",", "delta"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"graph", "=", RowBox[{"graphFromG", "[", "G", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"faces", "=", RowBox[{"FindFace", "[", "graph", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sigmas", "=", RowBox[{"findGeneratorsFromG", "[", "G", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ys", "=", RowBox[{ RowBox[{ RowBox[{ RowBox[{"search", "[", RowBox[{"sigmas", ",", "root", ",", RowBox[{"{", "}"}], ",", "#", ",", "faces"}], "]"}], "+", RowBox[{"Length", "[", "root", "]"}]}], "&"}], "/@", "xs"}]}], ";", "\[IndentingNewLine]", RowBox[{"data", "=", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ "xs", "\[LeftDoubleBracket]", "#", "\[RightDoubleBracket]"}], ",", RowBox[{ "ys", "\[LeftDoubleBracket]", "#", "\[RightDoubleBracket]"}]}], "}"}], "&"}], "/@", RowBox[{"Range", "[", RowBox[{"Length", "[", "ys", "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"nlm", "=", RowBox[{"NonlinearModelFit", "[", RowBox[{"data", ",", RowBox[{"a", " ", SuperscriptBox["x", "b"]}], ",", RowBox[{"{", RowBox[{"a", ",", "b"}], "}"}], ",", "x"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"params", "=", RowBox[{"nlm", "[", "\"\\"", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"nlm", "[", "\"\\"", "]"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"b", "/.", "params"}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.8339647725688353`*^9, 3.8339649328744087`*^9}, { 3.833965051157412*^9, 3.8339650578368483`*^9}, {3.833965560813403*^9, 3.8339655739990377`*^9}, {3.833965620539852*^9, 3.833965639062742*^9}, { 3.833965942784672*^9, 3.833965996602522*^9}, {3.8342709119109173`*^9, 3.8342709184846773`*^9}, {3.834271399281299*^9, 3.834271400142085*^9}, { 3.8345760352900133`*^9, 3.834576035855191*^9}, {3.834594490350781*^9, 3.834594498152722*^9}}, CellLabel->"In[21]:=",ExpressionUUID->"3971d33a-d19f-42ea-9b17-0801f7a59659"], Cell[BoxData[ RowBox[{ RowBox[{"pyramidG", "[", "n_", "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Which", "[", RowBox[{ RowBox[{ RowBox[{"i", "\[Equal]", "0"}], "&&", RowBox[{"j", "\[Equal]", "0"}]}], ",", "1", ",", RowBox[{ RowBox[{"i", "\[Equal]", "0"}], "||", RowBox[{"j", "\[Equal]", "0"}]}], ",", RowBox[{"-", "1"}], ",", "True", ",", RowBox[{"1", "-", FractionBox[ RowBox[{"2", SuperscriptBox[ RowBox[{"Sin", "[", FractionBox[ RowBox[{ RowBox[{"Abs", "[", RowBox[{"i", "-", "j"}], "]"}], "\[Pi]"}], "n"], "]"}], "2"]}], SuperscriptBox[ RowBox[{"Sin", "[", FractionBox["\[Pi]", "n"], "]"}], "2"]]}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", "n"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "0", ",", "n"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.833978075492923*^9, 3.833978098104927*^9}, { 3.833978140873678*^9, 3.833978187704298*^9}, {3.833979750071292*^9, 3.833979764905096*^9}, {3.833980891992284*^9, 3.833980904095957*^9}}, CellLabel->"In[22]:=",ExpressionUUID->"3db5443f-dda7-4082-8ab7-96e274634389"], Cell[BoxData[ RowBox[{ RowBox[{"pyramidFractalDimension", "[", RowBox[{"n_", ",", "max_", ",", "delta_"}], "]"}], ":=", RowBox[{"fractalDimensionFromG", "[", RowBox[{ RowBox[{"N", "[", RowBox[{"pyramidG", "[", "n", "]"}], "]"}], ",", "max", ",", "delta", ",", RowBox[{"N", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[Equal]", RowBox[{"n", "+", "1"}]}], ",", RowBox[{"-", "1"}], ",", FractionBox[ RowBox[{ RowBox[{"Sec", "[", FractionBox["\[Pi]", "n"], "]"}], "+", RowBox[{"Tan", "[", FractionBox["\[Pi]", "n"], "]"}]}], RowBox[{"Tan", "[", FractionBox["\[Pi]", "n"], "]"}]]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"n", "+", "1"}]}], "}"}]}], "]"}], "]"}]}], "]"}]}]], "Input",\ CellChangeTimes->{{3.833978967161902*^9, 3.8339789914381647`*^9}, { 3.833979205542704*^9, 3.833979255368734*^9}, {3.833979399981943*^9, 3.833979410979437*^9}, {3.8339798534902363`*^9, 3.833979853676499*^9}, { 3.8339800331837673`*^9, 3.833980033963599*^9}, {3.833981434488759*^9, 3.8339814414612226`*^9}, {3.833981948527481*^9, 3.8339819534472733`*^9}}, CellLabel->"In[23]:=",ExpressionUUID->"52eb731d-d72b-4ff7-afc4-5691e9750e37"], Cell[BoxData[ RowBox[{ RowBox[{"pyramidTuple", "[", "n_", "]"}], ":=", RowBox[{"N", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "\[Equal]", RowBox[{"n", "+", "1"}]}], ",", RowBox[{"-", "1"}], ",", FractionBox[ RowBox[{ RowBox[{"Sec", "[", FractionBox["\[Pi]", "n"], "]"}], "+", RowBox[{"Tan", "[", FractionBox["\[Pi]", "n"], "]"}]}], RowBox[{"Tan", "[", FractionBox["\[Pi]", "n"], "]"}]]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"n", "+", "1"}]}], "}"}]}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.8346584900042677`*^9, 3.834658495237359*^9}}, CellLabel->"In[24]:=",ExpressionUUID->"6e172e8f-4972-4597-9559-948bf406a2c4"] }, WindowSize->{1425., 776.25}, WindowMargins->{{7.5, Automatic}, {7.5, Automatic}}, TaggingRules->{ "WelcomeScreenSettings" -> {"FEStarting" -> False}, "TryRealOnly" -> False}, FrontEndVersion->"12.2 for Linux x86 (64-bit) (December 12, 2020)", StyleDefinitions->"Default.nb", ExpressionUUID->"e8622aad-0bd2-483b-a68b-2a26bc5485be" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[558, 20, 418, 9, 29, "Input",ExpressionUUID->"e1bc883b-2413-4a7d-abe0-4a19eb3f78fd"], Cell[979, 31, 1029, 27, 29, "Input",ExpressionUUID->"025b5df5-f2a6-4cee-a294-e76ee16e74d4"], Cell[2011, 60, 509, 11, 29, "Input",ExpressionUUID->"54cc4a6c-be37-4091-ac21-3dfd11eb53ea"], Cell[2523, 73, 439, 11, 29, "Input",ExpressionUUID->"d3298122-6e10-4115-8e61-a949acba4e08"], Cell[2965, 86, 1415, 34, 29, "Input",ExpressionUUID->"4e2a5664-aeb5-4dfb-88fb-7e7839ba2141"], Cell[4383, 122, 342, 8, 29, "Input",ExpressionUUID->"c9a1b25a-8cb3-40d1-ac83-1d2405398934"], Cell[4728, 132, 1140, 33, 29, "Input",ExpressionUUID->"30b57c08-a123-4e7d-9b0a-b512fcfecee8"], Cell[5871, 167, 740, 20, 29, "Input",ExpressionUUID->"e30807a9-5381-4ad1-b9fd-a6a877ae69fe"], Cell[6614, 189, 671, 19, 29, "Input",ExpressionUUID->"d1264330-efcb-4ca7-a1c2-f6744f28eebe"], Cell[7288, 210, 708, 19, 29, "Input",ExpressionUUID->"efd0e321-9f31-4641-bf42-f73e16044635"], Cell[7999, 231, 548, 14, 29, "Input",ExpressionUUID->"810323e6-91cb-44f2-ad55-323fbec422eb"], Cell[8550, 247, 702, 19, 29, "Input",ExpressionUUID->"948959db-c926-4458-9e45-ef7f3fb99ba5"], Cell[9255, 268, 996, 28, 71, "Input",ExpressionUUID->"e7b8a43b-0fbc-4073-928d-10a091e21dd7"], Cell[10254, 298, 4042, 107, 298, "Input",ExpressionUUID->"5cb4f612-3c02-42ac-ad57-4fb2daf3366b"], Cell[14299, 407, 10810, 230, 422, "Input",ExpressionUUID->"df61872a-1e93-4b2b-ad66-1c8fee203402"], Cell[25112, 639, 7146, 178, 422, "Input",ExpressionUUID->"dab3b84f-3f49-42e4-9bc4-79cb6408f946"], Cell[32261, 819, 912, 24, 29, "Input",ExpressionUUID->"bd52b017-bd99-4bdf-9126-b7c62804c9f2"], Cell[33176, 845, 5346, 111, 113, "Input",ExpressionUUID->"4186f080-27d0-474f-9433-7cdeb3a7a49d"], Cell[CellGroupData[{ Cell[38547, 960, 357, 5, 29, "Input",ExpressionUUID->"a546161f-063b-4b38-811b-1f5d9ac28696"], Cell[38907, 967, 2766, 39, 33, "Output",ExpressionUUID->"4556071e-a1ae-4f56-bd89-317072a8ba00"] }, Open ]], Cell[41688, 1009, 2787, 67, 262, "Input",ExpressionUUID->"3971d33a-d19f-42ea-9b17-0801f7a59659"], Cell[44478, 1078, 1277, 34, 66, "Input",ExpressionUUID->"3db5443f-dda7-4082-8ab7-96e274634389"], Cell[45758, 1114, 1383, 34, 65, "Input",ExpressionUUID->"52eb731d-d72b-4ff7-afc4-5691e9750e37"], Cell[47144, 1150, 823, 23, 65, "Input",ExpressionUUID->"6e172e8f-4972-4597-9559-948bf406a2c4"] } ] *)