(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 42068, 1508]*) (*NotebookOutlinePosition[ 43103, 1541]*) (* CellTagsIndexPosition[ 43059, 1537]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData["Chapter VI. Iteration in Procedural Programming"], "Title", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["18. Iterative Loops I: While"], "Title", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Last revision: March 23 1997"], "SmallText", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "In this section we introduce iterative loops, the primary method of \ implementing iteration in procedural programming. We show how loops are, in \ some cases, more efficient than list-based or recursive programming. \ Finally, we consider the type of evaluation precedence of boolean expressions \ called \"short-circuit evaluation\" and discuss its advantages."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" operations/structures introduced: \n", Evaluatable->False, AspectRatioFixed->True], StyleBox[" While[]\n PrimeQ[]\n Prime[]\n ", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["short-circuit evaluation", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier", FontSlant->"Italic"] }], "SmallText", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{ Cell[TextData["Loops and Efficiency"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "List-based programming and recursion are two excellent ways to accomplish \ iteration, because they tend to encourage code which is at once elegant and \ short. Still another method for iteration, however, is available: using ", Evaluatable->False, AspectRatioFixed->True], StyleBox["iterative loops", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ ". Using such loops produces somewhat longer, less elegant code, but in \ many situations it is more efficient to use iterative loops, and we introduce \ it in this section. Generally, any programming task solvable by list-based \ programming or recursive programming can be solved by using iterative loops; \ we have waited to discuss it, therefore, so that the advantages of the first \ two methods will have become evident before we introduce a method which, \ while always applicable, may not be the best solution.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData["The While Construct"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["The \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" construct instructs ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ " to repeat a sequence of commands, given as the second argument and \ separated by semicolons if necessary, until the boolean test specified by the \ first argument becomes ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[". In other words, ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" first executes the boolean test. If it is ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" command finishes. If it is ", Evaluatable->False, AspectRatioFixed->True], StyleBox["True", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" command executes all of the commands found in the second argument. \ Then the boolean test is evaluated again. If ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" command finishes. If ", Evaluatable->False, AspectRatioFixed->True], StyleBox["True", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ ", the commands are executed again, and so on. It is important, then, when \ designing a \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" loop---or any loop, for that matter---to insure that at some point the \ boolean test will result in a ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ " value. We consider several examples below, comparing list-based to loop \ solutions.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{ Cell[TextData[ "Example 1: Finding a Negative; Classic Principles of Loops"], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "How can we find the first negative number in a list of numbers?"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{ Cell[TextData["List-operation solution"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Clear[firstNeg];\nfirstNeg[x_List] := First[ Select[x, (#<0&)] ]"], "Input", AspectRatioFixed->True], Cell[TextData["firstNeg[{3,5,2,-7,4,3,11,-2,0,-1,8}]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "This works fine but is inefficient, for it does more work than necessary \ in determining the ", Evaluatable->False, AspectRatioFixed->True], StyleBox["entire", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" list of negatives ", Evaluatable->False, AspectRatioFixed->True], StyleBox["{-7,-2,-1}", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", from which then selects the first, namely ", Evaluatable->False, AspectRatioFixed->True], StyleBox["-7", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ ". A more efficient strategy would be to start at the front of the list, \ working through it until one finds a negative number, and then stopping. This \ procedure can be accomplished with a \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" loop.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData["While loop solution; Classic Principles"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["?While"], "Input", AspectRatioFixed->True], Cell[TextData[ "firstNeg[x_List] := Module[{i},\n i = 1;\n While[ x[[i]]>=0, i=i+1 ];\n \ x[[i]]\n]"], "Input", AspectRatioFixed->True], Cell[TextData["firstNeg[{3,5,2,-7,4,3,11,-2,0,-1,8}]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["Notice that the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" construct executes the commands after the boolean expression \ repeatedly, checking the value of the boolean expression each time, and \ stopping when the boolean expression evaluates to ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[". ", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Our example contains each of the following classic principles of an \ iterative loop:"], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "1. We initialize one or more variable(s) before entering the loop. These \ variables are typically local."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "2. We modify the variable(s) each time through the loop. In the example \ above, we increment \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" by ", Evaluatable->False, AspectRatioFixed->True], StyleBox["1", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" every time.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "3. After the loop completes, we execute at least one other command to \ return an answer. Loop structures themselves have no return value. In the \ example above, we execute \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["x[[i]]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" to provide the answer we are seeking.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["The boolean expression inside a \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" statement will always be ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" once ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" begins to execute the line after the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" statement, if the program ever does exit the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" loop. Otherwise, ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ " will enter an infinite loop, which keeps evaluating the same instructions \ indefinitely, unless you manually interrupt it. To interrupt a calculation, \ see \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Interrupt Evaluation", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Chicago", FontSize->10], StyleBox["\" under the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Kernel", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Chicago", FontSize->10], StyleBox["\" menu.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData["While loop solution with error handling"], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Our \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" loop above was not coded to be foolproof. For instance, what if the \ value of the parameter is a list with no negative element?", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["firstNeg[{3,5,2,4,3,11,0,8}]"], "Input", AspectRatioFixed->True], Cell[TextData[ "The first eight entries were non-negative, so it tried the ninth---but there \ is no ninth element."], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "What follows is a solution to this relatively common looping problem, that \ of running beyond the end of a list. The method below performs correctly \ because in ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" (and many, but not all, other languages) supports ", Evaluatable->False, AspectRatioFixed->True], StyleBox["short-circuit evaluation", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ ": if the first boolean expression in a list of expressions connected by \ boolean ", Evaluatable->False, AspectRatioFixed->True], StyleBox["And", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" operations (\"", Evaluatable->False, AspectRatioFixed->True], StyleBox["&&", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\") is false, then ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ " doesn't bother to test the second; if the second is false, it doesn't \ bother to test the third, and so on. Consider how short-circuit evaluation \ is used in the following solution. At the end of the section we will consider \ short-circuit evaluation in more detail.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell["\<\ Clear[firstNeg]; firstNeg[x_List] := Module[{i}, i = 1; While[ i<=Length[x] && x[[i]]>=0, i=i+1 ]; If[ i>Length[x], \"Sorry, no negative found.\", x[[i]] ] ]\ \>", "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["In the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" loop above, \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" begins at the value ", Evaluatable->False, AspectRatioFixed->True], StyleBox["1", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ " and can reach no higher than one greater than the length of the list \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["x", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". When the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" loop completes, \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["x[[i]]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" is evaluated only if \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" is valid index into the list \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["x", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\".", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["firstNeg[{3,5,2,-7,4,3,11,-2,0,-1,8}]"], "Input", AspectRatioFixed->True], Cell[TextData["firstNeg[{3,5,2,4,3,11,0,8}]"], "Input", AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell["Recursive solution with error handling", "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Here is a tail recursive solution. In this simple example, the \ recursive solution is as efficient as that with a ", Evaluatable->False, AspectRatioFixed->True], StyleBox["While", "Input", Evaluatable->False, AspectRatioFixed->True, FontWeight->"Plain"], StyleBox[" loop, and \"cleaner\" to read.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell["\<\ Clear[firstNeg]; firstNeg[x_List] := Which[ x == {}, \"Sorry, no negative found.\", First[x] < 0, First[x], True, firstNeg[Rest[x]] ];\ \>", "Input", AspectRatioFixed->True], Cell["firstNeg[{3,5,2,-7,4,3,11,-2,0,-1,8}]", "Input", AspectRatioFixed->True], Cell["firstNeg[{3,5,2,4,3,11,0,8}]", "Input", AspectRatioFixed->True] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[TextData["Example 2: Finding the first prime beyond n."], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Recall \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["PrimeQ[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\": a boolean test for a prime number. Here we use it to find the first \ prime number beyond \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["n", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\":", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["?PrimeQ"], "Input", AspectRatioFixed->True], Cell[TextData[ "firstPrimeBeyond[n_Integer?Positive] := \n Module[{i},\n i = n+1;\n \ While[ Not[PrimeQ[i] ], i++];\n i\n ]"], "Input", AspectRatioFixed->True], Cell[TextData["firstPrimeBeyond[20]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["(Note our use of the increment notation \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i++", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\".) There are two tempting pitfalls to dodge in trying to simplify the \ code above, as follows:", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{ Cell[TextData[ "Pitfall 1: The While command does not have a return value."], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Clear[firstPrimeBeyond];\nfirstPrimeBeyond[n_Integer?Positive] := \n \ Module[{i},\n i = n+1;\n While[ Not[PrimeQ[i]], i++]\n ]"], "Input", AspectRatioFixed->True], Cell[TextData["firstPrimeBeyond[20]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["The \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" loop executed correctly, but provided us with no answer.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData[ "Pitfall 2: Formal parameters cannot be used in place of local variables \ because formal parameters cannot be modified within a Module."], "Subsubsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "Many languages allow you to change the value of a formal parameter within \ the function, treating the formal parameter as a separate local variable, but \ ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" is not one of them. Therefore we cannot use \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["n", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" itself as the variable instead of local \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\".", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Clear[firstPrimeBeyond];\nfirstPrimeBeyond[n_Integer?Positive] := \n \ Module[{},\n n = n+1;\n While[ Not[PrimeQ[n]], n=n+1];\n n\n \ ]"], "Input", AspectRatioFixed->True], Cell[TextData[ "firstPrimeBeyond[20] (* Action, Interrupt this infinite loop. *)"], "Input",\ AspectRatioFixed->True], Cell[TextData[{ StyleBox["(What happens is that ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" substitutes 20 for \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["n", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" everywhere in the function, which is a nonstandard procedure. Thus the \ first line becomes \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["20 = 20+1", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" , generating an error since we can't assign a value to ", Evaluatable->False, AspectRatioFixed->True], StyleBox["20.", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" In most other languages this sort of code would work fine.)", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "These two pitfalls illustrate why one should generally abide by the three \ classic principles stated above."], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[TextData[ "Example 3: Programming the fixed-point iteration."], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Recall that \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["FixedPoint[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" works like \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Nest[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" except that it stops when two consecutive values are recognized as \ identical.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["NestList[Cos, 0.0, 20]"], "Input", AspectRatioFixed->True], Cell[TextData["Nest[Cos, 0.0, 20]"], "Input", AspectRatioFixed->True], Cell[TextData["FixedPoint[Cos, 0.0]"], "Input", AspectRatioFixed->True], Cell[TextData["?FixedPoint"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["If \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["FixedPoint[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" was not a pre-defined function, which it is not in many other \ languages, we could program our own version of \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["FixedPoint[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\", say called \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["myFixedPoint[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\", using a \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" loop, as follows.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "myFixedPoint[ f_, x0_ ] := Module[ {oldx, newx},\n oldx = x0;\n newx = \ f[x0];\n While[ oldx != newx,\n oldx = newx; \n (* replaces \ oldx with last computed value *)\n newx = f[newx]; \n (* computes \ a new value *)\n ];\n newx (* returns answer *)\n]"], "Input", AspectRatioFixed->True], Cell[TextData["myFixedPoint[Cos, 0.0]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["Notice how the second argument of \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" may be a compound expression of several lines separated by semicolons, \ as in a ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Module", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[".", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData[ "Example 4: Listing the prime numbers less than n."], "Subsection", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["For this example we will use the ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" function \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Prime[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\", which, for a value \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" of the argument, returns the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\"th prime number. The first 10 prime numbers may then be computed by \ executing the following expression.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Table[Prime[i],{i,1,10}]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "We wish to write a function which will return a list of all of the prime \ numbers which are less than \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["n", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". We can't use \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Table[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" since we don't know ahead of time how many there will be, so we use \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\".", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "primesUpTo[n_Integer?Positive] := \n Module[{i, primeList},\n i = 1;\n \ primeList = {};\n While[ Prime[i]True], Cell[TextData["primesUpTo[30]"], "Input", AspectRatioFixed->True], Cell[TextData["primesUpTo[200]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "One possible objection to the above program is that it computes \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Prime[i]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" twice. This may be inefficient, and it could be disaster in a \ different problem, if the function we repeated twice returned two different \ values when executed twice, say for instance if the function computed a \ random number. To compute \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Prime[i]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" only once, we need yet another local variable, in addition to the \ counter \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" and the cumulative \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["primeList", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\".", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "Clear[primesUpTo];\nprimesUpTo[n_Integer?Positive] := \n Module[{i, \ primeList, nextPrime},\n i = 1;\n nextPrime = Prime[1];\n primeList \ = {};\n While[ nextPrime < n, \n \t\t(* update all three variables,in \ this order! *)\n primeList = Append[primeList, nextPrime];\n i++;\n \ nextPrime = Prime[i]\n ];\n primeList\n]"], "Input", AspectRatioFixed->True], Cell[TextData["primesUpTo[200]"], "Input", AspectRatioFixed->True] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[TextData["Short-Circuit Evaluation"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "Short-circuit evaluation is a characteristic of a particular sort of \ \"evaluation precedence\" which\n", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ " and several other languages support. Specifically, under short-circuit \ evaluation, if a sequence of expressions are connected by several instances \ of \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["And[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" (\"", Evaluatable->False, AspectRatioFixed->True], StyleBox["&&", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\") or \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Or[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" (\"", Evaluatable->False, AspectRatioFixed->True], StyleBox["||", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\"), then the sequence of expressions is investigated from left to right, \ stopping as soon as the ultimate value can be determined. For instance, if, \ in an \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["And[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" construct, an expression evaluates as ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", then there is no need to continue, and hence ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ " will not evaluate any of the remaining expressions in the sequence of \ expressions connected by \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["And[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". Similarly, in an \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Or[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" construct, as soon as an expression, looking left to right, has a ", Evaluatable->False, AspectRatioFixed->True], StyleBox["True", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" value, ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[ " will not evaluate the rest of the expressions, simply returning the value \ ", Evaluatable->False, AspectRatioFixed->True], StyleBox["True", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ ", since it must be the final value of the sequence of expressions \ connected by \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Or[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". Here are some examples.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["(2==3) && (5==5)"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["This surely evaluates to False, but ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" didn't even check \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["5==5", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\"! After \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["2==3", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" returned ", Evaluatable->False, AspectRatioFixed->True], StyleBox["False", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", it stopped evaluating the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["And[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" sequence. To be sure, let's try this:", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Clear[b]\nb=2;\n(2==3) && ((b=3)==3)"], "Input", AspectRatioFixed->True], Cell[TextData["b"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["Notice that \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["b", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Delphian"], StyleBox["\" did not become 3, since ", Evaluatable->False, AspectRatioFixed->True], StyleBox["Mathematica", Evaluatable->False, AspectRatioFixed->True, FontSlant->"Italic"], StyleBox[" did not evaluate the expression \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["b=3", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". If, however, the first expression evaluated to ", Evaluatable->False, AspectRatioFixed->True], StyleBox["True", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", then the second expression would be evaluated.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Clear[b]\nb=2;\n(2==2) && ((b=3)==3)"], "Input", AspectRatioFixed->True], Cell[TextData["b"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["We have analogous examples for an \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Or[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\":", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Clear[b]\nb=2;\n(2==2) || ((b=3)==3)"], "Input", AspectRatioFixed->True], Cell[TextData["b"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["Here \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["b=3", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" was never evaluated, since the first expression returned ", Evaluatable->False, AspectRatioFixed->True], StyleBox["True", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[", and hence the \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["Or[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" must return a ", Evaluatable->False, AspectRatioFixed->True], StyleBox["True", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[" value also. However, in the following code, \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["b=3", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" is evaluated:", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["Clear[b]\nb=2;\n(2==3) || ((b=3)==3)"], "Input", AspectRatioFixed->True], Cell[TextData["b"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "To grasp the importance of short-circuit evaluation, consider the \ following problem. We wish to check whether or not the reciprocal of an \ integer is equal to variable \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["x", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". We might try the following statement:", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[ "If[(1/i)==x, (* Statement if true *), (* Otherwise *)]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox["But what if \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" were zero? Then \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["1/i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" would return an error. We might then refine our code to be the \ following:", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True], Cell[TextData["If[(i!=0)&&((1/i)==x), , ]"], "Input", AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "In this instance, however, if short-circuit evaluation were not in effect, \ then \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["1/i", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" might be evaluated before \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["i!=0", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" was tested, and an error would result. With short-circuit evaluation, \ we are guaranteed that the expressions will be evaluated left-to-right and \ that no error will occur.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]] }, Open ]] }, FrontEndVersion->"4.0 for Macintosh", ScreenRectangle->{{0, 832}, {0, 604}}, WindowToolbars->{}, WindowSize->{520, 509}, WindowMargins->{{124, Automatic}, {Automatic, 1}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, MacintoshSystemPageSetup->"\<\ 00<0004/0B`000002n88o?mooh<" ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1739, 51, 123, 2, 136, "Title", Evaluatable->False], Cell[1865, 55, 104, 2, 98, "Title", Evaluatable->False], Cell[1972, 59, 108, 2, 26, "SmallText", Evaluatable->False], Cell[2083, 63, 439, 7, 78, "Text", Evaluatable->False], Cell[2525, 72, 575, 19, 82, "SmallText", Evaluatable->False], Cell[CellGroupData[{ Cell[3125, 95, 97, 2, 50, "Section", Evaluatable->False], Cell[3225, 99, 1071, 23, 144, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[4333, 127, 96, 2, 30, "Section", Evaluatable->False], Cell[4432, 131, 3104, 108, 162, "Text", Evaluatable->False], Cell[CellGroupData[{ Cell[7561, 243, 140, 3, 46, "Subsection", Evaluatable->False], Cell[7704, 248, 138, 3, 30, "Text", Evaluatable->False], Cell[CellGroupData[{ Cell[7867, 255, 106, 2, 42, "Subsubsection", Evaluatable->False], Cell[7976, 259, 118, 2, 42, "Input"], Cell[8097, 263, 90, 1, 27, "Input"], Cell[8190, 266, 1182, 39, 98, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[9409, 310, 122, 2, 28, "Subsubsection", Evaluatable->False], Cell[9534, 314, 59, 1, 27, "Input"], Cell[9596, 317, 143, 3, 87, "Input"], Cell[9742, 322, 90, 1, 27, "Input"], Cell[9835, 325, 693, 23, 62, "Text", Evaluatable->False], Cell[10531, 350, 160, 4, 30, "Text", Evaluatable->False], Cell[10694, 356, 181, 4, 46, "Text", Evaluatable->False], Cell[10878, 362, 588, 22, 46, "Text", Evaluatable->False], Cell[11469, 386, 532, 16, 62, "Text", Evaluatable->False], Cell[12004, 404, 1919, 67, 101, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[13960, 476, 122, 2, 28, "Subsubsection", Evaluatable->False], Cell[14085, 480, 453, 15, 46, "Text", Evaluatable->False], Cell[14541, 497, 81, 1, 27, "Input"], Cell[14625, 500, 174, 4, 30, "Text", Evaluatable->False], Cell[14802, 506, 1614, 50, 134, "Text", Evaluatable->False], Cell[16419, 558, 233, 11, 147, "Input"], Cell[16655, 571, 1695, 63, 62, "Text", Evaluatable->False], Cell[18353, 636, 90, 1, 27, "Input"], Cell[18446, 639, 81, 1, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[18564, 645, 111, 2, 28, "Subsubsection", Evaluatable->False], Cell[18678, 649, 464, 14, 46, "Text", Evaluatable->False], Cell[19145, 665, 210, 9, 117, "Input"], Cell[19358, 676, 80, 1, 27, "Input"], Cell[19441, 679, 71, 1, 27, "Input"] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[19561, 686, 125, 2, 46, "Subsection", Evaluatable->False], Cell[19689, 690, 590, 22, 48, "Text", Evaluatable->False], Cell[20282, 714, 60, 1, 27, "Input"], Cell[20345, 717, 180, 3, 102, "Input"], Cell[20528, 722, 73, 1, 27, "Input"], Cell[20604, 725, 451, 15, 47, "Text", Evaluatable->False], Cell[CellGroupData[{ Cell[21080, 744, 146, 4, 42, "Subsubsection", Evaluatable->False], Cell[21229, 750, 198, 4, 102, "Input"], Cell[21430, 756, 73, 1, 27, "Input"], Cell[21506, 759, 377, 13, 31, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[21920, 777, 223, 5, 58, "Subsubsection", Evaluatable->False], Cell[22146, 784, 897, 30, 65, "Text", Evaluatable->False], Cell[23046, 816, 208, 4, 117, "Input"], Cell[23257, 822, 121, 3, 42, "Input"], Cell[23381, 827, 1080, 36, 82, "Text", Evaluatable->False], Cell[24464, 865, 183, 4, 46, "Text", Evaluatable->False] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[24696, 875, 131, 3, 30, "Subsection", Evaluatable->False], Cell[24830, 880, 601, 22, 47, "Text", Evaluatable->False], Cell[25434, 904, 75, 1, 27, "Input"], Cell[25512, 907, 71, 1, 27, "Input"], Cell[25586, 910, 73, 1, 27, "Input"], Cell[25662, 913, 64, 1, 27, "Input"], Cell[25729, 916, 1014, 36, 65, "Text", Evaluatable->False], Cell[26746, 954, 342, 5, 177, "Input"], Cell[27091, 961, 75, 1, 27, "Input"], Cell[27169, 964, 605, 22, 48, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[27811, 991, 131, 3, 30, "Subsection", Evaluatable->False], Cell[27945, 996, 1027, 36, 65, "Text", Evaluatable->False], Cell[28975, 1034, 77, 1, 27, "Input"], Cell[29055, 1037, 857, 31, 64, "Text", Evaluatable->False], Cell[29915, 1070, 266, 5, 162, "Input"], Cell[30184, 1077, 67, 1, 27, "Input"], Cell[30254, 1080, 68, 1, 27, "Input"], Cell[30325, 1083, 1252, 41, 97, "Text", Evaluatable->False], Cell[31580, 1126, 412, 6, 237, "Input"], Cell[31995, 1134, 68, 1, 27, "Input"] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[32112, 1141, 101, 2, 50, "Section", Evaluatable->False], Cell[32216, 1145, 3439, 119, 202, "Text", Evaluatable->False], Cell[35658, 1266, 69, 1, 27, "Input"], Cell[35730, 1269, 1137, 41, 49, "Text", Evaluatable->False], Cell[36870, 1312, 89, 1, 57, "Input"], Cell[36962, 1315, 54, 1, 27, "Input"], Cell[37019, 1318, 988, 34, 66, "Text", Evaluatable->False], Cell[38010, 1354, 89, 1, 57, "Input"], Cell[38102, 1357, 54, 1, 27, "Input"], Cell[38159, 1360, 348, 13, 31, "Text", Evaluatable->False], Cell[38510, 1375, 89, 1, 57, "Input"], Cell[38602, 1378, 54, 1, 27, "Input"], Cell[38659, 1381, 1141, 41, 48, "Text", Evaluatable->False], Cell[39803, 1424, 89, 1, 57, "Input"], Cell[39895, 1427, 54, 1, 27, "Input"], Cell[39952, 1430, 525, 16, 63, "Text", Evaluatable->False], Cell[40480, 1448, 108, 2, 42, "Input"], Cell[40591, 1452, 590, 22, 47, "Text", Evaluatable->False], Cell[41184, 1476, 79, 1, 27, "Input"], Cell[41266, 1479, 774, 25, 64, "Text", Evaluatable->False] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)