(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 135691, 3815] NotebookOptionsPosition[ 128413, 3594] NotebookOutlinePosition[ 128758, 3609] CellTagsIndexPosition[ 128715, 3606] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{"x_", ",", "y_", ",", "p_"}], "]"}], ":=", " ", RowBox[{"(*", " ", RowBox[{ "This", " ", "function", " ", "returns", " ", "the", " ", "quaternion", " ", "product", " ", "of", " ", "x", " ", "followed", " ", "by", " ", "y", " ", RowBox[{ RowBox[{"(", RowBox[{"mod", " ", "p"}], ")"}], "."}]}], " ", "*)"}], RowBox[{"(", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Length", "[", "x", "]"}], "\[NotEqual]", "4"}], "||", RowBox[{ RowBox[{"Length", "[", "y", "]"}], "\[NotEqual]", "4"}]}], ",", RowBox[{"Return", "[", "\"\\"", "]"}], ",", RowBox[{"Return", "[", RowBox[{"Mod", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "1", "]"}], "]"}]}], "-", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "2", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "2", "]"}], "]"}]}], "-", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "3", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "3", "]"}], "]"}]}], "-", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "4", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "4", "]"}], "]"}]}]}], ",", RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "2", "]"}], "]"}]}], "+", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "2", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "1", "]"}], "]"}]}], "+", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "3", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "4", "]"}], "]"}]}], "-", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "4", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "3", "]"}], "]"}]}]}], ",", RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "3", "]"}], "]"}]}], "-", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "2", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "4", "]"}], "]"}]}], "+", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "3", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "1", "]"}], "]"}]}], "+", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "4", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "2", "]"}], "]"}]}]}], ",", RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"[", "1", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "4", "]"}], "]"}]}], "+", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "2", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "3", "]"}], "]"}]}], "-", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "3", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "2", "]"}], "]"}]}], "+", RowBox[{ RowBox[{"x", "[", RowBox[{"[", "4", "]"}], "]"}], RowBox[{"y", "[", RowBox[{"[", "1", "]"}], "]"}]}]}]}], "}"}], ",", "p"}], "]"}], "]"}]}], "]"}], ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{ SubscriptBox["TransMatL", "4"], "[", "q_", "]"}], ":=", " ", RowBox[{"(*", " ", RowBox[{ "This", " ", "is", " ", "the", " ", "Transformation", " ", "Matrix", " ", "corresponding", " ", "to", " ", "quaternion", " ", "multiplication", " ", "from", " ", "the", " ", RowBox[{"Left", "."}]}], " ", "*)"}], RowBox[{"(", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}]}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}]}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}]}], ",", RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}]}], ",", RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "}"}], ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{ SubscriptBox["TransMatR", "4"], "[", "q_", "]"}], ":=", " ", RowBox[{"(*", " ", RowBox[{ "The", " ", "Transformation", " ", "Matrix", " ", "below", " ", "corresponds", " ", "to", " ", "quaternion", " ", "multiplication", " ", "from", " ", "the", " ", RowBox[{"Right", "."}]}], " ", "*)"}], RowBox[{"(", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}]}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}]}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}]}], ",", RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"q", "[", RowBox[{"[", "4", "]"}], "]"}], ",", RowBox[{"q", "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"-", RowBox[{"q", "[", RowBox[{"[", "2", "]"}], "]"}]}], ",", RowBox[{"q", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "}"}], ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"BuildUp", "[", RowBox[{"n_", ",", RowBox[{ SubscriptBox["Q", "1"], "_"}], ",", RowBox[{ SubscriptBox["Q", "2"], "_"}], ",", RowBox[{ SubscriptBox["Q", "3"], "_"}], ",", RowBox[{ SubscriptBox["Q", "4"], "_"}]}], "]"}], ":=", RowBox[{"(*", " ", RowBox[{"This", " ", "patches", " ", "together", " ", "4", " ", RowBox[{"(", RowBox[{"n", " ", "x", " ", "n"}], ")"}], " ", "quarters", " ", "to", " ", "return", " ", "a", " ", RowBox[{"(", RowBox[{"2", "n", " ", "x", " ", "2", "n"}], ")"}], " ", RowBox[{"matrix", "."}]}], " ", "*)"}], RowBox[{"(", RowBox[{"Return", "[", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{ SubscriptBox["Q", "1"], "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{ SubscriptBox["Q", "2"], "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "n"}], "}"}]}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{ SubscriptBox["Q", "3"], "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "n"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{ SubscriptBox["Q", "4"], "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "n"}], "}"}]}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "n"}], "}"}]}], "]"}]}], "]"}], "]"}], ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"PowerExtendedPartition", "[", "Mtx_", "]"}], ":=", RowBox[{"(", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "d", ",", "n", ",", "tmp", ",", "NumRows", ",", "NumCols", ",", "RowsQ", ",", "ColsQ"}], "}"}], ",", RowBox[{ RowBox[{"d", "=", RowBox[{"Dimensions", "[", "Mtx", "]"}]}], ";", RowBox[{"NumRows", "=", RowBox[{"d", "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", RowBox[{"NumCols", "=", RowBox[{"d", "[", RowBox[{"[", "2", "]"}], "]"}]}], ";", RowBox[{"n", "=", "1"}], ";", RowBox[{"Label", "[", "GetPower", "]"}], ";", RowBox[{"n", "=", RowBox[{"n", "+", "1"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"NumRows", ">", SuperscriptBox["2", "n"]}], ",", RowBox[{"Goto", "[", "GetPower", "]"}]}], "]"}], ";", RowBox[{"tmp", "=", "Mtx"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"NumRows", "<", SuperscriptBox["2", "n"]}], ",", RowBox[{ RowBox[{"tmp", "=", RowBox[{"IdentityMatrix", "[", SuperscriptBox["2", "n"], "]"}]}], ";", RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"tmp", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"Mtx", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "NumRows"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "NumCols"}], "}"}]}], "]"}]}]}], "]"}], ";", RowBox[{"RowsQ", "=", SuperscriptBox["2", RowBox[{"n", " ", "-", " ", "1"}]]}], ";", RowBox[{"ColsQ", "=", SuperscriptBox["2", RowBox[{"n", " ", "-", " ", "1"}]]}], ";", RowBox[{ SubscriptBox["Q", "1"], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"tmp", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "RowsQ"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "ColsQ"}], "}"}]}], "]"}]}], ";", RowBox[{ SubscriptBox["Q", "2"], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"tmp", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "RowsQ"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"ColsQ", "+", "1"}], ",", SuperscriptBox["2", "n"]}], "}"}]}], "]"}]}], ";", RowBox[{ SubscriptBox["Q", "3"], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"tmp", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"RowsQ", "+", "1"}], ",", SuperscriptBox["2", "n"]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "ColsQ"}], "}"}]}], "]"}]}], ";", RowBox[{ SubscriptBox["Q", "4"], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"tmp", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"RowsQ", "+", "1"}], ",", SuperscriptBox["2", "n"]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"ColsQ", "+", "1"}], ",", SuperscriptBox["2", "n"]}], "}"}]}], "]"}]}]}]}], "]"}], ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"SwitNeg", "[", "M_", "]"}], ":=", RowBox[{"(", RowBox[{"Return", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"M", "[", RowBox[{"[", RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", RowBox[{"-", RowBox[{"M", "[", RowBox[{"[", RowBox[{"1", ",", "2"}], "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", RowBox[{"M", "[", RowBox[{"[", RowBox[{"2", ",", "1"}], "]"}], "]"}]}], ",", RowBox[{"M", "[", RowBox[{"[", RowBox[{"1", ",", "1"}], "]"}], "]"}]}], "}"}]}], "}"}], "]"}], ")"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Inv", "[", RowBox[{"x_", ",", "p_"}], "]"}], ":=", RowBox[{"(", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "n", "}"}], ",", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Floor", "[", "x", "]"}], "\[NotEqual]", "x"}], ",", RowBox[{"Return", "[", "\"\\"", "]"}]}], "]"}], ";", RowBox[{"n", "=", RowBox[{"Mod", "[", RowBox[{"x", ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"n", "\[Equal]", "0"}], ",", RowBox[{"Return", "[", "\"\\"", "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"n", "\[Equal]", "1"}], "||", RowBox[{"n", "\[Equal]", RowBox[{"p", "-", "1"}]}]}], ",", RowBox[{"Return", "[", "n", "]"}]}], "]"}], ";", RowBox[{"st", "=", "1"}], ";", RowBox[{"Label", "[", "continue", "]"}], ";", RowBox[{"st", "=", RowBox[{"st", "+", "1"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"n", "*", "st"}], ",", "p"}], "]"}], "\[Equal]", "1"}], ",", RowBox[{"Return", "[", "st", "]"}], ",", RowBox[{"Goto", "[", "continue", "]"}]}], "]"}]}]}], "]"}], ")"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"The", " ", "Eight"}], "-", RowBox[{ "Step", " ", "Method", " ", "with", " ", "2", "x2", " ", "matrices"}]}], ",", " ", RowBox[{ "each", " ", "step", " ", "being", " ", "reduced", " ", "modulo", " ", "a", " ", "prime"}], ",", " ", RowBox[{"p", "."}]}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"ModPEP2x2", "[", RowBox[{"A_", ",", "B_", ",", "C_", ",", "D_", ",", "p_"}], "]"}], ":=", " ", RowBox[{"(*", " ", RowBox[{ "The", " ", "first", " ", "appropriate", " ", "PEP", " ", "Method", " ", "is", " ", RowBox[{"chosen", "."}]}], " ", "*)"}], RowBox[{"(", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"W", ",", "X", ",", "Y", ",", "Z"}], "}"}], ",", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "A", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "1"], "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "B", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "2"], "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "C", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "3"], "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "D", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "4"], "]"}], ",", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", RowBox[{"Return", "[", "\"\\"", "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "1"], "]"}], ";", RowBox[{"ivA", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "A", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"R1", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"-", "ivA"}], "*", RowBox[{"SwitNeg", "[", "A", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"S1", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"R1", ".", "B"}], ",", "p"}], "]"}]}], ";", RowBox[{"T1", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"C", ".", "S1"}], "+", "D"}], ",", "p"}], "]"}]}], ";", RowBox[{"iv", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "T1", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"iv", "\[Equal]", "\"\\""}], ",", RowBox[{"Return", "[", "\"\\"", "]"}]}], "]"}], ";", RowBox[{"Z", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"iv", "*", RowBox[{"SwitNeg", "[", "T1", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"X", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"S1", ".", "Z"}], ",", "p"}], "]"}]}], ";", RowBox[{"V1", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"C", ".", "R1"}], ",", "p"}], "]"}]}], ";", RowBox[{"Y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"Z", ".", "V1"}], ",", "p"}], "]"}]}], ";", RowBox[{"W", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"S1", ".", "Y"}], "-", "R1"}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", RowBox[{"BuildUp", "[", RowBox[{"2", ",", "W", ",", "X", ",", "Y", ",", "Z"}], "]"}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "2"], "]"}], ";", RowBox[{"ivB", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "B", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"R2", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"-", "ivB"}], "*", RowBox[{"SwitNeg", "[", "B", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"S2", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"R2", ".", "A"}], ",", "p"}], "]"}]}], ";", RowBox[{"T2", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"D", ".", "S2"}], "+", "C"}], ",", "p"}], "]"}]}], ";", RowBox[{"iv", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "T2", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"iv", "\[Equal]", "\"\\""}], ",", RowBox[{"Return", "[", "\"\\"", "]"}]}], "]"}], ";", RowBox[{"X", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"iv", "*", RowBox[{"SwitNeg", "[", "T2", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"Z", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"S2", ".", "X"}], ",", "p"}], "]"}]}], ";", RowBox[{"V2", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"D", ".", "R2"}], ",", "p"}], "]"}]}], ";", RowBox[{"W", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"X", ".", "V2"}], ",", "p"}], "]"}]}], ";", RowBox[{"Y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"S2", ".", "W"}], "-", "R2"}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", RowBox[{"BuildUp", "[", RowBox[{"2", ",", "W", ",", "X", ",", "Y", ",", "Z"}], "]"}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "3"], "]"}], ";", RowBox[{"ivC", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "C", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"R3", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"-", "ivC"}], "*", RowBox[{"SwitNeg", "[", "C", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"S3", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"R3", ".", "D"}], ",", "p"}], "]"}]}], ";", RowBox[{"T3", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"A", ".", "S3"}], "+", "B"}], ",", "p"}], "]"}]}], ";", RowBox[{"iv", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "T3", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"iv", "\[Equal]", "\"\\""}], ",", RowBox[{"Return", "[", "\"\\"", "]"}]}], "]"}], ";", RowBox[{"Y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"iv", "*", RowBox[{"SwitNeg", "[", "T3", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"W", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"S3", ".", "Y"}], ",", "p"}], "]"}]}], ";", RowBox[{"V3", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"A", ".", "R3"}], ",", "p"}], "]"}]}], ";", RowBox[{"Z", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"Y", ".", "V3"}], ",", "p"}], "]"}]}], ";", RowBox[{"X", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"S3", ".", "Z"}], "-", "R3"}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", RowBox[{"BuildUp", "[", RowBox[{"2", ",", "W", ",", "X", ",", "Y", ",", "Z"}], "]"}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "4"], "]"}], ";", RowBox[{"ivD", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "D", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"R4", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"-", "ivD"}], "*", RowBox[{"SwitNeg", "[", "D", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"S4", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"R4", ".", "C"}], ",", "p"}], "]"}]}], ";", RowBox[{"T4", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"B", ".", "S4"}], "+", "A"}], ",", "p"}], "]"}]}], ";", RowBox[{"iv", "=", RowBox[{"Inv", "[", RowBox[{ RowBox[{"Det", "[", "T4", "]"}], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"iv", "\[Equal]", "\"\\""}], ",", RowBox[{"Return", "[", "\"\\"", "]"}]}], "]"}], ";", RowBox[{"W", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"iv", "*", RowBox[{"SwitNeg", "[", "T4", "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{"Y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"S4", ".", "W"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["V", "4"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"B", ".", "R4"}], ",", "p"}], "]"}]}], ";", RowBox[{"X", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"W", ".", "V4"}], ",", "p"}], "]"}]}], ";", RowBox[{"Z", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"S4", ".", "X"}], "-", "R4"}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", RowBox[{"BuildUp", "[", RowBox[{"2", ",", "W", ",", "X", ",", "Y", ",", "Z"}], "]"}], "]"}]}]}], "]"}], ")"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"The", " ", "Eight"}], "-", RowBox[{ "Step", " ", "Method", " ", "with", " ", "4", "x4", " ", "matrices"}]}], ",", " ", RowBox[{ "each", " ", "step", " ", "being", " ", "reduced", " ", "modulo", " ", "a", " ", "prime"}], ",", " ", RowBox[{"p", "."}]}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"ModPEP4x4", "[", RowBox[{"A_", ",", "B_", ",", "C_", ",", "D_", ",", "p_"}], "]"}], ":=", RowBox[{"(", " ", RowBox[{"(*", " ", RowBox[{ "The", " ", "first", " ", "appropriate", " ", "PEP", " ", "Method", " ", "is", " ", RowBox[{"chosen", "."}]}], " ", "*)"}], RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "A", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "1"], "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "B", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "2"], "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "C", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "3"], "]"}]}], "]"}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Det", "[", "D", "]"}], ",", "p"}], "]"}], "\[NotEqual]", "0"}], ",", RowBox[{"Goto", "[", SubscriptBox["PEP", "4"], "]"}]}], "]"}], ";", RowBox[{"Return", "[", "\"\\"", "]"}], ";", "\[IndentingNewLine]", " ", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "1"], "]"}], ";", RowBox[{"PowerExtendedPartition", "[", "A", "]"}], ";", RowBox[{ SubscriptBox["R", "1"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"-", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["S", "1"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["R", "1"], ".", "B"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["T", "1"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"C", ".", SubscriptBox["S", "1"]}], "+", "D"}], ",", "p"}], "]"}]}], ";", RowBox[{"PowerExtendedPartition", "[", SubscriptBox["T", "1"], "]"}], ";", RowBox[{"Z", "=", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"Z", "\[Equal]", "\"\\""}], ",", RowBox[{ RowBox[{ "Print", "[", "\"\\"", "]"}], ";", RowBox[{"Return", "[", "]"}]}]}], "]"}], ";", RowBox[{"X", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["S", "1"], ".", "Z"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["V", "1"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"C", ".", SubscriptBox["R", "1"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"Z", ".", SubscriptBox["V", "1"]}], ",", "p"}], "]"}]}], ";", RowBox[{"W", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{ SubscriptBox["S", "1"], ".", "Y"}], "-", SubscriptBox["R", "1"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "2"], "]"}], ";", RowBox[{"PowerExtendedPartition", "[", "B", "]"}], ";", RowBox[{ SubscriptBox["R", "2"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"-", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["S", "2"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["R", "2"], ".", "A"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["T", "2"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"D", ".", SubscriptBox["S", "2"]}], "+", "C"}], ",", "p"}], "]"}]}], ";", RowBox[{"PowerExtendedPartition", "[", SubscriptBox["T", "2"], "]"}], ";", RowBox[{"X", "=", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"X", "\[Equal]", "\"\\""}], ",", RowBox[{ RowBox[{ "Print", "[", "\"\\"", "]"}], ";", RowBox[{"Return", "[", "]"}]}]}], "]"}], ";", RowBox[{"Z", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["S", "2"], ".", "X"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["V", "2"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"D", ".", SubscriptBox["R", "2"]}], ",", "p"}], "]"}]}], ";", RowBox[{"W", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"X", ".", SubscriptBox["V", "2"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{ SubscriptBox["S", "2"], ".", "W"}], "-", SubscriptBox["R", "2"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "3"], "]"}], ";", RowBox[{"PowerExtendedPartition", "[", "C", "]"}], ";", RowBox[{ SubscriptBox["R", "3"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"-", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["S", "3"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["R", "3"], ".", "D"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["T", "3"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"A", ".", SubscriptBox["S", "3"]}], "+", "B"}], ",", "p"}], "]"}]}], ";", RowBox[{"PowerExtendedPartition", "[", SubscriptBox["T", "3"], "]"}], ";", RowBox[{"Y", "=", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"Y", "\[Equal]", "\"\\""}], ",", RowBox[{ RowBox[{ "Print", "[", "\"\\"", "]"}], ";", RowBox[{"eturn", "[", "]"}]}]}], "]"}], ";", RowBox[{"W", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["S", "3"], ".", "Y"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["V", "3"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"A", ".", SubscriptBox["R", "3"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Z", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"Y", ".", SubscriptBox["V", "3"]}], ",", "p"}], "]"}]}], ";", RowBox[{"X", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{ SubscriptBox["S", "3"], ".", "Z"}], "-", SubscriptBox["R", "3"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Label", "[", SubscriptBox["PEP", "4"], "]"}], ";", RowBox[{"PowerExtendedPartition", "[", "D", "]"}], ";", RowBox[{ SubscriptBox["R", "4"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"-", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["S", "4"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["R", "4"], ".", "D"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["T", "4"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"B", ".", SubscriptBox["S", "4"]}], "+", "A"}], ",", "p"}], "]"}]}], ";", RowBox[{"PowerExtendedPartition", "[", SubscriptBox["T", "4"], "]"}], ";", RowBox[{"W", "=", RowBox[{"ModPEP2x2", "[", RowBox[{ SubscriptBox["Q", "1"], ",", SubscriptBox["Q", "2"], ",", SubscriptBox["Q", "3"], ",", SubscriptBox["Q", "4"], ",", "p"}], "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"W", "\[Equal]", "\"\\""}], ",", RowBox[{ RowBox[{ "Print", "[", "\"\\"", "]"}], ";", RowBox[{"Return", "[", "]"}]}]}], "]"}], ";", RowBox[{"Y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ SubscriptBox["S", "4"], ".", "W"}], ",", "p"}], "]"}]}], ";", RowBox[{ SubscriptBox["V", "4"], "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"B", ".", SubscriptBox["R", "4"]}], ",", "p"}], "]"}]}], ";", RowBox[{"X", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{"W", ".", SubscriptBox["V", "4"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Z", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{ SubscriptBox["S", "4"], ".", "X"}], "-", SubscriptBox["R", "4"]}], ",", "p"}], "]"}]}], ";", RowBox[{"Return", "[", "]"}]}], ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"RandQuatModP", "[", "p_", "]"}], ":=", RowBox[{"(", RowBox[{"If", "[", RowBox[{ RowBox[{"PrimeQ", "[", "p", "]"}], ",", RowBox[{ RowBox[{"RQMP", "=", RowBox[{"{", "}"}]}], ";", RowBox[{"Do", "[", RowBox[{ RowBox[{"RQMP", "=", RowBox[{"Append", "[", RowBox[{"RQMP", ",", RowBox[{"Floor", "[", RowBox[{"p", "*", RowBox[{"Random", "[", "]"}]}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "4"}], "}"}]}], "]"}], ";", RowBox[{"Return", "[", "RQMP", "]"}]}], ",", "\"\

\""}], "]"}], ")"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"To", " ", "quote", " ", "from", " ", "the", " ", StyleBox["wikipedia", FontVariations->{"Underline"->True}], " ", "web", " ", "site"}], ",", RowBox[{ "\"\\"", " ", "The", " ", "number", " ", "of", " ", "symmetries", " ", "of", " ", "a", " ", "General", " ", "Linear", " ", "Group", " ", "of", " ", "degree", " ", "n", " ", "over", " ", "any", " ", "field"}], ",", " ", RowBox[{"F", " ", "\[Rule]", " ", RowBox[{"GL", RowBox[{"(", RowBox[{"n", ",", "F"}], ")"}], " ", "is", " ", "defined", " ", RowBox[{"below", "."}]}]}]}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"GL", "[", RowBox[{"n_", ",", "F_"}], "]"}], ":=", RowBox[{"(", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"NumSyms", ",", "m", ",", "factor"}], "}"}], ",", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"F", "<", "2"}], "||", RowBox[{"n", "<", "1"}]}], ",", RowBox[{"Return", "[", "\"\\"", "]"}]}], "]"}], ";", RowBox[{"NumSyms", "=", "1"}], ";", RowBox[{"m", "=", "0"}], ";", RowBox[{"Label", "[", "continue", "]"}], ";", RowBox[{"factor", "=", RowBox[{ SuperscriptBox["F", "n"], "-", SuperscriptBox["F", "m"]}]}], ";", RowBox[{"NumSyms", "=", RowBox[{"NumSyms", "*", "factor"}]}], ";", RowBox[{"m", "=", RowBox[{"m", "+", "1"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"m", "\[Equal]", "n"}], ",", RowBox[{"Return", "[", "NumSyms", "]"}], ",", RowBox[{"Goto", "[", "continue", "]"}]}], "]"}]}]}], "]"}], ")"}]}]}], "Input", CellChangeTimes->CompressedData[" 1:eJwtyk8og3Ecx/EvFzlRHCQ7PLH8y8HFpIy5OdB6Diw5yMOilKbVTvSbw6Qc cHHRXLDUDtoQ+VNPm5MmcmDzZ0dtSYuLtAPP57PDr1fvz/enTc7r0+Uiov0/ SxFnLJbJuUQ1xKH03KXRA49Q2gLNz5YTS7R3md6u0OwOVIEITZvq1bKYgjJY E0TPlszUt7xZu99GK+1QvbeyvzrdsNAH1UKTDg/tUMzEMTxLQuW3naANjUbb ocr309zeOXbnPnXfX8DtB5p4gWozSz0f3MPf7PUf+vnL3VN2ifY1QnF10SEH PRrl/Wmc3WGwHV52cY7W+mg0SPNr/Fexxa4Ls68jdOqAe1Wc7Tyl1VfcvUn2 6g27O1XqYRO9oUNVGGGHxuiuQRdnLP8A3nMAyg== "]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{ RowBox[{ "Choosing", " ", "a", " ", "small", " ", "prime", " ", "modulus", " ", "makes", " ", "the", " ", "probability", " ", "that", " ", "no", " ", "solution", " ", "exists", " ", "higher", " ", "than", " ", "if", " ", "one", " ", "chooses", " ", "a", " ", "2", " ", "or", " ", "\[IndentingNewLine]", "3"}], "-", RowBox[{"dight", " ", RowBox[{"prime", ".", " ", "Let"}], " ", "p"}]}], " ", "=", " ", RowBox[{"the", " ", "prime", " ", "of", " ", "your", " ", RowBox[{"choice", ".", " ", "Since"}], " ", "there", " ", "are", " ", "p", " ", "numbers", " ", "in", " ", "the", " ", "system", " ", "mod", " ", "p"}]}], ",", " ", RowBox[{ RowBox[{ "it", " ", "would", "\[IndentingNewLine]", " ", "seem", " ", "that", " ", "the", " ", "probability", " ", "that", " ", "the", " ", "determinant", " ", "is", " ", "zero", " ", "of", " ", "a", " ", "randomly", " ", "picked", " ", "system", " ", "is", " ", "roughly", " ", RowBox[{ FractionBox[ RowBox[{" ", "1", " "}], "p"], ".", " ", "I"}], " ", "believe", " ", "the", " ", "formula", " ", "for", " ", "the", " ", "probability", " ", "of", " ", "a", " ", "determinant", " ", "being", " ", "zero"}], " ", "=", " ", RowBox[{"1", " ", "-", " ", RowBox[{ RowBox[{"GL", "[", RowBox[{"2", ",", "p"}], "]"}], " ", "/", " ", RowBox[{ SuperscriptBox["p", "4"], "."}]}]}]}]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.47222658996875*^9, 3.472226976515625*^9}, { 3.4722287198125*^9, 3.47222872290625*^9}, {3.472229799375*^9, 3.472229846046875*^9}, {3.472229878609375*^9, 3.47223000140625*^9}, 3.472230046296875*^9, {3.472231383078125*^9, 3.472231383765625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"SeedRandom", "[", "9791", "]"}], ";", RowBox[{"p", "=", "7"}], ";", RowBox[{ SubscriptBox["a", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["a", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["b", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["b", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["c", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["c", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["d", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["d", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["k", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["k", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}]}]], "Input", CellChangeTimes->{{3.4519467463709064`*^9, 3.4519467731052814`*^9}, 3.4519469266521564`*^9, {3.4700174400625*^9, 3.470017574734375*^9}, { 3.4700199685625*^9, 3.47002005671875*^9}, {3.470343593578125*^9, 3.4703435965625*^9}, {3.470344977*^9, 3.47034498725*^9}, { 3.47216849671875*^9, 3.472168549015625*^9}, {3.472173139*^9, 3.4721732489375*^9}, {3.47217526715625*^9, 3.472175332203125*^9}, 3.47220746075*^9, 3.472207886953125*^9, 3.4722085918125*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"5", ",", "1", ",", "3", ",", "2"}], "}"}]], "Output", CellChangeTimes->{3.47002005928125*^9, 3.470343611265625*^9, 3.470344989953125*^9, 3.472168469703125*^9, 3.472168550671875*^9, 3.472169218703125*^9, 3.472173256125*^9, 3.4721753374375*^9, 3.472200585296875*^9, 3.47220746378125*^9, 3.4722078895625*^9, 3.472208592984375*^9, 3.4722240715*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{ RowBox[{ "The", " ", "system", " ", "we", " ", "solve", " ", "for", " ", "x", " ", "and", " ", "y", " ", RowBox[{"is", ":", "\[IndentingNewLine]", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}]}]}]}], " ", "=", " ", RowBox[{ RowBox[{ RowBox[{ RowBox[{ SubscriptBox["k", "1"], " ", "&"}], "\[IndentingNewLine]", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}]}], " ", "=", " ", RowBox[{ RowBox[{ SubscriptBox["k", "2"], ".", " ", "\[IndentingNewLine]", "\t", "\[IndentingNewLine]", "\t", "Quaternions"}], " ", "are", " ", "noncommutative", " ", "so", " ", "that", " ", "multiplication", " ", "from", " ", "the", " ", "left", " ", "is", " ", "different", " ", "than", " ", "multiplication", " ", "\[IndentingNewLine]", "from", " ", "the", " ", RowBox[{"right", ".", " ", "For"}], " ", "the", " ", "most", " ", "general", " ", "case", " ", "we", " ", "choose", " ", "an", " ", "example", " ", "that", " ", "illustrates", " ", "multiplication", " ", "of", " ", "the", " ", "\[IndentingNewLine]", "unknkowns", " ", "from", " ", "both", " ", RowBox[{"directions", ".", " ", "The"}], " ", "grouping", " ", "given", " ", "above", " ", "is", " ", StyleBox["not", FontVariations->{"Underline"->True}], " ", "important", " ", "because", " ", "quaternions", " ", "are", " ", RowBox[{"associative", "."}]}]}]}], " ", "*)"}], " "}]], "Input", CellChangeTimes->{{3.472168642*^9, 3.47216920415625*^9}, { 3.472227038078125*^9, 3.472227038734375*^9}, {3.47222707940625*^9, 3.472227081484375*^9}, {3.472227544296875*^9, 3.4722275449375*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"AA", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.4721692905625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"AA", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["a", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["b", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.45200494458875*^9, 3.4520049453075*^9}, {3.47002018121875*^9, 3.470020189828125*^9}, {3.472168568859375*^9, 3.472168576078125*^9}, { 3.4721732724375*^9, 3.472173272609375*^9}, {3.47217534946875*^9, 3.472175350734375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", "4", ",", "0", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"6", ",", "0", ",", "5", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "3", ",", "1", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "4", ",", "1", ",", "1"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004279041875*^9, 3.452004947635625*^9, 3.452006391760625*^9, 3.4700176098125*^9, 3.47002021396875*^9, 3.470343629234375*^9, 3.4721685780625*^9, 3.47216922209375*^9, 3.472173284296875*^9, 3.472175351890625*^9, 3.472200592875*^9, 3.4722074706875*^9, 3.472207893890625*^9, 3.472208598*^9, 3.47222407709375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"BB", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.472169254859375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"BB", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["c", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["d", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004299135625*^9, 3.452004312541875*^9}, {3.452004953604375*^9, 3.45200495427625*^9}, {3.470020199328125*^9, 3.470020208515625*^9}, { 3.472168585171875*^9, 3.47216859146875*^9}, {3.472173276375*^9, 3.47217327659375*^9}, {3.472175355625*^9, 3.472175357390625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "2", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"6", ",", "6", ",", "0", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "6", ",", "2", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "0", ",", "1", ",", "1"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004316229375*^9, 3.4520049556825*^9, 3.452006404416875*^9, 3.4700176151875*^9, 3.470020218875*^9, 3.4703436348125*^9, 3.472168593234375*^9, 3.472173286640625*^9, 3.47217535840625*^9, 3.47220059390625*^9, 3.472207472078125*^9, 3.472207898640625*^9, 3.47220859896875*^9, 3.47222407890625*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"CC", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.45200743102625*^9, 3.45200745737*^9}, { 3.472169301671875*^9, 3.472169321234375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"CC", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["a", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["b", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004334479375*^9, 3.4520043486825*^9}, {3.452004964948125*^9, 3.4520049654325*^9}, {3.47002022515625*^9, 3.470020233140625*^9}, { 3.47216859853125*^9, 3.4721686064375*^9}, {3.472173278375*^9, 3.472173278578125*^9}, {3.472175362921875*^9, 3.47217536453125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"6", ",", "5", ",", "5", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"6", ",", "0", ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "5", ",", "6", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "4", ",", "2", ",", "5"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4520043513075*^9, 3.4520049684325*^9, 3.45200641690125*^9, 3.4700176195625*^9, 3.4700202340625*^9, 3.4703436379375*^9, 3.472168607859375*^9, 3.472169328375*^9, 3.47217328871875*^9, 3.4721753655*^9, 3.472200595015625*^9, 3.47220747309375*^9, 3.4722079070625*^9, 3.47220859990625*^9, 3.47222408046875*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"DD", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007465604375*^9, 3.45200749152625*^9}, { 3.472169335296875*^9, 3.472169354109375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DD", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["c", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["d", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004376541875*^9, 3.45200439008875*^9}, {3.45200498090125*^9, 3.45200498165125*^9}, {3.4700202383125*^9, 3.470020247078125*^9}, { 3.472168615203125*^9, 3.472168622921875*^9}, {3.472173280671875*^9, 3.472173280890625*^9}, {3.472175369421875*^9, 3.4721753714375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"5", ",", "5", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "2", ",", "6", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "5", ",", "3", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "0", ",", "0", ",", "1"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.45200439446375*^9, 3.4520049846825*^9, 3.452006433245*^9, 3.470017624484375*^9, 3.470020248265625*^9, 3.47034364090625*^9, 3.472168623859375*^9, 3.4721693604375*^9, 3.472173290375*^9, 3.47217537246875*^9, 3.472200596953125*^9, 3.472207474203125*^9, 3.472207909171875*^9, 3.4722086010625*^9, 3.472224082234375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"ModPEP4x4", "[", RowBox[{"AA", ",", "BB", ",", "CC", ",", "DD", ",", "p"}], "]"}]], "Input", CellChangeTimes->{{3.47217070646875*^9, 3.472170712609375*^9}, { 3.472170802390625*^9, 3.472170803625*^9}, {3.472173294828125*^9, 3.472173295*^9}, {3.472175381140625*^9, 3.472175382671875*^9}, { 3.472205121484375*^9, 3.472205127796875*^9}, {3.47222420284375*^9, 3.47222423296875*^9}, {3.472227218515625*^9, 3.472227230515625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"x", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"W", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"X", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.4722272406875*^9, 3.4722272459375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"0", ",", "6", ",", "0", ",", "2"}], "}"}]], "Output", CellChangeTimes->{3.47222725896875*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"Y", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"Z", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{3.472227252765625*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"1", ",", "6", ",", "6", ",", "1"}], "}"}]], "Output", CellChangeTimes->{3.472227261765625*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["a", "1"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["b", "1"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["c", "1"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["d", "1"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "1"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.47220470925*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "1"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472224303125*^9, 3.47222433228125*^9}, 3.47222438878125*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["a", "2"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["b", "2"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["c", "2"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["d", "2"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "2"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.472204754859375*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "1"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "2"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472224350359375*^9, 3.472224393265625*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["a", "2"], ",", RowBox[{"QuatDotMP", "[", RowBox[{"x", ",", SubscriptBox["b", "2"], ",", "p"}], "]"}], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["c", "2"], ",", RowBox[{"QuatDotMP", "[", RowBox[{"y", ",", SubscriptBox["d", "2"], ",", "p"}], "]"}], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "2"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.472204754859375*^9}, { 3.47222445065625*^9, 3.472224501546875*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ SubscriptBox["a", "2"], RowBox[{"(", SubscriptBox["xb", "2"], ")"}]}], " ", "+", " ", RowBox[{ SubscriptBox["c", "2"], RowBox[{"(", SubscriptBox["yd", "1"], ")"}]}]}]}]}], " ", "=", " ", SubscriptBox["k", "2"]}], ",", " ", RowBox[{"as", " ", RowBox[{"well", ".", " ", "It"}], " ", "was", " ", "mentioned", " ", "that", " ", "quaternions", " ", "are", " ", RowBox[{"associative", "."}]}]}], "\[IndentingNewLine]", " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472224521234375*^9, 3.472224622109375*^9}, { 3.472224696140625*^9, 3.4722247653125*^9}, {3.47222714609375*^9, 3.47222715425*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{ RowBox[{ "Now", " ", "let", " ", "us", " ", "illustrate", " ", "what", " ", "happens", " ", "when", " ", "the", " ", "coeficients", " ", "are", " ", RowBox[{"reversed", ".", " ", "We"}], " ", "again", " ", "solve", " ", "for", " ", "x", " ", "and", " ", "y", " ", RowBox[{"in", ":", "\[IndentingNewLine]", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "1"], "x"}], ")"}], SubscriptBox["a", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "1"], "y"}], ")"}], SubscriptBox["c", "1"]}]}]}]}], " ", "=", " ", RowBox[{ RowBox[{ RowBox[{ RowBox[{ SubscriptBox["k", "1"], " ", "&"}], "\[IndentingNewLine]", " ", RowBox[{"(", RowBox[{ SubscriptBox["b", "2"], "x"}], ")"}], SubscriptBox["a", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "2"], "y"}], ")"}], SubscriptBox["c", "2"]}]}], " ", "=", " ", RowBox[{ RowBox[{ SubscriptBox["k", "2"], ".", " ", "\[IndentingNewLine]", "\t", "\[IndentingNewLine]", "\t", "Quaternions"}], " ", "are", " ", "noncommutative", " ", "so", " ", "that", " ", "multiplication", " ", "from", " ", "the", " ", "left", " ", "is", " ", "different", " ", "than", " ", "multiplication", " ", "\[IndentingNewLine]", "from", " ", "the", " ", RowBox[{"right", ".", " ", "For"}], " ", "the", " ", "most", " ", "general", " ", "case", " ", "we", " ", "choose", " ", "an", " ", "example", " ", "that", " ", "illustrates", " ", "multiplication", " ", "of", " ", "the", " ", "\[IndentingNewLine]", "unknkowns", " ", "from", " ", "both", " ", RowBox[{"directions", ".", " ", "The"}], " ", "grouping", " ", "given", " ", "above", " ", "is", " ", StyleBox["not", FontVariations->{"Underline"->True}], " ", "important", " ", "because", " ", "quaternions", " ", "are", " ", RowBox[{"associative", "."}]}]}]}], " ", "*)"}], " "}]], "Input", CellChangeTimes->{{3.472168642*^9, 3.47216920415625*^9}, { 3.472227038078125*^9, 3.472227038734375*^9}, {3.47222707940625*^9, 3.472227081484375*^9}, {3.47222734546875*^9, 3.472227534640625*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"AA", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.4721692905625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"AA", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["b", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["a", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.45200494458875*^9, 3.4520049453075*^9}, {3.47002018121875*^9, 3.470020189828125*^9}, {3.472168568859375*^9, 3.472168576078125*^9}, { 3.4721732724375*^9, 3.472173272609375*^9}, {3.47217534946875*^9, 3.472175350734375*^9}, {3.47222757446875*^9, 3.472227604203125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"4", ",", "1", ",", "6", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "0", ",", "3", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "5", ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "6", ",", "4", ",", "1"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004279041875*^9, 3.452004947635625*^9, 3.452006391760625*^9, 3.4700176098125*^9, 3.47002021396875*^9, 3.470343629234375*^9, 3.4721685780625*^9, 3.47216922209375*^9, 3.472173284296875*^9, 3.472175351890625*^9, 3.472200592875*^9, 3.4722074706875*^9, 3.472207893890625*^9, 3.472208598*^9, 3.47222407709375*^9, 3.47222760709375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"BB", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.472169254859375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"BB", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["d", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["c", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004299135625*^9, 3.452004312541875*^9}, {3.452004953604375*^9, 3.45200495427625*^9}, {3.470020199328125*^9, 3.470020208515625*^9}, { 3.472168585171875*^9, 3.47216859146875*^9}, {3.472173276375*^9, 3.47217327659375*^9}, {3.472175355625*^9, 3.472175357390625*^9}, { 3.472227613484375*^9, 3.472227625890625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "1", ",", "2", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "6", ",", "6", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"6", ",", "0", ",", "2", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "2", ",", "2", ",", "1"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004316229375*^9, 3.4520049556825*^9, 3.452006404416875*^9, 3.4700176151875*^9, 3.470020218875*^9, 3.4703436348125*^9, 3.472168593234375*^9, 3.472173286640625*^9, 3.47217535840625*^9, 3.47220059390625*^9, 3.472207472078125*^9, 3.472207898640625*^9, 3.47220859896875*^9, 3.47222407890625*^9, 3.47222762753125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"CC", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.45200743102625*^9, 3.45200745737*^9}, { 3.472169301671875*^9, 3.472169321234375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"CC", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["b", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["a", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004334479375*^9, 3.4520043486825*^9}, {3.452004964948125*^9, 3.4520049654325*^9}, {3.47002022515625*^9, 3.470020233140625*^9}, { 3.47216859853125*^9, 3.4721686064375*^9}, {3.472173278375*^9, 3.472173278578125*^9}, {3.472175362921875*^9, 3.47217536453125*^9}, { 3.47222763775*^9, 3.47222765346875*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"6", ",", "1", ",", "6", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "0", ",", "5", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "1", ",", "6", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"6", ",", "1", ",", "2", ",", "5"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4520043513075*^9, 3.4520049684325*^9, 3.45200641690125*^9, 3.4700176195625*^9, 3.4700202340625*^9, 3.4703436379375*^9, 3.472168607859375*^9, 3.472169328375*^9, 3.47217328871875*^9, 3.4721753655*^9, 3.472200595015625*^9, 3.47220747309375*^9, 3.4722079070625*^9, 3.47220859990625*^9, 3.47222408046875*^9, 3.4722276808125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"DD", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007465604375*^9, 3.45200749152625*^9}, { 3.472169335296875*^9, 3.472169354109375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DD", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["d", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["c", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004376541875*^9, 3.45200439008875*^9}, {3.45200498090125*^9, 3.45200498165125*^9}, {3.4700202383125*^9, 3.470020247078125*^9}, { 3.472168615203125*^9, 3.472168622921875*^9}, {3.472173280671875*^9, 3.472173280890625*^9}, {3.472175369421875*^9, 3.4721753714375*^9}, { 3.4722276598125*^9, 3.472227671625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"5", ",", "0", ",", "5", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "2", ",", "5", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "6", ",", "3", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "0", ",", "3", ",", "1"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.45200439446375*^9, 3.4520049846825*^9, 3.452006433245*^9, 3.470017624484375*^9, 3.470020248265625*^9, 3.47034364090625*^9, 3.472168623859375*^9, 3.4721693604375*^9, 3.472173290375*^9, 3.47217537246875*^9, 3.472200596953125*^9, 3.472207474203125*^9, 3.472207909171875*^9, 3.4722086010625*^9, 3.472224082234375*^9, 3.472227687671875*^9}] }, Open ]], Cell[BoxData[ RowBox[{"ModPEP4x4", "[", RowBox[{"AA", ",", "BB", ",", "CC", ",", "DD", ",", "p"}], "]"}]], "Input", CellChangeTimes->{{3.47217070646875*^9, 3.472170712609375*^9}, { 3.472170802390625*^9, 3.472170803625*^9}, {3.472173294828125*^9, 3.472173295*^9}, {3.472175381140625*^9, 3.472175382671875*^9}, { 3.472205121484375*^9, 3.472205127796875*^9}, {3.47222420284375*^9, 3.47222423296875*^9}, {3.472227218515625*^9, 3.472227230515625*^9}}], Cell[BoxData[ RowBox[{"x", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"W", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"X", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.4722272406875*^9, 3.4722272459375*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"6", ",", "1", ",", "6", ",", "0"}], "}"}], " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"\"\\"", " ", "was"}], " ", "=", " ", RowBox[{"{", RowBox[{"0", ",", "6", ",", "0", ",", "2"}], "}"}]}], " ", "*)"}]}]], \ "Input", CellChangeTimes->{{3.472228032953125*^9, 3.472228071296875*^9}}], Cell[BoxData[ RowBox[{"y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"Y", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"Z", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{3.472227252765625*^9}], Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"6", ",", "4", ",", "6", ",", "1"}], "}"}], " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"\"\\"", " ", "was"}], " ", "=", " ", RowBox[{"{", RowBox[{"1", ",", "6", ",", "6", ",", "1"}], "}"}]}], " ", "*)"}]}]], \ "Input", CellChangeTimes->{{3.472228092875*^9, 3.472228117421875*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["b", "1"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["a", "1"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["d", "1"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["c", "1"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "1"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.47220470925*^9}, {3.472227726765625*^9, 3.472227759140625*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "1"], "x"}], ")"}], SubscriptBox["a", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "1"], "y"}], ")"}], SubscriptBox["c", "1"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "1"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.4722277794375*^9, 3.472227782546875*^9}, { 3.47222791103125*^9, 3.472227939390625*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["b", "2"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["a", "2"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["d", "2"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["c", "2"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "2"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.472204754859375*^9}, { 3.4722278231875*^9, 3.4722278634375*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "2"], "x"}], ")"}], SubscriptBox["a", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "2"], "y"}], ")"}], SubscriptBox["c", "2"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "2"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472227880453125*^9, 3.472227883125*^9}, 3.4722279166875*^9, {3.47222795428125*^9, 3.472227959484375*^9}}], Cell[BoxData["\[IndentingNewLine]"], "Input", CellChangeTimes->{3.472228179421875*^9}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"Choosing", " ", "p"}], " ", "=", " ", "97"}], ",", " ", "..."}], " ", "*)"}]], "Input", CellChangeTimes->{{3.472228251890625*^9, 3.47222826846875*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"SeedRandom", "[", "9791", "]"}], ";", RowBox[{"p", "=", "97"}], ";", RowBox[{ SubscriptBox["a", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["a", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["b", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["b", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["c", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["c", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["d", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["d", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["k", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["k", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}]}]], "Input", CellChangeTimes->{{3.4519467463709064`*^9, 3.4519467731052814`*^9}, 3.4519469266521564`*^9, {3.4700174400625*^9, 3.470017574734375*^9}, { 3.4700199685625*^9, 3.47002005671875*^9}, {3.470343593578125*^9, 3.4703435965625*^9}, {3.470344977*^9, 3.47034498725*^9}, { 3.47216849671875*^9, 3.472168549015625*^9}, {3.472173139*^9, 3.4721732489375*^9}, {3.47217526715625*^9, 3.472175332203125*^9}, 3.47220746075*^9, 3.472207886953125*^9, 3.4722085918125*^9, 3.4722282458125*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"74", ",", "13", ",", "50", ",", "28"}], "}"}]], "Output", CellChangeTimes->{3.47002005928125*^9, 3.470343611265625*^9, 3.470344989953125*^9, 3.472168469703125*^9, 3.472168550671875*^9, 3.472169218703125*^9, 3.472173256125*^9, 3.4721753374375*^9, 3.472200585296875*^9, 3.47220746378125*^9, 3.4722078895625*^9, 3.472208592984375*^9, 3.4722240715*^9, 3.47222827359375*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{ RowBox[{ "The", " ", "system", " ", "we", " ", "solve", " ", "for", " ", "x", " ", "and", " ", "y", " ", RowBox[{"is", ":", "\[IndentingNewLine]", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}]}]}]}], " ", "=", " ", RowBox[{ RowBox[{ RowBox[{ RowBox[{ SubscriptBox["k", "1"], " ", "&"}], "\[IndentingNewLine]", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}]}], " ", "=", " ", RowBox[{ RowBox[{ SubscriptBox["k", "2"], ".", " ", "\[IndentingNewLine]", "\t", "\[IndentingNewLine]", "\t", "Quaternions"}], " ", "are", " ", "noncommutative", " ", "so", " ", "that", " ", "multiplication", " ", "from", " ", "the", " ", "left", " ", "is", " ", "different", " ", "than", " ", "multiplication", " ", "\[IndentingNewLine]", "from", " ", "the", " ", RowBox[{"right", ".", " ", "For"}], " ", "the", " ", "most", " ", "general", " ", "case", " ", "we", " ", "choose", " ", "an", " ", "example", " ", "that", " ", "illustrates", " ", "multiplication", " ", "of", " ", "the", " ", "\[IndentingNewLine]", "unknkowns", " ", "from", " ", "both", " ", RowBox[{"directions", ".", " ", "The"}], " ", "grouping", " ", "given", " ", "above", " ", "is", " ", StyleBox["not", FontVariations->{"Underline"->True}], " ", "important", " ", "because", " ", "quaternions", " ", "are", " ", RowBox[{"associative", "."}]}]}]}], " ", "*)"}], " "}]], "Input", CellChangeTimes->{{3.472168642*^9, 3.47216920415625*^9}, { 3.472227038078125*^9, 3.472227038734375*^9}, {3.47222707940625*^9, 3.472227081484375*^9}, {3.472227544296875*^9, 3.4722275449375*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"AA", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.4721692905625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"AA", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["a", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["b", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.45200494458875*^9, 3.4520049453075*^9}, {3.47002018121875*^9, 3.470020189828125*^9}, {3.472168568859375*^9, 3.472168576078125*^9}, { 3.4721732724375*^9, 3.472173272609375*^9}, {3.47217534946875*^9, 3.472175350734375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"17", ",", "20", ",", "30", ",", "69"}], "}"}], ",", RowBox[{"{", RowBox[{"10", ",", "72", ",", "52", ",", "37"}], "}"}], ",", RowBox[{"{", RowBox[{"12", ",", "72", ",", "57", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"71", ",", "74", ",", "51", ",", "64"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004279041875*^9, 3.452004947635625*^9, 3.452006391760625*^9, 3.4700176098125*^9, 3.47002021396875*^9, 3.470343629234375*^9, 3.4721685780625*^9, 3.47216922209375*^9, 3.472173284296875*^9, 3.472175351890625*^9, 3.472200592875*^9, 3.4722074706875*^9, 3.472207893890625*^9, 3.472208598*^9, 3.47222407709375*^9, 3.47222828190625*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"BB", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.472169254859375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"BB", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["c", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["d", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004299135625*^9, 3.452004312541875*^9}, {3.452004953604375*^9, 3.45200495427625*^9}, {3.470020199328125*^9, 3.470020208515625*^9}, { 3.472168585171875*^9, 3.47216859146875*^9}, {3.472173276375*^9, 3.47217327659375*^9}, {3.472175355625*^9, 3.472175357390625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"92", ",", "49", ",", "80", ",", "74"}], "}"}], ",", RowBox[{"{", RowBox[{"26", ",", "66", ",", "21", ",", "14"}], "}"}], ",", RowBox[{"{", RowBox[{"42", ",", "20", ",", "95", ",", "94"}], "}"}], ",", RowBox[{"{", RowBox[{"87", ",", "8", ",", "45", ",", "45"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004316229375*^9, 3.4520049556825*^9, 3.452006404416875*^9, 3.4700176151875*^9, 3.470020218875*^9, 3.4703436348125*^9, 3.472168593234375*^9, 3.472173286640625*^9, 3.47217535840625*^9, 3.47220059390625*^9, 3.472207472078125*^9, 3.472207898640625*^9, 3.47220859896875*^9, 3.47222407890625*^9, 3.47222828428125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"CC", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.45200743102625*^9, 3.45200745737*^9}, { 3.472169301671875*^9, 3.472169321234375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"CC", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["a", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["b", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004334479375*^9, 3.4520043486825*^9}, {3.452004964948125*^9, 3.4520049654325*^9}, {3.47002022515625*^9, 3.470020233140625*^9}, { 3.47216859853125*^9, 3.4721686064375*^9}, {3.472173278375*^9, 3.472173278578125*^9}, {3.472175362921875*^9, 3.47217536453125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"35", ",", "81", ",", "91", ",", "81"}], "}"}], ",", RowBox[{"{", RowBox[{"35", ",", "37", ",", "28", ",", "23"}], "}"}], ",", RowBox[{"{", RowBox[{"55", ",", "49", ",", "30", ",", "54"}], "}"}], ",", RowBox[{"{", RowBox[{"88", ",", "47", ",", "21", ",", "77"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4520043513075*^9, 3.4520049684325*^9, 3.45200641690125*^9, 3.4700176195625*^9, 3.4700202340625*^9, 3.4703436379375*^9, 3.472168607859375*^9, 3.472169328375*^9, 3.47217328871875*^9, 3.4721753655*^9, 3.472200595015625*^9, 3.47220747309375*^9, 3.4722079070625*^9, 3.47220859990625*^9, 3.47222408046875*^9, 3.472228285765625*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"DD", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007465604375*^9, 3.45200749152625*^9}, { 3.472169335296875*^9, 3.472169354109375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DD", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["c", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["d", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004376541875*^9, 3.45200439008875*^9}, {3.45200498090125*^9, 3.45200498165125*^9}, {3.4700202383125*^9, 3.470020247078125*^9}, { 3.472168615203125*^9, 3.472168622921875*^9}, {3.472173280671875*^9, 3.472173280890625*^9}, {3.472175369421875*^9, 3.4721753714375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"60", ",", "35", ",", "35", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "74", ",", "59", ",", "52"}], "}"}], ",", RowBox[{"{", RowBox[{"14", ",", "18", ",", "47", ",", "86"}], "}"}], ",", RowBox[{"{", RowBox[{"28", ",", "44", ",", "94", ",", "86"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.45200439446375*^9, 3.4520049846825*^9, 3.452006433245*^9, 3.470017624484375*^9, 3.470020248265625*^9, 3.47034364090625*^9, 3.472168623859375*^9, 3.4721693604375*^9, 3.472173290375*^9, 3.47217537246875*^9, 3.472200596953125*^9, 3.472207474203125*^9, 3.472207909171875*^9, 3.4722086010625*^9, 3.472224082234375*^9, 3.47222828709375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"ModPEP4x4", "[", RowBox[{"AA", ",", "BB", ",", "CC", ",", "DD", ",", "p"}], "]"}]], "Input", CellChangeTimes->{{3.47217070646875*^9, 3.472170712609375*^9}, { 3.472170802390625*^9, 3.472170803625*^9}, {3.472173294828125*^9, 3.472173295*^9}, {3.472175381140625*^9, 3.472175382671875*^9}, { 3.472205121484375*^9, 3.472205127796875*^9}, {3.47222420284375*^9, 3.47222423296875*^9}, {3.472227218515625*^9, 3.472227230515625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"x", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"W", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"X", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.4722272406875*^9, 3.4722272459375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"36", ",", "37", ",", "93", ",", "83"}], "}"}]], "Output", CellChangeTimes->{3.47222725896875*^9, 3.472228290578125*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"Y", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"Z", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{3.472227252765625*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"51", ",", "17", ",", "44", ",", "74"}], "}"}]], "Output", CellChangeTimes->{3.472227261765625*^9, 3.472228292578125*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["a", "1"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["b", "1"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["c", "1"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["d", "1"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "1"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.47220470925*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "1"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472228310609375*^9, 3.4722283145625*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["a", "2"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["b", "2"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["c", "2"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["d", "2"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "2"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.472204754859375*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "1"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "2"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472228332421875*^9, 3.472228335*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["a", "2"], ",", RowBox[{"QuatDotMP", "[", RowBox[{"x", ",", SubscriptBox["b", "2"], ",", "p"}], "]"}], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["c", "2"], ",", RowBox[{"QuatDotMP", "[", RowBox[{"y", ",", SubscriptBox["d", "2"], ",", "p"}], "]"}], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "2"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.472204754859375*^9}, { 3.47222445065625*^9, 3.472224501546875*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ SubscriptBox["a", "2"], RowBox[{"(", SubscriptBox["xb", "2"], ")"}]}], " ", "+", " ", RowBox[{ SubscriptBox["c", "2"], RowBox[{"(", SubscriptBox["yd", "1"], ")"}]}]}]}]}], " ", "=", " ", SubscriptBox["k", "2"]}], ",", " ", RowBox[{"as", " ", RowBox[{"well", ".", " ", "It"}], " ", "was", " ", "mentioned", " ", "that", " ", "quaternions", " ", "are", " ", RowBox[{"associative", "."}]}]}], "\[IndentingNewLine]", " ", "*)"}]}]], "Input", CellChangeTimes->{{3.47222835840625*^9, 3.472228361421875*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{ RowBox[{ "Now", " ", "let", " ", "us", " ", "illustrate", " ", "what", " ", "happens", " ", "when", " ", "the", " ", "coeficients", " ", "are", " ", RowBox[{"reversed", ".", " ", "We"}], " ", "again", " ", "solve", " ", "for", " ", "x", " ", "and", " ", "y", " ", RowBox[{"in", ":", "\[IndentingNewLine]", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "1"], "x"}], ")"}], SubscriptBox["a", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "1"], "y"}], ")"}], SubscriptBox["c", "1"]}]}]}]}], " ", "=", " ", RowBox[{ RowBox[{ RowBox[{ RowBox[{ SubscriptBox["k", "1"], " ", "&"}], "\[IndentingNewLine]", " ", RowBox[{"(", RowBox[{ SubscriptBox["b", "2"], "x"}], ")"}], SubscriptBox["a", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "2"], "y"}], ")"}], SubscriptBox["c", "2"]}]}], " ", "=", " ", RowBox[{ RowBox[{ SubscriptBox["k", "2"], ".", " ", "\[IndentingNewLine]", "\t", "\[IndentingNewLine]", "\t", "Quaternions"}], " ", "are", " ", "noncommutative", " ", "so", " ", "that", " ", "multiplication", " ", "from", " ", "the", " ", "left", " ", "is", " ", "different", " ", "than", " ", "multiplication", " ", "\[IndentingNewLine]", "from", " ", "the", " ", RowBox[{"right", ".", " ", "For"}], " ", "the", " ", "most", " ", "general", " ", "case", " ", "we", " ", "choose", " ", "an", " ", "example", " ", "that", " ", "illustrates", " ", "multiplication", " ", "of", " ", "the", " ", "\[IndentingNewLine]", "unknkowns", " ", "from", " ", "both", " ", RowBox[{"directions", ".", " ", "The"}], " ", "grouping", " ", "given", " ", "above", " ", "is", " ", StyleBox["not", FontVariations->{"Underline"->True}], " ", "important", " ", "because", " ", "quaternions", " ", "are", " ", RowBox[{"associative", "."}]}]}]}], " ", "*)"}], " "}]], "Input", CellChangeTimes->{{3.472168642*^9, 3.47216920415625*^9}, { 3.472227038078125*^9, 3.472227038734375*^9}, {3.47222707940625*^9, 3.472227081484375*^9}, {3.47222734546875*^9, 3.472227534640625*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"AA", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "1"], "x"}], ")"}], SubscriptBox["b", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.4721692905625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"AA", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["b", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["a", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.45200494458875*^9, 3.4520049453075*^9}, {3.47002018121875*^9, 3.470020189828125*^9}, {3.472168568859375*^9, 3.472168576078125*^9}, { 3.4721732724375*^9, 3.472173272609375*^9}, {3.47217534946875*^9, 3.472175350734375*^9}, {3.47222757446875*^9, 3.472227604203125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"17", ",", "87", ",", "85", ",", "26"}], "}"}], ",", RowBox[{"{", RowBox[{"77", ",", "72", ",", "72", ",", "74"}], "}"}], ",", RowBox[{"{", RowBox[{"67", ",", "52", ",", "57", ",", "51"}], "}"}], ",", RowBox[{"{", RowBox[{"28", ",", "37", ",", "2", ",", "64"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004279041875*^9, 3.452004947635625*^9, 3.452006391760625*^9, 3.4700176098125*^9, 3.47002021396875*^9, 3.470343629234375*^9, 3.4721685780625*^9, 3.47216922209375*^9, 3.472173284296875*^9, 3.472175351890625*^9, 3.472200592875*^9, 3.4722074706875*^9, 3.472207893890625*^9, 3.472208598*^9, 3.47222407709375*^9, 3.47222760709375*^9, 3.472228376234375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"BB", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.472169254859375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"BB", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["d", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["c", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004299135625*^9, 3.452004312541875*^9}, {3.452004953604375*^9, 3.45200495427625*^9}, {3.470020199328125*^9, 3.470020208515625*^9}, { 3.472168585171875*^9, 3.47216859146875*^9}, {3.472173276375*^9, 3.47217327659375*^9}, {3.472175355625*^9, 3.472175357390625*^9}, { 3.472227613484375*^9, 3.472227625890625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"92", ",", "71", ",", "55", ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{"48", ",", "66", ",", "20", ",", "8"}], "}"}], ",", RowBox[{"{", RowBox[{"17", ",", "21", ",", "95", ",", "45"}], "}"}], ",", RowBox[{"{", RowBox[{"23", ",", "14", ",", "94", ",", "45"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004316229375*^9, 3.4520049556825*^9, 3.452006404416875*^9, 3.4700176151875*^9, 3.470020218875*^9, 3.4703436348125*^9, 3.472168593234375*^9, 3.472173286640625*^9, 3.47217535840625*^9, 3.47220059390625*^9, 3.472207472078125*^9, 3.472207898640625*^9, 3.47220859896875*^9, 3.47222407890625*^9, 3.47222762753125*^9, 3.472228379296875*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"CC", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.45200743102625*^9, 3.45200745737*^9}, { 3.472169301671875*^9, 3.472169321234375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"CC", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["b", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["a", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004334479375*^9, 3.4520043486825*^9}, {3.452004964948125*^9, 3.4520049654325*^9}, {3.47002022515625*^9, 3.470020233140625*^9}, { 3.47216859853125*^9, 3.4721686064375*^9}, {3.472173278375*^9, 3.472173278578125*^9}, {3.472175362921875*^9, 3.47217536453125*^9}, { 3.47222763775*^9, 3.47222765346875*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"35", ",", "62", ",", "42", ",", "9"}], "}"}], ",", RowBox[{"{", RowBox[{"16", ",", "37", ",", "49", ",", "47"}], "}"}], ",", RowBox[{"{", RowBox[{"6", ",", "28", ",", "30", ",", "21"}], "}"}], ",", RowBox[{"{", RowBox[{"16", ",", "23", ",", "54", ",", "77"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4520043513075*^9, 3.4520049684325*^9, 3.45200641690125*^9, 3.4700176195625*^9, 3.4700202340625*^9, 3.4703436379375*^9, 3.472168607859375*^9, 3.472169328375*^9, 3.47217328871875*^9, 3.4721753655*^9, 3.472200595015625*^9, 3.47220747309375*^9, 3.4722079070625*^9, 3.47220859990625*^9, 3.47222408046875*^9, 3.4722276808125*^9, 3.472228382828125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"DD", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007465604375*^9, 3.45200749152625*^9}, { 3.472169335296875*^9, 3.472169354109375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DD", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["d", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["c", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004376541875*^9, 3.45200439008875*^9}, {3.45200498090125*^9, 3.45200498165125*^9}, {3.4700202383125*^9, 3.470020247078125*^9}, { 3.472168615203125*^9, 3.472168622921875*^9}, {3.472173280671875*^9, 3.472173280890625*^9}, {3.472175369421875*^9, 3.4721753714375*^9}, { 3.4722276598125*^9, 3.472227671625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"60", ",", "93", ",", "83", ",", "69"}], "}"}], ",", RowBox[{"{", RowBox[{"62", ",", "74", ",", "18", ",", "44"}], "}"}], ",", RowBox[{"{", RowBox[{"62", ",", "59", ",", "47", ",", "94"}], "}"}], ",", RowBox[{"{", RowBox[{"96", ",", "52", ",", "86", ",", "86"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.45200439446375*^9, 3.4520049846825*^9, 3.452006433245*^9, 3.470017624484375*^9, 3.470020248265625*^9, 3.47034364090625*^9, 3.472168623859375*^9, 3.4721693604375*^9, 3.472173290375*^9, 3.47217537246875*^9, 3.472200596953125*^9, 3.472207474203125*^9, 3.472207909171875*^9, 3.4722086010625*^9, 3.472224082234375*^9, 3.472227687671875*^9, 3.47222838621875*^9}] }, Open ]], Cell[BoxData[ RowBox[{"ModPEP4x4", "[", RowBox[{"AA", ",", "BB", ",", "CC", ",", "DD", ",", "p"}], "]"}]], "Input", CellChangeTimes->{{3.47217070646875*^9, 3.472170712609375*^9}, { 3.472170802390625*^9, 3.472170803625*^9}, {3.472173294828125*^9, 3.472173295*^9}, {3.472175381140625*^9, 3.472175382671875*^9}, { 3.472205121484375*^9, 3.472205127796875*^9}, {3.47222420284375*^9, 3.47222423296875*^9}, {3.472227218515625*^9, 3.472227230515625*^9}}], Cell[BoxData[ RowBox[{"x", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"W", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"X", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.4722272406875*^9, 3.4722272459375*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"43", ",", "5", ",", "25", ",", "35"}], "}"}], " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"\"\\"", " ", "was"}], " ", "=", " ", RowBox[{"{", RowBox[{"36", ",", "37", ",", "93", ",", "83"}], "}"}]}], " ", "*)"}]}]],\ "Input", CellChangeTimes->{{3.472228541109375*^9, 3.472228568046875*^9}}], Cell[BoxData[ RowBox[{"y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"Y", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"Z", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{3.472227252765625*^9}], Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"15", ",", "28", ",", "88", ",", "5"}], "}"}], " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"\"\\"", " ", "was"}], " ", "=", " ", RowBox[{"{", RowBox[{"51", ",", "17", ",", "44", ",", "74"}], "}"}]}], " ", "*)"}]}]],\ "Input", CellChangeTimes->{{3.472228503421875*^9, 3.47222850540625*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["b", "1"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["a", "1"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["d", "1"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["c", "1"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "1"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.47220470925*^9}, {3.472227726765625*^9, 3.472227759140625*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "1"], "x"}], ")"}], SubscriptBox["a", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "1"], "y"}], ")"}], SubscriptBox["c", "1"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "1"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.4722284511875*^9, 3.47222845275*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["b", "2"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["a", "2"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["d", "2"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["c", "2"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "2"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.472204754859375*^9}, { 3.4722278231875*^9, 3.4722278634375*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "2"], "x"}], ")"}], SubscriptBox["a", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "2"], "y"}], ")"}], SubscriptBox["c", "2"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "2"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.47222843553125*^9, 3.47222843775*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "Below", " ", "is", " ", "an", " ", "example", " ", "of", " ", "where", " ", "no", " ", "solution", " ", RowBox[{"exists", "."}]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.472231416140625*^9, 3.47223144646875*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"SeedRandom", "[", "9797", "]"}], ";", RowBox[{"p", "=", "7"}], ";", RowBox[{ SubscriptBox["a", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["a", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["b", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["b", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["c", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["c", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["d", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["d", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["k", "1"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}], ";", RowBox[{ SubscriptBox["k", "2"], "=", RowBox[{"RandQuatModP", "[", "p", "]"}]}]}]], "Input", CellChangeTimes->{{3.4519467463709064`*^9, 3.4519467731052814`*^9}, 3.4519469266521564`*^9, {3.4700174400625*^9, 3.470017574734375*^9}, { 3.4700199685625*^9, 3.47002005671875*^9}, {3.470343593578125*^9, 3.4703435965625*^9}, {3.470344977*^9, 3.47034498725*^9}, { 3.47216849671875*^9, 3.472168549015625*^9}, {3.472173139*^9, 3.4721732489375*^9}, {3.47217526715625*^9, 3.472175332203125*^9}, 3.47220746075*^9, 3.472207886953125*^9, 3.4722085918125*^9, { 3.472230179671875*^9, 3.472230180453125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"6", ",", "6", ",", "1", ",", "6"}], "}"}]], "Output", CellChangeTimes->{3.472230182234375*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Mod", "[", RowBox[{ RowBox[{"Sum", "[", RowBox[{ SuperscriptBox[ RowBox[{ SubscriptBox["d", "2"], "[", RowBox[{"[", "i", "]"}], "]"}], "2"], ",", RowBox[{"{", RowBox[{"i", ",", "4"}], "}"}]}], "]"}], ",", "7"}], "]"}]], "Input", CellChangeTimes->{{3.47223019171875*^9, 3.472230340140625*^9}}], Cell[BoxData["6"], "Output", CellChangeTimes->{{3.47223028059375*^9, 3.47223034190625*^9}}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"AA", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["a", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["b", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.45200494458875*^9, 3.4520049453075*^9}, {3.47002018121875*^9, 3.470020189828125*^9}, {3.472168568859375*^9, 3.472168576078125*^9}, { 3.4721732724375*^9, 3.472173272609375*^9}, {3.47217534946875*^9, 3.472175350734375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2", ",", "6", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"6", ",", "4", ",", "0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "6", ",", "4"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004279041875*^9, 3.452004947635625*^9, 3.452006391760625*^9, 3.4700176098125*^9, 3.47002021396875*^9, 3.470343629234375*^9, 3.4721685780625*^9, 3.47216922209375*^9, 3.472173284296875*^9, 3.472175351890625*^9, 3.472200592875*^9, 3.4722074706875*^9, 3.472207893890625*^9, 3.472208598*^9, 3.47222407709375*^9, 3.47222828190625*^9, 3.472230458578125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"BB", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.472169254859375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"BB", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["c", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["d", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004299135625*^9, 3.452004312541875*^9}, {3.452004953604375*^9, 3.45200495427625*^9}, {3.470020199328125*^9, 3.470020208515625*^9}, { 3.472168585171875*^9, 3.47216859146875*^9}, {3.472173276375*^9, 3.47217327659375*^9}, {3.472175355625*^9, 3.472175357390625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"6", ",", "4", ",", "4", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "5", ",", "6", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "1", ",", "5", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "4", ",", "6"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004316229375*^9, 3.4520049556825*^9, 3.452006404416875*^9, 3.4700176151875*^9, 3.470020218875*^9, 3.4703436348125*^9, 3.472168593234375*^9, 3.472173286640625*^9, 3.47217535840625*^9, 3.47220059390625*^9, 3.472207472078125*^9, 3.472207898640625*^9, 3.47220859896875*^9, 3.47222407890625*^9, 3.47222828428125*^9, 3.47223046334375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"CC", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.45200743102625*^9, 3.45200745737*^9}, { 3.472169301671875*^9, 3.472169321234375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"CC", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["a", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["b", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004334479375*^9, 3.4520043486825*^9}, {3.452004964948125*^9, 3.4520049654325*^9}, {3.47002022515625*^9, 3.470020233140625*^9}, { 3.47216859853125*^9, 3.4721686064375*^9}, {3.472173278375*^9, 3.472173278578125*^9}, {3.472175362921875*^9, 3.47217536453125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "2", ",", "2", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "3", ",", "4", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "6", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "1", ",", "6", ",", "4"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4520043513075*^9, 3.4520049684325*^9, 3.45200641690125*^9, 3.4700176195625*^9, 3.4700202340625*^9, 3.4703436379375*^9, 3.472168607859375*^9, 3.472169328375*^9, 3.47217328871875*^9, 3.4721753655*^9, 3.472200595015625*^9, 3.47220747309375*^9, 3.4722079070625*^9, 3.47220859990625*^9, 3.47222408046875*^9, 3.472228285765625*^9, 3.472230467328125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"DD", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007465604375*^9, 3.45200749152625*^9}, { 3.472169335296875*^9, 3.472169354109375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DD", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["c", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["d", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004376541875*^9, 3.45200439008875*^9}, {3.45200498090125*^9, 3.45200498165125*^9}, {3.4700202383125*^9, 3.470020247078125*^9}, { 3.472168615203125*^9, 3.472168622921875*^9}, {3.472173280671875*^9, 3.472173280890625*^9}, {3.472175369421875*^9, 3.4721753714375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "4", ",", "3", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "4", ",", "1", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "0", ",", "2", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "5", ",", "1", ",", "6"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.45200439446375*^9, 3.4520049846825*^9, 3.452006433245*^9, 3.470017624484375*^9, 3.470020248265625*^9, 3.47034364090625*^9, 3.472168623859375*^9, 3.4721693604375*^9, 3.472173290375*^9, 3.47217537246875*^9, 3.472200596953125*^9, 3.472207474203125*^9, 3.472207909171875*^9, 3.4722086010625*^9, 3.472224082234375*^9, 3.47222828709375*^9, 3.4722304706875*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ModPEP4x4", "[", RowBox[{"AA", ",", "BB", ",", "CC", ",", "DD", ",", "p"}], "]"}]], "Input", CellChangeTimes->{{3.47217070646875*^9, 3.472170712609375*^9}, { 3.472170802390625*^9, 3.472170803625*^9}, {3.472173294828125*^9, 3.472173295*^9}, {3.472175381140625*^9, 3.472175382671875*^9}, { 3.472205121484375*^9, 3.472205127796875*^9}, {3.47222420284375*^9, 3.47222423296875*^9}, {3.472227218515625*^9, 3.472227230515625*^9}}], Cell[BoxData["\<\"There is no solution to the given system.\"\>"], "Print", CellChangeTimes->{3.472231157453125*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"AA", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["b", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["a", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.45200494458875*^9, 3.4520049453075*^9}, {3.47002018121875*^9, 3.470020189828125*^9}, {3.472168568859375*^9, 3.472168576078125*^9}, { 3.4721732724375*^9, 3.472173272609375*^9}, {3.47217534946875*^9, 3.472175350734375*^9}, {3.47223153346875*^9, 3.47223154628125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "6", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "4", ",", "2", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "0", ",", "1", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "0", ",", "2", ",", "4"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004279041875*^9, 3.452004947635625*^9, 3.452006391760625*^9, 3.4700176098125*^9, 3.47002021396875*^9, 3.470343629234375*^9, 3.4721685780625*^9, 3.47216922209375*^9, 3.472173284296875*^9, 3.472175351890625*^9, 3.472200592875*^9, 3.4722074706875*^9, 3.472207893890625*^9, 3.472208598*^9, 3.47222407709375*^9, 3.47222828190625*^9, 3.472230458578125*^9, 3.47223160184375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"BB", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "1"], "y"}], ")"}], SubscriptBox["d", "1"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007399510625*^9, 3.45200742690125*^9}, { 3.4721692313125*^9, 3.472169254859375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"BB", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["d", "1"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["c", "1"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004299135625*^9, 3.452004312541875*^9}, {3.452004953604375*^9, 3.45200495427625*^9}, {3.470020199328125*^9, 3.470020208515625*^9}, { 3.472168585171875*^9, 3.47216859146875*^9}, {3.472173276375*^9, 3.47217327659375*^9}, {3.472175355625*^9, 3.472175357390625*^9}, { 3.4722315505*^9, 3.47223156265625*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"6", ",", "4", ",", "3", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "5", ",", "1", ",", "3"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "6", ",", "5", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"2", ",", "3", ",", "3", ",", "6"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.452004316229375*^9, 3.4520049556825*^9, 3.452006404416875*^9, 3.4700176151875*^9, 3.470020218875*^9, 3.4703436348125*^9, 3.472168593234375*^9, 3.472173286640625*^9, 3.47217535840625*^9, 3.47220059390625*^9, 3.472207472078125*^9, 3.472207898640625*^9, 3.47220859896875*^9, 3.47222407890625*^9, 3.47222828428125*^9, 3.47223046334375*^9, 3.472231603703125*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"CC", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["a", "2"], "x"}], ")"}], SubscriptBox["b", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.45200743102625*^9, 3.45200745737*^9}, { 3.472169301671875*^9, 3.472169321234375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"CC", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["b", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["a", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004334479375*^9, 3.4520043486825*^9}, {3.452004964948125*^9, 3.4520049654325*^9}, {3.47002022515625*^9, 3.470020233140625*^9}, { 3.47216859853125*^9, 3.4721686064375*^9}, {3.472173278375*^9, 3.472173278578125*^9}, {3.472175362921875*^9, 3.47217536453125*^9}, { 3.472231568296875*^9, 3.47223157978125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "3", ",", "4", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "3", ",", "6", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "4", ",", "1", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "4", ",", "2", ",", "4"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.4520043513075*^9, 3.4520049684325*^9, 3.45200641690125*^9, 3.4700176195625*^9, 3.4700202340625*^9, 3.4703436379375*^9, 3.472168607859375*^9, 3.472169328375*^9, 3.47217328871875*^9, 3.4721753655*^9, 3.472200595015625*^9, 3.47220747309375*^9, 3.4722079070625*^9, 3.47220859990625*^9, 3.47222408046875*^9, 3.472228285765625*^9, 3.472230467328125*^9, 3.47223160621875*^9}] }, Open ]], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"DD", " ", "corresponds", " ", "to", " ", RowBox[{"(", RowBox[{ SubscriptBox["c", "2"], "y"}], ")"}], SubscriptBox["d", "2"]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.452007465604375*^9, 3.45200749152625*^9}, { 3.472169335296875*^9, 3.472169354109375*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DD", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"TransMat4L", "[", SubscriptBox["d", "2"], "]"}], ".", RowBox[{"TransMat4R", "[", SubscriptBox["c", "2"], "]"}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.452004227885625*^9, 3.45200426612*^9}, { 3.452004376541875*^9, 3.45200439008875*^9}, {3.45200498090125*^9, 3.45200498165125*^9}, {3.4700202383125*^9, 3.470020247078125*^9}, { 3.472168615203125*^9, 3.472168622921875*^9}, {3.472173280671875*^9, 3.472173280890625*^9}, {3.472175369421875*^9, 3.4721753714375*^9}, { 3.472231584296875*^9, 3.472231596125*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "2", ",", "4", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "4", ",", "0", ",", "5"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "1", ",", "2", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"5", ",", "1", ",", "4", ",", "6"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{3.45200439446375*^9, 3.4520049846825*^9, 3.452006433245*^9, 3.470017624484375*^9, 3.470020248265625*^9, 3.47034364090625*^9, 3.472168623859375*^9, 3.4721693604375*^9, 3.472173290375*^9, 3.47217537246875*^9, 3.472200596953125*^9, 3.472207474203125*^9, 3.472207909171875*^9, 3.4722086010625*^9, 3.472224082234375*^9, 3.47222828709375*^9, 3.4722304706875*^9, 3.472231607375*^9}] }, Open ]], Cell[BoxData[ RowBox[{"ModPEP4x4", "[", RowBox[{"AA", ",", "BB", ",", "CC", ",", "DD", ",", "p"}], "]"}]], "Input", CellChangeTimes->{{3.47217070646875*^9, 3.472170712609375*^9}, { 3.472170802390625*^9, 3.472170803625*^9}, {3.472173294828125*^9, 3.472173295*^9}, {3.472175381140625*^9, 3.472175382671875*^9}, { 3.472205121484375*^9, 3.472205127796875*^9}, {3.47222420284375*^9, 3.47222423296875*^9}, {3.472227218515625*^9, 3.472227230515625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"x", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"W", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"X", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{{3.4722272406875*^9, 3.4722272459375*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{"5", ",", "5", ",", "0", ",", "5"}], "}"}]], "Output", CellChangeTimes->{3.472231679140625*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"y", "=", RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"Y", ".", SubscriptBox["k", "1"]}], "+", RowBox[{"Z", ".", SubscriptBox["k", "2"]}]}], ",", "p"}], "]"}]}]], "Input", CellChangeTimes->{3.472227252765625*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{"5", ",", "6", ",", "4", ",", "4"}], "}"}]], "Output", CellChangeTimes->{3.472231689546875*^9}] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["b", "1"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["a", "1"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["d", "1"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["c", "1"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "1"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.47220470925*^9}, {3.472227726765625*^9, 3.472227759140625*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "1"], "x"}], ")"}], SubscriptBox["a", "1"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "1"], "y"}], ")"}], SubscriptBox["c", "1"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "1"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472231709296875*^9, 3.4722317121875*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Mod", "[", RowBox[{ RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["b", "2"], ",", "x", ",", "p"}], "]"}], ",", SubscriptBox["a", "2"], ",", "p"}], "]"}], "+", RowBox[{"QuatDotMP", "[", RowBox[{ RowBox[{"QuatDotMP", "[", RowBox[{ SubscriptBox["d", "2"], ",", "y", ",", "p"}], "]"}], ",", SubscriptBox["c", "2"], ",", "p"}], "]"}]}], ",", "p"}], "]"}], "\[Equal]", SubscriptBox["k", "2"]}]], "Input", CellChangeTimes->{{3.4722045825*^9, 3.472204754859375*^9}, { 3.4722278231875*^9, 3.4722278634375*^9}}], Cell[BoxData[ RowBox[{"True", " ", RowBox[{"(*", " ", RowBox[{ RowBox[{"Checks", " ", RowBox[{"that", ":", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["b", "2"], "x"}], ")"}], SubscriptBox["a", "2"]}], " ", "+", " ", RowBox[{ RowBox[{"(", RowBox[{ SubscriptBox["d", "2"], "y"}], ")"}], SubscriptBox["c", "2"]}]}]}]}], " ", "=", " ", RowBox[{ SubscriptBox["k", "2"], "."}]}], " ", "*)"}]}]], "Input", CellChangeTimes->{{3.472231728203125*^9, 3.47223173109375*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{"Thus", ",", " ", RowBox[{ RowBox[{ RowBox[{ RowBox[{ "we", " ", "see", " ", "that", " ", "the", " ", "order", " ", "of", " ", "the", " ", "constants", " ", "is", " ", RowBox[{"crucial", ".", " ", "One"}], " ", "way", " ", "there", " ", "was", " ", "a", " ", "solution"}], "\[IndentingNewLine]", "&"}], " ", "the", " ", "other", " ", "way", " ", "there", " ", "was", " ", RowBox[{"not", ".", " ", "There"}], " ", "are", " ", "14", " ", "other", " ", "possibilities", " ", "to", " ", "check", " ", RowBox[{"out", ".", " ", "Your"}], " ", "homework", " ", "is"}], " ", "..."}]}], " ", "*)"}]], "Input", CellChangeTimes->{{3.4722318284375*^9, 3.47223203146875*^9}}] }, WindowSize->{947, 630}, WindowMargins->{{24, Automatic}, {Automatic, -7}}, FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (February 18, 2009)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[545, 20, 43310, 1206, 1948, "Input"], Cell[43858, 1228, 1865, 38, 101, "Input"], Cell[CellGroupData[{ Cell[45748, 1270, 1545, 40, 72, "Input"], Cell[47296, 1312, 397, 7, 30, "Output"] }, Open ]], Cell[47708, 1322, 2296, 54, 192, "Input"], Cell[50007, 1378, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[50359, 1390, 558, 13, 31, "Input"], Cell[50920, 1405, 716, 16, 30, "Output"] }, Open ]], Cell[51651, 1424, 329, 8, 31, "Input"], Cell[CellGroupData[{ Cell[52005, 1436, 602, 13, 31, "Input"], Cell[52610, 1451, 696, 15, 30, "Output"] }, Open ]], Cell[53321, 1469, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[53673, 1481, 599, 13, 31, "Input"], Cell[54275, 1496, 709, 16, 30, "Output"] }, Open ]], Cell[54999, 1515, 331, 8, 31, "Input"], Cell[CellGroupData[{ Cell[55355, 1527, 604, 13, 31, "Input"], Cell[55962, 1542, 716, 15, 30, "Output"] }, Open ]], Cell[56693, 1560, 461, 7, 31, "Input"], Cell[CellGroupData[{ Cell[57179, 1571, 294, 9, 31, "Input"], Cell[57476, 1582, 134, 3, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[57647, 1590, 274, 9, 31, "Input"], Cell[57924, 1601, 135, 3, 30, "Output"] }, Open ]], Cell[58074, 1607, 641, 19, 31, "Input"], Cell[58718, 1628, 636, 20, 31, InheritFromParent], Cell[59357, 1650, 645, 19, 31, "Input"], Cell[60005, 1671, 615, 19, 31, InheritFromParent], Cell[60623, 1692, 695, 20, 31, "Input"], Cell[61321, 1714, 894, 24, 52, InheritFromParent], Cell[62218, 1740, 2468, 56, 192, "Input"], Cell[64689, 1798, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[65041, 1810, 603, 13, 31, "Input"], Cell[65647, 1825, 737, 16, 30, "Output"] }, Open ]], Cell[66399, 1844, 329, 8, 31, "Input"], Cell[CellGroupData[{ Cell[66753, 1856, 651, 14, 31, "Input"], Cell[67407, 1872, 720, 16, 30, "Output"] }, Open ]], Cell[68142, 1891, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[68494, 1903, 643, 14, 31, "Input"], Cell[69140, 1919, 729, 16, 30, "Output"] }, Open ]], Cell[69884, 1938, 331, 8, 31, "Input"], Cell[CellGroupData[{ Cell[70240, 1950, 648, 14, 31, "Input"], Cell[70891, 1966, 741, 16, 30, "Output"] }, Open ]], Cell[71647, 1985, 461, 7, 31, "Input"], Cell[72111, 1994, 294, 9, 31, "Input"], Cell[72408, 2005, 374, 10, 31, InheritFromParent], Cell[72785, 2017, 274, 9, 31, "Input"], Cell[73062, 2028, 371, 10, 31, InheritFromParent], Cell[73436, 2040, 690, 20, 31, "Input"], Cell[74129, 2062, 662, 20, 31, InheritFromParent], Cell[74794, 2084, 690, 20, 31, "Input"], Cell[75487, 2106, 682, 20, 31, InheritFromParent], Cell[76172, 2128, 87, 1, 52, "Input"], Cell[76262, 2131, 228, 6, 31, "Input"], Cell[CellGroupData[{ Cell[76515, 2141, 1570, 41, 72, "Input"], Cell[78088, 2184, 422, 7, 30, "Output"] }, Open ]], Cell[78525, 2194, 2296, 54, 192, "Input"], Cell[80824, 2250, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[81176, 2262, 558, 13, 31, "Input"], Cell[81737, 2277, 752, 16, 30, "Output"] }, Open ]], Cell[82504, 2296, 329, 8, 31, "Input"], Cell[CellGroupData[{ Cell[82858, 2308, 602, 13, 31, "Input"], Cell[83463, 2323, 735, 16, 30, "Output"] }, Open ]], Cell[84213, 2342, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[84565, 2354, 599, 13, 31, "Input"], Cell[85167, 2369, 747, 16, 30, "Output"] }, Open ]], Cell[85929, 2388, 331, 8, 31, "Input"], Cell[CellGroupData[{ Cell[86285, 2400, 604, 13, 31, "Input"], Cell[86892, 2415, 754, 16, 30, "Output"] }, Open ]], Cell[87661, 2434, 461, 7, 31, "Input"], Cell[CellGroupData[{ Cell[88147, 2445, 294, 9, 31, "Input"], Cell[88444, 2456, 160, 3, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[88641, 2464, 274, 9, 31, "Input"], Cell[88918, 2475, 161, 3, 30, "Output"] }, Open ]], Cell[89094, 2481, 641, 19, 31, "Input"], Cell[89738, 2502, 612, 19, 31, InheritFromParent], Cell[90353, 2523, 645, 19, 31, "Input"], Cell[91001, 2544, 608, 19, 31, InheritFromParent], Cell[91612, 2565, 695, 20, 31, "Input"], Cell[92310, 2587, 802, 22, 52, InheritFromParent], Cell[93115, 2611, 2468, 56, 192, "Input"], Cell[95586, 2669, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[95938, 2681, 603, 13, 31, "Input"], Cell[96544, 2696, 774, 16, 30, "Output"] }, Open ]], Cell[97333, 2715, 329, 8, 31, "Input"], Cell[CellGroupData[{ Cell[97687, 2727, 651, 14, 31, "Input"], Cell[98341, 2743, 757, 16, 30, "Output"] }, Open ]], Cell[99113, 2762, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[99465, 2774, 643, 14, 31, "Input"], Cell[100111, 2790, 765, 16, 30, "Output"] }, Open ]], Cell[100891, 2809, 331, 8, 31, "Input"], Cell[CellGroupData[{ Cell[101247, 2821, 648, 14, 31, "Input"], Cell[101898, 2837, 778, 16, 30, "Output"] }, Open ]], Cell[102691, 2856, 461, 7, 31, "Input"], Cell[103155, 2865, 294, 9, 31, "Input"], Cell[103452, 2876, 377, 10, 31, InheritFromParent], Cell[103832, 2888, 274, 9, 31, "Input"], Cell[104109, 2899, 384, 10, 31, InheritFromParent], Cell[104496, 2911, 690, 20, 31, "Input"], Cell[105189, 2933, 609, 19, 31, InheritFromParent], Cell[105801, 2954, 690, 20, 31, "Input"], Cell[106494, 2976, 609, 19, 31, InheritFromParent], Cell[107106, 2997, 277, 6, 31, "Input"], Cell[CellGroupData[{ Cell[107408, 3007, 1595, 41, 72, "Input"], Cell[109006, 3050, 135, 3, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[109178, 3058, 367, 11, 33, "Input"], Cell[109548, 3071, 92, 1, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[109677, 3077, 558, 13, 31, "Input"], Cell[110238, 3092, 759, 16, 30, "Output"] }, Open ]], Cell[111012, 3111, 329, 8, 31, "Input"], Cell[CellGroupData[{ Cell[111366, 3123, 602, 13, 31, "Input"], Cell[111971, 3138, 741, 16, 30, "Output"] }, Open ]], Cell[112727, 3157, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[113079, 3169, 599, 13, 31, "Input"], Cell[113681, 3184, 753, 16, 30, "Output"] }, Open ]], Cell[114449, 3203, 331, 8, 31, "Input"], Cell[CellGroupData[{ Cell[114805, 3215, 604, 13, 31, "Input"], Cell[115412, 3230, 760, 16, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[116209, 3251, 461, 7, 31, "Input"], Cell[116673, 3260, 117, 1, 23, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[116827, 3266, 602, 13, 31, "Input"], Cell[117432, 3281, 783, 17, 30, "Output"] }, Open ]], Cell[118230, 3301, 329, 8, 31, "Input"], Cell[CellGroupData[{ Cell[118584, 3313, 645, 14, 31, "Input"], Cell[119232, 3329, 763, 16, 30, "Output"] }, Open ]], Cell[120010, 3348, 327, 8, 31, "Input"], Cell[CellGroupData[{ Cell[120362, 3360, 647, 14, 31, "Input"], Cell[121012, 3376, 777, 17, 30, "Output"] }, Open ]], Cell[121804, 3396, 331, 8, 31, "Input"], Cell[CellGroupData[{ Cell[122160, 3408, 650, 14, 31, "Input"], Cell[122813, 3424, 779, 16, 30, "Output"] }, Open ]], Cell[123607, 3443, 461, 7, 31, "Input"], Cell[CellGroupData[{ Cell[124093, 3454, 294, 9, 31, "Input"], Cell[124390, 3465, 135, 3, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[124562, 3473, 274, 9, 31, "Input"], Cell[124839, 3484, 135, 3, 30, "Output"] }, Open ]], Cell[124989, 3490, 690, 20, 31, "Input"], Cell[125682, 3512, 613, 19, 31, InheritFromParent], Cell[126298, 3533, 690, 20, 31, "Input"], Cell[126991, 3555, 616, 19, 31, InheritFromParent], Cell[127610, 3576, 799, 16, 52, "Input"] } ] *) (* End of internal cache information *)