(* 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[ 10774, 338] NotebookOptionsPosition[ 8198, 257] NotebookOutlinePosition[ 9304, 293] CellTagsIndexPosition[ 9220, 288] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Defining Functions", "Section", CellChangeTimes->{{3.414227082117578*^9, 3.414227087244145*^9}}], Cell[TextData[{ "Note: to evaluate ", StyleBox["Mathematica", FontSlant->"Italic"], " commands, press Shift-Enter" }], "Text", CellChangeTimes->{{3.415685155231065*^9, 3.415685166661867*^9}}, FontSize->18], Cell[BoxData[ RowBox[{ RowBox[{"testfunc", "[", "x_", "]"}], ":=", RowBox[{"Sin", "[", "x", "]"}]}]], "Input", CellChangeTimes->{{3.41422617176963*^9, 3.414226182395082*^9}}], Cell[BoxData[ RowBox[{"testfunc", "[", "Pi", "]"}]], "Input", CellChangeTimes->{{3.41422618480277*^9, 3.414226187988439*^9}}], Cell[BoxData[ RowBox[{"testfunc", "[", RowBox[{"Pi", "/", "2"}], "]"}]], "Input", CellChangeTimes->{{3.414226192856291*^9, 3.414226193027785*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Everything is an Expression", "Section", CellChangeTimes->{{3.414227082117578*^9, 3.414227101566248*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"MyList", "=", RowBox[{"{", RowBox[{"3", ",", "2", ",", "a", ",", " ", "1.0"}], "}"}]}], ";"}]], "Input", CellChangeTimes->{{3.414226368402262*^9, 3.414226380892553*^9}}], Cell[BoxData[ RowBox[{"MyList", "//", "FullForm"}]], "Input", CellChangeTimes->{{3.414226511813084*^9, 3.41422651323095*^9}}], Cell[BoxData[ RowBox[{"MyList", "//", "TreeForm"}]], "Input", CellChangeTimes->{{3.414226518110434*^9, 3.414226520177752*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"MyExpression", " ", "=", " ", RowBox[{ RowBox[{"x", "^", "3"}], "+", RowBox[{"y", "*", "z"}]}]}], ";"}]], "Input", CellChangeTimes->{{3.414226276165014*^9, 3.414226291894227*^9}, 3.414226383485729*^9}], Cell[BoxData[ RowBox[{"MyExpression", "//", "FullForm"}]], "Input", CellChangeTimes->{{3.414226294393746*^9, 3.414226300698505*^9}}], Cell[BoxData[ RowBox[{"MyExpression", "//", "TreeForm"}]], "Input", CellChangeTimes->{{3.414226328178076*^9, 3.414226330995835*^9}}], Cell[BoxData[ RowBox[{"Head", "[", "MyExpression", "]"}]], "Input", CellChangeTimes->{{3.414226337630055*^9, 3.414226340816959*^9}}], Cell[BoxData[ RowBox[{"MyExpression", "//", "Last"}]], "Input", CellChangeTimes->{{3.414226349091253*^9, 3.414226356431398*^9}}], Cell[BoxData[ RowBox[{"MyExpression", "//", "First"}]], "Input", CellChangeTimes->{{3.414226361551219*^9, 3.414226362695864*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"MySystem", "=", RowBox[{"{", RowBox[{ RowBox[{"x", "\[Equal]", RowBox[{"y", "+", "v"}]}], ",", " ", RowBox[{"z", "\[Equal]", RowBox[{"x", "+", "b"}]}]}], "}"}]}], ";"}]], "Input", CellChangeTimes->{{3.414226533021449*^9, 3.414226564073885*^9}}], Cell[BoxData[ RowBox[{"%", "//", "TreeForm"}]], "Input", CellChangeTimes->{{3.414226566776927*^9, 3.414226568519383*^9}}], Cell[BoxData[ RowBox[{"MySystem", "/.", RowBox[{"Equal", "\[Rule]", " ", "Rule"}]}]], "Input", CellChangeTimes->{{3.414226580503475*^9, 3.414226584125517*^9}}], Cell[BoxData[ RowBox[{"x", "/.", "%"}]], "Input", CellChangeTimes->{{3.414226587324009*^9, 3.414226589713395*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Patterns", "Section", CellChangeTimes->{{3.414227082117578*^9, 3.414227101566248*^9}, { 3.414227145818817*^9, 3.41422714756305*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"testMultiply", "[", "x___", "]"}], ":=", RowBox[{"Times", "[", "x", "]"}]}]], "Input", CellChangeTimes->{{3.414226610734359*^9, 3.414226624566103*^9}}], Cell[BoxData[ RowBox[{"testMultiply", "[", RowBox[{"2", ",", "3"}], "]"}]], "Input", CellChangeTimes->{{3.414226669235096*^9, 3.414226670446865*^9}}], Cell[BoxData[ RowBox[{"testMultiply", "[", RowBox[{"2", ",", "3", ",", "4"}], "]"}]], "Input", CellChangeTimes->{{3.414226629206938*^9, 3.414226639395091*^9}}], Cell[BoxData[ RowBox[{"testMultiply", "[", "]"}]], "Input", CellChangeTimes->{{3.414226658524907*^9, 3.414226659256736*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"testRestrictDef", "[", "x___Symbol", "]"}], ":=", RowBox[{"Plus", "[", "x", "]"}]}]], "Input", CellChangeTimes->{{3.414226648973631*^9, 3.414226651470185*^9}, { 3.414226695213309*^9, 3.414226733809507*^9}}], Cell[BoxData[ RowBox[{"testRestrictDef", "[", RowBox[{"1", ",", "2", ",", "3"}], "]"}]], "Input", CellChangeTimes->{{3.414226711516511*^9, 3.414226713877319*^9}}], Cell[BoxData[ RowBox[{"testRestrictDef", "[", RowBox[{"a1", ",", "a2", ",", "a3"}], "]"}]], "Input", CellChangeTimes->{{3.414226718182567*^9, 3.414226719679206*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Map and Apply", "Section", CellChangeTimes->{{3.414227164808231*^9, 3.414227170488803*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "Map"}]], "Input", CellChangeTimes->{{3.414227179265316*^9, 3.414227179669717*^9}}], Cell[BoxData[ RowBox[{ StyleBox["\<\"\\!\\(\\*RowBox[{\\\"Map\\\", \\\"[\\\", \ RowBox[{StyleBox[\\\"f\\\", \\\"TI\\\"], \\\",\\\", StyleBox[\\\"expr\\\", \\\ \"TI\\\"]}], \\\"]\\\"}]\\) or \\!\\(\\*RowBox[{StyleBox[\\\"f\\\", \ \\\"TI\\\"], \\\"/@\\\", StyleBox[\\\"expr\\\", \\\"TI\\\"]}]\\) applies \ \\!\\(\\*StyleBox[\\\"f\\\", \\\"TI\\\"]\\) to each element on the first \ level in \\!\\(\\*StyleBox[\\\"expr\\\", \\\"TI\\\"]\\). \\n\\!\\(\\*RowBox[{\ \\\"Map\\\", \\\"[\\\", RowBox[{StyleBox[\\\"f\\\", \\\"TI\\\"], \\\",\\\", \ StyleBox[\\\"expr\\\", \\\"TI\\\"], \\\",\\\", StyleBox[\\\"levelspec\\\", \\\ \"TI\\\"]}], \\\"]\\\"}]\\) applies \\!\\(\\*StyleBox[\\\"f\\\", \ \\\"TI\\\"]\\) to parts of \\!\\(\\*StyleBox[\\\"expr\\\", \\\"TI\\\"]\\) \ specified by \\!\\(\\*StyleBox[\\\"levelspec\\\", \\\"TI\\\"]\\). \"\>", "MSG"], " ", ButtonBox[ StyleBox["\[RightSkeleton]", "SR"], Active->True, BaseStyle->"Link", ButtonData->"paclet:ref/Map"]}]], "Print", "PrintUsage", CellChangeTimes->{3.414227180280262*^9}, CellTags->"Info3414230780-1501048"] }, Open ]], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"Head", "[", "#", "]"}], "&"}], "/@", RowBox[{"{", RowBox[{"a", ",", "b", ",", "1", ",", "2.0", ",", "6.5", ",", RowBox[{"f", "[", "t", "]"}]}], "}"}]}]], "Input", CellChangeTimes->{{3.414226743105823*^9, 3.414226779040885*^9}, { 3.414226843278122*^9, 3.414226844954763*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"a", ",", "b", ",", "1", ",", "2.0", ",", "6.5", ",", RowBox[{"f", "[", "t", "]"}]}], "}"}], "/.", RowBox[{"x_Real", "\[Rule]", " ", RowBox[{"x", "^", "2"}]}]}]], "Input", CellChangeTimes->{{3.414226808814112*^9, 3.414226857733642*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"a", ",", "b", ",", "1", ",", "2.0", ",", "6.5", ",", RowBox[{"f", "[", "t", "]"}]}], "}"}], "/.", RowBox[{"x_Real", "\[Rule]", " ", RowBox[{"x", "^", "2"}]}]}]], "Input"], Cell[BoxData[ RowBox[{"?", "Apply"}]], "Input", CellChangeTimes->{{3.414226936934944*^9, 3.41422695052572*^9}}], Cell[BoxData[ RowBox[{"Times", "@@", RowBox[{"{", RowBox[{"a", ",", "b", ",", "1", ",", "2.0", ",", "6.5", ",", RowBox[{"f", "[", "t", "]"}]}], "}"}]}]], "Input", CellChangeTimes->{{3.414226886558263*^9, 3.414226887566131*^9}}], Cell[BoxData[ RowBox[{"Plus", "@@", RowBox[{"{", RowBox[{"a", ",", "b", ",", "1", ",", "2.0", ",", "6.5", ",", RowBox[{"f", "[", "t", "]"}]}], "}"}]}]], "Input", CellChangeTimes->{{3.414226898479015*^9, 3.414226900107816*^9}}], Cell[BoxData[ RowBox[{"myFunc", "@@", RowBox[{"{", RowBox[{"a", ",", "b", ",", "1", ",", "2.0", ",", "6.5", ",", RowBox[{"f", "[", "t", "]"}]}], "}"}]}]], "Input", CellChangeTimes->{{3.414226908648051*^9, 3.414226925353996*^9}}] }, Open ]] }, WindowSize->{902, 926}, WindowMargins->{{Automatic, 102}, {Automatic, 0}}, PrintingPageRange->{Automatic, Automatic}, PrintingOptions->{"Magnification"->1., "PaperOrientation"->"Portrait", "PaperSize"->{611.25, 789.5625}, "PostScriptOutputFile"->"/home/jameslu/Teaching/MathModelBioSciences_Summer08/\ Lecture2/MathematicaPreliminaries.nb.ps"}, ShowSelection->True, FrontEndVersion->"6.0 for Linux x86 (32-bit) (April 20, 2007)", StyleDefinitions->Notebook[{ Cell[ StyleData[StyleDefinitions -> "Default.nb"]], Cell[ StyleData["Input"], FontSize -> 24], Cell[ StyleData["Output"], FontSize -> 24, FontWeight -> "Plain"]}, Visible -> False, FrontEndVersion -> "6.0 for Linux x86 (32-bit) (April 20, 2007)", StyleDefinitions -> "PrivateStylesheetFormatting.nb"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "Info3414230780-1501048"->{ Cell[5362, 181, 1081, 20, 64, "Print", CellTags->"Info3414230780-1501048"]} } *) (*CellTagsIndex CellTagsIndex->{ {"Info3414230780-1501048", 9115, 282} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 103, 1, 73, "Section"], Cell[696, 26, 212, 7, 33, "Text"], Cell[911, 35, 181, 4, 41, "Input"], Cell[1095, 41, 127, 2, 39, "Input"], Cell[1225, 45, 151, 3, 39, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[1413, 53, 112, 1, 73, "Section"], Cell[1528, 56, 217, 6, 39, "Input"], Cell[1748, 64, 127, 2, 39, "Input"], Cell[1878, 68, 128, 2, 39, "Input"], Cell[2009, 72, 254, 7, 39, "Input"], Cell[2266, 81, 134, 2, 39, "Input"], Cell[2403, 85, 134, 2, 39, "Input"], Cell[2540, 89, 134, 2, 39, "Input"], Cell[2677, 93, 130, 2, 39, "Input"], Cell[2810, 97, 131, 2, 39, "Input"], Cell[2944, 101, 314, 9, 39, "Input"], Cell[3261, 112, 123, 2, 39, "Input"], Cell[3387, 116, 164, 3, 39, "Input"], Cell[3554, 121, 116, 2, 39, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[3707, 128, 141, 2, 73, "Section"], Cell[3851, 132, 190, 4, 41, "Input"], Cell[4044, 138, 154, 3, 39, "Input"], Cell[4201, 143, 164, 3, 39, "Input"], Cell[4368, 148, 126, 2, 39, "Input"], Cell[4497, 152, 247, 5, 41, "Input"], Cell[4747, 159, 167, 3, 39, "Input"], Cell[4917, 164, 170, 3, 39, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[5124, 172, 98, 1, 73, "Section"], Cell[CellGroupData[{ Cell[5247, 177, 112, 2, 39, "Input"], Cell[5362, 181, 1081, 20, 64, "Print", CellTags->"Info3414230780-1501048"] }, Open ]], Cell[6458, 204, 336, 8, 39, "Input"], Cell[6797, 214, 300, 7, 41, "Input"], Cell[7100, 223, 234, 6, 41, "Input"], Cell[7337, 231, 113, 2, 39, "Input"], Cell[7453, 235, 241, 5, 39, "Input"], Cell[7697, 242, 240, 5, 39, "Input"], Cell[7940, 249, 242, 5, 39, "Input"] }, Open ]] } ] *) (* End of internal cache information *)