(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 9793, 260] NotebookOptionsPosition[ 9502, 246] NotebookOutlinePosition[ 9844, 261] CellTagsIndexPosition[ 9801, 258] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"Weight", "[", "M_", "]"}], ":=", RowBox[{ UnderoverscriptBox["\[Product]", RowBox[{"i", "=", "1"}], RowBox[{"Length", "[", RowBox[{"Flatten", "[", "M", "]"}], "]"}]], RowBox[{ SuperscriptBox["p", RowBox[{ RowBox[{"Flatten", "[", "M", "]"}], "[", RowBox[{"[", "i", "]"}], "]"}]], SuperscriptBox[ RowBox[{"(", RowBox[{"1", "-", "p"}], ")"}], RowBox[{"1", "-", RowBox[{ RowBox[{"Flatten", "[", "M", "]"}], "[", RowBox[{"[", "i", "]"}], "]"}]}]]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"RandM", "[", RowBox[{"d_", ",", "D_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"L", ",", "i", ",", "j"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"L", "=", RowBox[{"IntegerDigits", "[", RowBox[{ RowBox[{"Random", "[", RowBox[{"Integer", ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{ SuperscriptBox["2", RowBox[{"D", " ", "d"}]], "-", "1"}]}], "}"}]}], "]"}], ",", "2", ",", RowBox[{"D", " ", "d"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"L", "[", RowBox[{"[", RowBox[{"i", "+", " ", RowBox[{ RowBox[{"(", RowBox[{"j", "-", "1"}], ")"}], "d"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "D"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "d"}], "}"}]}], "]"}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"IsSolvable", "[", "M_", "]"}], ":=", RowBox[{ RowBox[{"IsSolvable", "[", "M", "]"}], "=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "A", ",", "B", ",", "D", ",", "d", ",", "i", ",", "j", ",", "k"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"D", ",", "d"}], "}"}], "=", RowBox[{"Dimensions", "[", "M", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"A", "=", RowBox[{"Range", "[", "d", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", " ", "=", "1"}], ",", RowBox[{"i", "\[LessEqual]", "D"}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"Print", "[", "A", "]"}], ";"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"B", "=", RowBox[{"Cases", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"M", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "\[Equal]", "1"}], ",", "j", ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "d"}], "}"}]}], "]"}], ",", RowBox[{"x_", "/;", RowBox[{"x", ">", "0"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"A", "=", RowBox[{"A", "\[Intersection]", "B"}]}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"k", "=", "1"}], ",", RowBox[{"k", "\[LessEqual]", "d"}], ",", RowBox[{"k", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"For", "[", RowBox[{ RowBox[{"j", "=", "1"}], ",", RowBox[{"j", "\[LessEqual]", RowBox[{"Length", "[", "A", "]"}]}], ",", RowBox[{"j", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"B", ",", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "j", "]"}], "]"}], "-", "1"}]}], "]"}], ",", RowBox[{"A", "=", RowBox[{"A", "\[Union]", RowBox[{"{", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "j", "]"}], "]"}], "-", "1"}], "}"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"B", ",", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "j", "]"}], "]"}], "+", "1"}]}], "]"}], ",", RowBox[{"A", "=", RowBox[{"A", "\[Union]", RowBox[{"{", RowBox[{ RowBox[{"A", "[", RowBox[{"[", "j", "]"}], "]"}], "+", "1"}], "}"}]}]}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", "A", "]"}], ">", "0"}], ",", RowBox[{"Return", "[", "True", "]"}], ",", RowBox[{"Return", "[", "False", "]"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"MonteCarlo", "[", RowBox[{"d_", ",", "D_", ",", "K_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"num", ",", "denom", ",", "M", ",", "W", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"num", "=", "0"}], ";", RowBox[{"denom", "=", "0"}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"i", "=", "1"}], ",", RowBox[{"i", "\[LessEqual]", "K"}], ",", RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"M", "=", RowBox[{"RandM", "[", RowBox[{"d", ",", "D"}], "]"}]}], ";", RowBox[{"W", "=", RowBox[{"Weight", "[", "M", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"IsSolvable", "[", "M", "]"}], ",", RowBox[{"num", "+=", "W"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"denom", "+=", "W"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"Print", "[", RowBox[{"Plot", "[", RowBox[{ RowBox[{"num", "/", "denom"}], ",", RowBox[{"{", RowBox[{"p", ",", "0", ",", "1"}], "}"}]}], "]"}], "]"}], ";"}], "*)"}], "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{ RowBox[{"Expand", "[", "num", "]"}], "/", RowBox[{"Expand", "[", "denom", "]"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.449221755765625*^9, 3.449221764359375*^9}, { 3.449221920109375*^9, 3.449221945359375*^9}, {3.449222068734375*^9, 3.44922207909375*^9}, {3.44922211109375*^9, 3.4492221150625*^9}, { 3.44922220725*^9, 3.449222223421875*^9}, {3.449222262390625*^9, 3.44922231546875*^9}, {3.44922243703125*^9, 3.4492224616875*^9}, { 3.449222535046875*^9, 3.44922254415625*^9}, {3.44922258075*^9, 3.449222593953125*^9}, {3.4492226355625*^9, 3.449222648734375*^9}, { 3.449223082984375*^9, 3.449223229734375*^9}, {3.449223320734375*^9, 3.44922333371875*^9}, 3.44922337375*^9, {3.449223465640625*^9, 3.44922350509375*^9}, {3.449223964671875*^9, 3.449224068171875*^9}, { 3.449224102703125*^9, 3.44922410903125*^9}, {3.4492241595625*^9, 3.449224215671875*^9}, {3.44924192346875*^9, 3.449241927890625*^9}, { 3.449242043046875*^9, 3.44924206115625*^9}, {3.449242174890625*^9, 3.449242230453125*^9}, {3.449412030765625*^9, 3.449412034171875*^9}, { 3.449412112671875*^9, 3.44941211446875*^9}, {3.44941443059375*^9, 3.44941444278125*^9}, {3.449414617859375*^9, 3.44941467140625*^9}, { 3.449415013296875*^9, 3.449415026796875*^9}, {3.449415174671875*^9, 3.44941517928125*^9}, {3.44941673971875*^9, 3.449416743578125*^9}}], Cell["\<\ Released under Kellen's license: \ http://math.rutgers.edu/~kellenm/license.html\ \>", "Text", CellChangeTimes->{{3.474378710914875*^9, 3.474378724446125*^9}}] }, WindowSize->{1230, 668}, WindowMargins->{{0, Automatic}, {Automatic, -1}}, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (April 28, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 8757, 217, 759, "Input"], Cell[9328, 240, 170, 4, 34, "Text"] } ] *) (* End of internal cache information *)