(* 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[ 68834, 2406] NotebookOptionsPosition[ 57432, 2080] NotebookOutlinePosition[ 57876, 2098] CellTagsIndexPosition[ 57833, 2095] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Introduction to ", StyleBox["Mathematica \[MathematicaIcon]", FontSlant->"Italic"] }], "Title"], Cell["2. More about Functions and Lists", "Subtitle"], Cell["\<\ P. S. Cally, School of Mathematical Sciences, Monash University\ \>", "Author"], Cell[CellGroupData[{ Cell["Ways to Define Functions, Map, and Apply", "Section"], Cell["The following three definitions are equivalent:", "Text"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], "=", SuperscriptBox["x", "2"]}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"g", "=", RowBox[{"Function", "[", RowBox[{"x", ",", SuperscriptBox["x", "2"]}], "]"}]}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"h", "=", RowBox[{ SuperscriptBox["#", "2"], "&"}]}], ";"}]], "Input"], Cell["\<\ (# represents the argument, and & says this is a pure function). Let's check:\ \ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "x", "]"}], "\[Equal]", RowBox[{"g", "[", "x", "]"}], "\[Equal]", RowBox[{"h", "[", "x", "]"}]}]], "Input", CellChangeTimes->{{3.4013143866068573`*^9, 3.4013143963267193`*^9}, 3.401554564164714*^9}], Cell["or", "Text", CellChangeTimes->{{3.4013144430552673`*^9, 3.401314443407826*^9}}], Cell[BoxData[ RowBox[{"TableForm", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", RowBox[{"f", "[", "x", "]"}], ",", RowBox[{"g", "[", "x", "]"}], ",", RowBox[{"h", "[", "x", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "1", ",", "6"}], "}"}]}], "]"}], ",", RowBox[{"TableHeadings", "\[Rule]", RowBox[{"{", RowBox[{"None", ",", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], "}"}]}]}], "]"}]], "Input"], Cell["\<\ We don't need these definitions anymore, so let's clear them.\ \>", "Text"], Cell[BoxData[ RowBox[{"Clear", "[", RowBox[{"f", ",", "g", ",", "h"}], "]"}]], "Input"], Cell["\<\ g and h are called \"pure functions\". They are very useful for use with many \ utilities such as Map, Apply, and Nest. For example Map[function,list] maps \ the function onto the list:\ \>", "Text"], Cell[BoxData[ RowBox[{"Map", "[", RowBox[{"Exp", ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4", ",", "5"}], "}"}]}], "]"}]], "Input"], Cell[TextData[{ "That's fine if your function has a simple name. But what if we wanted to \ find ", Cell[BoxData[ FormBox[ FractionBox["1", RowBox[{"x", "+", "1"}]], TraditionalForm]]], " for a set of values" }], "Text"], Cell[BoxData[ RowBox[{"Map", "[", RowBox[{ RowBox[{ FractionBox["1", RowBox[{"1", "+", "#"}]], "&"}], ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4", ",", "5"}], "}"}]}], "]"}]], "Input"], Cell["\<\ The function here must be \"pure\", i.e., just the function name, and not the \ [\[Ellipsis]] part. A more convenient short-cut notation for Map is /@, thus\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{ FractionBox["1", RowBox[{"1", "+", "#"}]], "&"}], " ", "/@", " ", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4", ",", "5"}], "}"}]}]], "Input"], Cell["\<\ Actually, there's an even simpler way to do this sort of thing in many \ instances:\ \>", "Text"], Cell[BoxData[ RowBox[{"Exp", "[", RowBox[{"Range", "[", RowBox[{"1", ",", "5"}], "]"}], "]"}]], "Input"], Cell["\<\ This works because the exponential function has the attribute Listable, so it \ automatically applies individually to every element of a list.\ \>", "Text"], Cell[BoxData[ RowBox[{"Attributes", "[", "Exp", "]"}]], "Input"], Cell["\<\ Now take some arbitrary function which is not defined to be Listable:\ \>", "Text"], Cell[BoxData[ RowBox[{"Attributes", "[", "f", "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"Range", "[", RowBox[{"1", ",", "5"}], "]"}], "]"}]], "Input"], Cell["\<\ Do you see that f did not thread over the list. But we can change that:\ \>", "Text"], Cell[BoxData[ RowBox[{"SetAttributes", "[", RowBox[{"f", ",", "Listable"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"Range", "[", RowBox[{"1", ",", "5"}], "]"}], "]"}]], "Input"], Cell["Of course, we could also have done this:", "Text"], Cell[BoxData[ RowBox[{"f", "/@", RowBox[{"Range", "[", RowBox[{"1", ",", "5"}], "]"}]}]], "Input"], Cell["Many built-in mathematical functions are Listable", "Text"], Cell[BoxData[ RowBox[{"Attributes", "[", "BesselJ", "]"}]], "Input", CellChangeTimes->{{3.401314559187132*^9, 3.4013145629461193`*^9}}], Cell["\<\ but of course many are not. It would not make sense to make this Listable:\ \>", "Text"], Cell[BoxData[ RowBox[{"Attributes", "[", "Eigenvalues", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Eigenvalues", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "2"}], "}"}]}], "}"}], "]"}]], "Input", CellChangeTimes->{{3.4013146150677834`*^9, 3.401314661001231*^9}}], Cell["\<\ Now here is Apply[function,list], which applies the function to the whole \ list, e.g, Apply[f,{a,b,c,\[Ellipsis]}]=f[a,b,c,\[Ellipsis]]. Here is a \ common example:\ \>", "Text"], Cell[BoxData[ RowBox[{"Apply", "[", RowBox[{"Plus", ",", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3", ",", "4", ",", "5"}], "}"}]}], "]"}]], "Input"], Cell["or more conveniently", "Text"], Cell[BoxData[ RowBox[{"Plus", "@@", RowBox[{"Range", "[", "5", "]"}]}]], "Input"], Cell["This adds all the elements in a list. To multiply them", "Text"], Cell[BoxData[ RowBox[{"Times", "@@", RowBox[{"Range", "[", "5", "]"}]}]], "Input"], Cell["which is of course", "Text"], Cell[BoxData[ RowBox[{"5", "!"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Nest and its ilk", "Section"], Cell[TextData[{ "Given a \"seed\" x, we can form a list {", StyleBox["x, f(x), f(f(x), f(f(f(x))), \[Ellipsis]", FontSlant->"Italic"], "} using NestList" }], "Text"], Cell[BoxData[ RowBox[{"NestList", "[", RowBox[{"Cos", ",", "1.", ",", "40"}], "]"}]], "Input"], Cell["\<\ If you are only interested in the final value, just use Nest instead, rather \ than NestList which gives all the intermediate results.\ \>", "Text"], Cell[BoxData[ RowBox[{"Nest", "[", RowBox[{"Cos", ",", "1.", ",", "40"}], "]"}]], "Input"], Cell[TextData[{ "Now, the sharp witted amongst you will have noticed that our NestList \ example above seemed to be settling down to some limit. How can we find what \ that is? Of course, we could try NestList with a big enough ", StyleBox["n", FontSlant->"Italic"], ", but we don't know how big ", StyleBox["n", FontSlant->"Italic"], " should be except by trial and error. A better idea is to use FixedPoint:" }], "Text", CellChangeTimes->{3.4013147229386787`*^9}], Cell[BoxData[ RowBox[{"FixedPoint", "[", RowBox[{"Cos", ",", "1."}], "]"}]], "Input"], Cell[TextData[{ "FixedPoint keeps applying more and more layers of f until the result \ doesn't change any more. In this way we have actually solved the \ trancendental equation cos ", StyleBox["x ", FontSlant->"Italic"], "= ", StyleBox["x", FontSlant->"Italic"], " using the fixed point method!" }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Cos", "[", "%", "]"}], "\[Equal]", "%"}]], "Input"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], "'s built in general purpose root finder FindRoot (which in this instance \ uses Newton's method with 0.7 as a starting guess) agrees:" }], "Text"], Cell[BoxData[ RowBox[{"FindRoot", "[", RowBox[{ RowBox[{ RowBox[{"Cos", "[", "x", "]"}], "\[Equal]", "x"}], ",", RowBox[{"{", RowBox[{"x", ",", ".7"}], "}"}]}], "]"}]], "Input"], Cell[TextData[{ "But of course, the fixed point method doesn't always work (we can show that \ solving ", StyleBox["f(x)", FontSlant->"Italic"], "=", StyleBox["x", FontSlant->"Italic"], " to find the solution ", StyleBox["x", FontSlant->"Italic"], "=", StyleBox["X", FontSlant->"Italic"], " by the fixed point method only works if ", StyleBox["|f ' (X) | < 1", FontSlant->"Italic"], "). For example, solving ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["x", "2"], "=", " ", "x"}], TraditionalForm]]], ", we obviously have two solutions, 0 and 1. Let's try using the fixed point \ method to find the x=1 root by starting out iterations very close to it:" }], "Text", CellChangeTimes->{{3.4013148014928713`*^9, 3.401314807089641*^9}}], Cell[BoxData[ RowBox[{"NestList", "[", RowBox[{ RowBox[{ SuperscriptBox["#", "2"], "&"}], ",", ".999", ",", "20"}], "]"}]], "Input"], Cell[TextData[{ "Clearly, it ran away from x=1 and homed in on x=0. This is predictable from \ the graph, since the slope of ", Cell[BoxData[ FormBox[ SuperscriptBox["x", "2"], TraditionalForm]]], "at 1 exceeds 1, but vanishes at 0." }], "Text"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", SuperscriptBox["x", "2"]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "0.2"}], ",", "1.2"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.401314833788014*^9, 3.4013148359695377`*^9}}], Cell[TextData[{ "Here we see the rapid convergence to the ", StyleBox["x=0", FontSlant->"Italic"], " root." }], "Text"], Cell[BoxData[ RowBox[{"FixedPointList", "[", RowBox[{ RowBox[{ SuperscriptBox["#", "2"], "&"}], ",", ".999"}], "]"}]], "Input"], Cell["\<\ We can get rid of all those ludicrously small numbers:\ \>", "Text", CellChangeTimes->{{3.401314855404276*^9, 3.40131485760229*^9}}], Cell[BoxData[ RowBox[{"FixedPointList", "[", RowBox[{ RowBox[{ RowBox[{"Chop", "[", SuperscriptBox["#", "2"], "]"}], "&"}], ",", ".999"}], "]"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Functions with Conditions", "Section"], Cell["\<\ Frequently, we wish to define function only for certain values of their \ argument. For example, we may set\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{ SqrtBox["x"], "/;", RowBox[{"x", "\[GreaterEqual]", "0"}]}]}]], "Input"], Cell[TextData[{ "meaning that f(x) is ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ SqrtBox["x"], " ", "on", " ", "the", " ", "condition", " ", "that", " ", "x", " ", "is", " ", "non"}], "-", "negative"}], TraditionalForm]]], ";" }], "Text"], Cell[BoxData[ RowBox[{"f", "[", "4", "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"-", "3"}], "]"}]], "Input"], Cell[TextData[{ StyleBox["f", FontSlant->"Italic"], " is undefined for negative arguments! Of course, we can also define ", StyleBox["f", FontSlant->"Italic"], " for negative ", StyleBox["x ", FontSlant->"Italic"], "if we wish:" }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{ RowBox[{"Sin", "[", "x", "]"}], "/;", RowBox[{"x", "<", "0"}]}]}]], "Input"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "5"}], ",", "5"}], "}"}]}], "]"}]], "Input"], Cell[TextData[{ "Let's just check how ", StyleBox["Mathematica", FontSlant->"Italic"], " thinks of ", StyleBox["f", FontSlant->"Italic"], "." }], "Text"], Cell[BoxData[ RowBox[{"?", "f"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "f", "]"}]], "Input"], Cell["Now here is an interesting function you will know all about.", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"g", "[", "x_", "]"}], ":=", FractionBox[ RowBox[{"Sin", "[", "x", "]"}], "x"]}]], "Input"], Cell["It is easily evaluated at any point,", "Text"], Cell[BoxData[ RowBox[{"g", "[", "1.0", "]"}]], "Input"], Cell[TextData[{ "\[Ellipsis] except ", StyleBox["x=0", FontSlant->"Italic"], ", where it is not defined (or, as ", StyleBox["Mathematica", FontSlant->"Italic"], " says, it is Indeterminate)." }], "Text"], Cell[BoxData[ RowBox[{"g", "[", "0.", "]"}]], "Input"], Cell["\<\ Yet we know how to \"fill in the gap\" to make the function continuous\ \>", "Text"], Cell[BoxData[ RowBox[{"Limit", "[", RowBox[{ RowBox[{"g", "[", "x", "]"}], ",", RowBox[{"x", "\[Rule]", "0"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "g", "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"g", "[", "x_", "]"}], ":=", RowBox[{ FractionBox[ RowBox[{"Sin", "[", "x", "]"}], "x"], "/;", RowBox[{"x", "\[NotEqual]", "0"}]}]}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"g", "[", "0", "]"}], "=", "1"}], ";", RowBox[{ RowBox[{"g", "[", "0.", "]"}], "=", "1"}], ";"}]], "Input"], Cell[BoxData[ RowBox[{"?", "g"}]], "Input"], Cell[BoxData[ RowBox[{"TableForm", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", RowBox[{"g", "[", "x", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "5."}], ",", "5."}], "}"}]}], "]"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"g", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "25"}], ",", "25"}], "}"}], ",", RowBox[{"PlotPoints", "\[Rule]", "100"}], ",", RowBox[{"PlotRange", "\[Rule]", "All"}], ",", RowBox[{"Frame", "\[Rule]", "True"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "g", "]"}]], "Input"], Cell["\<\ There is an even more convenient way to do this sort of thing in some cases. \ Say I want to define a function which applies for integer arguments only.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "n_Integer", "]"}], ":=", " ", RowBox[{"Range", "[", "n", "]"}]}]], "Input"], Cell["\<\ This says that f is defined for any argument that has integer \"head\". Let's \ see what heads some types of numbers have:\ \>", "Text"], Cell[BoxData[ RowBox[{"Head", "[", "3", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Head", "[", FractionBox["1", "3"], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Head", "[", "4.5", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Head", "[", RowBox[{"1", "+", RowBox[{"2", "\[ImaginaryI]"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Head", "[", "y", "]"}]], "Input"], Cell["So, let's try it for integer argument", "Text"], Cell[BoxData[ RowBox[{"f", "[", "3", "]"}]], "Input"], Cell["and for non-integer", "Text"], Cell[BoxData[ RowBox[{"f", "[", "3.1", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "f", "]"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Piecewise Functions", "Section"], Cell["\<\ There are many ways to define piecewise functions. We have already seen how \ to do it with /; but here are some other methods. The basic \ If[test,then,else] construct is fine if there are only two possibilities:\ \>", "Text"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"x", ">", "0"}], ",", RowBox[{"1", "-", SuperscriptBox["x", "2"]}], ",", RowBox[{"-", "1"}]}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "1.1"}], ",", "1.1"}], "}"}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"{", "Blue", "}"}], "}"}]}]}], "]"}]], "Input", CellChangeTimes->{{3.401315094764786*^9, 3.401315107041823*^9}}], Cell["With more, it is better to use Piecewise", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"Piecewise", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ SuperscriptBox["x", "2"], ",", RowBox[{"x", "\[GreaterEqual]", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{ RowBox[{"-", "1"}], "<", "x", "<", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"x", "\[LessEqual]", RowBox[{"-", "1"}]}]}], "}"}]}], "}"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"f", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "3"}], ",", "3"}], "}"}]}], "]"}]], "Input"], Cell["\<\ or equivalently pw followed by ctr+, and ctrl+enter to construct\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"g", "[", "x_", "]"}], ":=", RowBox[{"\[Piecewise]", GridBox[{ { SuperscriptBox["x", "2"], RowBox[{"x", "\[GreaterEqual]", "1"}]}, {"x", RowBox[{ RowBox[{"-", "1"}], "<", "x", "<", "1"}]}, { RowBox[{"-", "1"}], RowBox[{"x", "\[LessEqual]", RowBox[{"-", "1"}]}]} }]}]}]], "Input"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"g", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "3"}], ",", "3"}], "}"}]}], "]"}]], "Input"], Cell["Another option is Which:", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"h", "[", "x_", "]"}], ":=", RowBox[{"Which", "[", RowBox[{ RowBox[{"x", "\[GreaterEqual]", "1"}], ",", SuperscriptBox["x", "2"], ",", RowBox[{ RowBox[{"-", "1"}], "<", "x", "<", "1"}], ",", "x", ",", "True", ",", RowBox[{"-", "1"}]}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"h", "[", "x", "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "3"}], ",", "3"}], "}"}]}], "]"}]], "Input"], Cell["Clean up!", "Text"], Cell[BoxData[ RowBox[{"Clear", "[", RowBox[{"f", ",", "g", ",", "h"}], "]"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Rules and Pattern Matching", "Section"], Cell["\<\ ReplaceAllexpression,rule], or expression /. rule, specifies that the rule is \ used to make substitutions in expression. For example,\ \>", "Text"], Cell[BoxData[ RowBox[{ SuperscriptBox["x", "2"], "/.", RowBox[{"x", "\[Rule]", "3"}]}]], "Input"], Cell[TextData[{ "In this case, ", StyleBox["x", FontSlant->"Italic"], " is replaced by a and ", Cell[BoxData[ FormBox[ RowBox[{ SuperscriptBox["x", "2"], " ", "by", " ", "x", " ", "at", " ", "the", " ", "same", " ", RowBox[{"time", "."}]}], TraditionalForm]]] }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"x", "+", SuperscriptBox["x", "2"]}], "/.", RowBox[{"{", RowBox[{ RowBox[{"x", "\[Rule]", "a"}], ",", RowBox[{ SuperscriptBox["x", "2"], "\[Rule]", "x"}]}], "}"}]}]], "Input"], Cell["\<\ Here though, the replacement is performed repeatedly until nothing changes.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"x", "+", SuperscriptBox["x", "2"]}], "//.", RowBox[{"{", RowBox[{ RowBox[{"x", "\[Rule]", "a"}], ",", RowBox[{ SuperscriptBox["x", "2"], "\[Rule]", "x"}]}], "}"}]}]], "Input"], Cell[TextData[{ "Solutions coming from many ", StyleBox["Mathematica", FontSlant->"Italic"], " utilities are presented in the form of rules, e.g.," }], "Text"], Cell[BoxData[ RowBox[{"FindRoot", "[", RowBox[{ RowBox[{ RowBox[{ SuperscriptBox["x", "5"], "+", SuperscriptBox["x", "\[Pi]"]}], "\[Equal]", "1"}], ",", RowBox[{"{", RowBox[{"x", ",", ".5"}], "}"}]}], "]"}]], "Input"], Cell["\<\ Sometimes, when wanting to make substitutions, we may need to use \"pattern \ matching\":\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"f", "[", "a", "]"}], "+", RowBox[{"f", "[", "b", "]"}]}], "/.", RowBox[{ RowBox[{"f", "[", "x_", "]"}], "\[Rule]", SuperscriptBox["x", "2"]}]}]], "Input"], Cell["although this could also have been done with", "Text"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"f", "[", "a", "]"}], "+", RowBox[{"f", "[", "b", "]"}]}], "/.", RowBox[{"f", "\[Rule]", RowBox[{"Function", "[", RowBox[{"x", ",", SuperscriptBox["x", "2"]}], "]"}]}]}]], "Input"], Cell["\<\ Here we try to find the positions in a list which are powers of x. Try\ \>", "Text"], Cell[BoxData[ RowBox[{"Position", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Sin", "[", "x", "]"}], ",", RowBox[{"Tan", "[", "x", "]"}], ",", SuperscriptBox["x", "3"], ",", SuperscriptBox["y", "2"], ",", RowBox[{"Log", "[", "x", "]"}], ",", RowBox[{ SuperscriptBox["x", "4"], "+", SuperscriptBox["z", "3"], "+", "2"}]}], "}"}], ",", SuperscriptBox["x", "n_"]}], "]"}]], "Input"], Cell[TextData[{ "The {3} is easy to understand, but what does the {6,2} mean? Well, element \ 6 is ", Cell[BoxData[ RowBox[{ SuperscriptBox["x", "4"], "+", SuperscriptBox["z", "3"], "+", "2"}]]], ". How does ", StyleBox["Mathematica", FontSlant->"Italic"], " define this?" }], "Text"], Cell[BoxData[ RowBox[{"FullForm", "[", RowBox[{ SuperscriptBox["x", "4"], "+", SuperscriptBox["z", "3"], "+", "2"}], "]"}]], "Input"], Cell["And what is the second part?", "Text"], Cell[BoxData[ RowBox[{"%", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}]], "Input"], Cell["Aha, now that makes sense.", "Text"], Cell[TextData[{ "Fine, so we found the ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ SuperscriptBox["x", "3"], " ", "alright"}], ",", " ", RowBox[{"and", " ", "the", " ", "part", " ", "of", " ", "the", " ", SuperscriptBox["6", "th"], "element", " ", "that", " ", "is", " ", "a", " ", "power", " ", "of", " ", "x"}], ",", " ", RowBox[{ "but", " ", "it", " ", "did", " ", "not", " ", "find", " ", "the", " ", "powers", " ", "of", " ", "y", " ", "or", " ", RowBox[{"z", "."}]}]}], TraditionalForm]]], " If we wanted them as well we may do" }], "Text"], Cell[BoxData[ RowBox[{"Position", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Sin", "[", "x", "]"}], ",", RowBox[{"Tan", "[", "x", "]"}], ",", SuperscriptBox["x", "3"], ",", SuperscriptBox["y", "2"], ",", RowBox[{"Log", "[", "x", "]"}], ",", RowBox[{ SuperscriptBox["x", "4"], "+", SuperscriptBox["z", "3"], "+", "2"}]}], "}"}], ",", SuperscriptBox["x_", "n_"]}], "]"}]], "Input"], Cell[TextData[{ "The ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ SubscriptBox["x", "\[Placeholder]"], " ", "referes", " ", "to", " ", "any", " ", "variable"}], ",", " ", RowBox[{"x", " ", "or", " ", "z", " ", "in", " ", "this", " ", RowBox[{"case", "."}]}]}], TraditionalForm]]] }], "Text", CellChangeTimes->{{3.401315281892703*^9, 3.401315326118709*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["Functions with Defaults", "Section"], Cell["\<\ Frequently, we want to define functions of several variables where one or \ more arguments need not be given if they are to take on default values. For \ example, define\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", SuperscriptBox["x", "y"]}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"2", ",", "3"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"a", ",", "b"}], "]"}]], "Input"], Cell[TextData[{ "Of course, ", StyleBox["f(3)", FontSlant->"Italic"], " is undefined:" }], "Text"], Cell[BoxData[ RowBox[{"f", "[", "3", "]"}]], "Input"], Cell[TextData[{ "But here is how we can define ", StyleBox["y", FontSlant->"Italic"], " to have default 1." }], "Text"], Cell[BoxData[ RowBox[{"Clear", "[", "f", "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", RowBox[{"y_:", "1"}]}], "]"}], ":=", SuperscriptBox["x", "y"]}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"2", ",", "3"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", "3", "]"}]], "Input"], Cell["\<\ Another useful way to include optional arguments, especially option rules, is \ to use the triple underline a___ rather than a_ in the function definition. \ This refers to zero or more entries. For example, here opts can be any (or \ no) sequence of options to Plot.\ \>", "Text"], Cell[BoxData[ RowBox[{"Clear", "[", "f", "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"plt", "[", RowBox[{"f_", ",", "a_", ",", "b_", ",", "opts___"}], "]"}], ":=", RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{"f", "[", "x", "]"}], "+", SuperscriptBox[ RowBox[{"f", "[", "x", "]"}], "2"]}], ",", RowBox[{"{", RowBox[{"x", ",", "a", ",", "b"}], "}"}], ",", "opts"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"plt", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Sin", "[", "#", "]"}], "+", RowBox[{"Cos", "[", SuperscriptBox["#", "2"], "]"}]}], "&"}], ",", "0", ",", RowBox[{"3", "\[Pi]"}]}], "]"}]], "Input", CellChangeTimes->{3.401315403395616*^9}], Cell[BoxData[ RowBox[{"plt", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Sin", "[", "#", "]"}], "+", RowBox[{"Cos", "[", SuperscriptBox["#", "2"], "]"}]}], "&"}], ",", "0", ",", RowBox[{"3", "\[Pi]"}], ",", RowBox[{"Frame", "\[Rule]", "True"}], ",", RowBox[{"Axes", "\[Rule]", RowBox[{"{", RowBox[{"True", ",", "False"}], "}"}]}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"PlotStyle", "\[Rule]", RowBox[{"{", RowBox[{"{", RowBox[{"Hue", "[", ".6", "]"}], "}"}], "}"}]}], ",", RowBox[{"RotateLabel", "\[Rule]", "False"}], ",", RowBox[{"Epilog", "->", RowBox[{"{", RowBox[{ RowBox[{"PointSize", "[", "0.03", "]"}], ",", RowBox[{"Hue", "[", "1", "]"}], ",", RowBox[{"Point", "[", RowBox[{"{", RowBox[{"\[Pi]", ",", "4"}], "}"}], "]"}]}], "}"}]}], ",", RowBox[{"PlotPoints", "\[Rule]", "250"}]}], "]"}]], "Input", CellChangeTimes->{3.401315412573681*^9}] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Recursion and Functions which Remember\ \>", "Section", CellChangeTimes->{{3.4013154367163486`*^9, 3.4013154386583652`*^9}}], Cell[TextData[{ "Of course, ", StyleBox["Mathematica", FontSlant->"Italic"], " has a built in factorial function" }], "Text"], Cell[BoxData[ RowBox[{"54", "!"}]], "Input", CellChangeTimes->{{3.4013154868905973`*^9, 3.4013154989528313`*^9}}], Cell["\<\ But just as an exercise, let's see how we could write one ourselves (just for \ integers).\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"fac", "[", "0", "]"}], "=", "1"}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"fac", "[", "n_Integer", "]"}], ":=", RowBox[{"n", "*", RowBox[{"fac", "[", RowBox[{"n", "-", "1"}], "]"}]}]}]], "Input"], Cell[BoxData[ RowBox[{"fac", "[", "9", "]"}]], "Input"], Cell[BoxData[ RowBox[{"?", "fac"}]], "Input"], Cell[TextData[{ "This works through recursion. This may be a little inefficient though if we \ intend to use fac many times. For example, if I wanted fac(12) it would first \ have to work out fac(1), then fac(2), etc. But I may have already calculated \ fac(9) earlier. It ", StyleBox["might", FontWeight->"Bold"], " make sense to store these (it doesn't for the factorial because they are \ so cheap to calculate -- it's a trade off between computation time and \ storage). Here's how to do it:" }], "Text"], Cell[BoxData[ RowBox[{"Clear", "[", "fac", "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"fac", "[", "0", "]"}], "=", "1"}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"fac", "[", "n_Integer", "]"}], ":=", RowBox[{ RowBox[{"fac", "[", "n", "]"}], "=", RowBox[{"n", "*", RowBox[{"fac", "[", RowBox[{"n", "-", "1"}], "]"}]}]}]}]], "Input"], Cell[BoxData[ RowBox[{"fac", "[", "9", "]"}]], "Input"], Cell[TextData[{ "Let's now see how ", StyleBox["Mathematica", FontSlant->"Italic"], " defines f." }], "Text"], Cell[BoxData[ RowBox[{"?", "fac"}]], "Input"], Cell["\<\ All values up to f[9] are stored, along with the recursion rule. If we now \ ask for f(12), it picks up from there and fills the gap.\ \>", "Text"], Cell[BoxData[ RowBox[{"fac", "[", "12", "]"}]], "Input"], Cell[BoxData[ RowBox[{"?", "fac"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "fac", "]"}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Vectors", "Section"], Cell["\<\ We can do vector calculus with the aid of a standard package:\ \>", "Text"], Cell[BoxData[ RowBox[{"<<", "\"\\""}]], "Input"], Cell["Choose our coordinate system:", "Text"], Cell[BoxData[ RowBox[{"SetCoordinates", "[", RowBox[{"Cartesian", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], "]"}]], "Input"], Cell["Check:", "Text"], Cell[BoxData[ RowBox[{"{", RowBox[{"CoordinateSystem", ",", RowBox[{"Coordinates", "[", "]"}]}], "}"}]], "Input"], Cell["Define a scalar field:", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", "y_", ",", "z_"}], "]"}], ":=", RowBox[{"x", " ", SuperscriptBox["y", "2"], RowBox[{"Cos", "[", RowBox[{"x", " ", "z"}], "]"}]}]}]], "Input"], Cell["Now we can take its grad:", "Text"], Cell[BoxData[ RowBox[{"gradf", "=", RowBox[{"Grad", "[", RowBox[{"f", "[", RowBox[{"x", ",", "y", ",", "z"}], "]"}], "]"}]}]], "Input"], Cell["\<\ Of course, you know what happens when you take the curl of a grad:\ \>", "Text"], Cell[BoxData[ RowBox[{"Curl", "[", "gradf", "]"}]], "Input"], Cell["Define a constant vector:", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"a", "=", RowBox[{"{", RowBox[{"1", ",", "2", ",", "3"}], "}"}]}], ";"}]], "Input"], Cell["Take a dot product", "Text"], Cell[BoxData[ RowBox[{"a", ".", "gradf"}]], "Input"], Cell["or", "Text"], Cell[BoxData[ RowBox[{"DotProduct", "[", RowBox[{"a", ",", "gradf"}], "]"}]], "Input"], Cell["And a cross product:", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"CrossProduct", "[", RowBox[{"a", ",", "gradf"}], "]"}], "//", "Simplify"}]], "Input", CellChangeTimes->{{3.4013156635879583`*^9, 3.401315666009345*^9}, { 3.4013157100834827`*^9, 3.401315742153153*^9}}], Cell["Here's div:", "Text"], Cell[BoxData[ RowBox[{"Div", "[", "gradf", "]"}]], "Input"], Cell[BoxData[ RowBox[{"%", "//", "Simplify"}]], "Input"], Cell["\<\ \[Ellipsis] and much much more. You can also do all this in many other \ coordinate systems;\ \>", "Text"], Cell[BoxData[ FormBox[GridBox[{ {Cell[TextData[StyleBox["Bipolar", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}], Cell[TextData[StyleBox[ "Bispherical", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]}, {Cell[TextData[StyleBox["Cartesian", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}], Cell[TextData[StyleBox[ "ConfocalEllipsoidal", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]}, {Cell[TextData[StyleBox["ConfocalParaboloidal", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}], Cell[TextData[StyleBox[ "Conical", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]}, {Cell[TextData[StyleBox["Cylindrical", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}], Cell[TextData[StyleBox[ "EllipticCylindrical", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]}, {Cell[TextData[StyleBox["OblateSpheroidal", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}], Cell[TextData[StyleBox[ "ParabolicCylindrical", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]}, {Cell[TextData[StyleBox["Paraboloidal", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}], Cell[TextData[StyleBox[ "ProlateSpheroidal", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]}, {Cell[TextData[StyleBox["Spherical", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}], Cell[TextData[StyleBox[ "Toroidal", GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]], GridBoxOptions->{ GridBoxDividers->{ "Columns" -> {{False}}, "ColumnsIndexed" -> {}, "Rows" -> {{False}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.16]}, Offset[0.2]}, "RowsIndexed" -> {}}}]} }, GridBoxAlignment->{ "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}], TraditionalForm]], "Text"], Cell[BoxData[ RowBox[{"Clear", "[", RowBox[{"a", ",", " ", "f", ",", " ", "gradf"}], "]"}]], "Input", CellChangeTimes->{{3.401316419151781*^9, 3.401316429875573*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["Exercises", "Section", FontColor->RGBColor[0, 0, 1]], Cell["\<\ Do not look at the solution until you have completed the exercise!\ \>", "Text", TextAlignment->Center, FontFamily->"Helvetica", FontSize->18, FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[CellGroupData[{ Cell["Using Map and Apply", "Subsection"], Cell[TextData[{ "Write a function ", StyleBox["h", FontSlant->"Italic"], " which calculates the sum of the prime factors of an integer (e.g., ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"h", "(", "12", ")"}], "=", RowBox[{ RowBox[{"h", "(", RowBox[{ SuperscriptBox["2", "2"], "3"}], ")"}], "=", RowBox[{ RowBox[{"2", "+", "2", "+", "3"}], "=", "7", " "}]}]}], TraditionalForm]]], "). You will need FactorInteger. Make sure it only applies to integers. \ Construct a table of ", StyleBox["h(n)", FontSlant->"Italic"], " against ", StyleBox["n", FontSlant->"Italic"], " for ", StyleBox["n", FontSlant->"Italic"], "=1,2,\[Ellipsis],100, and plot it using ListPlot. (Try to make the table \ without using Table[\[Ellipsis]].)" }], "Text"], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ RowBox[{"Clear", "[", "h", "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"h", "[", "n_Integer", "]"}], ":=", RowBox[{"Plus", "@@", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"Times", "@@", "#"}], "&"}], "/@", RowBox[{"FactorInteger", "[", "n", "]"}]}], ")"}]}]}]], "Input"], Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"n", ",", RowBox[{"h", "[", "n", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "100"}], "}"}]}], "]"}]], "Input"], Cell["or alternatively", "Text"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"#", ",", RowBox[{"h", "[", "#", "]"}]}], "}"}], "&"}], "/@", RowBox[{"Range", "[", "100", "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"ListPlot", "[", "%", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "h", "]"}]], "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Fixed Point and Root Finding", "Subsection"], Cell[TextData[{ "Graphically estimate the first positive root of tan ", StyleBox["x ", FontSlant->"Italic"], "= 2", StyleBox["x", FontSlant->"Italic"], ". Is the obvious fixed point scheme ", Cell[BoxData[ FormBox[ RowBox[{"x", "=", RowBox[{ FractionBox["1", "2"], "tan", " ", "x", " ", "convergent", " ", "for", " ", "this", " ", RowBox[{"point", "?", " "}]}]}], TraditionalForm]]], "If not, construct a ", StyleBox["convergent", FontWeight->"Bold"], " fixed point method and apply it to solve for ", StyleBox["x", FontSlant->"Italic"], ". Check your answer using FindRoot." }], "Text"], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Tan", "[", "x", "]"}], ",", RowBox[{"2", " ", "x"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "1.4`"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Plot", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"ArcTan", "[", RowBox[{"2", " ", "x"}], "]"}], ",", "x"}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", "0", ",", "1.4`"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"NestList", "[", RowBox[{ RowBox[{ RowBox[{ FractionBox["1", "2"], RowBox[{"Tan", "[", "#", "]"}]}], "&"}], ",", "1.2", ",", "23"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"FixedPointList", "[", RowBox[{ RowBox[{ RowBox[{"ArcTan", "[", RowBox[{"2", "#"}], "]"}], "&"}], ",", "1.2"}], "]"}]], "Input", CellChangeTimes->{{3.40131596418045*^9, 3.40131598204982*^9}, { 3.401316019548634*^9, 3.401316023049439*^9}}], Cell[BoxData[ RowBox[{"x", "/.", RowBox[{"FindRoot", "[", RowBox[{ RowBox[{ RowBox[{"Tan", "[", "x", "]"}], "\[Equal]", RowBox[{"2", "x"}]}], ",", RowBox[{"{", RowBox[{"x", ",", "1.2"}], "}"}]}], "]"}]}]], "Input", CellChangeTimes->{{3.401316028828767*^9, 3.401316030457568*^9}}] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Finding a Needle in a Haystack", "Subsection"], Cell[TextData[{ "Construct a list ", StyleBox["v", FontWeight->"Bold"], " of 100 integers randomly chosen from 1,2,\[Ellipsis],100, and then \ construct an ", StyleBox["ordered", FontWeight->"Bold"], " list of all those which are prime, keeping multiple entries. Finally, make \ an ordered list of all primes in 1,2,\[Ellipsis],100 which are ", StyleBox["not", FontWeight->"Bold"], " in your list. You will need to rumage around in the help utility to find \ how to do this. The functions PrimePi[] and Complement[] may be useful." }], "Text", CellChangeTimes->{{3.40131615170737*^9, 3.401316163848228*^9}, { 3.401316204259099*^9, 3.401316249824451*^9}}], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ RowBox[{"v", "=", RowBox[{"RandomInteger", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "100"}], "}"}], ",", "100"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"p", "=", RowBox[{ RowBox[{"Select", "[", RowBox[{"v", ",", "PrimeQ"}], "]"}], "//", "Sort"}]}]], "Input"], Cell[BoxData[ RowBox[{"allprimes", "=", RowBox[{"Prime", "[", RowBox[{"Range", "[", RowBox[{"PrimePi", "[", "100", "]"}], "]"}], "]"}]}]], "Input"], Cell[BoxData[ RowBox[{"Complement", "[", RowBox[{"allprimes", ",", "p"}], "]"}]], "Input"], Cell["\<\ By the way, note that Prime has the attribute Listable, so we didn't need to \ write Prime/@Range[PrimePi[100]], though this would of course still work.\ \>", "Text"], Cell[BoxData[ RowBox[{"??", "Prime"}]], "Input"], Cell[BoxData[ RowBox[{"Prime", "[", RowBox[{"Range", "[", RowBox[{"PrimePi", "[", "100", "]"}], "]"}], "]"}]], "Input", CellChangeTimes->{{3.401316281175434*^9, 3.40131631364915*^9}}] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Define a function of an arbitrary number of variables", "Subsection"], Cell[TextData[{ "Define a function ", StyleBox["f", FontSlant->"Italic"], " which takes an arbitrary number of arguments x,y,z,\[Ellipsis] and returns \ ", Cell[BoxData[ FormBox[ SuperscriptBox["x", SuperscriptBox["y", SuperscriptBox["z", "\[AscendingEllipsis]"]]], TraditionalForm]]], ". By the way, does ", StyleBox["Mathematica", FontSlant->"Italic"], " interpret ", Cell[BoxData[ FormBox[ SuperscriptBox["x", SuperscriptBox["y", "z"]], TraditionalForm]]], "as x^(y^z) or as (x^y)^z?" }], "Text"], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", RowBox[{"x_", ",", "y___"}], "]"}], ":=", SuperscriptBox["x", "y"]}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"a", ",", "b", ",", "c", ",", "d"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"2", ",", "3", ",", "4"}], "]"}]], "Input", CellChangeTimes->{{3.401316558784761*^9, 3.401316588553132*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"2", "^", RowBox[{"(", RowBox[{"3", "^", "4"}], ")"}]}], ",", RowBox[{ RowBox[{"(", RowBox[{"2", "^", "3"}], ")"}], "^", "4"}]}], "}"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "f", "]"}]], "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Recursion", "Subsection"], Cell[TextData[{ "Write a function ", StyleBox["with memory", FontWeight->"Bold"], " to generate the Fibonacci sequence 1,1,2,3,5,8,\[Ellipsis], where each \ element is the sum of the two previous. Counting from one, so that fib(1)=1, \ fib(2)=1, etc, find fib(10) and fib(20). Check using the built-in function \ Fibonnaci[\[Ellipsis]]." }], "Text"], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ RowBox[{"Clear", "[", "fib", "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"fib", "[", "1", "]"}], "=", RowBox[{ RowBox[{"fib", "[", "2", "]"}], "=", "1"}]}], ";"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"fib", "[", "n_Integer", "]"}], ":=", RowBox[{ RowBox[{"fib", "[", "n", "]"}], "=", RowBox[{ RowBox[{"fib", "[", RowBox[{"n", "-", "1"}], "]"}], "+", RowBox[{"fib", "[", RowBox[{"n", "-", "2"}], "]"}]}]}]}]], "Input"], Cell[BoxData[ RowBox[{"fib", "[", "10", "]"}]], "Input"], Cell[BoxData[ RowBox[{"fib", "[", "20", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Fibonacci", "[", "20", "]"}]], "Input"], Cell[BoxData[ RowBox[{"?", "fib"}]], "Input"], Cell[BoxData[ RowBox[{"Clear", "[", "fib", "]"}]], "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Vectors", "Subsection"], Cell[TextData[{ "Set your default coordinate system to be spherical {r,\[Theta],\[Phi]}. Use \ CoordinatesToCartesian[ ] to find the Cartesian coordinates of r=2, ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"\[Theta]", "=", RowBox[{"30", "\[Degree]"}]}], ",", RowBox[{"\[Phi]", "=", RowBox[{"15", "\[Degree]"}]}]}], TraditionalForm]]], ". Check your answer using CoordinatesFromCartesian[ ]. Letting ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"f", "(", RowBox[{"r", ",", "\[Theta]", ",", "\[Phi]"}], ")"}], "=", SuperscriptBox["r", "3"]}], TraditionalForm]]], " sin(\[Theta]+\[Phi])cos(3\[Theta]-2\[Phi]), find ", Cell[BoxData[ FormBox[ RowBox[{ StyleBox["\[Del]", FontWeight->"Bold"], "f"}], TraditionalForm]]], ", ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ SuperscriptBox["\[Del]", "2"], "f"}], ","}], TraditionalForm]]], " ", StyleBox["\[Del]", FontWeight->"Bold"], "\[Times](", StyleBox["f ", FontSlant->"Italic"], StyleBox["\[Del]", FontWeight->"Bold"], StyleBox["f", FontSlant->"Italic"], "). Explain this last result." }], "Text"], Cell[CellGroupData[{ Cell["Solution", "Subsubsection"], Cell[BoxData[ RowBox[{"SetCoordinates", "[", RowBox[{"Spherical", "[", RowBox[{"r", ",", "\[Theta]", ",", "\[Phi]"}], "]"}], "]"}]], "Input"], Cell["Check:", "Text"], Cell[BoxData[ RowBox[{"{", RowBox[{"CoordinateSystem", ",", RowBox[{"Coordinates", "[", "]"}]}], "}"}]], "Input"], Cell[BoxData[ RowBox[{"CoordinatesToCartesian", "[", RowBox[{"{", RowBox[{"2", ",", RowBox[{"30", "Degree"}], ",", RowBox[{"15", "Degree"}]}], "}"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"CoordinatesFromCartesian", "[", "%", "]"}], "//", "N"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"{", RowBox[{"2", ",", RowBox[{"30", "Degree"}], ",", RowBox[{"15", "Degree"}]}], "}"}], "//", "N"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", RowBox[{"r_", ",", "\[Theta]_", ",", "\[Phi]_"}], "]"}], ":=", RowBox[{ SuperscriptBox["r", "3"], " ", RowBox[{"Sin", "[", RowBox[{"\[Theta]", "+", "\[Phi]"}], "]"}], RowBox[{"Cos", "[", RowBox[{ RowBox[{"3", "\[Theta]"}], "-", RowBox[{"2", "\[Phi]"}]}], "]"}]}]}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"Grad", "[", RowBox[{"f", "[", RowBox[{"r", ",", "\[Theta]", ",", "\[Phi]"}], "]"}], "]"}], "//", "Simplify"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"Laplacian", "[", RowBox[{"f", "[", RowBox[{"r", ",", "\[Theta]", ",", "\[Phi]"}], "]"}], "]"}], "//", "Simplify"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"Curl", "[", RowBox[{ RowBox[{"f", "[", RowBox[{"r", ",", "\[Theta]", ",", "\[Phi]"}], "]"}], RowBox[{"Grad", "[", RowBox[{"f", "[", RowBox[{"r", ",", "\[Theta]", ",", "\[Phi]"}], "]"}], "]"}]}], "]"}], "//", "Simplify"}]], "Input"], Cell[TextData[{ StyleBox["\[Del]", FontWeight->"Bold"], "\[Times](", StyleBox["f ", FontSlant->"Italic"], StyleBox["\[Del]", FontWeight->"Bold"], StyleBox["f", FontSlant->"Italic"], ") = ", StyleBox["\[Del]", FontWeight->"Bold"], StyleBox["f", FontSlant->"Italic"], " \[Times] ", StyleBox["\[Del]", FontWeight->"Bold"], StyleBox["f", FontSlant->"Italic"], " + ", StyleBox["f ", FontSlant->"Italic"], StyleBox["\[Del]", FontWeight->"Bold"], "\[Times]", StyleBox["\[Del]", FontWeight->"Bold"], StyleBox["f = ", FontSlant->"Italic"], StyleBox["0 ", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["+ ", FontSlant->"Italic"], StyleBox["0 ", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[".", FontSlant->"Italic"] }], "Text"] }, Closed]] }, Closed]] }, Closed]] }, Open ]] }, WindowSize->{816, 852}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, ShowSelection->True, Magnification->1, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (June 19, 2007)", StyleDefinitions->FrontEnd`FileName[{"Creative"}, "NaturalColor.nb", CharacterEncoding -> "UTF-8"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 118, 4, 66, "Title"], Cell[711, 29, 53, 0, 31, "Subtitle"], Cell[767, 31, 89, 2, 20, "Author"], Cell[CellGroupData[{ Cell[881, 37, 59, 0, 72, "Section"], Cell[943, 39, 63, 0, 26, "Text"], Cell[1009, 41, 122, 4, 40, "Input"], Cell[1134, 47, 155, 5, 43, "Input"], Cell[1292, 54, 112, 4, 40, "Input"], Cell[1407, 60, 103, 3, 26, "Text"], Cell[1513, 65, 253, 6, 37, "Input"], Cell[1769, 73, 86, 1, 26, "Text"], Cell[1858, 76, 607, 18, 53, "Input"], Cell[2468, 96, 85, 2, 26, "Text"], Cell[2556, 100, 91, 2, 37, "Input"], Cell[2650, 104, 209, 4, 41, "Text"], Cell[2862, 110, 163, 5, 37, "Input"], Cell[3028, 117, 233, 8, 37, "Text"], Cell[3264, 127, 229, 8, 56, "Input"], Cell[3496, 137, 180, 3, 41, "Text"], Cell[3679, 142, 202, 6, 56, "Input"], Cell[3884, 150, 107, 3, 26, "Text"], Cell[3994, 155, 112, 3, 37, "Input"], Cell[4109, 160, 166, 3, 41, "Text"], Cell[4278, 165, 65, 1, 37, "Input"], Cell[4346, 168, 93, 2, 26, "Text"], Cell[4442, 172, 63, 1, 37, "Input"], Cell[4508, 175, 110, 3, 37, "Input"], Cell[4621, 180, 95, 2, 26, "Text"], Cell[4719, 184, 96, 2, 37, "Input"], Cell[4818, 188, 110, 3, 37, "Input"], Cell[4931, 193, 56, 0, 26, "Text"], Cell[4990, 195, 106, 3, 37, "Input"], Cell[5099, 200, 65, 0, 26, "Text"], Cell[5167, 202, 137, 2, 37, "Input"], Cell[5307, 206, 98, 2, 26, "Text"], Cell[5408, 210, 73, 1, 37, "Input"], Cell[5484, 213, 281, 8, 37, "Input"], Cell[5768, 223, 189, 4, 41, "Text"], Cell[5960, 229, 166, 5, 37, "Input"], Cell[6129, 236, 36, 0, 26, "Text"], Cell[6168, 238, 85, 2, 37, "Input"], Cell[6256, 242, 70, 0, 26, "Text"], Cell[6329, 244, 86, 2, 37, "Input"], Cell[6418, 248, 34, 0, 26, "Text"], Cell[6455, 250, 44, 1, 37, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[6536, 256, 35, 0, 42, "Section"], Cell[6574, 258, 170, 5, 22, "Text"], Cell[6747, 265, 98, 2, 44, "Input"], Cell[6848, 269, 158, 3, 22, "Text"], Cell[7009, 274, 94, 2, 44, "Input"], Cell[7106, 278, 475, 11, 37, "Text"], Cell[7584, 291, 89, 2, 44, "Input"], Cell[7676, 295, 317, 10, 37, "Text"], Cell[7996, 307, 86, 2, 44, "Input"], Cell[8085, 311, 213, 5, 22, "Text"], Cell[8301, 318, 197, 6, 44, "Input"], Cell[8501, 326, 770, 25, 55, "Text"], Cell[9274, 353, 143, 4, 50, "Input"], Cell[9420, 359, 253, 7, 25, "Text"], Cell[9676, 368, 308, 9, 50, "Input"], Cell[9987, 379, 124, 5, 22, "Text"], Cell[10114, 386, 138, 4, 50, "Input"], Cell[10255, 392, 143, 3, 22, "Text"], Cell[10401, 397, 172, 5, 50, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[10610, 407, 44, 0, 42, "Section"], Cell[10657, 409, 131, 3, 22, "Text"], Cell[10791, 414, 154, 5, 49, "Input"], Cell[10948, 421, 262, 9, 27, "Text"], Cell[11213, 432, 54, 1, 44, "Input"], Cell[11270, 435, 72, 2, 44, "Input"], Cell[11345, 439, 252, 10, 22, "Text"], Cell[11600, 451, 158, 5, 44, "Input"], Cell[11761, 458, 189, 6, 44, "Input"], Cell[11953, 466, 162, 8, 22, "Text"], Cell[12118, 476, 44, 1, 44, "Input"], Cell[12165, 479, 58, 1, 44, "Input"], Cell[12226, 482, 76, 0, 22, "Text"], Cell[12305, 484, 131, 4, 64, "Input"], Cell[12439, 490, 52, 0, 22, "Text"], Cell[12494, 492, 56, 1, 44, "Input"], Cell[12553, 495, 212, 8, 22, "Text"], Cell[12768, 505, 55, 1, 44, "Input"], Cell[12826, 508, 94, 2, 22, "Text"], Cell[12923, 512, 140, 4, 44, "Input"], Cell[13066, 518, 58, 1, 44, "Input"], Cell[13127, 521, 191, 6, 64, "Input"], Cell[13321, 529, 159, 5, 44, "Input"], Cell[13483, 536, 44, 1, 44, "Input"], Cell[13530, 539, 286, 9, 44, "Input"], Cell[13819, 550, 339, 9, 44, "Input"], Cell[14161, 561, 58, 1, 44, "Input"], Cell[14222, 564, 176, 3, 22, "Text"], Cell[14401, 569, 123, 3, 44, "Input"], Cell[14527, 574, 146, 3, 22, "Text"], Cell[14676, 579, 57, 1, 44, "Input"], Cell[14736, 582, 78, 2, 64, "Input"], Cell[14817, 586, 59, 1, 44, "Input"], Cell[14879, 589, 111, 3, 44, "Input"], Cell[14993, 594, 57, 1, 44, "Input"], Cell[15053, 597, 53, 0, 22, "Text"], Cell[15109, 599, 54, 1, 44, "Input"], Cell[15166, 602, 35, 0, 22, "Text"], Cell[15204, 604, 56, 1, 44, "Input"], Cell[15263, 607, 58, 1, 44, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[15358, 613, 38, 0, 42, "Section"], Cell[15399, 615, 237, 4, 37, "Text"], Cell[15639, 621, 498, 15, 50, "Input"], Cell[16140, 638, 56, 0, 22, "Text"], Cell[16199, 640, 552, 18, 50, "Input"], Cell[16754, 660, 189, 6, 44, "Input"], Cell[16946, 668, 98, 2, 22, "Text"], Cell[17047, 672, 383, 14, 81, "Input"], Cell[17433, 688, 189, 6, 44, "Input"], Cell[17625, 696, 40, 0, 22, "Text"], Cell[17668, 698, 319, 9, 50, "Input"], Cell[17990, 709, 189, 6, 44, "Input"], Cell[18182, 717, 25, 0, 22, "Text"], Cell[18210, 719, 91, 2, 44, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[18338, 726, 45, 0, 42, "Section"], Cell[18386, 728, 158, 3, 22, "Text"], Cell[18547, 733, 103, 3, 47, "Input"], Cell[18653, 738, 296, 11, 25, "Text"], Cell[18952, 751, 234, 8, 50, "Input"], Cell[19189, 761, 99, 2, 22, "Text"], Cell[19291, 765, 235, 8, 50, "Input"], Cell[19529, 775, 164, 5, 22, "Text"], Cell[19696, 782, 248, 8, 50, "Input"], Cell[19947, 792, 113, 3, 22, "Text"], Cell[20063, 797, 215, 7, 47, "Input"], Cell[20281, 806, 60, 0, 22, "Text"], Cell[20344, 808, 248, 8, 50, "Input"], Cell[20595, 818, 94, 2, 22, "Text"], Cell[20692, 822, 444, 13, 50, "Input"], Cell[21139, 837, 300, 11, 25, "Text"], Cell[21442, 850, 144, 4, 50, "Input"], Cell[21589, 856, 44, 0, 22, "Text"], Cell[21636, 858, 93, 1, 44, "Input"], Cell[21732, 861, 42, 0, 22, "Text"], Cell[21777, 863, 601, 15, 41, "Text"], Cell[22381, 880, 445, 13, 50, "Input"], Cell[22829, 895, 389, 11, 22, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[23255, 911, 42, 0, 42, "Section"], Cell[23300, 913, 193, 4, 37, "Text"], Cell[23496, 919, 128, 4, 46, "Input"], Cell[23627, 925, 77, 2, 44, "Input"], Cell[23707, 929, 77, 2, 44, "Input"], Cell[23787, 933, 103, 5, 22, "Text"], Cell[23893, 940, 54, 1, 44, "Input"], Cell[23950, 943, 124, 5, 22, "Text"], Cell[24077, 950, 58, 1, 44, "Input"], Cell[24138, 953, 149, 5, 46, "Input"], Cell[24290, 960, 77, 2, 44, "Input"], Cell[24370, 964, 54, 1, 44, "Input"], Cell[24427, 967, 291, 5, 37, "Text"], Cell[24721, 974, 58, 1, 44, "Input"], Cell[24782, 977, 381, 12, 50, "Input"], Cell[25166, 991, 292, 9, 50, "Input"], Cell[25461, 1002, 1070, 30, 85, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[26568, 1037, 135, 3, 42, "Section"], Cell[26706, 1042, 130, 5, 22, "Text"], Cell[26839, 1049, 115, 2, 44, "Input"], Cell[26957, 1053, 114, 3, 22, "Text"], Cell[27074, 1058, 98, 3, 44, "Input"], Cell[27175, 1063, 167, 5, 44, "Input"], Cell[27345, 1070, 56, 1, 44, "Input"], Cell[27404, 1073, 46, 1, 44, "Input"], Cell[27453, 1076, 513, 10, 52, "Text"], Cell[27969, 1088, 60, 1, 44, "Input"], Cell[28032, 1091, 98, 3, 44, "Input"], Cell[28133, 1096, 224, 7, 44, "Input"], Cell[28360, 1105, 56, 1, 44, "Input"], Cell[28419, 1108, 114, 5, 22, "Text"], Cell[28536, 1115, 46, 1, 44, "Input"], Cell[28585, 1118, 157, 3, 22, "Text"], Cell[28745, 1123, 57, 1, 44, "Input"], Cell[28805, 1126, 46, 1, 44, "Input"], Cell[28854, 1129, 60, 1, 44, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[28951, 1135, 26, 0, 42, "Section"], Cell[28980, 1137, 85, 2, 20, "Text"], Cell[29068, 1141, 67, 1, 27, "Input"], Cell[29138, 1144, 45, 0, 20, "Text"], Cell[29186, 1146, 137, 3, 27, "Input"], Cell[29326, 1151, 22, 0, 20, "Text"], Cell[29351, 1153, 121, 3, 27, "Input"], Cell[29475, 1158, 38, 0, 20, "Text"], Cell[29516, 1160, 224, 7, 30, "Input"], Cell[29743, 1169, 41, 0, 20, "Text"], Cell[29787, 1171, 148, 4, 27, "Input"], Cell[29938, 1177, 90, 2, 20, "Text"], Cell[30031, 1181, 61, 1, 27, "Input"], Cell[30095, 1184, 41, 0, 20, "Text"], Cell[30139, 1186, 126, 4, 27, "Input"], Cell[30268, 1192, 34, 0, 20, "Text"], Cell[30305, 1194, 53, 1, 27, "Input"], Cell[30361, 1197, 18, 0, 20, "Text"], Cell[30382, 1199, 90, 2, 27, "Input"], Cell[30475, 1203, 36, 0, 20, "Text"], Cell[30514, 1205, 243, 5, 27, "Input"], Cell[30760, 1212, 27, 0, 20, "Text"], Cell[30790, 1214, 60, 1, 27, "Input"], Cell[30853, 1217, 57, 1, 27, "Input"], Cell[30913, 1220, 116, 3, 20, "Text"], Cell[31032, 1225, 13592, 327, 125, "Text"], Cell[44627, 1554, 171, 3, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[44835, 1562, 59, 1, 42, "Section"], Cell[44897, 1565, 207, 7, 32, "Text"], Cell[CellGroupData[{ Cell[45129, 1576, 41, 0, 34, "Subsection"], Cell[45173, 1578, 801, 28, 56, "Text"], Cell[CellGroupData[{ Cell[45999, 1610, 33, 0, 18, "Subsubsection"], Cell[46035, 1612, 58, 1, 27, "Input"], Cell[46096, 1615, 259, 8, 27, "Input"], Cell[46358, 1625, 222, 7, 27, "Input"], Cell[46583, 1634, 32, 0, 20, "Text"], Cell[46618, 1636, 182, 6, 27, "Input"], Cell[46803, 1644, 61, 1, 27, "Input"], Cell[46867, 1647, 58, 1, 27, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[46974, 1654, 50, 0, 26, "Subsection"], Cell[47027, 1656, 633, 22, 44, "Text"], Cell[CellGroupData[{ Cell[47685, 1682, 33, 0, 18, "Subsubsection"], Cell[47721, 1684, 250, 8, 27, "Input"], Cell[47974, 1694, 254, 8, 27, "Input"], Cell[48231, 1704, 196, 7, 46, "Input"], Cell[48430, 1713, 280, 7, 27, "Input"], Cell[48713, 1722, 314, 9, 27, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[49076, 1737, 52, 0, 26, "Subsection"], Cell[49131, 1739, 670, 16, 50, "Text"], Cell[CellGroupData[{ Cell[49826, 1759, 33, 0, 18, "Subsubsection"], Cell[49862, 1761, 168, 5, 27, "Input"], Cell[50033, 1768, 140, 4, 27, "Input"], Cell[50176, 1774, 160, 4, 27, "Input"], Cell[50339, 1780, 94, 2, 27, "Input"], Cell[50436, 1784, 176, 3, 20, "Text"], Cell[50615, 1789, 49, 1, 27, "Input"], Cell[50667, 1792, 192, 4, 27, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[50908, 1802, 75, 0, 26, "Subsection"], Cell[50986, 1804, 538, 20, 44, "Text"], Cell[CellGroupData[{ Cell[51549, 1828, 33, 0, 18, "Subsubsection"], Cell[51585, 1830, 130, 4, 29, "Input"], Cell[51718, 1836, 97, 2, 27, "Input"], Cell[51818, 1840, 153, 3, 27, "Input"], Cell[51974, 1845, 222, 8, 27, "Input"], Cell[52199, 1855, 58, 1, 27, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[52306, 1862, 31, 0, 26, "Subsection"], Cell[52340, 1864, 354, 8, 35, "Text"], Cell[CellGroupData[{ Cell[52719, 1876, 33, 0, 18, "Subsubsection"], Cell[52755, 1878, 60, 1, 27, "Input"], Cell[52818, 1881, 154, 5, 27, "Input"], Cell[52975, 1888, 282, 9, 27, "Input"], Cell[53260, 1899, 57, 1, 27, "Input"], Cell[53320, 1902, 57, 1, 27, "Input"], Cell[53380, 1905, 63, 1, 27, "Input"], Cell[53446, 1908, 46, 1, 27, "Input"], Cell[53495, 1911, 60, 1, 27, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[53604, 1918, 29, 0, 26, "Subsection"], Cell[53636, 1920, 1134, 40, 38, "Text"], Cell[CellGroupData[{ Cell[54795, 1964, 33, 0, 18, "Subsubsection"], Cell[54831, 1966, 149, 3, 27, "Input"], Cell[54983, 1971, 22, 0, 20, "Text"], Cell[55008, 1973, 121, 3, 27, "Input"], Cell[55132, 1978, 184, 5, 27, "Input"], Cell[55319, 1985, 101, 2, 27, "Input"], Cell[55423, 1989, 159, 5, 27, "Input"], Cell[55585, 1996, 358, 11, 30, "Input"], Cell[55946, 2009, 167, 5, 27, "Input"], Cell[56116, 2016, 172, 5, 27, "Input"], Cell[56291, 2023, 301, 9, 27, "Input"], Cell[56595, 2034, 785, 40, 20, "Text"] }, Closed]] }, Closed]] }, Closed]] }, Open ]] } ] *) (* End of internal cache information *)