(* Content-type: application/vnd.wolfram.cdf.text *) (*** Wolfram CDF File ***) (* http://www.wolfram.com/cdf *) (* CreatedBy='Mathematica 9.0' *) (*************************************************************************) (* *) (* The Mathematica License under which this file was created prohibits *) (* restricting third parties in receipt of this file from republishing *) (* or redistributing it by any means, including but not limited to *) (* rights management or terms of use, without the express consent of *) (* Wolfram Research, Inc. For additional information concerning CDF *) (* licensing and redistribution see: *) (* *) (* www.wolfram.com/cdf/adopting-cdf/licensing-options.html *) (* *) (*************************************************************************) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 1063, 20] NotebookDataLength[ 8705, 250] NotebookOptionsPosition[ 9365, 250] NotebookOutlinePosition[ 9710, 265] CellTagsIndexPosition[ 9667, 262] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{"Manipulate", "[", RowBox[{ RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "=", RowBox[{"data", "[", RowBox[{"[", RowBox[{ RowBox[{"1", ";;", "h"}], ",", RowBox[{"1", ";;", "h"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"nums", "=", RowBox[{"p", "[", RowBox[{"t", ",", RowBox[{"_", "?", "NumberQ"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"fx", "=", RowBox[{"Nearest", "[", RowBox[{"p", "[", RowBox[{"t", ",", "x"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"flagMinus", "/@", RowBox[{"p", "[", RowBox[{"t", ",", "F"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"eqs", "=", RowBox[{"MapIndexed", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"c", "@@", RowBox[{ RowBox[{"nums", "[", RowBox[{"[", "#2", "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], "]"}], "]"}], "\[Equal]", RowBox[{"g", "@", "#1"}]}], "&"}], ",", RowBox[{ RowBox[{ RowBox[{"fx", "[", RowBox[{"#", ",", RowBox[{"{", RowBox[{"8", ",", "1.5"}], "}"}]}], "]"}], "&"}], "/@", "nums"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"vars", "=", RowBox[{"Union", "@", RowBox[{"Cases", "[", RowBox[{"eqs", ",", "_q", ",", "4"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"s", "=", RowBox[{"Solve", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{"eqs", ",", RowBox[{"Thread", "[", RowBox[{"0", "\[LessEqual]", "vars", "<", "2"}], "]"}]}], "]"}], ",", "vars", ",", "Integers"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"s", "\[Equal]", RowBox[{"{", RowBox[{"{", "}"}], "}"}]}], ",", RowBox[{"ns", "=", "\"\\""}], ",", RowBox[{"ns", "=", "\"\<\>\""}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"numSols", "=", RowBox[{"Length", "@", "s"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"numSols", "\[NotEqual]", "0"}], ",", RowBox[{"res", "=", RowBox[{ RowBox[{"(", RowBox[{"Transpose", "@", "s"}], ")"}], "[", RowBox[{"[", RowBox[{"All", ",", "All", ",", "2"}], "]"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"numSols", "\[NotEqual]", "0"}], ",", RowBox[{"colMap", "=", RowBox[{"Grid", "[", RowBox[{ RowBox[{"Union", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Blend", "[", RowBox[{ RowBox[{"{", RowBox[{"Green", ",", "Red"}], "}"}], ",", "#"}], "]"}], ",", RowBox[{"Rectangle", "[", "]"}]}], "}"}], ",", RowBox[{"ImageSize", "\[Rule]", "20"}]}], "]"}], ",", RowBox[{"N", "@", "#"}]}], "}"}], "&"}], "/@", RowBox[{"(", RowBox[{ RowBox[{"Tr", "/@", "res"}], "/", "numSols"}], ")"}]}], "]"}], ",", RowBox[{"Dividers", "\[Rule]", "All"}]}], "]"}]}], ",", RowBox[{"colMap", "=", "\"\<\>\""}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "Store", " ", "Prob", " ", "of", " ", "bomb", " ", "in", " ", "h"}], "*)"}], "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"numSols", "\[NotEqual]", "0"}], ",", RowBox[{"cols", "=", RowBox[{"Thread", "[", RowBox[{"Rule", "[", RowBox[{ RowBox[{"First", "/@", RowBox[{"List", "@@@", "vars"}]}], ",", RowBox[{ RowBox[{ RowBox[{"Blend", "[", RowBox[{ RowBox[{"{", RowBox[{"Green", ",", "Red"}], "}"}], ",", "#"}], "]"}], "&"}], "/@", RowBox[{"(", RowBox[{ RowBox[{"Tr", "/@", "res"}], "/", "numSols"}], ")"}]}]}], "]"}], "]"}]}], ",", RowBox[{"cols", "=", RowBox[{"{", "}"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Row", "[", RowBox[{"{", RowBox[{ RowBox[{"Grid", "[", RowBox[{ RowBox[{"Take", "[", RowBox[{"data", ",", "h", ",", "h"}], "]"}], ",", RowBox[{"Background", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", "None", ",", "cols"}], "}"}]}], ",", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", "Center"}], "}"}]}], ",", RowBox[{"Dividers", "\[Rule]", "All"}]}], "]"}], ",", "\"\< \>\"", ",", RowBox[{"Column", "[", RowBox[{"{", RowBox[{"\"\\"", ",", "colMap"}], "}"}], "]"}], ",", "\"\< \>\"", ",", "ns"}], "}"}], "]"}]}], "\[IndentingNewLine]", ")"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"data", ",", RowBox[{"ConstantArray", "[", RowBox[{"x", ",", RowBox[{"{", RowBox[{"10", ",", "10"}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"ControlType", "\[Rule]", "None"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"h", ",", "5"}], "}"}], ",", "1", ",", "10", ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Dynamic", "[", RowBox[{"Panel", "[", RowBox[{"Grid", "[", RowBox[{"Outer", "[", RowBox[{ RowBox[{ RowBox[{"PopupMenu", "[", RowBox[{ RowBox[{"Dynamic", "[", RowBox[{"data", "[", RowBox[{"[", RowBox[{"#1", ",", "#2"}], "]"}], "]"}], "]"}], ",", RowBox[{"Join", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "F"}], "}"}], ",", RowBox[{"Range", "[", RowBox[{"0", ",", "8"}], "]"}]}], "]"}]}], "]"}], "&"}], ",", RowBox[{"Range", "[", "h", "]"}], ",", RowBox[{"Range", "[", "h", "]"}]}], "]"}], "]"}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Initialization", "\[RuleDelayed]", RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"c", "=", "Sequence"}], ";", "\[IndentingNewLine]", RowBox[{"p", "=", "Position"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"flagMinus", "[", "flag_", "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Norm", "[", RowBox[{"#", "-", "flag"}], "]"}], "<", "1.5"}], ",", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"c", "@@", "#"}], "]"}], "]"}], "--"}]}], "]"}], "&"}], "/@", "nums"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"g", "@", "x_List"}], ":=", RowBox[{"Tr", "[", RowBox[{ RowBox[{ RowBox[{"q", "[", "#", "]"}], "&"}], "/@", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", ")"}]}], ",", "\[IndentingNewLine]", RowBox[{"TrackedSymbols", "\[RuleDelayed]", RowBox[{"{", RowBox[{"data", ",", "h"}], "}"}]}]}], "]"}]], "Input"] }, WindowSize->{715, 655}, WindowMargins->{{144, Automatic}, {Automatic, 30}}, FrontEndVersion->"9.0 for Microsoft Windows (32-bit) (January 25, 2013)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1463, 33, 7898, 215, 812, "Input"] } ] *) (* End of internal cache information *) (* NotebookSignature 2wTDTMpMbF488DgSEz3tFiLs *)