Circle-Packings/fractal_dimension/fractal_dimension.nb
William Ball 08eebc050f updates
2021-07-01 08:09:24 -04:00

1191 lines
48 KiB
Mathematica

(* 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[ 48647, 1183]
NotebookOptionsPosition[ 45943, 1141]
NotebookOutlinePosition[ 46344, 1157]
CellTagsIndexPosition[ 46301, 1154]
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", "[", "\[IndentingNewLine]",
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"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"i", "\[Equal]", "j"}], "&&",
RowBox[{"i", ">", "2"}]}], ",", "1", ",", "\[IndentingNewLine]",
"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}},
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", "[", "\[IndentingNewLine]",
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}},
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]", "\"\<Name\>\""}]}], "]"}],
"]"}]}]], "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", ",", "\"\<PlanarEmbedding\>\""}], "]"}]}], ";",
"\[IndentingNewLine]",
RowBox[{"FindFace", "[",
RowBox[{"g", ",", "emb"}], "]"}]}]}], "]"}]}], ";"}],
"\[IndentingNewLine]"}], "\n",
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},
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", "[",
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[{"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", "[",
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.833981987629899*^9, 3.83398199939977*^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]", "\"\<Name\>\""}]}], "]"}], "]"}],
"]"}], ",",
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_", ",", "previous_", ",", "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", "[",
RowBox[{"[", "i", "]"}], "]"}], ",",
RowBox[{"faces", "[",
RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",", "0", ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"Length", "[", "current", "]"}], "-",
RowBox[{"Length", "[",
RowBox[{"faces", "[",
RowBox[{"[", "i", "]"}], "]"}], "]"}], "-",
RowBox[{"Length", "[",
RowBox[{"Select", "[",
RowBox[{
RowBox[{"Delete", "[",
RowBox[{"current", ",",
RowBox[{
RowBox[{
RowBox[{"{", "#", "}"}], "&"}], "/@",
RowBox[{"faces", "[",
RowBox[{"[", "i", "]"}], "]"}]}]}], "]"}], ",",
RowBox[{
RowBox[{"#", ">", "upperBound"}], "&"}]}], "]"}], "]"}], "+",
RowBox[{"search", "[",
RowBox[{"generators", ",",
RowBox[{
RowBox[{"generators", "[",
RowBox[{"[", "i", "]"}], "]"}], ".", "current"}], ",", "current",
",",
RowBox[{"generators", "[",
RowBox[{"[", "i", "]"}], "]"}], ",", "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},
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},
CellLabel->"Out[20]=",ExpressionUUID->"299896e7-f4d5-4c1e-b36c-96dee19d0d36"]
}, 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[{"1", ",", "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[{"search", "[",
RowBox[{"sigmas", ",", "root", ",",
RowBox[{"{", "}"}], ",",
RowBox[{"{", "}"}], ",", "#", ",", "faces"}], "]"}], "&"}], "/@",
"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", "[", "\"\<BestFitParameters\>\"", "]"}]}], ";",
"\[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}},
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[CellGroupData[{
Cell[BoxData[
RowBox[{"Timing", "[",
RowBox[{"pyramidFractalDimension", "[",
RowBox[{"13", ",", "100000", ",", "5000"}], "]"}], "]"}]], "Input",
CellChangeTimes->CompressedData["
1:eJwd0n0s1HEcB/Cj8nDp4crYioWJckfc5Wk6RVxNFD2g21zrRsJKD1wMpXnY
aW6Uoi6ra+mPdMaYpVqoPGWmllKMOXV3Lk9FKo/p9/788d3rj+8+n+93n8/b
Xpp8OM6YxWKJmAOVbqUrXhaPB6gcvU2gpM+TDX2qU8nercJAOKo2CYbtVaHR
sGG2gNwzoo+FB81Hyffzc4VQJnJWwGlNWB10OaIlpYLxVsi3t2uDKU3NE3Cx
cozMDuLNwCyZ4i+0Yt8xbkSflk5S81BlCkVZNWRkpOUa6C6Uk9aVNhVQ4Mwl
H5fkcZrwX33NRtj5zsIeFiZWOsH1A/PesF+81wf2LtUKoXKQ5w/LDbG+zYx6
7lWSZ3csEcqzE0hroyLpK9wX3SPj17zNhc+re0hD3U/BG9Rp/5GS5RdJUNvX
T/qLj9fDi7/FpNds2DNoog4nW2d+8FsYW+QrBDCk/Nct2Oi/qhTa3q/d3or6
6NfkgC52JzRZNvKCeYcGg2F8e44Irnxhnga1pbvIxA8tDbBb95F0Nfuc08bY
kzBJug0n9UPx7gzyWo3Ss53xZISadMntb4C1Xw0k93s3vwPz4X4h8xZ6Hd4y
7j/zjTyaNR/TiX76EQnkLy95dDFuamDxYTY7LhFOLh5Jho2pWWkwRG64DCUW
9SpYesq5AnZM8Suhgv2ELPjQ5jWAvLrpSL11QP4Q3t8XRLo38Yrg5Uxfctqw
esc37N9HTQ6fuDAGT2TKyLUslaMWueY9Iq8vFwTDdFkZ6RKuSIfsunJyLqS4
G57W3CUnWx+Y6hhvaqpIQWbCFXhOmE7e5pRZ6pHLCCWZumHBBgYqzW1hSv3T
rSOMzX5tZL7CyRUOTQhIm0/PIw2MXRmDUTBzQWQ2ivkbRZGmQ+dDpxnDt8hJ
M7W5Eko5HPLGzikddPr5h4zRJAl+MR5QpZMGJ+MSGBjMIfVJ9ptnGNdt8yDv
pVl1QMclB1LleLb5N+MlPxX5H70PdsY=
"],
CellLabel->"In[24]:=",ExpressionUUID->"00d846ff-ba2d-4cd3-a367-6099b9094d1e"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"5810.517884`", ",", "1.3226209682694214`"}], "}"}]], "Output",
CellChangeTimes->{3.834073037328405*^9, 3.834080358442856*^9,
3.83409056453896*^9, 3.834091284692438*^9, 3.83409188242869*^9,
3.834092639669347*^9, 3.834093669438568*^9, 3.8340951224331083`*^9,
3.834097070082343*^9, 3.834102985541628*^9},
CellLabel->"Out[24]=",ExpressionUUID->"4f0a289e-6a4f-487e-8412-7b3a421e3b51"]
}, Open ]]
},
WindowSize->{1425., 776.25},
WindowMargins->{{7.5, Automatic}, {7.5, Automatic}},
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, 1053, 27, 92, "Input",ExpressionUUID->"025b5df5-f2a6-4cee-a294-e76ee16e74d4"],
Cell[2035, 60, 509, 11, 29, "Input",ExpressionUUID->"54cc4a6c-be37-4091-ac21-3dfd11eb53ea"],
Cell[2547, 73, 439, 11, 29, "Input",ExpressionUUID->"d3298122-6e10-4115-8e61-a949acba4e08"],
Cell[2989, 86, 1406, 33, 51, "Input",ExpressionUUID->"4e2a5664-aeb5-4dfb-88fb-7e7839ba2141"],
Cell[4398, 121, 342, 8, 29, "Input",ExpressionUUID->"c9a1b25a-8cb3-40d1-ac83-1d2405398934"],
Cell[4743, 131, 1140, 33, 29, "Input",ExpressionUUID->"30b57c08-a123-4e7d-9b0a-b512fcfecee8"],
Cell[5886, 166, 740, 20, 29, "Input",ExpressionUUID->"e30807a9-5381-4ad1-b9fd-a6a877ae69fe"],
Cell[6629, 188, 671, 19, 29, "Input",ExpressionUUID->"d1264330-efcb-4ca7-a1c2-f6744f28eebe"],
Cell[7303, 209, 708, 19, 29, "Input",ExpressionUUID->"efd0e321-9f31-4641-bf42-f73e16044635"],
Cell[8014, 230, 548, 14, 29, "Input",ExpressionUUID->"810323e6-91cb-44f2-ad55-323fbec422eb"],
Cell[8565, 246, 702, 19, 29, "Input",ExpressionUUID->"948959db-c926-4458-9e45-ef7f3fb99ba5"],
Cell[9270, 267, 996, 28, 71, "Input",ExpressionUUID->"e7b8a43b-0fbc-4073-928d-10a091e21dd7"],
Cell[10269, 297, 3990, 106, 298, "Input",ExpressionUUID->"5cb4f612-3c02-42ac-ad57-4fb2daf3366b"],
Cell[14262, 405, 10810, 230, 422, "Input",ExpressionUUID->"df61872a-1e93-4b2b-ad66-1c8fee203402"],
Cell[25075, 637, 6823, 176, 422, "Input",ExpressionUUID->"dab3b84f-3f49-42e4-9bc4-79cb6408f946"],
Cell[31901, 815, 912, 24, 29, "Input",ExpressionUUID->"bd52b017-bd99-4bdf-9126-b7c62804c9f2"],
Cell[32816, 841, 4342, 93, 133, "Input",ExpressionUUID->"4186f080-27d0-474f-9433-7cdeb3a7a49d"],
Cell[CellGroupData[{
Cell[37183, 938, 357, 5, 29, "Input",ExpressionUUID->"a546161f-063b-4b38-811b-1f5d9ac28696"],
Cell[37543, 945, 1538, 22, 33, "Output",ExpressionUUID->"299896e7-f4d5-4c1e-b36c-96dee19d0d36"]
}, Open ]],
Cell[39096, 970, 2424, 60, 242, "Input",ExpressionUUID->"3971d33a-d19f-42ea-9b17-0801f7a59659"],
Cell[41523, 1032, 1277, 34, 66, "Input",ExpressionUUID->"3db5443f-dda7-4082-8ab7-96e274634389"],
Cell[42803, 1068, 1383, 34, 65, "Input",ExpressionUUID->"52eb731d-d72b-4ff7-afc4-5691e9750e37"],
Cell[CellGroupData[{
Cell[44211, 1106, 1283, 23, 29, "Input",ExpressionUUID->"00d846ff-ba2d-4cd3-a367-6099b9094d1e"],
Cell[45497, 1131, 430, 7, 56, "Output",ExpressionUUID->"4f0a289e-6a4f-487e-8412-7b3a421e3b51"]
}, Open ]]
}
]
*)