(* 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[ 10519, 357] NotebookOptionsPosition[ 9605, 323] NotebookOutlinePosition[ 9941, 338] CellTagsIndexPosition[ 9898, 335] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell["MATH 540: Boundary Problem System of Equations", "Text", TextAlignment->Center, FontSize->18, FontWeight->"Bold"], Cell["NAME:", "Text", FontWeight->"Bold"], Cell[TextData[{ "Instructions: (a) Type your name above. \n (b) For each exercise: (i) \ Copy and paste the program provided within the ", StyleBox["System of Equations ", FontWeight->"Bold"], "section below. \n (ii) Make the necessary edits to the initial parameters \ and then enter all the commands. \n (iii) Write sentences that summarize the \ answers to the questions. " }], "Text"], Cell[CellGroupData[{ Cell["System of Equations Method", "Section", TextAlignment->Left, FontSize->14, FontWeight->"Bold"], Cell["\<\ SizeOfUpwardJumps=a=3; SizeOfDownwardJumps=b=2; ProbUp=p=.4; ProbDown=q=.5; ProbConstant=r=1-q-p; UpperBound=n=10; LowerBound=m=0;\ \>", "Input", AspectRatioFixed->True], Cell[BoxData[{ RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"i", ",", "j"}], "]"}], "=", "0"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"i", ",", "i"}], "]"}], "=", "1"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", "m"}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"i", ",", RowBox[{"i", "-", "b"}]}], "]"}], "=", "q"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1"}], ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"i", ",", RowBox[{"i", "+", "a"}]}], "]"}], "=", "p"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1"}], ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"i", ",", "i"}], "]"}], "=", RowBox[{"r", "-", "1"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1"}], ",", RowBox[{"n", "-", "1"}]}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"t", "[", RowBox[{"i", ",", "i"}], "]"}], "=", "1"}], ",", RowBox[{"{", RowBox[{"i", ",", "n", ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"T", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"t", "[", RowBox[{"i", ",", "j"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}]}], "]"}]}], ";"}], "\n", RowBox[{"MatrixForm", "[", "T", "]"}], "\[IndentingNewLine]", RowBox[{"Det", "[", "T", "]"}]}], "Input"], Cell[BoxData[{ RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}], "=", "0"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", RowBox[{"n", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "1"}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}], "=", "1"}], ",", RowBox[{"{", RowBox[{"i", ",", "n", ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "1"}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"F", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "1"}], "}"}]}], "]"}]}], ";"}]}], "Input"], Cell["\<\ Probabilities of Reaching Upper Boundary First for Each Starting Height:\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"soln", "=", RowBox[{"N", "[", RowBox[{ RowBox[{"Inverse", "[", "T", "]"}], ".", "F"}], "]"}]}], ";"}], "\n", RowBox[{"MatrixForm", "[", RowBox[{"Reverse", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"m", "+", "i", "-", "b"}], ",", RowBox[{"soln", "[", RowBox[{"[", "i", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"n", "-", "m", "+", "a", "+", "b", "-", "1"}]}], "}"}]}], "]"}], "]"}], "]"}]}], "Input"], Cell["\<\ Average Number of Steps to Hit Boundary from Each Initial Starting Height\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}], "=", "0"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", "m"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "1"}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}], "=", RowBox[{"-", "1"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1"}], ",", RowBox[{"n", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "1"}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}], "=", "0"}], ",", RowBox[{"{", RowBox[{"i", ",", "n", ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "1"}], "}"}]}], "]"}], ";"}], "\n", RowBox[{ RowBox[{"F", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"m", "+", "1", "-", "b"}], ",", RowBox[{"n", "-", "1", "+", "a"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "1"}], "}"}]}], "]"}]}], ";"}]}], "Input"], Cell[BoxData[{ RowBox[{ RowBox[{"soln", "=", RowBox[{"N", "[", RowBox[{ RowBox[{"Inverse", "[", "T", "]"}], ".", "F"}], "]"}]}], ";"}], "\n", RowBox[{"MatrixForm", "[", RowBox[{"Reverse", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"m", "+", "i", "-", "b"}], ",", RowBox[{"soln", "[", RowBox[{"[", "i", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"n", "-", "m", "+", "a", "+", "b", "-", "1"}]}], "}"}]}], "]"}], "]"}], "]"}]}], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Exercise 1", "Section"], Cell["\<\ In a gambling game, you bet $30 at a time with a 4 : 3 payoff and a \ probability of p = 0.42 of winning. (There are no ties.) You want at least \ a 75% chance of reaching $300 (or more) before going bust. (a) What is the minimum dollar amount with which you must start? (b) If you start with this amount, then what is the exact probability of \ attaining your goal, and what is the average number of bets you can make \ before attaining your goal or going bust? (c) In order to maximize the average number of bets you can make, with \ what dollar amount should you begin, and what would be the probability of \ attaining your goal when starting with this amount?\ \>", "Text", TextJustification->0] }, Closed]], Cell[CellGroupData[{ Cell["Exercise 2", "Section"], Cell["\<\ In a gambling game, let p = 0.10 and let the payoff be 8 : 1. (Again, no \ ties.) You bet $10 at a time. You wish to quit when you \ \[OpenCurlyDoubleQuote]go ahead\[CloseCurlyDoubleQuote] or go bust (i.e., \ start with $10 and have a goal of $20 or more; or start with $20 and have a \ goal of $30 or more, etc.). In general, you start with $10k and have a top goal of $10(k+1) or more. You \ want at least an 80% chance of attaining your goal. (a) What is the minimum dollar amount with which you must start? (b) With this initial amount, what is the average number of bets that would \ be made? Note: In this case, it is best to scale down the dollar values to avoid \ creating huge matrices. Also, you must verify that the starting amount you \ find is indeed the minimum possible value.\ \>", "Text", TextAlignment->Left, TextJustification->0] }, Closed]] }, WindowSize->{740, 446}, WindowMargins->{{Automatic, 28}, {Automatic, 0}}, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (April 20, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 123, 3, 32, "Text"], Cell[694, 26, 42, 1, 26, "Text"], Cell[739, 29, 402, 8, 71, "Text"], Cell[CellGroupData[{ Cell[1166, 41, 103, 3, 61, "Section"], Cell[1272, 46, 180, 9, 105, "Input"], Cell[1455, 57, 2467, 82, 148, "Input"], Cell[3925, 141, 1090, 35, 58, "Input"], Cell[5018, 178, 97, 3, 41, "Text"], Cell[5118, 183, 584, 18, 43, "Input"], Cell[5705, 203, 97, 2, 26, "Text"], Cell[5805, 207, 1434, 47, 73, "Input"], Cell[7242, 256, 584, 18, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[7863, 279, 29, 0, 37, "Section"], Cell[7895, 281, 735, 13, 166, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[8667, 299, 29, 0, 37, "Section"], Cell[8699, 301, 890, 19, 242, "Text"] }, Closed]] } ] *) (* End of internal cache information *)