(************** Content-type: application/mathematica ************** Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. 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[ 186336, 6236]*) (*NotebookOutlinePosition[ 189518, 6324]*) (* CellTagsIndexPosition[ 188812, 6304]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Controlled Evaluation of ", StyleBox["Mathematica", FontSlant->"Italic"], " Expressions" }], "Title"], Cell[TextData[{ "David Park\ndjmp@earthlink.net\n", ButtonBox["http://home.earthlink.net/~djmp/", ButtonData:>{ URL[ "http://home.earthlink.net/~djmp/"], None}, ButtonStyle->"Hyperlink"] }], "Subtitle"], Cell[TextData[{ "Ted Ersek is the coauthor of the ExpressionManipulation package and did a \ significant part of the coding.\nErsekTR@navair.navy.mil\n", ButtonBox["http://www.verbeia.com/mathematica/tips/Tricks.html", ButtonData:>{ URL[ "http://www.verbeia.com/mathematica/tips/Tricks.html"], None}, ButtonStyle->"Hyperlink"] }], "Subtitle"], Cell["\<\ Updated on 21 April 2001 with a new ColorPositions routine and options.\ \>", "Text"], Cell[CellGroupData[{ Cell["Initialization", "Section"], Cell["\<\ The following package, available from my web-site above is used in this \ notebook. The package should be placed in the AddOns/ExtraPackages/Algebra \ directory.\ \>", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input", CellLabel->"In[1]:="] }, Open ]], Cell[CellGroupData[{ Cell["1 Introduction", "Section"], Cell[TextData[{ "This notebook is both a tutorial on the routines in the \ ExpressionManipulation package and a tutorial on how to perform controlled \ evaluations on ", StyleBox["Mathematica", FontSlant->"Italic"], " expressions. The notebook is partly aimed at junior high school or high \ school students, and relative beginners at ", StyleBox["Mathematica", FontSlant->"Italic"], " who wish to know how to evaluate mathematical expressions so as to see \ the various steps. The examples run from simple fraction problems to \ integation by substitution." }], "Text"], Cell["\<\ How should you do algebra and arithmetic problems? Should you do them by hand \ or by computer? At first, it may seem easier to do them by hand. But doing \ problems by hand has it's difficulties. Should you copy the whole expression \ over with each change? Should you attempt to make several changes at once? \ Should you erase part of an expression and replace it with the simpler form? \ How can you keep from making mistakes? Did you substitute the correct number \ for the variable? If the answer doesn't check, how do you recover? Should you \ start over from scratch? If you did get the correct answer, are you confident \ that you got it by a correct method? Maybe you were just lucky. Can you say: \ \"Yes! I understand it.\"?\ \>", "Text"], Cell[TextData[{ "Doing a problem using ", StyleBox["Mathematica", FontSlant->"Italic"], " can solve most of these problems. ", StyleBox["Mathematica", FontSlant->"Italic"], " won't make clerical errors. ", StyleBox["Mathematica", FontSlant->"Italic"], " will lay out everything neatly. ", StyleBox["Mathematica", FontSlant->"Italic"], " will clearly show everything that you did. If you make a mistake you can \ usually see where the mistake was and correct it without having to copy \ everything over or start from scratch." }], "Text"], Cell[TextData[{ "However, there are two difficulties with doing problems with ", StyleBox["Mathematica", FontSlant->"Italic"], ". The first problem is that ", StyleBox["Mathematica", FontSlant->"Italic"], " generally evaluates everything it can, as far as it can. It uses all its \ built-in rules, plus any definitions we may have given it. When learning \ elementary mathematics, this is a problem because it skips right through the \ steps you want to do and see. This can be a problem even when you get to \ advanced mathematics such as calculus. The second problem is: how do you tell \ ", StyleBox["Mathematica", FontSlant->"Italic"], " which part of an expression you want to change? When you do a problem by \ hand, you can see and point to the part you want to change. But with ", StyleBox["Mathematica", FontSlant->"Italic"], " you have to tell it specifically which part of an expression you want to \ change." }], "Text"], Cell[TextData[{ "Fortunately, ", StyleBox["Mathematica", FontSlant->"Italic"], " is a very powerful system and it is usually possible to write routines to \ make it do what you want. The ExpressionManipulation package provides \ routines that make it easy to do elementary problems with ", StyleBox["Mathematica", FontSlant->"Italic"], " one step at a time. The following sections will show you how to use these \ routines." }], "Text"], Cell[TextData[{ "This notebook assumes that you know how to type expressions into ", StyleBox["Mathematica", FontSlant->"Italic"], ", and such basic things as the difference between parentheses ", Cell[BoxData[ \(\(()\)\)]], ", square brackets ", Cell[BoxData[ \(Sqrt[x]\)]], ", and curly brackets ", Cell[BoxData[ \({1, 2, 3}\)]], " and between ", Cell[BoxData[ \( = \)]], ", which sets a variable to a value, and ", Cell[BoxData[ \( == \)]], ", which tests if two things are equal. You should also know how to look \ routines up in Help, and how to obtain more information about private package \ routines by using ", Cell[BoxData[ \(\(?routinename\)\)]], ". Two high school tutorial notebooks at David's web site give some \ introduction to using some of the functional procedures of ", StyleBox["Mathematica", FontSlant->"Italic"], " which are occasionally used in this notebook." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["2 Substituting Values into Expressions", "Section"], Cell[TextData[{ "Evaluate the following expression when ", Cell[BoxData[ \(y \[Equal] 5\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(y\^2 + 4 y\)], "Input", CellLabel->"In[2]:="], Cell[BoxData[ \(4\ y + y\^2\)], "Output", CellLabel->"Out[2]="] }, Open ]], Cell[TextData[{ "The best way to do this is to use a replacement rule that says that y \ should be replaced by 5. The ", Cell[BoxData[ \( /. \)]], ", called ReplaceAll, is the way to tell ", StyleBox["Mathematica", FontSlant->"Italic"], " that you want to make a replacement, and ", Cell[BoxData[ \(y \[Rule] 5\)]], " is a replacement rule that tells ", StyleBox["Mathematica", FontSlant->"Italic"], " that you want to replace every occurrence of ", Cell[BoxData[ \(y\)]], " by ", Cell[BoxData[ \(5\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(y\^2 + 4 y /. y \[Rule] 5\)], "Input", CellLabel->"In[3]:="], Cell[BoxData[ \(45\)], "Output", CellLabel->"Out[3]="] }, Open ]], Cell[TextData[{ "Once ", StyleBox["Mathematica", FontSlant->"Italic"], " put in a 5 everyplace there was a y in the expression, it went on to \ complete the calculation. Perhaps we would like to do the calculation step by \ step, so we can see better what happened. You will see how to do that in the \ following sections. Right now we will see how to prevent calculation and make \ substitutions." }], "Text"], Cell["\<\ To prevent an expression from being evaluated, we can put it in a Hold \ statement. We can still make a substitution, but no more evaluation will take \ place.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Hold[y\^2 + 4 y] /. y \[Rule] 5\)], "Input", CellLabel->"In[4]:="], Cell[BoxData[ \(Hold[5\^2 + 4\ 5]\)], "Output", CellLabel->"Out[4]="] }, Open ]], Cell[TextData[{ "Now, we can see quite clearly where the 5 was placed in the expression. \ But the Hold prevented ", StyleBox["Mathematica", FontSlant->"Italic"], " from going on and completing the calculation. A nicer form of Hold is \ HoldForm which does the same thing, but remains invisible." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[y\^2 + 4 y] /. y \[Rule] 5\)], "Input", CellLabel->"In[5]:="], Cell[BoxData[ TagBox[\(5\^2 + 4\ 5\), HoldForm]], "Output", CellLabel->"Out[5]="] }, Open ]], Cell[TextData[{ "Suppose we want to make substitutions for several variables. Calculate ", Cell[BoxData[ \(a - 2 d\)]], " when ", Cell[BoxData[ \(a \[Equal] 8\)]], " and ", Cell[BoxData[ \(d \[Equal] 3\)]], ". We can do it by giving a list of replacement rules. The curly brackets \ are used for lists." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[a - 2 d] /. {a \[Rule] 8, d \[Rule] 3}\)], "Input", CellLabel->"In[6]:="], Cell[BoxData[ TagBox[\(8 - 2\ 3\), HoldForm]], "Output", CellLabel->"Out[6]="] }, Open ]], Cell["Sometimes we might be tempted to write...", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \({a, d} \[Rule] {8, 3}\)], "Input", CellLabel->"In[7]:="], Cell[BoxData[ \({a, d} \[Rule] {8, 3}\)], "Output", CellLabel->"Out[7]="] }, Open ]], Cell[TextData[{ "But this won't work. What we would like to do is \"thread\" the rule, \ i.e., the ", Cell[BoxData[ \( \[Rule] \)]], ", over the corresponding elements in each list to obtain the form that we \ actually used above. ", StyleBox["Mathematica", FontSlant->"Italic"], " has a command to do this, naturally enough called Thread." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Thread[{a, d} \[Rule] {8, 3}]\)], "Input", CellLabel->"In[8]:="], Cell[BoxData[ \({a \[Rule] 8, d \[Rule] 3}\)], "Output", CellLabel->"Out[8]="] }, Open ]], Cell["\<\ (If you see a command you are not familiar with, be sure to look it up in \ Help.) So, we could have written...\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[a - 2 d] /. Thread[{a, d} \[Rule] {8, 3}]\)], "Input", CellLabel->"In[9]:="], Cell[BoxData[ TagBox[\(8 - 2\ 3\), HoldForm]], "Output", CellLabel->"Out[9]="] }, Open ]], Cell["\<\ Is we are going to make substitutions in a number of expressions, it may be \ convenient to save the set of replacement rules so we can use them \ repeatedly.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(subrules = Thread[{a, d, y} \[Rule] {8, 3, 5}]\)], "Input", CellLabel->"In[10]:="], Cell[BoxData[ \({a \[Rule] 8, d \[Rule] 3, y \[Rule] 5}\)], "Output", CellLabel->"Out[10]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[y\^2 + 4 y] /. subrules\)], "Input", CellLabel->"In[11]:="], Cell[BoxData[ TagBox[\(5\^2 + 4\ 5\), HoldForm]], "Output", CellLabel->"Out[11]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[a - 2 d] /. subrules\)], "Input", CellLabel->"In[12]:="], Cell[BoxData[ TagBox[\(8 - 2\ 3\), HoldForm]], "Output", CellLabel->"Out[12]="] }, Open ]], Cell["\<\ It doesn't matter if the list of substitution rules has rules that are not \ used.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["3 Multiple Line Statements", "Section"], Cell[TextData[{ "It is often convenient to do a calculation all in one cell. You can write \ one statement on each line, using the return key, and build up a calculation \ step by step. Remember that ", Cell[BoxData[ \(%\)]], " is the ", StyleBox["Mathematica", FontSlant->"Italic"], " symbol for the output from the previous statement that was evaluated. \ Using % can sometimes get you into trouble because it refers to the previous \ (in time or Out number) output and not necessarily the output of the \ statement directly above. However, within a single cell it will always be the \ output of the statement directly above. Here is an example." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[a - 2 d]\), "\[IndentingNewLine]", \(% /. a \[Rule] 8\), "\[IndentingNewLine]", \(% /. d \[Rule] 3\), "\[IndentingNewLine]", \(% // ReleaseHold\)}], "Input", CellLabel->"In[13]:="], Cell[BoxData[ TagBox[\(a - 2\ d\), HoldForm]], "Output", CellLabel->"Out[13]="], Cell[BoxData[ TagBox[\(8 - 2\ d\), HoldForm]], "Output", CellLabel->"Out[14]="], Cell[BoxData[ TagBox[\(8 - 2\ 3\), HoldForm]], "Output", CellLabel->"Out[15]="], Cell[BoxData[ \(2\)], "Output", CellLabel->"Out[16]="] }, Open ]], Cell[TextData[{ "This is just a short example of a calculation. Perhaps you can begin to \ see the advantages of working problems with ", StyleBox["Mathematica", FontSlant->"Italic"], ". All of our steps and instructions are neatly contained in the Input \ cell. The results of the steps are neatly displayed in the series of output \ cells. You can clearly see what you did and what happened. If you made a \ mistake, maybe a should have been 9, you can easily correct it and \ reevaluate. Unless you got way off the track, you usually won't have to \ retype everything. Furthermore, you can build up the calculation step by \ step. Do the first steps and make certain they are correct. Then add the next \ step (in the same original cell) and reevaluate. You can reevaluate as many \ times as you want. ", StyleBox["Mathematica", FontSlant->"Italic"], " doesn't mind repeating the original steps. That is the convenient and \ easy way to build up a calculation and solve a problem." }], "Text"], Cell[TextData[{ "In the above calculation we used the command ReleaseHold in the last step. \ It does just what it says, and then ", StyleBox["Mathematica", FontSlant->"Italic"], " finished the calculation. In the next section we will see how to continue \ with a controlled evaluation." }], "Text"], Cell["\<\ Sometimes we want to calculate something and then put it in a HoldForm. If \ you try to do this directly, you may have difficulty. Suppose we have \ calculated the first line, and then want to put it in an unevaluated \ integral. It doesn't work, because Hold means Hold.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(1 + y\^2\), "\[IndentingNewLine]", \(HoldForm[Integrate[%, y]]\)}], "Input", CellLabel->"In[17]:="], Cell[BoxData[ \(1 + y\^2\)], "Output", CellLabel->"Out[17]="], Cell[BoxData[ TagBox[\(\[Integral]% \[DifferentialD]y\), HoldForm]], "Output", CellLabel->"Out[18]="] }, Open ]], Cell["One way to do this is with a substitution.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(1 + y\^2\), "\[IndentingNewLine]", \(HoldForm[Integrate[a, y]] /. a \[Rule] %\)}], "Input", CellLabel->"In[19]:="], Cell[BoxData[ \(1 + y\^2\)], "Output", CellLabel->"Out[19]="], Cell[BoxData[ TagBox[\(\[Integral]\((1 + y\^2)\) \[DifferentialD]y\), HoldForm]], "Output", CellLabel->"Out[20]="] }, Open ]], Cell[TextData[{ "A more versatile way is to Apply a HoldForm pure function to a list of \ arguments. (You will probably have to look up pure functions and Apply, which \ is represented by ", Cell[BoxData[ \( @@ \)]], ")" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(1 + y\^2\), "\[IndentingNewLine]", \(\(HoldForm[Integrate[#1, #2]] &\) @@ {%, y}\)}], "Input", CellLabel->"In[21]:="], Cell[BoxData[ \(1 + y\^2\)], "Output", CellLabel->"Out[21]="], Cell[BoxData[ TagBox[\(\[Integral]\((1 + y\^2)\) \[DifferentialD]y\), HoldForm]], "Output", CellLabel->"Out[22]="] }, Open ]], Cell["\<\ Here, we use the same technique to generated an unevaluated sum of numbers.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(HoldForm[Plus[##]] &\) @@ Range[5]\)], "Input", CellLabel->"In[23]:="], Cell[BoxData[ TagBox[\(1 + 2 + 3 + 4 + 5\), HoldForm]], "Output", CellLabel->"Out[23]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["4 Controlled Evaluation", "Section"], Cell[TextData[{ "Evaluate ", Cell[BoxData[ \(2 a + 5 d + 3 x\)]], " at ", Cell[BoxData[ \({a, d, x} \[Rule] {8, 3, 4}\)]] }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2 a + 5 d + 3 x]\), "\[IndentingNewLine]", \(% /. Thread[{a, d, x} \[Rule] {8, 3, 4}]\)}], "Input", CellLabel->"In[24]:="], Cell[BoxData[ TagBox[\(2\ a + 5\ d + 3\ x\), HoldForm]], "Output", CellLabel->"Out[24]="], Cell[BoxData[ TagBox[\(2\ 8 + 5\ 3 + 3\ 4\), HoldForm]], "Output", CellLabel->"Out[25]="] }, Open ]], Cell[TextData[{ "Now we would like to perform each of the multiplications. If we use a \ ReleaseHold, ", StyleBox["Mathematica", FontSlant->"Italic"], " will completely evaluate to a single number. How do we do a partial \ evaluation, so that we can see each step? We do it by using the command \ EvaluateAtPattern, which is one of the ExpressionManipulation routines. " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?EvaluateAtPattern\)\)], "Input", CellLabel->"In[26]:="], Cell[BoxData[ \("EvaluateAtPattern[pattern, levelspec:\[Infinity], \ functionname:Identity][expr] will evaluate held expressions at the positions \ within the level specification which match the pattern. A pure function given \ by functionname may be applied to the results of the evaluations."\)], "Print",\ CellTags->"Info3195323465-9333467"] }, Open ]], Cell[TextData[{ "Here, the preceding input cell has been copied down, but normally you \ would just continue with the initial cell above. We tell ", StyleBox["Mathematica", FontSlant->"Italic"], " to evaluate the subexpression ", Cell[BoxData[ \(2\ 8\)]], " which becomes 16. Notice that there is a space between the 2 and the 8 \ which indicates multiplication." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2 a + 5 d + 3 x]\), "\[IndentingNewLine]", \(% /. Thread[{a, d, x} \[Rule] {8, 3, 4}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[2\ 8]\)}], "Input", CellLabel->"In[27]:="], Cell[BoxData[ TagBox[\(2\ a + 5\ d + 3\ x\), HoldForm]], "Output", CellLabel->"Out[27]="], Cell[BoxData[ TagBox[\(2\ 8 + 5\ 3 + 3\ 4\), HoldForm]], "Output", CellLabel->"Out[28]="], Cell[BoxData[ TagBox[\(16 + 5\ 3 + 3\ 4\), HoldForm]], "Output", CellLabel->"Out[29]="] }, Open ]], Cell[TextData[{ "We can also use the vertical bar to give a series of patterns to evaluate. \ This tells ", StyleBox["Mathematica", FontSlant->"Italic"], " to evaluate any subexpression that matches one of the patterns. The \ result is that all of the multiplications are performed." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2 a + 5 d + 3 x]\), "\[IndentingNewLine]", \(% /. Thread[{a, d, x} \[Rule] {8, 3, 4}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[2\ 8 | 5\ 3 | 3\ 4]\)}], "Input", CellLabel->"In[30]:="], Cell[BoxData[ TagBox[\(2\ a + 5\ d + 3\ x\), HoldForm]], "Output", CellLabel->"Out[30]="], Cell[BoxData[ TagBox[\(2\ 8 + 5\ 3 + 3\ 4\), HoldForm]], "Output", CellLabel->"Out[31]="], Cell[BoxData[ TagBox[\(16 + 15 + 12\), HoldForm]], "Output", CellLabel->"Out[32]="] }, Open ]], Cell[TextData[{ "There is another way to do this. Do you understand how patterns work? You \ may have to look at Section 2.3.1 in the Book. Remember that ", Cell[BoxData[ \(2\ 8\)]], " is actually stored by ", StyleBox["Mathematica", FontSlant->"Italic"], " as ", Cell[BoxData[ \(Times[2, 8]\)]], ", a subexpression whose Head is Times. Any such expression can be \ represented by the pattern ", Cell[BoxData[ \(_Times\)]], ". If we use that as the pattern, all multiplications will be evaluated. \ This saves us the effort of copying or typing each of the specific \ subexpressions we want to evaluate. After the multiplications are performed, \ we are left with a sum. Sums in ", StyleBox["Mathematica", FontSlant->"Italic"], " are represented by expressions of the form ", Cell[BoxData[ \(Plus[16, 15, 12]\)]], ". So we can use the same method on the next line to evaluate the sum." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2 a + 5 d + 3 x]\), "\[IndentingNewLine]", \(% /. Thread[{a, d, x} \[Rule] {8, 3, 4}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Times]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\)}], "Input", CellLabel->"In[33]:="], Cell[BoxData[ TagBox[\(2\ a + 5\ d + 3\ x\), HoldForm]], "Output", CellLabel->"Out[33]="], Cell[BoxData[ TagBox[\(2\ 8 + 5\ 3 + 3\ 4\), HoldForm]], "Output", CellLabel->"Out[34]="], Cell[BoxData[ TagBox[\(16 + 15 + 12\), HoldForm]], "Output", CellLabel->"Out[35]="], Cell[BoxData[ TagBox["43", HoldForm]], "Output", CellLabel->"Out[36]="] }, Open ]], Cell[TextData[{ "We could also have used a ReleaseHold as the last step, since there was \ only one operation left to do. There are often many ways to solve a problem \ with ", StyleBox["Mathematica", FontSlant->"Italic"], " and it is often difficult to say that one is better than another." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["5 Visualizing Parts of Expressions", "Section"], Cell["\<\ I mentioned in the Introduction that one of the problems with manipulating \ algebraic expressions with a computer is that we can't just point to a part \ of the expression and say: \"Change that!\". In Section 4, I showed how we \ can use patterns to indicate the part of an expression we wanted to evaluate. \ Sometimes we may not want to evaluate all multiplications but only certain \ ones. A specific pattern may occur in several places in an expression and we \ may want to evaluate only one of them. To obtain a more precise control we \ need to understand how to address specific parts of an expression.\ \>", "Text"], Cell["Here is a simple algebraic expression.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = a + b\ x\)], "Input", CellLabel->"In[2]:="], Cell[BoxData[ \(a + b\ x\)], "Output", CellLabel->"Out[2]="] }, Open ]], Cell[TextData[{ "We can see how ", StyleBox["Mathematica", FontSlant->"Italic"], " represents this expression internally by using FullForm." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FullForm[expr]\)], "Input", CellLabel->"In[3]:="], Cell[BoxData[ TagBox[ StyleBox[\(Plus[a, Times[b, x]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]], "Output", CellLabel->"Out[3]//FullForm="] }, Open ]], Cell[TextData[{ "Each part, and each subpart of an expression has an \"address\" or \ position which uniquely specifies it. We can find that position by using the \ Position command. Suppose we want to find the position of ", Cell[BoxData[ \(x\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(pos = Position[expr, x]\)], "Input", CellLabel->"In[4]:="], Cell[BoxData[ \({{2, 2}}\)], "Output", CellLabel->"Out[4]="] }, Open ]], Cell[TextData[{ "There may be more than one x in an expression and the position of each one \ is given by a list. So generally we will obtain a list of lists, with each \ inner list a position or address of an x. In this case there is only one \ position. The position is ", Cell[BoxData[ \({2, 2}\)]], ". The first 2 points to ", Cell[BoxData[ \(Times[b, x]\)]], " which is the second part of the Plus (the first part is ", Cell[BoxData[ \(a\)]], "). ", Cell[BoxData[ \(x\)]], " is the second part of ", Cell[BoxData[ \(Times[b, x]\)]], ". So the position is ", Cell[BoxData[ \({2, 2}\)]], ", the second part of the second part." }], "Text"], Cell[TextData[{ "The routine ", Cell[BoxData[ \(ColorPositions\)]], " aids in visualizing positions. It is used this way:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?ColorPositions\)\)], "Input", CellLabel->"In[5]:="], Cell[BoxData[ \("ColorPositions[positions][expr] will color the expression at the \ specified positions. positions may be a single position, a list of positions, \ or a list of lists of positions. The positions within a single list of \ positions will have various colors. If positions consist of multiple lists, \ then positions within each group will have the same color but the different \ groups will have various colors. The option EMPositionTag determines how the \ positions will be tagged. Extended positions may be used. The option \ EMPositionFontSize can be used to control the font size in the position \ tags."\)], "Print", CellTags->"Info3196846179-1302708"] }, Open ]], Cell[TextData[{ "Extended positions will be explained in Section 7, here I only illustrate \ regular positions. ", Cell[BoxData[ \(pos\)]], " gives the position of the x which we calculated above." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // ColorPositions[pos]\)], "Input", CellLabel->"In[6]:="], Cell[BoxData[ TagBox[ RowBox[{"a", "+", RowBox[{"b", " ", RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 2}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["x", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 10]]], " ", HoldForm[ x]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)], ")"}]}]}], HoldForm]], "Output", CellLabel->"Out[6]="] }, Open ]], Cell[TextData[{ "The simple subexpression ", Cell[BoxData[ \(x\)]], " is colored and tagged with it position in the entire expression. We could \ copy the position right from the output statement into a Part expression. \ Note that the parentheses are not used." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr\[LeftDoubleBracket]2, 2\[RightDoubleBracket]\)], "Input", CellLabel->"In[7]:="], Cell[BoxData[ \(x\)], "Output", CellLabel->"Out[7]="] }, Open ]], Cell[TextData[{ "If we don't want to see the actual position, the index in the list of \ positions we used, we can use the option ", Cell[BoxData[ \(EMPositionTag\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // ColorPositions[pos, EMPositionTag \[Rule] EMIndex]\)], "Input", CellLabel->"In[8]:="], Cell[BoxData[ TagBox[ RowBox[{"a", "+", RowBox[{"b", " ", RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox["1"], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["x", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ 1]], " ", HoldForm[ x]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)], ")"}]}]}], HoldForm]], "Output", CellLabel->"Out[8]="] }, Open ]], Cell["\<\ The 1 with a box around it indicates that this was the first position on the \ list of positions. In this case there was only one. On the other hand, if all \ we want to do is color the position with no tag, we can use the following.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // ColorPositions[pos, EMPositionTag \[Rule] None]\)], "Input", CellLabel->"In[9]:="], Cell[BoxData[ TagBox[ RowBox[{"a", "+", RowBox[{"b", " ", TagBox[ TagBox[ StyleBox[ FrameBox[ TagBox["x", HoldForm]], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)], DisplayForm]}]}], HoldForm]], "Output", CellLabel->"Out[9]="] }, Open ]], Cell["\<\ Suppose we want to find and display the positions of a, b and x. We can do it \ this way. Here, I use another option to increase the size of the position \ font, which may sometimes be desirable.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(pos = Position[expr, a | b | x]\), "\[IndentingNewLine]", \(expr // ColorPositions[pos, EMPositionFontSize \[Rule] 12]\)}], "Input",\ CellLabel->"In[13]:="], Cell[BoxData[ \(a + b\ x\)], "Output", CellLabel->"Out[13]="], Cell[BoxData[ \({{1}, {2, 1}, {2, 2}}\)], "Output", CellLabel->"Out[14]="], Cell[BoxData[ TagBox[ RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1}\), FontSize->12], (StyleForm[ #, FontSize -> 12]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["a", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1}, FontSize -> 12]]], " ", HoldForm[ a]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], "+", RowBox[{ RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 1}\), FontSize->12], (StyleForm[ #, FontSize -> 12]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["b", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 12]]], " ", HoldForm[ b]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.607996]], ( StyleForm[ #, Background -> Hue[ .34999999999999998, .40000000000000002, \ .94999999999999996]]&)], ")"}], " ", RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 2}\), FontSize->12], (StyleForm[ #, FontSize -> 12]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["x", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 12]]], " ", HoldForm[ x]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)], ")"}]}]}], HoldForm]], "Output", CellLabel->"Out[15]="] }, Open ]], Cell["\<\ If we want the positions all in the same color, we can inclose them in an \ extra pair of brackets.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // ColorPositions[{pos}, EMPositionFontSize \[Rule] 12]\)], "Input",\ CellLabel->"In[16]:="], Cell[BoxData[ TagBox[ RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1}\), FontSize->12], (StyleForm[ #, FontSize -> 12]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["a", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1}, FontSize -> 12]]], " ", HoldForm[ a]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)], "+", RowBox[{ RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 1}\), FontSize->12], (StyleForm[ #, FontSize -> 12]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["b", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 12]]], " ", HoldForm[ b]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)], ")"}], " ", RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 2}\), FontSize->12], (StyleForm[ #, FontSize -> 12]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["x", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 12]]], " ", HoldForm[ x]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)], ")"}]}]}], HoldForm]], "Output", CellLabel->"Out[16]="] }, Open ]], Cell[TextData[{ "If we want to see absolutely all of the subexpressions and their positions \ in ", Cell[BoxData[ \(expr\)]], " we can do this..." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(pos = Position[expr, _]\), "\[IndentingNewLine]", \(expr // ColorPositions[pos]\)}], "Input", CellLabel->"In[17]:="], Cell[BoxData[ \(a + b\ x\)], "Output", CellLabel->"Out[17]="], Cell[BoxData[ \({{0}, {1}, {2, 0}, {2, 1}, {2, 2}, {2}, {}}\)], "Output", CellLabel->"Out[18]="], Cell[BoxData[ TagBox[ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[ RowBox[{ RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({0}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["Plus", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {0}, FontSize -> 10]]], " ", HoldForm[ Plus]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], ")"}], "[", RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["a", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1}, FontSize -> 10]]], " ", HoldForm[ a]], Editable->False], Background->RGBColor[0.949996, 0.835996, 0.570001]], ( StyleForm[ #, Background -> Hue[ .11666666666666665, .40000000000000002, \ .94999999999999996]]&)], ",", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[ RowBox[{ RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 0}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["Times", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 0}, FontSize -> 10]]], " ", HoldForm[ Times]], Editable->False], Background->RGBColor[0.798001, 0.949996, 0.570001]], ( StyleForm[ #, Background -> Hue[ .23333333333333331, \ .40000000000000002, .94999999999999996]]&)], ")"}], "[", RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["b", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 10]]], " ", HoldForm[ b]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.607996]], ( StyleForm[ #, Background -> Hue[ .34999999999999998, \ .40000000000000002, .94999999999999996]]&)], ",", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 2}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["x", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 10]]], " ", HoldForm[ x]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.874006]], ( StyleForm[ #, Background -> Hue[ .46666666666666662, \ .40000000000000002, .94999999999999996]]&)]}], "]"}], HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2}, FontSize -> 10]]], " ", HoldForm[ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 0}, FontSize -> 10]]], " ", HoldForm[ Times]], Background -> Hue[ .23333333333333331, .40000000000000002, \ .94999999999999996]][ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 10]]], " ", HoldForm[ b]], Background -> Hue[ .34999999999999998, \ .40000000000000002, .94999999999999996]], StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 10]]], " ", HoldForm[ x]], Background -> Hue[ .46666666666666662, \ .40000000000000002, .94999999999999996]]]]], Editable->False], Background->RGBColor[0.570001, 0.760006, 0.949996]], ( StyleForm[ #, Background -> Hue[ .58333333333333326, .40000000000000002, \ .94999999999999996]]&)]}], "]"}], HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {}, FontSize -> 10]]], " ", HoldForm[ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {0}, FontSize -> 10]]], " ", HoldForm[ Plus]], Background -> Hue[ 0, .40000000000000002, .94999999999999996]][ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1}, FontSize -> 10]]], " ", HoldForm[ a]], Background -> Hue[ .11666666666666665, .40000000000000002, \ .94999999999999996]], StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2}, FontSize -> 10]]], " ", HoldForm[ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 0}, FontSize -> 10]]], " ", HoldForm[ Times]], Background -> Hue[ .23333333333333331, .40000000000000002, \ .94999999999999996]][ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 10]]], " ", HoldForm[ b]], Background -> Hue[ .34999999999999998, .40000000000000002, \ .94999999999999996]], StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 10]]], " ", HoldForm[ x]], Background -> Hue[ .46666666666666662, .40000000000000002, \ .94999999999999996]]]]], Background -> Hue[ .58333333333333326, .40000000000000002, \ .94999999999999996]]]]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], (StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)], HoldForm]], "Output", CellLabel->"Out[19]="] }, Open ]], Cell[TextData[{ "The pattern, ", Cell[BoxData[ \(_\)]], ", represents any expression. ", Cell[BoxData[ \({}\)]], " is the position for the entire expression. Positions that end with 0 are \ heads of expressions. Position looked at all levels 0 to \[Infinity], and \ also looked at the heads of expressions. We can tell Positions to start at \ level 1 and omit heads by writing..." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(pos = Position[expr, _, {1, \[Infinity]}, Heads \[Rule] False]\), "\[IndentingNewLine]", \(expr // ColorPositions[pos, PositionIndex \[Rule] False]\)}], "Input", CellLabel->"In[20]:="], Cell[BoxData[ \(a + b\ x\)], "Output", CellLabel->"Out[20]="], Cell[BoxData[ \({{1}, {2, 1}, {2, 2}, {2}}\)], "Output", CellLabel->"Out[21]="], Cell[BoxData[ TagBox[ RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["a", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1}, FontSize -> 10]]], " ", HoldForm[ a]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[ RowBox[{ RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["b", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 10]]], " ", HoldForm[ b]], Editable->False], Background->RGBColor[0.798001, 0.949996, 0.570001]], ( StyleForm[ #, Background -> Hue[ .23333333333333331, .40000000000000002, \ .94999999999999996]]&)], ")"}], " ", RowBox[{"(", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 2}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["x", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 10]]], " ", HoldForm[ x]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.874006]], ( StyleForm[ #, Background -> Hue[ .46666666666666662, .40000000000000002, \ .94999999999999996]]&)], ")"}]}], HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2}, FontSize -> 10]]], " ", HoldForm[ Times[ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 10]]], " ", HoldForm[ b]], Background -> Hue[ .23333333333333331, .40000000000000002, \ .94999999999999996]], StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 2}, FontSize -> 10]]], " ", HoldForm[ x]], Background -> Hue[ .46666666666666662, .40000000000000002, \ .94999999999999996]]]]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)]}], HoldForm]], "Output", CellLabel->"Out[22]="] }, Open ]], Cell[TextData[{ "Notice that some positions can be inside other positions. So ", Cell[BoxData[ \({2, 1}\)]], " and ", Cell[BoxData[ \({2, 2}\)]], " are inside position ", Cell[BoxData[ \({2}\)]], " above. Also notice that when we obtained the heads of expressions, ", StyleBox["Mathematica", FontSlant->"Italic"], " gave us the FullForm of the expression, but without Heads we obtain the \ more usual form." }], "Text"], Cell["\<\ If you need to find a position in some expression, you may wish to copy the \ expression to a scratch notebook on the side and use Position and \ ColorPositions to find the addresses you want.\ \>", "Text"], Cell["\<\ Also, see Section 11 for an alternative method of finding regular positions \ with the PositionsPalette.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["6 Using HoldPattern and Pattern Problems", "Section"], Cell["\<\ Sometimes it is necessary to stop a pattern from being evaluated. Let's \ continue with the previous example.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = a + b\ x\)], "Input", CellLabel->"In[53]:="], Cell[BoxData[ \(a + b\ x\)], "Output", CellLabel->"Out[53]="] }, Open ]], Cell[TextData[{ "We might be tempted to find the position of ", Cell[BoxData[ \(b\ x\)]], " by the following statement." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(pos = Position[expr, Times[_, _]]\), "\[IndentingNewLine]", \(expr // ColorPositions[pos]\)}], "Input", CellLabel->"In[54]:="], Cell[BoxData[ \({}\)], "Output", CellLabel->"Out[54]="], Cell[BoxData[ TagBox[\(a + b\ x\), HoldForm]], "Output", CellLabel->"Out[55]="] }, Open ]], Cell[TextData[{ "Why didn't Position find ", Cell[BoxData[ \(Times[b, x]\)]], "? If we look at the pattern we are trying to find, we will see why." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Times[_, _]\)], "Input", CellLabel->"In[56]:="], Cell[BoxData[ \(_\^2\)], "Output", CellLabel->"Out[56]="] }, Open ]], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " evaluated the pattern to give us a different pattern which does not occur \ in our expression. There are several ways we can obtain what we want. The \ first way is to wrap our search pattern in a HoldPattern. This prevents it \ from being evaluated, but it still works for pattern matching." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldPattern[Times[_, _]]\)], "Input", CellLabel->"In[57]:="], Cell[BoxData[ \(HoldPattern[_\ _]\)], "Output", CellLabel->"Out[57]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(pos = Position[expr, HoldPattern[Times[_, _]]]\), "\[IndentingNewLine]", \(expr // ColorPositions[pos]\)}], "Input", CellLabel->"In[58]:="], Cell[BoxData[ \({{2}}\)], "Output", CellLabel->"Out[58]="], Cell[BoxData[ TagBox[ RowBox[{"a", "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox["1"], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(b\ x\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ 1]], " ", HoldForm[ Times[ b, x]]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)]}], HoldForm]], "Output", CellLabel->"Out[59]="] }, Open ]], Cell["\<\ A second method is to indicate that the two slots in the pattern may be \ different.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Times[a_, b_]\)], "Input", CellLabel->"In[60]:="], Cell[BoxData[ \(a_\ b_\)], "Output", CellLabel->"Out[60]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(pos = Position[expr, Times[a_, b_]]\), "\[IndentingNewLine]", \(expr // ColorPositions[pos]\)}], "Input", CellLabel->"In[61]:="], Cell[BoxData[ \({{2}}\)], "Output", CellLabel->"Out[61]="], Cell[BoxData[ TagBox[ RowBox[{"a", "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox["1"], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(b\ x\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ 1]], " ", HoldForm[ Times[ b, x]]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.949996]], ( StyleForm[ #, Background -> Hue[ .5, .40000000000000002, .94999999999999996]]&)]}], HoldForm]], "Output", CellLabel->"Out[62]="] }, Open ]], Cell[TextData[{ "It takes some practice and knowledge to tailor patterns to do just what we \ want. If a pattern does not work for you, even though it seems that it \ should, evaluate the pattern to see if it is what you want, and perhaps put \ it in a HoldPattern. If it still does not work, look at the FullForm of the \ expression you are trying to match. Especially troublesome to beginners are \ expressions with denominator variables or square roots in the denominator. \ These are usually represented in ", StyleBox["Mathematica", FontSlant->"Italic"], " as Power expressions. The following expression does not contain ", Cell[BoxData[ \(\@x\)]], ", despite its deceptive formatting." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(1/\@x\), "\[IndentingNewLine]", \(% // FullForm\)}], "Input", CellLabel->"In[63]:="], Cell[BoxData[ \(1\/\@x\)], "Output", CellLabel->"Out[63]="], Cell[BoxData[ TagBox[ StyleBox[\(Power[x, Rational[\(-1\), 2]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]], "Output", CellLabel->"Out[64]//FullForm="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\@x // FullForm\)], "Input", CellLabel->"In[65]:="], Cell[BoxData[ TagBox[ StyleBox[\(Power[x, Rational[1, 2]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]], "Output", CellLabel->"Out[65]//FullForm="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["7 Extended Positions", "Section"], Cell[CellGroupData[{ Cell["ExtendedPosition", "Subsection"], Cell["\<\ Sometimes we wish to work with parts of an expression which don't actually \ have a position. Here is an example.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = \(1 + a + b + c + d\)\/\(x + a + c\)\)], "Input", CellLabel->"In[23]:="], Cell[BoxData[ \(\(1 + a + b + c + d\)\/\(a + c + x\)\)], "Output", CellLabel->"Out[23]="] }, Open ]], Cell[TextData[{ "Suppose we want to substitute values for ", Cell[BoxData[ \(a + c\)]], " in the numerator of the above expression. We can't do the following \ because it substitutes in the denominator as well." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr /. Thread[{a, c} \[Rule] {3, 4}]\)], "Input", CellLabel->"In[24]:="], Cell[BoxData[ \(\(8 + b + d\)\/\(7 + x\)\)], "Output", CellLabel->"Out[24]="] }, Open ]], Cell[TextData[{ "Nor is there a position for ", Cell[BoxData[ \(a + c\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Position[expr, a + c]\)], "Input", CellLabel->"In[25]:="], Cell[BoxData[ \({}\)], "Output", CellLabel->"Out[25]="] }, Open ]], Cell[TextData[{ " ", Cell[BoxData[ \(a + c\)]], " are just two terms in a larger sum which does have a position. Every \ expression has a head, and there is no head for just ", Cell[BoxData[ \(a + c\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(1 + a + b + c + d // FullForm\)], "Input", CellLabel->"In[26]:="], Cell[BoxData[ TagBox[ StyleBox[\(Plus[1, a, b, c, d]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]], "Output", CellLabel->"Out[26]//FullForm="] }, Open ]], Cell[TextData[{ Cell[BoxData[ \(a + c\)]], " are just the second and fourth parts of a subexpression that does have a \ head. The routine ", Cell[BoxData[ \(ExtendedPosition\)]], " allows us to pick out addresses for such parts." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(posn = ExtendedPosition[expr, a + c]\)], "Input", CellLabel->"In[27]:="], Cell[BoxData[ \({eP[{1}, {2, 4}], eP[{2, 1}, {1, 2}]}\)], "Output", CellLabel->"Out[27]="] }, Open ]], Cell["Extended positions are packaged with a head eP.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?eP\)\)], "Input", CellLabel->"In[28]:="], Cell[BoxData[ \("eP is a wrapper for extended positions. An extended position is a \ subset of level parts in a base position corresponding to a subexpression \ which is Flat and Orderless. eP[base position, list of level parts]. For \ example eP[{1},{2,4}] is an extended position and specifies the position of \n\ a+c in f[1+a+b+c]."\)], "Print", CellTags->"Info3196847581-4883457"] }, Open ]], Cell["\<\ We can look at the two base positions corresponding to our two extended \ positions. \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // ColorPositions[{{1}, {2, 1}}]\)], "Input", CellLabel->"In[29]:="], Cell[BoxData[ TagBox[ FractionBox[ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(1 + a + b + c + d\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1}, FontSize -> 10]]], " ", HoldForm[ Plus[ 1, a, b, c, d]]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({2, 1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(a + c + x\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {2, 1}, FontSize -> 10]]], " ", HoldForm[ Plus[ a, c, x]]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)]], HoldForm]], "Output", CellLabel->"Out[29]="] }, Open ]], Cell[TextData[{ "The numerator ", Cell[BoxData[ \(a + c\)]], " consists of the 2nd and 4th items in the numerator sum. Therefore its \ extended position is ", Cell[BoxData[ \(eP[{1}, {2, 4}]\)]], ". The denominator ", Cell[BoxData[ \(a + c\)]], " consists of the 1st and 2nd items in the denominator sum. Therefore its \ extended position is ", Cell[BoxData[ \(eP[{2, 1}, {1, 2}]\)]], "." }], "Text"], Cell[TextData[{ "ColorPositions can accept extended positions. However, it displays them in \ a special manner. It puts the extended expression in what would have been the \ first slot. For example ", Cell[BoxData[ \(a + c\)]], " went where ", Cell[BoxData[ \(a\)]], " used to be." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // ColorPositions[posn]\)], "Input", CellLabel->"In[30]:="], Cell[BoxData[ TagBox[ FractionBox[ RowBox[{"1", "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{1}, {2, 4}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(a + c\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {1}, {2, 4}], FontSize -> 10]]], " ", HoldForm[ Plus[ a, c]]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], "+", "b", "+", "d"}], RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{2, 1}, {1, 2}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(a + c\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {2, 1}, {1, 2}], FontSize -> 10]]], " ", HoldForm[ Plus[ a, c]]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)], "+", "x"}]], HoldForm]], "Output", CellLabel->"Out[30]="] }, Open ]], Cell[TextData[{ "The routine ", Cell[BoxData[ \(EvaluateAt\)]], " will accept extended positions and the regular ", StyleBox["Mathematica", FontSlant->"Italic"], " routines ", Cell[BoxData[ \(Extract\)]], ", ", Cell[BoxData[ \(MapAt\)]], ", and ", Cell[BoxData[ \(ReplacePart\)]], " are modified by the ExpressionManipulation package to accept extended \ positions. If we just want to make a replacement in the numerator we can use \ ", Cell[BoxData[ \(MapAt\)]], " with an extended position." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(MapAt[# /. Thread[{a, c} \[Rule] {3, 4}] &, expr, eP[{1}, {2, 4}]]\)}], "Input", CellLabel->"In[31]:="], Cell[BoxData[ \(\(1 + a + b + c + d\)\/\(a + c + x\)\)], "Output", CellLabel->"Out[31]="], Cell[BoxData[ \(\(8 + b + d\)\/\(a + c + x\)\)], "Output", CellLabel->"Out[32]="] }, Open ]], Cell["\<\ These routines are illustrated somewhat more fully in Section 9.\ \>", "Text"], Cell[TextData[{ Cell[BoxData[ \(ColorPositions\)]], " will try to display all the positions given to it. But if given \ overlapping positions, which can happen with extended positions, it will \ generally give a confused display." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(ExtendedPosition[expr, \ #] &\) /@ {a + c, a + d, b + c}\), "\[IndentingNewLine]", \(expr // ColorPositions[%]\)}], "Input", CellLabel->"In[34]:="], Cell[BoxData[ \({{eP[{1}, {2, 4}], eP[{2, 1}, {1, 2}]}, {eP[{1}, {2, 5}]}, {eP[{1}, {3, 4}]}}\)], "Output", CellLabel->"Out[34]="], Cell[BoxData[ TagBox[ FractionBox[ RowBox[{"1", "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{1}, {2, 5}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[ RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{1}, {2, 4}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(a + c\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {1}, {2, 4}], FontSize -> 10]]], " ", HoldForm[ Plus[ a, c]]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], "+", "d"}], HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {1}, {2, 5}], FontSize -> 10]]], " ", HoldForm[ Plus[ StyleForm[ SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {1}, {2, 4}], FontSize -> 10]]], " ", HoldForm[ Plus[ a, c]]], Background -> Hue[ 0, .40000000000000002, .94999999999999996]], d]]], Editable->False], Background->RGBColor[0.570001, 0.949996, 0.607996]], ( StyleForm[ #, Background -> Hue[ .34999999999999998, .40000000000000002, \ .94999999999999996]]&)], "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{1}, {3, 4}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(+b\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {1}, {3, 4}], FontSize -> 10]]], " ", HoldForm[ Plus[ b]]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)]}], RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{2, 1}, {1, 2}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(a + c\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {2, 1}, {1, 2}], FontSize -> 10]]], " ", HoldForm[ Plus[ a, c]]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], "+", "x"}]], HoldForm]], "Output", CellLabel->"Out[35]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["ExtendedPattern", "Subsection"], Cell["\<\ ExtendedPosition is best when picking off specific level subparts of an \ expression. ExtendedPattern will find all extended positions for which the \ level subparts match the pattern. \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?ExtendedPattern\)\)], "Input", CellLabel->"In[36]:="], Cell[BoxData[ \("ExtendedPattern[expr, pattern, levelspec:{0,\[Infinity]}, \ n:\[Infinity]] will find all the extended positions for which the subparts \ match the pattern. Only extended positions which contain two or more subparts \ will be returned. The optional arguments can be used to restrict the search \ levels and the number of extended positions returned."\)], "Print", CellTags->"Info3196850217-4712458"] }, Open ]], Cell["\<\ Here is an example which will find weighted sums of Sin and Cos.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(1 + 3 Cos[x] + a\ Sin[x]\)\/\(3 \((a + b\ Sin[x] + 4\ Cos[x])\)\)\), \ "\[IndentingNewLine]", \(ExtendedPattern[%, a_. \((Sin[_] | Cos[_])\)]\), "\[IndentingNewLine]", \(%% // ColorPositions[%]\)}], "Input", CellLabel->"In[37]:="], Cell[BoxData[ \(\(1 + 3\ Cos[x] + a\ Sin[x]\)\/\(3\ \((a + 4\ Cos[x] + b\ \ Sin[x])\)\)\)], "Output", CellLabel->"Out[37]="], Cell[BoxData[ \({eP[{2}, {2, 3}], eP[{3, 1}, {2, 3}]}\)], "Output", CellLabel->"Out[38]="], Cell[BoxData[ TagBox[ FractionBox[ RowBox[{"1", "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{2}, {2, 3}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(3\ Cos[x] + a\ Sin[x]\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {2}, {2, 3}], FontSize -> 10]]], " ", HoldForm[ Plus[ Times[ 3, Cos[ x]], Times[ a, Sin[ x]]]]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)]}], RowBox[{"3", " ", RowBox[{"(", RowBox[{"a", "+", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\(eP[{3, 1}, {2, 3}]\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(4\ Cos[x] + b\ Sin[x]\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ eP[ {3, 1}, {2, 3}], FontSize -> 10]]], " ", HoldForm[ Plus[ Times[ 4, Cos[ x]], Times[ b, Sin[ x]]]]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)]}], ")"}]}]], HoldForm]], "Output", CellLabel->"Out[39]="] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["8 FlattenHold", "Section"], Cell[TextData[{ "When ", StyleBox["Mathematica", FontSlant->"Italic"], " does substitutions into held expressions, it doesn't do any \ simplification, and that includes flattening subexpressions that would \ otherwise be flat. Sometimes this will be acceptable, but often we will want \ to flatten the expression, perhaps to obtain an extended position. Here is an \ example:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr = HoldForm[1 + a\ b\ c]\), "\[IndentingNewLine]", \(% /. b \[Rule] b\ d\ e\), "\[IndentingNewLine]", \(% // FullForm\)}], "Input", CellLabel->"In[80]:="], Cell[BoxData[ TagBox[\(1 + a\ b\ c\), HoldForm]], "Output", CellLabel->"Out[80]="], Cell[BoxData[ TagBox[\(1 + a\ \((b\ d\ e)\)\ c\), HoldForm]], "Output", CellLabel->"Out[81]="], Cell[BoxData[ TagBox[ StyleBox[\(HoldForm[Plus[1, Times[a, Times[b, d, e], c]]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]], "Output", CellLabel->"Out[82]//FullForm="] }, Open ]], Cell["\<\ We could not find an extended position for d c, say, because they are not \ level parts of a single subexpression. We can use FlattenHold to create a \ flat expressions for any head which has the attribute Flat.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?FlattenHold\)\)], "Input", CellLabel->"In[83]:="], Cell[BoxData[ \("FlattenHold[][expr] will Flatten any subexpression whose head has the \ attribute Flat. Flatten[f][expr] will flatten only expressions whose head \ matches the pattern f, regardless of their attributes. This is sometimes \ desirable after a replacement rule has introduced a nonflat expression which \ would normally be flattened in a non-Held expression."\)], "Print", CellTags->"Info3195323592-9236389"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(expr = HoldForm[1 + a\ b\ c]\), "\[IndentingNewLine]", \(% /. b \[Rule] b\ d\ e\), "\[IndentingNewLine]", \(% // FlattenHold[]\), "\[IndentingNewLine]", \(ExtendedPosition[%, \ d\ c]\)}], "Input", CellLabel->"In[84]:="], Cell[BoxData[ TagBox[\(1 + a\ b\ c\), HoldForm]], "Output", CellLabel->"Out[84]="], Cell[BoxData[ TagBox[\(1 + a\ \((b\ d\ e)\)\ c\), HoldForm]], "Output", CellLabel->"Out[85]="], Cell[BoxData[ TagBox[\(1 + a\ b\ d\ e\ c\), HoldForm]], "Output", CellLabel->"Out[86]="], Cell[BoxData[ \({eP[{1, 2}, {5, 3}]}\)], "Output", CellLabel->"Out[87]="] }, Open ]], Cell["\<\ In the following, f is given the attribute Flat, but g has no attributes. As \ a result, only f is flattened.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(ClearAll[f, g]\), "\[IndentingNewLine]", \(\(Attributes[f] = {Flat, Orderless};\)\), "\[IndentingNewLine]", \(expr = HoldForm[1 + f[a1, b1, c1] + g[a2, b2, c2]]\), "\[IndentingNewLine]", \(expr /. {b1 \[Rule] f[b1, d1, e1], b2 \[Rule] g[b2, d2, e2]}\), "\[IndentingNewLine]", \(% // FlattenHold[]\)}], "Input", CellLabel->"In[88]:="], Cell[BoxData[ TagBox[\(1 + f[a1, b1, c1] + g[a2, b2, c2]\), HoldForm]], "Output", CellLabel->"Out[90]="], Cell[BoxData[ TagBox[\(1 + f[a1, f[b1, d1, e1], c1] + g[a2, g[b2, d2, e2], c2]\), HoldForm]], "Output", CellLabel->"Out[91]="], Cell[BoxData[ TagBox[\(1 + f[a1, b1, d1, e1, c1] + g[a2, g[b2, d2, e2], c2]\), HoldForm]], "Output", CellLabel->"Out[92]="] }, Open ]], Cell["\<\ We can also specify that expressions with a specific head will be flattened. \ Here g is flattened, even though it does not have the attribute Flat and f is \ not flattened, even though it does have the attribute Flat.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr = HoldForm[1 + f[a1, b1, c1] + g[a2, b2, c2]]\), "\[IndentingNewLine]", \(expr /. {b1 \[Rule] f[b1, d1, e1], b2 \[Rule] g[b2, d2, e2]}\), "\[IndentingNewLine]", \(% // FlattenHold[g]\)}], "Input", CellLabel->"In[93]:="], Cell[BoxData[ TagBox[\(1 + f[a1, b1, c1] + g[a2, b2, c2]\), HoldForm]], "Output", CellLabel->"Out[93]="], Cell[BoxData[ TagBox[\(1 + f[a1, f[b1, d1, e1], c1] + g[a2, g[b2, d2, e2], c2]\), HoldForm]], "Output", CellLabel->"Out[94]="], Cell[BoxData[ TagBox[\(1 + f[a1, f[b1, d1, e1], c1] + g[a2, b2, d2, e2, c2]\), HoldForm]], "Output", CellLabel->"Out[95]="] }, Open ]], Cell["This flattens both f and g.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr = HoldForm[1 + f[a1, b1, c1] + g[a2, b2, c2]]\), "\[IndentingNewLine]", \(expr /. {b1 \[Rule] f[b1, d1, e1], b2 \[Rule] g[b2, d2, e2]}\), "\[IndentingNewLine]", \(% // FlattenHold[f | g]\), "\[IndentingNewLine]", \(ExtendedPosition[%, f[b1, e1]]\)}], "Input", CellLabel->"In[96]:="], Cell[BoxData[ TagBox[\(1 + f[a1, b1, c1] + g[a2, b2, c2]\), HoldForm]], "Output", CellLabel->"Out[96]="], Cell[BoxData[ TagBox[\(1 + f[a1, f[b1, d1, e1], c1] + g[a2, g[b2, d2, e2], c2]\), HoldForm]], "Output", CellLabel->"Out[97]="], Cell[BoxData[ TagBox[\(1 + f[a1, b1, d1, e1, c1] + g[a2, b2, d2, e2, c2]\), HoldForm]], "Output", CellLabel->"Out[98]="], Cell[BoxData[ \({eP[{1, 2}, {2, 4}]}\)], "Output", CellLabel->"Out[99]="] }, Open ]], Cell["\<\ Remember that we can obtain extended positions only from Flat and Orderless \ subexpressions. Even though we have flattened g, we still could not obtain an \ extended position from it.\ \>", "Text"], Cell[BoxData[ \(ClearAll[f]\)], "Input", CellLabel->"In[100]:="] }, Closed]], Cell[CellGroupData[{ Cell["9 Extract, MapAt, ReplacePart, EvaluateAt", "Section"], Cell["\<\ Along with ColorPositions, these routines will accept extended positions. \ Let's use an example to illustrate their use.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = \(1 + a + b + Sin[x]\^2 + c\ d\)\/\(a + 2 x + x\^2\)\)], "Input",\ CellLabel->"In[40]:="], Cell[BoxData[ \(\(1 + a + b + c\ d + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\)], "Output", CellLabel->"Out[40]="] }, Open ]], Cell[CellGroupData[{ Cell["Extract", "Subsection"], Cell["\<\ You probably won't use Extract often in manipulating an expression. But it is \ used by the other routines which manipulate expressions.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?Extract\)\)], "Input", CellLabel->"In[102]:="], Cell[BoxData[ RowBox[{"\<\"Extract[expr, list] extracts the part of expr at the \ position specified by list. Extract[expr, {list1, list2, ... }] extracts a \ list of parts of expr. Extract[expr, ... , h] extracts parts of expr, \ wrapping each of them with head h before evaluation. The positions in Extract \ can be extended positions such as \\n eP[{1},{2,4}] which is the position of \ a+c in f[1+a+b+c].\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], ButtonData:>"Extract", Active->True, ButtonStyle->"RefGuideLink"]}]], "Print", CellTags->"Info3195323620-8066706"] }, Open ]], Cell["\<\ Below, after substitution, we extract two terms from the numerator. \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm @@ {expr}\), "\[IndentingNewLine]", \(% /. Thread[{c, d} \[Rule] {3, 4}]\), "\[IndentingNewLine]", \(pos = ExtendedPosition[%, HoldPattern[a + 3\ 4]]\), "\[IndentingNewLine]", \(Extract[%%, pos]\)}], "Input", CellLabel->"In[103]:="], Cell[BoxData[ TagBox[\(\(1 + a + b + c\ d + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\), HoldForm]], "Output", CellLabel->"Out[103]="], Cell[BoxData[ TagBox[\(\(1 + a + b + 3\ 4 + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\), HoldForm]], "Output", CellLabel->"Out[104]="], Cell[BoxData[ \({eP[{1, 2}, {2, 4}]}\)], "Output", CellLabel->"Out[105]="], Cell[BoxData[ \({12 + a}\)], "Output", CellLabel->"Out[106]="] }, Open ]], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " extracted ", Cell[BoxData[ \(a + \ 3\ 4\)]], " and evaluated it. If we do not want to evaluate the extracted expression \ we can tell Extract to wrap it in a HoldForm." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm @@ {expr}\), "\[IndentingNewLine]", \(% /. Thread[{c, d} \[Rule] {3, 4}]\), "\[IndentingNewLine]", \(pos = ExtendedPosition[%, HoldPattern[a + 3\ 4]]\), "\[IndentingNewLine]", \(Extract[%%, pos, HoldForm]\)}], "Input", CellLabel->"In[107]:="], Cell[BoxData[ TagBox[\(\(1 + a + b + c\ d + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\), HoldForm]], "Output", CellLabel->"Out[107]="], Cell[BoxData[ TagBox[\(\(1 + a + b + 3\ 4 + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\), HoldForm]], "Output", CellLabel->"Out[108]="], Cell[BoxData[ \({eP[{1, 2}, {2, 4}]}\)], "Output", CellLabel->"Out[109]="], Cell[BoxData[ RowBox[{"{", TagBox[\(a + 3\ 4\), HoldForm], "}"}]], "Output", CellLabel->"Out[110]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["ReplacePart", "Subsection"], Cell["\<\ ReplacePart had been extended so that it will also handle extended positions. \ We could often do this just as well with a simple substitution rule, but \ ReplacePart allows us to target a specific extended position.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?ReplacePart\)\)], "Input", CellLabel->"In[111]:="], Cell[BoxData[ RowBox[{"\<\"ReplacePart[expr, new, n] yields an expression in which the \ nth part of expr is replaced by new. ReplacePart[expr, new, {i, j, ... }] \ replaces the part at position {i, j, ... }. ReplacePart[expr, new, {{i1, j1, \ ... }, {i2, j2, ... }, ... }] replaces parts at several positions by new. \ ReplacePart[expr, new, pos, npos] replaces parts at positions pos in expr by \ parts at positions npos in new. The positions in ReplacePart can be extended \ positions such as \\n eP[{1},{2,4}] which is the position of a+c in \ f[1+a+b+c].\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], ButtonData:>"ReplacePart", Active->True, ButtonStyle->"RefGuideLink"]}]], "Print", CellTags->"Info3195323635-2346324"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(pos = ExtendedPosition[%, a + c\ d]\), "\[IndentingNewLine]", \(ReplacePart[expr, new, pos]\)}], "Input", CellLabel->"In[112]:="], Cell[BoxData[ \(\(1 + a + b + c\ d + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\)], "Output", CellLabel->"Out[112]="], Cell[BoxData[ \({eP[{2}, {2, 4}]}\)], "Output", CellLabel->"Out[113]="], Cell[BoxData[ \(\(1 + b + new + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\)], "Output", CellLabel->"Out[114]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["MapAt", "Subsection"], Cell["\<\ MapAt may be one of the most useful routines for \"surgery on \ expressions.\"\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?MapAt\)\)], "Input", CellLabel->"In[115]:="], Cell[BoxData[ RowBox[{"\<\"MapAt[f, expr, n] applies f to the element at position n in \ expr. If n is negative, the position is counted from the end. MapAt[f, expr, \ {i, j, ... }] applies f to the part of expr at position {i, j, ... }. \ MapAt[f, expr, {{i1, j1, ... }, {i2, j2, ... }, ... }] applies f to parts of \ expr at several positions. The positions in MapAt can be extended positions \ such as \\n eP[{1},{2,4}] which is the position of a+c in f[1+a+b+c].\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], ButtonData:>"MapAt", Active->True, ButtonStyle->"RefGuideLink"]}]], "Print", CellTags->"Info3195323647-8764614"] }, Open ]], Cell["\<\ Here we perform a trigonometric operation on two terms from the numerator, \ and a complete the square operation on two terms in the denominator. (Note \ that %% refers to the second previous output.)\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(pos1 = ExtendedPosition[expr, a + Sin[_]\^2]\), "\[IndentingNewLine]", \(MapAt[TrigFactor, expr, pos1]\), "\[IndentingNewLine]", \(pos2 = ExtendedPosition[%, 2 x + x\^2]\), "\[IndentingNewLine]", \(MapAt[CompleteTheSquare, %%, pos2]\)}], "Input", CellLabel->"In[116]:="], Cell[BoxData[ \(\(1 + a + b + c\ d + Sin[x]\^2\)\/\(a + 2\ x + x\^2\)\)], "Output", CellLabel->"Out[116]="], Cell[BoxData[ \({eP[{2}, {2, 5}]}\)], "Output", CellLabel->"Out[117]="], Cell[BoxData[ \(\(1 + b + c\ d + 1\/2\ \((1 + 2\ a - Cos[2\ x])\)\)\/\(a + 2\ x + \ x\^2\)\)], "Output", CellLabel->"Out[118]="], Cell[BoxData[ \({eP[{1, 1}, {2, 3}]}\)], "Output", CellLabel->"Out[119]="], Cell[BoxData[ \(\(1 + b + c\ d + 1\/2\ \((1 + 2\ a - Cos[2\ x])\)\)\/\(\(-1\) + a + \ \((1 + x)\)\^2\)\)], "Output", CellLabel->"Out[120]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["EvaluateAt ", "Subsection"], Cell["\<\ EvaluateAt allows us to evaluate at a specific location in a held expression.\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?EvaluateAt\)\)], "Input", CellLabel->"In[41]:="], Cell[BoxData[ \("EvaluateAt[pos][expr] forces evaluation of expr at the position \ indicated by pos. EvaluateAt[{pos1, pos2, ...}][expr] forces evaluation at \ several positions. EvaluateAt[pos, f][expr] and EvaluateAt[{pos1, pos2, ...}, \ f][expr] evaluates function f on specified positions."\)], "Print", CellTags->"Info3196850340-4676273"] }, Open ]], Cell[TextData[{ "Here we have an integral, which we let ", StyleBox["Mathematica", FontSlant->"Italic"], " evaluate." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr = HoldForm[\[Integral]\(\(x \((x\^2 + 2 x)\)\)\/\(\((x + 1)\) \((x + 2)\)\)\) \[DifferentialD]x]\), "\[IndentingNewLine]", \(% // ReleaseHold\)}], "Input", CellLabel->"In[42]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\(x\ \((x\^2 + 2\ x)\)\)\/\(\((x + 1)\)\ \((x + 2)\)\)\) \[DifferentialD]x\), HoldForm]], "Output", CellLabel->"Out[42]="], Cell[BoxData[ \(\(-x\) + x\^2\/2 + Log[1 + x]\)], "Output", CellLabel->"Out[43]="] }, Open ]], Cell[TextData[{ "Here we get some idea of how ", StyleBox["Mathematica", FontSlant->"Italic"], " did the integral. We use ", Cell[BoxData[ \(ColorPositions\)]], " to check the position of the integrand in our expression. Then we use ", Cell[BoxData[ \(EvaluateAt\)]], " with Apart to split the integrand into three terms. Then we use a rule \ and ", Cell[BoxData[ \(FlattenHold\)]], " to split the integral into three integrals. Now it is easier to see the \ origin of each term in the ", StyleBox["Mathematica", FontSlant->"Italic"], " answer." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr // ColorPositions[ Position[expr, _, {2}, Heads \[Rule] False]]\), "\[IndentingNewLine]", \(expr // EvaluateAt[{1, 1}, Apart]\), "\[IndentingNewLine]", \(% //. HoldPattern[\[Integral]\((a_ + b_)\) \[DifferentialD]x_] \[RuleDelayed] \[Integral]a \ \[DifferentialD]x + \[Integral]b \[DifferentialD]x\), "\[IndentingNewLine]", \(% // FlattenHold[]\), "\[IndentingNewLine]", \(% // ReleaseHold\)}], "Input", CellLabel->"In[44]:="], Cell[BoxData[ TagBox[ TagBox[ RowBox[{"Integrate", "[", RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1, 1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(\(x\ \((x\^2 + 2\ x)\)\)\/\(\((x + 1)\)\ \((x + 2)\)\)\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1, 1}, FontSize -> 10]]], " ", HoldForm[ Times[ x, Plus[ Power[ x, 2], Times[ 2, x]], Power[ Times[ Plus[ x, 1], Plus[ x, 2]], -1]]]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], ",", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1, 2}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["x", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1, 2}, FontSize -> 10]]], " ", HoldForm[ x]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)]}], "]"}], HoldForm], HoldForm]], "Output", CellLabel->"Out[44]="], Cell[BoxData[ TagBox[\(\[Integral]\((\(-1\) + x + 1\/\(1 + x\))\) \[DifferentialD]x\), HoldForm]], "Output", CellLabel->"Out[45]="], Cell[BoxData[ TagBox[\(\[Integral]\(-1\) \[DifferentialD]x + \((\[Integral]x \ \[DifferentialD]x + \[Integral]\(1\/\(1 + x\)\) \[DifferentialD]x)\)\), HoldForm]], "Output", CellLabel->"Out[46]="], Cell[BoxData[ TagBox[\(\[Integral]\(-1\) \[DifferentialD]x + \[Integral]x \ \[DifferentialD]x + \[Integral]\(1\/\(1 + x\)\) \[DifferentialD]x\), HoldForm]], "Output", CellLabel->"Out[47]="], Cell[BoxData[ \(\(-x\) + x\^2\/2 + Log[1 + x]\)], "Output", CellLabel->"Out[48]="] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["10 Examples", "Section"], Cell["\<\ The examples contain various cases where students might wish to do controlled \ evaluation.\ \>", "Text"], Cell[CellGroupData[{ Cell["List of ExpressionManipulation Routines", "Subsection"], Cell[BoxData[ \(\(?Algebra`ExpressionManipulation`*\)\)], "Input", CellLabel->"In[52]:="] }, Open ]], Cell[CellGroupData[{ Cell["Case 1 - Exponent Notation ", "Subsection"], Cell["\<\ We would like to illustrate exponent notation with the following held \ expression.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = HoldForm[d\ d\ d\ e\ e\ e\ e\ ]\)], "Input", CellLabel->"In[130]:="], Cell[BoxData[ TagBox[\(d\ d\ d\ e\ e\ e\ e\), HoldForm]], "Output", CellLabel->"Out[130]="] }, Open ]], Cell["This is a good place to use ExtendedPattern.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr // EvaluateAt[ExtendedPattern[expr, d]]\), "\[IndentingNewLine]", \(% // EvaluateAt[ExtendedPattern[%, e]]\)}], "Input", CellLabel->"In[131]:="], Cell[BoxData[ TagBox[\(d\^3\ e\ e\ e\ e\), HoldForm]], "Output", CellLabel->"Out[131]="], Cell[BoxData[ TagBox[\(d\^3\ e\^4\), HoldForm]], "Output", CellLabel->"Out[132]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Case 2 - Laws of Signs", "Subsection"], Cell[TextData[{ "As a general rule, the younger the age at which some mathematical topic is \ taught, the more difficult it is to get ", StyleBox["Mathematica", FontSlant->"Italic"], " to do it. The rules for multiplying and adding positive and negative \ numbers is a case in point. Even within held expressions, ", StyleBox["Mathematica", FontSlant->"Italic"], " expression interpretation implements some of the rules we may wish to \ explicitly implement ourselves. Even though this is in a HoldForm, ", StyleBox["Mathematica", FontSlant->"Italic"], " displays the following expression as a difference rather than as a sum." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[2 + \((\(-3\))\) \((\(-4\))\)]\)], "Input", CellLabel->"In[133]:="], Cell[BoxData[ TagBox[\(2 - 3\ \((\(-4\))\)\), HoldForm]], "Output", CellLabel->"Out[133]="] }, Open ]], Cell[TextData[{ "We could try to use MakeBoxes to override the standard ", StyleBox["Mathematica", FontSlant->"Italic"], " formatting of all of these sign expressions, but it would be a major \ chore. Instead I will use a common trick when I don't like the way ", StyleBox["Mathematica", FontSlant->"Italic"], " handles something. Package the \"something\" in a wrapper and handle it \ myself. In this case, we don't like the way negative numbers are displayed, \ so instead of expressing them as ", Cell[BoxData[ \(\(-x\)\)]], ", we can express them as ", Cell[BoxData[ \(n[x]\)]], ". Then we can write a Format rule to display these the way we want." }], "Text"], Cell[BoxData[ \(Format[n[a_]] := DisplayForm[RowBox[{"\<(\>", \(-a\), "\<)\>"}]]\)], "Input", CellLabel->"In[134]:="], Cell[CellGroupData[{ Cell[BoxData[ \(a + \((\(-b\))\)\)], "Input", CellLabel->"In[135]:="], Cell[BoxData[ \(a - b\)], "Output", CellLabel->"Out[135]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(a + n[b]\)], "Input", CellLabel->"In[136]:="], Cell[BoxData[ RowBox[{"a", "+", TagBox[\((\(-b\))\), DisplayForm]}]], "Output", CellLabel->"Out[136]="] }, Open ]], Cell["Now we can illustrate various sign rules.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[3 + n[2]]\), "\[IndentingNewLine]", \(% /. n[a_] \[Rule] \(-a\)\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\)}], "Input", CellLabel->"In[137]:="], Cell[BoxData[ TagBox[ RowBox[{"3", "+", TagBox[\((\(-2\))\), DisplayForm]}], HoldForm]], "Output", CellLabel->"Out[137]="], Cell[BoxData[ TagBox[\(3 - 2\), HoldForm]], "Output", CellLabel->"Out[138]="], Cell[BoxData[ TagBox["1", HoldForm]], "Output", CellLabel->"Out[139]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2 + n[3] n[4]]\), "\[IndentingNewLine]", \(% /. n[a_] n[b_] \[RuleDelayed] a\ b\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Times]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\)}], "Input", CellLabel->"In[140]:="], Cell[BoxData[ TagBox[ RowBox[{"2", "+", RowBox[{ TagBox[\((\(-3\))\), DisplayForm], " ", TagBox[\((\(-4\))\), DisplayForm]}]}], HoldForm]], "Output", CellLabel->"Out[140]="], Cell[BoxData[ TagBox[\(2 + 3\ 4\), HoldForm]], "Output", CellLabel->"Out[141]="], Cell[BoxData[ TagBox[\(2 + 12\), HoldForm]], "Output", CellLabel->"Out[142]="], Cell[BoxData[ TagBox["14", HoldForm]], "Output", CellLabel->"Out[143]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[n[2] n[3] 4 n[5]]\), "\[IndentingNewLine]", \(% // EvaluateAt[ ExtendedPosition[%, n[2] n[3]], # /. n[a_] \[RuleDelayed] \(-a\) &]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Times]\), "\[IndentingNewLine]", \(% /. n[5] \[Rule] \(-5\) // EvaluateAtPattern[_Times]\)}], "Input", CellLabel->"In[144]:="], Cell[BoxData[ TagBox[ RowBox[{ TagBox[\((\(-2\))\), DisplayForm], " ", TagBox[\((\(-3\))\), DisplayForm], " ", "4", " ", TagBox[\((\(-5\))\), DisplayForm]}], HoldForm]], "Output", CellLabel->"Out[144]="], Cell[BoxData[ TagBox[ RowBox[{"6", " ", "4", " ", TagBox[\((\(-5\))\), DisplayForm]}], HoldForm]], "Output", CellLabel->"Out[145]="], Cell[BoxData[ TagBox[ RowBox[{"24", " ", TagBox[\((\(-5\))\), DisplayForm]}], HoldForm]], "Output", CellLabel->"Out[146]="], Cell[BoxData[ TagBox[\(-120\), HoldForm]], "Output", CellLabel->"Out[147]="] }, Open ]], Cell[BoxData[ \(ClearAll[n]\)], "Input", CellLabel->"In[148]:="] }, Closed]], Cell[CellGroupData[{ Cell["Case 3 - Evaluating an Expression", "Subsection"], Cell[TextData[{ "Evaluate the following expression at ", Cell[BoxData[ \(x \[Equal] 3\)]], ", step-by-step. " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = HoldForm[\[PartialD]\_x\((x\^2 + 2 x + 3)\)/\[PartialD]\_x\((3 x\^3 - 2 x\^2 + x)\)]\)], "Input", CellLabel->"In[149]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((x\^2 + 2\ x + 3)\)\/\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)\), HoldForm]], "Output", CellLabel->"Out[149]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(% // EvaluateAt[ Position[expr, HoldPattern[\[PartialD]\_x\ _]]]\), "\[IndentingNewLine]", \(% /. x \[Rule] 3\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[3\^2]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Times]\)}], "Input", CellLabel->"In[150]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((x\^2 + 2\ x + 3)\)\/\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)\), HoldForm]], "Output", CellLabel->"Out[150]="], Cell[BoxData[ TagBox[\(\(2 + 2\ x\)\/\(1 - 4\ x + 9\ x\^2\)\), HoldForm]], "Output", CellLabel->"Out[151]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 9\ 3\^2\)\), HoldForm]], "Output", CellLabel->"Out[152]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 9\ 9\)\), HoldForm]], "Output", CellLabel->"Out[153]="], Cell[BoxData[ TagBox[\(\(2 + 6\)\/\(1 - 12 + 81\)\), HoldForm]], "Output", CellLabel->"Out[154]="], Cell[BoxData[ TagBox[\(8\/70\), HoldForm]], "Output", CellLabel->"Out[155]="], Cell[BoxData[ TagBox[\(4\/35\), HoldForm]], "Output", CellLabel->"Out[156]="] }, Open ]], Cell[TextData[{ "There are, of course, many different paths of evaluation. ", Cell[BoxData[ \(EvaluateAtPattern[_, {\(-2\)}]\)]], "will perform the lowest level operation. Doing a series of these is \ another way to evaluate an expression step-by-step." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(% // EvaluateAt[{1}]\), "\[IndentingNewLine]", \(% /. x \[Rule] 3\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\)}], "Input", CellLabel->"In[157]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((x\^2 + 2\ x + 3)\)\/\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)\), HoldForm]], "Output", CellLabel->"Out[157]="], Cell[BoxData[ TagBox[\(\(2 + 2\ x\)\/\(1 - 4\ x + 9\ x\^2\)\), HoldForm]], "Output", CellLabel->"Out[158]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 9\ 3\^2\)\), HoldForm]], "Output", CellLabel->"Out[159]="], Cell[BoxData[ TagBox[\(\(2 + 6\)\/\(1 - 12 + 9\ 9\)\), HoldForm]], "Output", CellLabel->"Out[160]="], Cell[BoxData[ TagBox[\(8\/\(1 - 12 + 81\)\), HoldForm]], "Output", CellLabel->"Out[161]="], Cell[BoxData[ TagBox[\(8\/70\), HoldForm]], "Output", CellLabel->"Out[162]="], Cell[BoxData[ TagBox[\(8\/70\), HoldForm]], "Output", CellLabel->"Out[163]="], Cell[BoxData[ TagBox[\(4\/35\), HoldForm]], "Output", CellLabel->"Out[164]="] }, Open ]], Cell["\<\ This can be written more shortly using NestList. Notice that two of the \ results that appear to be the same, really have a different internal \ representation.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(% // EvaluateAt[{1}]\), "\[IndentingNewLine]", \(% /. x \[Rule] 3\), "\[IndentingNewLine]", \(NestList[EvaluateAtPattern[_, {\(-2\)}], %, 5]\), "\[IndentingNewLine]", \(FullForm /@ %\)}], "Input", CellLabel->"In[165]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((x\^2 + 2\ x + 3)\)\/\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)\), HoldForm]], "Output", CellLabel->"Out[165]="], Cell[BoxData[ TagBox[\(\(2 + 2\ x\)\/\(1 - 4\ x + 9\ x\^2\)\), HoldForm]], "Output", CellLabel->"Out[166]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 9\ 3\^2\)\), HoldForm]], "Output", CellLabel->"Out[167]="], Cell[BoxData[ RowBox[{"{", RowBox[{ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 9\ 3\^2\)\), HoldForm], ",", TagBox[\(\(2 + 6\)\/\(1 - 12 + 9\ 9\)\), HoldForm], ",", TagBox[\(8\/\(1 - 12 + 81\)\), HoldForm], ",", TagBox[\(8\/70\), HoldForm], ",", TagBox[\(8\/70\), HoldForm], ",", TagBox[\(4\/35\), HoldForm]}], "}"}]], "Output", CellLabel->"Out[168]="], Cell[BoxData[ RowBox[{"{", RowBox[{ TagBox[ StyleBox[\(HoldForm[ Times[Plus[2, Times[2, 3]], Power[Plus[1, Times[\(-4\), 3], Times[9, Power[3, 2]]], \(-1\)]]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm], ",", TagBox[ StyleBox[\(HoldForm[ Times[Plus[2, 6], Power[Plus[1, \(-12\), Times[9, 9]], \(-1\)]]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm], ",", TagBox[ StyleBox[\(HoldForm[ Times[8, Power[Plus[1, \(-12\), 81], \(-1\)]]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm], ",", TagBox[ StyleBox[\(HoldForm[Times[8, Power[70, \(-1\)]]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm], ",", TagBox[ StyleBox[\(HoldForm[Times[8, Rational[1, 70]]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm], ",", TagBox[ StyleBox[\(HoldForm[Rational[4, 35]]\), ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]}], "}"}]], "Output", CellLabel->"Out[169]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Case 4 - An Alternative Evaluation of Case 4", "Subsection"], Cell[TextData[{ "Evaluate the following expression at ", Cell[BoxData[ \(x \[Equal] 3\)]], ", step-by-step." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = HoldForm[\[PartialD]\_x\((x\^2 + 2 x + 3)\)/\[PartialD]\_x\((3 x\^3 - 2 x\^2 + x)\)]\)], "Input", CellLabel->"In[170]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((x\^2 + 2\ x + 3)\)\/\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)\), HoldForm]], "Output", CellLabel->"Out[170]="] }, Open ]], Cell[TextData[{ "Evaluate each subexpression by ", StyleBox["copying it and pasting it into an EvaluateAtPattern statement", FontWeight->"Bold"], ". The only tricky part is that we must use ", Cell[BoxData[ \(\(-4\)\ 3\)]], " and we can't match ", Cell[BoxData[ \(4\ 3\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[\[PartialD]\_x\((x\^2 + 2\ x + 3)\)]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)]\), "\[IndentingNewLine]", \(% /. x \[Rule] 3\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[3\^2]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[9\ 9]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[\(-4\)\ 3]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[2\ 3]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[2 + 6]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[1 - 12 + 81]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[8\/70]\)}], "Input", CellLabel->"In[171]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((x\^2 + 2\ x + 3)\)\/\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)\), HoldForm]], "Output", CellLabel->"Out[171]="], Cell[BoxData[ TagBox[\(\(2 + 2\ x\)\/\[PartialD]\_x\((3\ x\^3 - 2\ x\^2 + x)\)\), HoldForm]], "Output", CellLabel->"Out[172]="], Cell[BoxData[ TagBox[\(\(2 + 2\ x\)\/\(1 - 4\ x + 9\ x\^2\)\), HoldForm]], "Output", CellLabel->"Out[173]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 9\ 3\^2\)\), HoldForm]], "Output", CellLabel->"Out[174]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 9\ 9\)\), HoldForm]], "Output", CellLabel->"Out[175]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 4\ 3 + 81\)\), HoldForm]], "Output", CellLabel->"Out[176]="], Cell[BoxData[ TagBox[\(\(2 + 2\ 3\)\/\(1 - 12 + 81\)\), HoldForm]], "Output", CellLabel->"Out[177]="], Cell[BoxData[ TagBox[\(\(2 + 6\)\/\(1 - 12 + 81\)\), HoldForm]], "Output", CellLabel->"Out[178]="], Cell[BoxData[ TagBox[\(8\/\(1 - 12 + 81\)\), HoldForm]], "Output", CellLabel->"Out[179]="], Cell[BoxData[ TagBox[\(8\/70\), HoldForm]], "Output", CellLabel->"Out[180]="], Cell[BoxData[ TagBox[\(4\/35\), HoldForm]], "Output", CellLabel->"Out[181]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Case 5 - Calculating a Derivative From the Definition", "Subsection"], Cell[CellGroupData[{ Cell["Example 1 ", "Subsubsection"], Cell[BoxData[{ \(ClearAll[f]\), "\n", \(f[x_] := x\/\(x - 1\)\)}], "Input", CellLabel->"In[182]:="], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[\(f[x + h] - f[x]\)\/h]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_f]\), "\[IndentingNewLine]", \(\(pos = ExtendedPosition[%, \(h + x\)\/\(\(-1\) + h + x\) - x\/\(\(-1\) + x\)];\)\), "\[IndentingNewLine]", \(%% // EvaluateAt[pos, Simplify]\), "\[IndentingNewLine]", \(% // EvaluateAt[{1}, Cancel]\), "\[IndentingNewLine]", \(% /. h \[Rule] 0\), "\[IndentingNewLine]", \(% // ReleaseHold\)}], "Input", CellLabel->"In[184]:="], Cell[BoxData[ TagBox[\(\(f[x + h] - f[x]\)\/h\), HoldForm]], "Output", CellLabel->"Out[184]="], Cell[BoxData[ TagBox[\(\(\(h + x\)\/\(\(-1\) + h + x\) - x\/\(\(-1\) + x\)\)\/h\), HoldForm]], "Output", CellLabel->"Out[185]="], Cell[BoxData[ TagBox[\(-\(h\/\(\((\((\(-1\) + x)\)\ \((\(-1\) + h + x)\))\)\ h\)\)\), HoldForm]], "Output", CellLabel->"Out[187]="], Cell[BoxData[ TagBox[\(-\(1\/\(\((\(-1\) + x)\)\ \((\(-1\) + h + x)\)\)\)\), HoldForm]], "Output", CellLabel->"Out[188]="], Cell[BoxData[ TagBox[\(-\(1\/\(\((\(-1\) + x)\)\ \((\(-1\) + 0 + x)\)\)\)\), HoldForm]], "Output", CellLabel->"Out[189]="], Cell[BoxData[ \(\(-\(1\/\((\(-1\) + x)\)\^2\)\)\)], "Output", CellLabel->"Out[190]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(f'\)[x] // Simplify\)], "Input", CellLabel->"In[191]:="], Cell[BoxData[ \(\(-\(1\/\((\(-1\) + x)\)\^2\)\)\)], "Output", CellLabel->"Out[191]="] }, Open ]], Cell[BoxData[ \(Clear[f]\)], "Input", CellLabel->"In[192]:="] }, Closed]], Cell[CellGroupData[{ Cell["Example 2", "Subsubsection"], Cell[TextData[{ "This uses the ExpressionManipulation routine ", Cell[BoxData[ \(NDTimesExpand\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?NDTimesExpand\)\)], "Input", CellLabel->"In[193]:="], Cell[BoxData[ \("NDTimesExpand[expression, factor] multiplies the numerator and \ denominator of expr by factor and expands each of them."\)], "Print", CellTags->"Info3195323771-9489066"] }, Open ]], Cell[BoxData[ \(f[x_] := \@x\)], "Input", CellLabel->"In[194]:="], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[\(f[x + h] - f[x]\)\/h]\), "\[IndentingNewLine]", \(% // ReleaseHold\), "\[IndentingNewLine]", \(NDTimesExpand[%, \@\(h + x\) + \@x]\), "\[IndentingNewLine]", \(% // Cancel\), "\[IndentingNewLine]", \(% /. h \[Rule] 0\)}], "Input", CellLabel->"In[195]:="], Cell[BoxData[ TagBox[\(\(f[x + h] - f[x]\)\/h\), HoldForm]], "Output", CellLabel->"Out[195]="], Cell[BoxData[ \(\(\(-\@x\) + \@\(h + x\)\)\/h\)], "Output", CellLabel->"Out[196]="], Cell[BoxData[ \(h\/\(h\ \@x + h\ \@\(h + x\)\)\)], "Output", CellLabel->"Out[197]="], Cell[BoxData[ \(1\/\(\@x + \@\(h + x\)\)\)], "Output", CellLabel->"Out[198]="], Cell[BoxData[ \(1\/\(2\ \@x\)\)], "Output", CellLabel->"Out[199]="] }, Open ]], Cell[BoxData[ \(Clear[f]\)], "Input", CellLabel->"In[200]:="] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Case 6 - Differentiation of Ratio", "Subsection"], Cell["\<\ Here we differentiate a ratio of functions, first generating the general \ formula, then substituting the actual functions and their derivatives.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(Clear[f, g];\)\), "\[IndentingNewLine]", \(HoldForm[D[\ f[x]/g[x], x]]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[\[PartialD]\_x\ _, \[Infinity], Together]\), "\[IndentingNewLine]", \(\((f[x_] := x^3 - 4 x + 3; g[x_] := x^\((4/3)\);)\)\), "\[IndentingNewLine]", \(%% // EvaluateAtPattern[\((f | g)\)[_]]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[\((f' | g')\)[_]]\), "\[IndentingNewLine]", \(% // EvaluateAt[{1, 2}, Expand]\), "\[IndentingNewLine]", \(% // EvaluateAt[{1, 1}, Expand]\), "\[IndentingNewLine]", \(% // EvaluateAt[{1}, Cancel]\)}], "Input", CellLabel->"In[201]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\( f[x]\/g[x]\)\), HoldForm]], "Output", CellLabel->"Out[202]="], Cell[BoxData[ TagBox[ FractionBox[ RowBox[{ RowBox[{\(g[x]\), " ", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "[", "x", "]"}]}], "-", RowBox[{\(f[x]\), " ", RowBox[{ SuperscriptBox["g", "\[Prime]", MultilineFunction->None], "[", "x", "]"}]}]}], \(g[x]\^2\)], HoldForm]], "Output", CellLabel->"Out[203]="], Cell[BoxData[ TagBox[ FractionBox[ RowBox[{ RowBox[{\(x\^\(4/3\)\), " ", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "[", "x", "]"}]}], "-", RowBox[{\((3 - 4\ x + x\^3)\), " ", RowBox[{ SuperscriptBox["g", "\[Prime]", MultilineFunction->None], "[", "x", "]"}]}]}], \(\((x\^\(4/3\))\)\^2\)], HoldForm]], "Output", CellLabel->"Out[205]="], Cell[BoxData[ TagBox[\(\(x\^\(4/3\)\ \((\(-4\) + 3\ x\^2)\) - 1\/3\ \((3 - 4\ x + x\^3)\)\ \((4\ x\^\(1/3\))\)\)\/\((x\^\(4/3\))\)\^2\), HoldForm]], "Output", CellLabel->"Out[206]="], Cell[BoxData[ TagBox[\(\(\(-4\)\ x\^\(1/3\) + \(4\ x\^\(4/3\)\)\/3 + \(5\ x\^\(10/3\)\)\ \/3\)\/\((x\^\(4/3\))\)\^2\), HoldForm]], "Output", CellLabel->"Out[207]="], Cell[BoxData[ TagBox[\(\(\(-4\)\ x\^\(1/3\) + \(4\ x\^\(4/3\)\)\/3 + \(5\ x\^\(10/3\)\)\ \/3\)\/x\^\(8/3\)\), HoldForm]], "Output", CellLabel->"Out[208]="], Cell[BoxData[ TagBox[\(\(\(-12\) + 4\ x + 5\ x\^3\)\/\(3\ x\^\(7/3\)\)\), HoldForm]], "Output", CellLabel->"Out[209]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Case 7 - L'Hopital's Rule", "Subsection"], Cell[TextData[{ "Find the limit of the following expression as ", Cell[BoxData[ \(x \[Rule] 0\)]], " using l'Hopital's Rule." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(e1 = HoldForm[\(3\ x - Sin[x]\)\/x]\), "\[IndentingNewLine]", \(expr = % /. x \[Rule] 0\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\), "\[IndentingNewLine]", \(e1 = e1 // EvaluateAt[{1}, \((\[PartialD]\_x\ Numerator[#])\)/\((\[PartialD]\_x\ Denominator[#])\) &]\), "\[IndentingNewLine]", \(% /. x \[Rule] 0\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Cos]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\)}], "Input", CellLabel->"In[210]:="], Cell[BoxData[ TagBox[\(\(3\ x - Sin[x]\)\/x\), HoldForm]], "Output", CellLabel->"Out[210]="], Cell[BoxData[ TagBox[\(1\/0\ \((3\ 0 - Sin[0])\)\), HoldForm]], "Output", CellLabel->"Out[211]="], Cell[BoxData[ TagBox[\(0\/0\), HoldForm]], "Output", CellLabel->"Out[212]="], Cell[BoxData[ TagBox[\(3 - Cos[x]\), HoldForm]], "Output", CellLabel->"Out[213]="], Cell[BoxData[ TagBox[\(3 - Cos[0]\), HoldForm]], "Output", CellLabel->"Out[214]="], Cell[BoxData[ TagBox[\(3 - 1\), HoldForm]], "Output", CellLabel->"Out[215]="], Cell[BoxData[ TagBox["2", HoldForm]], "Output", CellLabel->"Out[216]="] }, Open ]], Cell["We could also do it this way.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(e1 = HoldForm[\(3\ x - Sin[x]\)\/x]\), "\[IndentingNewLine]", \(expr = % /. x \[Rule] 0\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\), "\[IndentingNewLine]", \(e1 = e1 /. a_/b_ \[RuleDelayed] \[PartialD]\_x\ a/\[PartialD]\_x\ b\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[\[PartialD]\_x\ _]\), "\[IndentingNewLine]", \(% /. x \[Rule] 0\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Times]\)}], "Input", CellLabel->"In[217]:="], Cell[BoxData[ TagBox[\(\(3\ x - Sin[x]\)\/x\), HoldForm]], "Output", CellLabel->"Out[217]="], Cell[BoxData[ TagBox[\(1\/0\ \((3\ 0 - Sin[0])\)\), HoldForm]], "Output", CellLabel->"Out[218]="], Cell[BoxData[ TagBox[\(0\/0\), HoldForm]], "Output", CellLabel->"Out[219]="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((3\ x - Sin[x])\)\/\[PartialD]\_x x\), HoldForm]], "Output", CellLabel->"Out[220]="], Cell[BoxData[ TagBox[\(\((3 - Cos[x])\)\ 1\/1\), HoldForm]], "Output", CellLabel->"Out[221]="], Cell[BoxData[ TagBox[\(\((3 - Cos[0])\)\ 1\/1\), HoldForm]], "Output", CellLabel->"Out[222]="], Cell[BoxData[ TagBox[\(\((3 - 1)\)\ 1\), HoldForm]], "Output", CellLabel->"Out[223]="], Cell[BoxData[ TagBox["2", HoldForm]], "Output", CellLabel->"Out[224]="] }, Open ]], Cell[BoxData[ \(Clear[e1]\)], "Input", CellLabel->"In[225]:="] }, Closed]], Cell[CellGroupData[{ Cell["Case 8 - L'Hopital's Rule with Commentary", "Subsection"], Cell[TextData[{ "Here is a way to do a l'Hopital's Rule problem step by step with \ commentary. Here l'Hopital's rule is implemented with a mere ", StyleBox["Mathematica", FontSlant->"Italic"], " rule, and then evaluated." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(Print["\"]\), "\[IndentingNewLine]", \(e1 = HoldForm[\((3 x - Sin[x])\)/x]\), "\[IndentingNewLine]", \(Print["\"]\), "\[IndentingNewLine]", \(e1 /. x \[Rule] 0\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[Sin[0] | \((3\ 0)\)]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\), "\[IndentingNewLine]", \(Print["\"]\), "\[IndentingNewLine]", \(e2 = e1 /. a_/b_ \[RuleDelayed] \[PartialD]\_x\ a/\[PartialD]\_x\ b\), "\[IndentingNewLine]", \(e2 = % // EvaluateAtPattern[\[PartialD]\_x\ _]\), "\[IndentingNewLine]", \(Print["\"]\), "\[IndentingNewLine]", \(e2 /. x \[Rule] 0\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[Cos[0]]\), "\[IndentingNewLine]", \(ReleaseHold[%]\)}], "Input", CellLabel->"In[226]:="], Cell[BoxData[ \("Find the limit as x \[Rule] 0"\)], "Print", CellLabel->"From In[226]:="], Cell[BoxData[ TagBox[\(\(3\ x - Sin[x]\)\/x\), HoldForm]], "Output", CellLabel->"Out[227]="], Cell[BoxData[ \("Put x \[Equal] 0."\)], "Print", CellLabel->"From In[226]:="], Cell[BoxData[ TagBox[\(1\/0\ \((3\ 0 - Sin[0])\)\), HoldForm]], "Output", CellLabel->"Out[229]="], Cell[BoxData[ TagBox[\(\(0 - 0\)\/0\), HoldForm]], "Output", CellLabel->"Out[230]="], Cell[BoxData[ TagBox[\(0\/0\), HoldForm]], "Output", CellLabel->"Out[231]="], Cell[BoxData[ \("The expression is indeterminate so differentiate the numerator and \ denominator."\)], "Print", CellLabel->"From In[226]:="], Cell[BoxData[ TagBox[\(\[PartialD]\_x\((3\ x - Sin[x])\)\/\[PartialD]\_x x\), HoldForm]], "Output", CellLabel->"Out[233]="], Cell[BoxData[ TagBox[\(\((3 - Cos[x])\)\ 1\/1\), HoldForm]], "Output", CellLabel->"Out[234]="], Cell[BoxData[ \("Put x \[Equal] 0."\)], "Print", CellLabel->"From In[226]:="], Cell[BoxData[ TagBox[\(\((3 - Cos[0])\)\ 1\/1\), HoldForm]], "Output", CellLabel->"Out[236]="], Cell[BoxData[ TagBox[\(\((3 - 1)\)\ 1\/1\), HoldForm]], "Output", CellLabel->"Out[237]="], Cell[BoxData[ \(2\)], "Output", CellLabel->"Out[238]="] }, Open ]], Cell[BoxData[ \(Clear[e1, e2]\)], "Input", CellLabel->"In[239]:="] }, Closed]], Cell[CellGroupData[{ Cell["Case 9 - Simple Fraction Problems ", "Subsection"], Cell[TextData[{ "Simple fraction problems are another challenge for controlled evaluation \ with ", StyleBox["Mathematica", FontSlant->"Italic"], ". Ordinary rules still come in handy. Here we add fractions with a common \ denominator" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2/6 + 3/6]\), "\[IndentingNewLine]", \(% /. a_/c_ + b_/c_ \[RuleDelayed] \((a + b)\)/ c\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\)}], "Input", CellLabel->"In[240]:="], Cell[BoxData[ TagBox[\(2\/6 + 3\/6\), HoldForm]], "Output", CellLabel->"Out[240]="], Cell[BoxData[ TagBox[\(\(2 + 3\)\/6\), HoldForm]], "Output", CellLabel->"Out[241]="], Cell[BoxData[ TagBox[\(5\/6\), HoldForm]], "Output", CellLabel->"Out[242]="] }, Open ]], Cell[TextData[{ "Here we add three fractions and write the resulting improper fraction in \ proper form using ", Cell[BoxData[ \(SequenceForm\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2/6 + 3/6 + 3/6]\), "\[IndentingNewLine]", \(% /. a_/c_ + b_/c_ \[RuleDelayed] \((a + b)\)/ c\), "\[IndentingNewLine]", \(% /. a_/c_ + b_/c_ \[RuleDelayed] \((a + b)\)/ c\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Plus]\), "\[IndentingNewLine]", \(ReleaseHold[%]\), "\[IndentingNewLine]", \(SequenceForm[IntegerPart[%], FractionalPart[%]]\)}], "Input", CellLabel->"In[243]:="], Cell[BoxData[ TagBox[\(2\/6 + 3\/6 + 3\/6\), HoldForm]], "Output", CellLabel->"Out[243]="], Cell[BoxData[ TagBox[\(3\/6 + \(2 + 3\)\/6\), HoldForm]], "Output", CellLabel->"Out[244]="], Cell[BoxData[ TagBox[\(1\/6\ \((3 + \((2 + 3)\))\)\), HoldForm]], "Output", CellLabel->"Out[245]="], Cell[BoxData[ TagBox[\(\(3 + 5\)\/6\), HoldForm]], "Output", CellLabel->"Out[246]="], Cell[BoxData[ TagBox[\(8\/6\), HoldForm]], "Output", CellLabel->"Out[247]="], Cell[BoxData[ \(4\/3\)], "Output", CellLabel->"Out[248]="], Cell[BoxData[ InterpretationBox[\(1\[InvisibleSpace]1\/3\), SequenceForm[ 1, Rational[ 1, 3]], Editable->False]], "Output", CellLabel->"Out[249]="] }, Open ]], Cell["Here we add fractions with different denominators.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[2/3 + 1/4]\), "\[IndentingNewLine]", \(% /. a_/b_ + c_/d_ \[RuleDelayed] \((a\ d + b\ c)\)/\((b\ d)\)\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_Times, {\(-2\)}]\), "\[IndentingNewLine]", \(% // EvaluateAtPattern[_, {\(-2\)}]\)}], "Input", CellLabel->"In[250]:="], Cell[BoxData[ TagBox[\(2\/3 + 1\/4\), HoldForm]], "Output", CellLabel->"Out[250]="], Cell[BoxData[ TagBox[\(\(2\ 4 + 3\ 1\)\/\(3\ 4\)\), HoldForm]], "Output", CellLabel->"Out[251]="], Cell[BoxData[ TagBox[\(\(8 + 3\)\/12\), HoldForm]], "Output", CellLabel->"Out[252]="], Cell[BoxData[ TagBox[\(11\/12\), HoldForm]], "Output", CellLabel->"Out[253]="] }, Open ]], Cell["\<\ Here we add three fractions with different denominators, use NestList to run \ through the step-by-step simplifications, extract the answer and put it in \ proper form.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(HoldForm[3/5 + 7/20 + 1/2]\), "\[IndentingNewLine]", \(% /. a_/b_ + c_/d_ \[RuleDelayed] \((a\ d + b\ c)\)/\((b\ d)\)\), "\[IndentingNewLine]", \(% /. a_/b_ + c_/d_ \[RuleDelayed] \((a\ d + b\ c)\)/\((b\ d)\)\), "\[IndentingNewLine]", \(NestList[EvaluateAtPattern[_, {\(-2\)}], %, 5]\), "\[IndentingNewLine]", \(ReleaseHold[Last[%]]\), "\[IndentingNewLine]", \(SequenceForm[IntegerPart[%], FractionalPart[%]]\)}], "Input", CellLabel->"In[254]:="], Cell[BoxData[ TagBox[\(3\/5 + 7\/20 + 1\/2\), HoldForm]], "Output", CellLabel->"Out[254]="], Cell[BoxData[ TagBox[\(1\/2 + \(3\ 20 + 5\ 7\)\/\(5\ 20\)\), HoldForm]], "Output", CellLabel->"Out[255]="], Cell[BoxData[ TagBox[\(\(5\ 20 + 2\ \((3\ 20 + 5\ 7)\)\)\/\(2\ \((5\ 20)\)\)\), HoldForm]], "Output", CellLabel->"Out[256]="], Cell[BoxData[ RowBox[{"{", RowBox[{ TagBox[\(\(5\ 20 + 2\ \((3\ 20 + 5\ 7)\)\)\/\(2\ \((5\ 20)\)\)\), HoldForm], ",", TagBox[\(\(1\ 100 + 2\ \((60 + 35)\)\)\/\(2\ 100\)\), HoldForm], ",", TagBox[\(1\/200\ \((100 + 2\ 95)\)\), HoldForm], ",", TagBox[\(\(100 + 190\)\/200\), HoldForm], ",", TagBox[\(290\/200\), HoldForm], ",", TagBox[\(29\/20\), HoldForm]}], "}"}]], "Output", CellLabel->"Out[257]="], Cell[BoxData[ \(29\/20\)], "Output", CellLabel->"Out[258]="], Cell[BoxData[ InterpretationBox[\(1\[InvisibleSpace]9\/20\), SequenceForm[ 1, Rational[ 9, 20]], Editable->False]], "Output", CellLabel->"Out[259]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Case 10 - Integration by Substitution - First Method", "Subsection"], Cell["Integrate the following expression by making a substitution.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(intg = HoldForm[\[Integral]\(\@\(1 + y\^2\)\) 2 y \[DifferentialD]y]\)], "Input", CellLabel->"In[49]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(1 + y\^2\)\ 2\ y\) \[DifferentialD]y\), HoldForm]], "Output", CellLabel->"Out[49]="] }, Open ]], Cell["This shows the the parts of the Integrate expression.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(pos = Position[intg, _, {2}, Heads \[Rule] False]\), "\[IndentingNewLine]", \(intg // ColorPositions[pos]\)}], "Input", CellLabel->"In[50]:="], Cell[BoxData[ \({{1, 1}, {1, 2}}\)], "Output", CellLabel->"Out[50]="], Cell[BoxData[ TagBox[ TagBox[ RowBox[{"Integrate", "[", RowBox[{ TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1, 1}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox[\(\@\(1 + y\^2\)\ 2\ y\), HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1, 1}, FontSize -> 10]]], " ", HoldForm[ Times[ Power[ Plus[ 1, Power[ y, 2]], Rational[ 1, 2]], 2, y]]], Editable->False], Background->RGBColor[0.949996, 0.570001, 0.570001]], ( StyleForm[ #, Background -> Hue[ 0, .40000000000000002, .94999999999999996]]&)], ",", TagBox[ StyleBox[ InterpretationBox[ RowBox[{ TagBox[ FrameBox[ TagBox[ StyleBox[\({1, 2}\), FontSize->10], (StyleForm[ #, FontSize -> 10]&)]], DisplayForm], "\[InvisibleSpace]", "\<\" \"\>", "\[InvisibleSpace]", TagBox["y", HoldForm]}], SequenceForm[ DisplayForm[ FrameBox[ StyleForm[ {1, 2}, FontSize -> 10]]], " ", HoldForm[ y]], Editable->False], Background->RGBColor[0.646006, 0.570001, 0.949996]], ( StyleForm[ #, Background -> Hue[ .69999999999999996, .40000000000000002, \ .94999999999999996]]&)]}], "]"}], HoldForm], HoldForm]], "Output", CellLabel->"Out[51]="] }, Open ]], Cell[TextData[{ "We will make the substitution ", Cell[BoxData[ \(1 + y\^2 \[Equal] u\)]], ". This solves for x, the new differential, and the factor that must \ multiply the integrand with the change of variable. Notice that we can't work \ directly with ", Cell[BoxData[ \(\[DifferentialD]\)]], " because it is not really part of the expression." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(Solve[u \[Equal] 1 + y\^2, y]\)\[LeftDoubleBracket]1, 1\[RightDoubleBracket]\), "\[IndentingNewLine]", \(Dt[%]\), "\[IndentingNewLine]", \(Coefficient[%\[LeftDoubleBracket]2\[RightDoubleBracket], Dt[u]]\)}], "Input", CellLabel->"In[263]:="], Cell[BoxData[ \(y \[Rule] \(-\@\(\(-1\) + u\)\)\)], "Output", CellLabel->"Out[263]="], Cell[BoxData[ \(Dt[y] \[Rule] \(-\(Dt[u]\/\(2\ \@\(\(-1\) + u\)\)\)\)\)], "Output", CellLabel->"Out[264]="], Cell[BoxData[ \(\(-\(1\/\(2\ \@\(\(-1\) + u\)\)\)\)\)], "Output", CellLabel->"Out[265]="] }, Open ]], Cell["\<\ This does the substitution using the more general form of ReplacePart. It \ doesn't use any of our new routines.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(intg\), "\[IndentingNewLine]", \(e1 = % /. \ y \[Rule] \(-\@\(\(-1\) + u\)\)\), "\[IndentingNewLine]", \(ReplacePart[%, {%\[LeftDoubleBracket]1, 1\[RightDoubleBracket] \((\(-\(1\/\(2\ \@\(\(-1\) + u\)\)\)\))\), u}, {{1, 1}, {1, 2}}, {{1}, {2}}]\), "\[IndentingNewLine]", \(% + C // ReleaseHold\), "\[IndentingNewLine]", \(% /. u \[Rule] 1 + y\^2\)}], "Input", CellLabel->"In[266]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(1 + y\^2\)\ 2\ y\) \[DifferentialD]y\), HoldForm]], "Output", CellLabel->"Out[266]="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(1 + \((\(-\@\(\(-1\) + u\)\))\)\^2\)\ 2\ \((\(-\ \@\(\(-1\) + u\)\))\)\) \[DifferentialD]\((\(-\@\(\(-1\) + u\)\))\)\), HoldForm]], "Output", CellLabel->"Out[267]="], Cell[BoxData[ TagBox[\(\[Integral]\(\@u\) \[DifferentialD]u\), HoldForm]], "Output", CellLabel->"Out[268]="], Cell[BoxData[ \(C + \(2\ u\^\(3/2\)\)\/3\)], "Output", CellLabel->"Out[269]="], Cell[BoxData[ \(C + 2\/3\ \((1 + y\^2)\)\^\(3/2\)\)], "Output", CellLabel->"Out[270]="] }, Open ]], Cell["This does the substitution using EvaluateAt.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(intg\), "\[IndentingNewLine]", \(e1 = % /. \ y \[Rule] \(-\@\(\(-1\) + u\)\)\), "\[IndentingNewLine]", \(\(% // EvaluateAt[{1, 1}, %\[LeftDoubleBracket]1, 1\[RightDoubleBracket] \((\(-\(1\/\(2\ \@\(\(-1\) + \ u\)\)\)\))\) &]\) // EvaluateAt[{1, 2}, u &]\), "\[IndentingNewLine]", \(% + C // ReleaseHold\), "\[IndentingNewLine]", \(% /. u \[Rule] 1 + y\^2\)}], "Input", CellLabel->"In[271]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(1 + y\^2\)\ 2\ y\) \[DifferentialD]y\), HoldForm]], "Output", CellLabel->"Out[271]="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(1 + \((\(-\@\(\(-1\) + u\)\))\)\^2\)\ 2\ \((\(-\ \@\(\(-1\) + u\)\))\)\) \[DifferentialD]\((\(-\@\(\(-1\) + u\)\))\)\), HoldForm]], "Output", CellLabel->"Out[272]="], Cell[BoxData[ TagBox[\(\[Integral]\(\@u\) \[DifferentialD]u\), HoldForm]], "Output", CellLabel->"Out[273]="], Cell[BoxData[ \(C + \(2\ u\^\(3/2\)\)\/3\)], "Output", CellLabel->"Out[274]="], Cell[BoxData[ \(C + 2\/3\ \((1 + y\^2)\)\^\(3/2\)\)], "Output", CellLabel->"Out[275]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Case 11 - An Integration by Substitution Routine", "Subsection"], Cell[TextData[{ "This uses HoldForm to implement an ", Cell[BoxData[ \(IntegrateBySubstitution\ routine\)]], ". First we print the substitution rules. Then the new integrand and \ integral is constructed and evaluated. Then the original variable is \ resubstituted. A check is made to see that the new integrand is entirely in \ the new variable and a further check is made to see if ", StyleBox["Mathematica", FontSlant->"Italic"], " actually performed the integration." }], "Text"], Cell[BoxData[{ \(\(Clear[IntegrateBySubstitution];\)\), "\[IndentingNewLine]", \(\(\(IntegrateBySubstitution::usage = "\";\)\(\[IndentingNewLine]\) \)\), "\[IndentingNewLine]", \(\(\(IntegrateBySubstitution::badsub = "\";\)\(\[IndentingNewLine]\) \)\), "\[IndentingNewLine]", \(\(\(IntegrateBySubstitution::intg = "\";\)\(\[IndentingNewLine]\) \)\), "\[IndentingNewLine]", \(\(IntegrateBySubstitution[subrule_Rule]\)[ intg_] := \[IndentingNewLine]Module[{subintegrand, subintegral, subvar, subexpr, var, dvar, drule}, \[IndentingNewLine]Print[ intg]; \[IndentingNewLine]var = intg\[LeftDoubleBracket]1, 2\[RightDoubleBracket]; \[IndentingNewLine]{subvar, subexpr} = List @@ subrule; \[IndentingNewLine]\[IndentingNewLine]dvar = Symbol["\" <> SymbolName[var]]; \[IndentingNewLine]drule = \(Dt[ subrule] /. \((HoldPattern[ Dt[sname : a | b]] /. {a \[Rule] var, b \[Rule] subvar})\) \[RuleDelayed] Symbol["\" <> SymbolName[sname]]\) /. Dt[_] \[Rule] 0; \[IndentingNewLine]drule = \(Solve[Equal @@ drule, dvar]\)\[LeftDoubleBracket]1, 1\[RightDoubleBracket] // Simplify; \[IndentingNewLine]Print[{drule, Reverse[subrule]}]; \ \[IndentingNewLine]\[IndentingNewLine]subintegrand = Simplify[\((intg\[LeftDoubleBracket]1, 1\[RightDoubleBracket]/\[PartialD]\_var\ subexpr)\) /. Reverse[subrule]]; \[IndentingNewLine]subintegral = \(HoldForm[ Integrate[#1, #2]] &\) @@ {subintegrand, subvar}; \[IndentingNewLine]Print[ subintegral]; \[IndentingNewLine]If[\[Not] FreeQ[subintegrand, \ var], Message[IntegrateBySubstitution::badsub, subintegrand, var]; Return[$Failed]]; \[IndentingNewLine]subintegral = ReleaseHold[subintegral]; \[IndentingNewLine]Print[ subintegral + C]; \[IndentingNewLine]If[ Head[subintegral] === Integrate, Message[IntegrateBySubstitution::intg], subintegral + C /. subrule]\[IndentingNewLine]]\)}], "Input", CellLabel->"In[276]:="], Cell[CellGroupData[{ Cell[BoxData[ \(\(?IntegrateBySubstitution\)\)], "Input", CellLabel->"In[281]:="], Cell[BoxData[ \("IntegrateBySubstitution[u \[Rule] expression][HoldForm[\[Integral]f[x]\ \[DifferentialD]x]] will integrate an indefinite integral by making the \ substitution u \[Rule] expression."\)], "Print", CellTags->"Info3195323872-6948727"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(\@\(1 + y\^2\)\) 2 y \[DifferentialD]y] \ // \[IndentingNewLine]IntegrateBySubstitution[u \[Rule] 1 + y\^2]\)], "Input",\ CellLabel->"In[282]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(1 + y\^2\)\ 2\ y\) \[DifferentialD]y\), HoldForm]], "Print", CellLabel->"From In[282]:="], Cell[BoxData[ \({dy \[Rule] du\/\(2\ y\), 1 + y\^2 \[Rule] u}\)], "Print", CellLabel->"From In[282]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@u\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[282]:="], Cell[BoxData[ \(C + \(2\ u\^\(3/2\)\)\/3\)], "Print", CellLabel->"From In[282]:="], Cell[BoxData[ \(C + 2\/3\ \((1 + y\^2)\)\^\(3/2\)\)], "Output", CellLabel->"Out[282]="] }, Open ]], Cell["\<\ This fails because it only makes the direct reverse substitution and doesn't \ try to solve for y in terms of u.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(\@\(1 + y\^2\)\) 2 y \[DifferentialD]y] \ // \[IndentingNewLine]IntegrateBySubstitution[ u \[Rule] \@\(1 + y\^2\)]\)], "Input", CellLabel->"In[283]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(1 + y\^2\)\ 2\ y\) \[DifferentialD]y\), HoldForm]], "Print", CellLabel->"From In[283]:="], Cell[BoxData[ \({dy \[Rule] \(du\ \@\(1 + y\^2\)\)\/y, \@\(1 + y\^2\) \[Rule] u}\)], "Print", CellLabel->"From In[283]:="], Cell[BoxData[ TagBox[\(\[Integral]\(2\ \((1 + y\^2)\)\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[283]:="], Cell[BoxData[ \(IntegrateBySubstitution::"badsub" \(\(:\)\(\ \)\) "New integrand \!\(2\\ \(\((1 + y\^2)\)\)\) is not free of \ \!\(y\)."\)], "Message", CellLabel->"From In[283]:="], Cell[BoxData[ \($Failed\)], "Output", CellLabel->"Out[283]="] }, Open ]], Cell[TextData[{ "Here, ", StyleBox["Mathematica", FontSlant->"Italic"], " failed to do the integration." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]Sin[Sin[y\^2]] 2 y \[DifferentialD]y] \ // \[IndentingNewLine]IntegrateBySubstitution[u \[Rule] y\^2]\)], "Input", CellLabel->"In[284]:="], Cell[BoxData[ TagBox[\(\[Integral]\(Sin[Sin[y\^2]]\ 2\ y\) \[DifferentialD]y\), HoldForm]], "Print", CellLabel->"From In[284]:="], Cell[BoxData[ \({dy \[Rule] du\/\(2\ y\), y\^2 \[Rule] u}\)], "Print", CellLabel->"From In[284]:="], Cell[BoxData[ TagBox[\(\[Integral]Sin[Sin[u]] \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[284]:="], Cell[BoxData[ \(C + \[Integral]Sin[Sin[u]] \[DifferentialD]u\)], "Print", CellLabel->"From In[284]:="], Cell[BoxData[ \(IntegrateBySubstitution::"intg" \(\(:\)\(\ \)\) "Mathematica failed to evaluate the integral."\)], "Message", CellLabel->"From In[284]:="] }, Open ]], Cell[CellGroupData[{ Cell["Other Examples", "Subsubsection"], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(\((x + 2)\)\^5\) \[DifferentialD]x] // IntegrateBySubstitution[u \[Rule] x + 2]\)], "Input", CellLabel->"In[285]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\((x + 2)\)\^5\) \[DifferentialD]x\), HoldForm]], "Print", CellLabel->"From In[285]:="], Cell[BoxData[ \({dx \[Rule] du, 2 + x \[Rule] u}\)], "Print", CellLabel->"From In[285]:="], Cell[BoxData[ TagBox[\(\[Integral]\(u\^5\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[285]:="], Cell[BoxData[ \(C + u\^6\/6\)], "Print", CellLabel->"From In[285]:="], Cell[BoxData[ \(C + 1\/6\ \((2 + x)\)\^6\)], "Output", CellLabel->"Out[285]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(\@\(4 t - 1\)\) \[DifferentialD]t] // IntegrateBySubstitution[u \[Rule] 4 t - 1]\)], "Input", CellLabel->"In[286]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@\(4\ t - 1\)\) \[DifferentialD]t\), HoldForm]], "Print", CellLabel->"From In[286]:="], Cell[BoxData[ \({dt \[Rule] du\/4, \(-1\) + 4\ t \[Rule] u}\)], "Print", CellLabel->"From In[286]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\@u\/4\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[286]:="], Cell[BoxData[ \(C + u\^\(3/2\)\/6\)], "Print", CellLabel->"From In[286]:="], Cell[BoxData[ \(C + 1\/6\ \((\(-1\) + 4\ t)\)\^\(3/2\)\)], "Output", CellLabel->"Out[286]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]Cos[7 \[Theta] + 5] \[DifferentialD]\[Theta]] // IntegrateBySubstitution[v \[Rule] 7 \[Theta] + 5]\)], "Input", CellLabel->"In[287]:="], Cell[BoxData[ TagBox[\(\[Integral]Cos[7\ \[Theta] + 5] \[DifferentialD]\[Theta]\), HoldForm]], "Print", CellLabel->"From In[287]:="], Cell[BoxData[ \({d\[Theta] \[Rule] dv\/7, 5 + 7\ \[Theta] \[Rule] v}\)], "Print", CellLabel->"From In[287]:="], Cell[BoxData[ TagBox[\(\[Integral]\(Cos[v]\/7\) \[DifferentialD]v\), HoldForm]], "Print", CellLabel->"From In[287]:="], Cell[BoxData[ \(C + Sin[v]\/7\)], "Print", CellLabel->"From In[287]:="], Cell[BoxData[ \(C + 1\/7\ Sin[5 + 7\ \[Theta]]\)], "Output", CellLabel->"Out[287]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(x\^2\) Sin[x\^3] \[DifferentialD]x] // IntegrateBySubstitution[u \[Rule] x\^3]\)], "Input", CellLabel->"In[288]:="], Cell[BoxData[ TagBox[\(\[Integral]\(x\^2\ Sin[x\^3]\) \[DifferentialD]x\), HoldForm]], "Print", CellLabel->"From In[288]:="], Cell[BoxData[ \({dx \[Rule] du\/\(3\ x\^2\), x\^3 \[Rule] u}\)], "Print", CellLabel->"From In[288]:="], Cell[BoxData[ TagBox[\(\[Integral]\(Sin[u]\/3\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[288]:="], Cell[BoxData[ \(C - Cos[u]\/3\)], "Print", CellLabel->"From In[288]:="], Cell[BoxData[ \(C - Cos[x\^3]\/3\)], "Output", CellLabel->"Out[288]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(1\/Cos[2 \[Theta]]\^2\) \ \[DifferentialD]\[Theta]] // IntegrateBySubstitution[u \[Rule] 2 \[Theta]]\)], "Input", CellLabel->"In[289]:="], Cell[BoxData[ TagBox[\(\[Integral]\(1\/Cos[2\ \[Theta]]\^2\) \[DifferentialD]\[Theta]\), HoldForm]], "Print", CellLabel->"From In[289]:="], Cell[BoxData[ \({d\[Theta] \[Rule] du\/2, 2\ \[Theta] \[Rule] u}\)], "Print", CellLabel->"From In[289]:="], Cell[BoxData[ TagBox[\(\[Integral]\(Sec[u]\^2\/2\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[289]:="], Cell[BoxData[ \(C + Tan[u]\/2\)], "Print", CellLabel->"From In[289]:="], Cell[BoxData[ \(C + 1\/2\ Tan[2\ \[Theta]]\)], "Output", CellLabel->"Out[289]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(\((x\^2 + 2 x - 3)\)\^2\) \((x + 1)\) \[DifferentialD]x] // IntegrateBySubstitution[u \[Rule] x\^2 + 2 x - 3]\)], "Input", CellLabel->"In[290]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\((x\^2 + 2\ x - 3)\)\^2\ \((x + 1)\)\) \[DifferentialD]x\), HoldForm]], "Print", CellLabel->"From In[290]:="], Cell[BoxData[ \({dx \[Rule] du\/\(2 + 2\ x\), \(-3\) + 2\ x + x\^2 \[Rule] u}\)], "Print", CellLabel->"From In[290]:="], Cell[BoxData[ TagBox[\(\[Integral]\(u\^2\/2\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[290]:="], Cell[BoxData[ \(C + u\^3\/6\)], "Print", CellLabel->"From In[290]:="], Cell[BoxData[ \(C + 1\/6\ \((\(-3\) + 2\ x + x\^2)\)\^3\)], "Output", CellLabel->"Out[290]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(Sin[t]\^4\) Cos[t] \[DifferentialD]t] // IntegrateBySubstitution[u \[Rule] Sin[t]]\)], "Input", CellLabel->"In[291]:="], Cell[BoxData[ TagBox[\(\[Integral]\(Sin[t]\^4\ Cos[t]\) \[DifferentialD]t\), HoldForm]], "Print", CellLabel->"From In[291]:="], Cell[BoxData[ \({dt \[Rule] du\ Sec[t], Sin[t] \[Rule] u}\)], "Print", CellLabel->"From In[291]:="], Cell[BoxData[ TagBox[\(\[Integral]\(u\^4\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[291]:="], Cell[BoxData[ \(C + u\^5\/5\)], "Print", CellLabel->"From In[291]:="], Cell[BoxData[ \(C + Sin[t]\^5\/5\)], "Output", CellLabel->"Out[291]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(\(2 z\)\/\@\(z\^2 + 1\)\%3\) \[DifferentialD]z] // IntegrateBySubstitution[u \[Rule] z\^2 + 1]\)], "Input", CellLabel->"In[292]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\(2\ z\)\/\((z\^2 + 1)\)\^\(1/3\)\) \ \[DifferentialD]z\), HoldForm]], "Print", CellLabel->"From In[292]:="], Cell[BoxData[ \({dz \[Rule] du\/\(2\ z\), 1 + z\^2 \[Rule] u}\)], "Print", CellLabel->"From In[292]:="], Cell[BoxData[ TagBox[\(\[Integral]\(1\/u\^\(1/3\)\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[292]:="], Cell[BoxData[ \(C + \(3\ u\^\(2/3\)\)\/2\)], "Print", CellLabel->"From In[292]:="], Cell[BoxData[ \(C + 3\/2\ \((1 + z\^2)\)\^\(2/3\)\)], "Output", CellLabel->"Out[292]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(HoldForm[\[Integral]\(\(2 z\)\/\@\(z\^2 + 1\)\%3\) \[DifferentialD]z] // IntegrateBySubstitution[u \[Rule] \@\(z\^2 + 1\)\%3]\)], "Input", CellLabel->"In[293]:="], Cell[BoxData[ TagBox[\(\[Integral]\(\(2\ z\)\/\((z\^2 + 1)\)\^\(1/3\)\) \ \[DifferentialD]z\), HoldForm]], "Print", CellLabel->"From In[293]:="], Cell[BoxData[ \({dz \[Rule] \(3\ du\ \((1 + z\^2)\)\^\(2/3\)\)\/\(2\ z\), \((1 + \ z\^2)\)\^\(1/3\) \[Rule] u}\)], "Print", CellLabel->"From In[293]:="], Cell[BoxData[ TagBox[\(\[Integral]\(3\ u\) \[DifferentialD]u\), HoldForm]], "Print", CellLabel->"From In[293]:="], Cell[BoxData[ \(C + \(3\ u\^2\)\/2\)], "Print", CellLabel->"From In[293]:="], Cell[BoxData[ \(C + 3\/2\ \((1 + z\^2)\)\^\(2/3\)\)], "Output", CellLabel->"Out[293]="] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["RootsTogether", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?RootsTogether\)\)], "Input", CellLabel->"In[294]:="], Cell[BoxData[ \("RootsTogether[expr] will put factors involving the same kind of root \ together under one root sign. Like PowerExpand it is not always a permissible \ operation. Mathematica automatically removes numeric factors from root \ expressions."\)], "Print", CellTags->"Info3195323910-3120561"] }, Open ]], Cell[TextData[{ Cell[BoxData[ \(RootsTogether\)]], " will combine symbolic radicals under one radical sign. But ", StyleBox["Mathematica", FontSlant->"Italic"], " always factors out numerical factors. ", "To obtain textbook style expressions we have to use a HoldForm and a rule \ to put numerical factors back in the radical." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(Solve[energy \[Equal] m\ v\^2/2, v]\)\[LeftDoubleBracket]2, 1\[RightDoubleBracket]\), "\[IndentingNewLine]", \(% // RootsTogether\), "\[IndentingNewLine]", \(HoldForm @@ {%} /. \(\@n_? NumericQ\) \@x_ \[RuleDelayed] \@\(n\ x\)\)}], "Input", CellLabel->"In[295]:="], Cell[BoxData[ \(v \[Rule] \(\@2\ \@energy\)\/\@m\)], "Output", CellLabel->"Out[295]="], Cell[BoxData[ \(v \[Rule] \@2\ \@\(energy\/m\)\)], "Output", CellLabel->"Out[296]="], Cell[BoxData[ TagBox[\(v \[Rule] \@\(\(2\ energy\)\/m\)\), HoldForm]], "Output", CellLabel->"Out[297]="] }, Open ]], Cell["\<\ Like PowerExpand, this is not always a correct operation. But it is safe if \ all of the quantities under the root signs represent positive numbers, which \ is the case in many simple physics problems.\ \>", "Text"], Cell["RootsTogether will combine similar roots of all kinds.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(\(\(\@a\) \@b\)\/\@\(a + b\)\) \@\(x\^2\)\%3\/\@\(y\^2\)\%3\), "\ \[IndentingNewLine]", \(% // RootsTogether\)}], "Input", CellLabel->"In[298]:="], Cell[BoxData[ \(\(\@a\ \@b\ \((x\^2)\)\^\(1/3\)\)\/\(\@\(a + b\)\ \((y\^2)\)\^\(1/3\)\)\ \)], "Output", CellLabel->"Out[298]="], Cell[BoxData[ \(\@\(\(a\ b\)\/\(a + b\)\)\ \((x\/y)\)\^\(2/3\)\)], "Output", CellLabel->"Out[299]="] }, Open ]], Cell["\<\ You can also do this in Version 4 by specifying conditions for Simplify.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(\(\@a\) \@b\)\/\@\(a + b\)\) \@\(x\^2\)\%3\/\@\(y\^2\)\%3 // Simplify[#, a > 0 \[And] b > 0 \[And] x > 0 \[And] y > 0] &\)], "Input",\ CellLabel->"In[300]:="], Cell[BoxData[ \(\@\(\(a\ b\)\/\(a + b\)\)\ \((x\/y)\)\^\(2/3\)\)], "Output", CellLabel->"Out[300]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["CompleteThe Square", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?CompleteTheSquare\)\)], "Input", CellLabel->"In[301]:="], Cell[BoxData[ \("CompleteTheSquare[expr, var:x] returns expr as a perfect square plus a \ constant. If the variable is not x, it must be supplied as the second \ argument."\)], "Print", CellTags->"Info3195323919-8995725"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(CompleteTheSquare[4 x\^2 - 2 x]\)], "Input", CellLabel->"In[302]:="], Cell[BoxData[ \(\(-\(1\/4\)\) + 4\ \((\(-\(1\/4\)\) + x)\)\^2\)], "Output", CellLabel->"Out[302]="] }, Open ]], Cell["\<\ If the quadratic variable is other than x, it must be supplied as the second \ argument.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(CompleteTheSquare[y\^2 + 3 y + 10, y]\)], "Input", CellLabel->"In[303]:="], Cell[BoxData[ \(31\/4 + \((3\/2 + y)\)\^2\)], "Output", CellLabel->"Out[303]="] }, Open ]], Cell[TextData[{ "The following steps integrate the expression ", Cell[BoxData[ \(1\/\@\(8 x - x\^2\)\)]], "by completing the square and using a substitution to get one of the \ standard integration forms." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(1\/\@\(8 x - x\^2\)\), "\[IndentingNewLine]", \(MapAt[CompleteTheSquare, %, {1}]\), "\[IndentingNewLine]", \(\((subrule = u \[Rule] x - 4; \[IndentingNewLine]%/\((\[PartialD]\_x\ subrule)\)\_\(\(\ \[LeftDoubleBracket]\)\(2\)\(\[RightDoubleBracket]\)\) /. Reverse[subrule])\)\), "\[IndentingNewLine]", \(\(HoldForm[\[Integral]# \[DifferentialD]u] &\) @@ {%}\), "\ \[IndentingNewLine]", \(% + C // ReleaseHold\), "\[IndentingNewLine]", \(% /. subrule\)}], "Input", CellLabel->"In[304]:="], Cell[BoxData[ \(1\/\@\(8\ x - x\^2\)\)], "Output", CellLabel->"Out[304]="], Cell[BoxData[ \(1\/\@\(16 - \((\(-4\) + x)\)\^2\)\)], "Output", CellLabel->"Out[305]="], Cell[BoxData[ \(1\/\@\(16 - u\^2\)\)], "Output", CellLabel->"Out[306]="], Cell[BoxData[ TagBox[\(\[Integral]\(1\/\@\(16 - u\^2\)\) \[DifferentialD]u\), HoldForm]], "Output", CellLabel->"Out[307]="], Cell[BoxData[ \(C + ArcSin[u\/4]\)], "Output", CellLabel->"Out[308]="], Cell[BoxData[ \(C + ArcSin[1\/4\ \((\(-4\) + x)\)]\)], "Output", CellLabel->"Out[309]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["NDTimesExpand", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?NDTimesExpand\)\)], "Input", CellLabel->"In[310]:="], Cell[BoxData[ \("NDTimesExpand[expression, factor] multiplies the numerator and \ denominator of expr by factor and expands each of them."\)], "Print", CellTags->"Info3195323928-9062154"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(NDTimesExpand[1\/\(1 - x\), 1 + x]\)], "Input", CellLabel->"In[311]:="], Cell[BoxData[ \(\(1 + x\)\/\(1 - x\^2\)\)], "Output", CellLabel->"Out[311]="] }, Open ]], Cell[TextData[{ "The following does not work because ", StyleBox["Mathematica", FontSlant->"Italic"], " automatically cancels. The numerator and denominator must be expanded \ before ", StyleBox["Mathematica", FontSlant->"Italic"], " has a chance to cancel." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(1\/\(1 - x\)\) \(1 + x\)\/\(1 + x\)\)], "Input", CellLabel->"In[312]:="], Cell[BoxData[ \(1\/\(1 - x\)\)], "Output", CellLabel->"Out[312]="] }, Open ]], Cell[TextData[{ "Here we integrate ", Cell[BoxData[ \(Sec[x]\)]], " by putting it into a new form and making a substitution." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(Sec[x]\), "\[IndentingNewLine]", \(NDTimesExpand[%, Sec[x] + Tan[x]]\), "\[IndentingNewLine]", \(\((subrule = u \[Rule] Sec[x] + Tan[x]; \[IndentingNewLine]%/\[PartialD]\_x\ subrule\_\(\(\[LeftDoubleBracket]\)\(2\)\(\[RightDoubleBracket]\)\ \) /. Reverse[subrule])\)\), "\[IndentingNewLine]", \(\(HoldForm[\[Integral]# \[DifferentialD]u] &\) @@ {%}\), "\ \[IndentingNewLine]", \(% + C // ReleaseHold\), "\[IndentingNewLine]", \(% /. subrule\)}], "Input", CellLabel->"In[313]:="], Cell[BoxData[ \(Sec[x]\)], "Output", CellLabel->"Out[313]="], Cell[BoxData[ \(\(Sec[x]\^2 + Sec[x]\ Tan[x]\)\/\(Sec[x] + Tan[x]\)\)], "Output", CellLabel->"Out[314]="], Cell[BoxData[ \(1\/u\)], "Output", CellLabel->"Out[315]="], Cell[BoxData[ TagBox[\(\[Integral]\(1\/u\) \[DifferentialD]u\), HoldForm]], "Output", CellLabel->"Out[316]="], Cell[BoxData[ \(C + Log[u]\)], "Output", CellLabel->"Out[317]="], Cell[BoxData[ \(C + Log[Sec[x] + Tan[x]]\)], "Output", CellLabel->"Out[318]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["ErsekComplexity", "Subsection"], Cell[TextData[{ "With Simplify and FullSimplify, ", StyleBox["Mathematica", FontSlant->"Italic"], " uses a complexity function to determine the simplest form of an \ expression. The actual form of the complexity function automatically used by \ ", StyleBox["Mathematica", FontSlant->"Italic"], " is not known to mere users. Ted Ersek has supplied a new complexity \ function which appears, especially with FullSimplify, to work as well or \ better than the Automatic form. It does take somewhat longer to evaluate than \ the Automatic setting. I (David Park) have named the function ErsekComplexity \ to give it a convenient identification." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?ErsekComplexity\)\)], "Input", CellLabel->"In[319]:="], Cell[BoxData[ \("ErsekComplexity is a complexity function for Simplify and FullSimplify \ which sometimes results in simpler expressions but may take longer to run. \ Usage is Simplify[expr, ComplexityFunction \[Rule] ErsekComplexity] and \ likewise for FullSimplify."\)], "Print", CellTags->"Info3195323940-8825526"] }, Open ]], Cell["\<\ Here are a few expressions for which the Automatic complexity function may \ not satisfy.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FullSimplify /@ {1 - Cosh[x] + Sinh[x], 8 \((\(-1\) + x)\) \((1 + x)\), n1 = 59^5*1579^7; n2 = 3^5*19^7*113^5; Log[n1*n2]}\)], "Input", CellLabel->"In[320]:="], Cell[BoxData[ \({1 - Cosh[x] + Sinh[x], 8\ \((\(-1\) + x\^2)\), 7\ Log[19] + 5\ Log[59] + 5\ Log[113] + Log[243] + 7\ Log[1579]}\)], "Output", CellLabel->"Out[320]="] }, Open ]], Cell["Here are the results with the ErsekComplexity function.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(FullSimplify[#, ComplexityFunction \[Rule] ErsekComplexity] &\) /@ {1 - Cosh[x] + Sinh[x], 8 \((\(-1\) + x)\) \((1 + x)\), n1 = 59^5*1579^7; n2 = 3^5*19^7*113^5; Log[n1*n2]}\)], "Input", CellLabel->"In[321]:="], Cell[BoxData[ \({1 - \[ExponentialE]\^\(-x\), 8\ \((\(-1\) + x\^2)\), 5\ Log[20001] + 7\ Log[30001]}\)], "Output", CellLabel->"Out[321]="] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["11 Using the PositionsPalette", "Section"], Cell[CellGroupData[{ Cell["Description of the PositionsPalettes Buttons", "Subsection"], Cell["\<\ \tWhen you read in the package the positions palette should appear. The \ palette is not saved, but generated each session. If the palette is lost you \ can always regenerate it by evaluating PositionsPalette.\ \>", "Text"], Cell[TextData[{ "\tThe ", StyleBox["Capture[\[SelectionPlaceholder]]", Background->RGBColor[0.820005, 0.945006, 0.988006]], " button is used to capture the expression of which you want to find \ subparts. Generally this will be the complete contents of an output cell. \ Select the complete contents and then use the ", StyleBox["Capture[\[SelectionPlaceholder]]", Background->RGBColor[0.820005, 0.945006, 0.988006]], " button. The captured expression will be rewritten in a new cell and \ stored internally by the palette. If the captured expression was in an input \ cell, then the input cell will be rewritten. You can capture just part of the \ cell contents, but if it is an input cell you will lose the rest of cell \ contents. If you try to capture a part of the cell which does not form a \ complete expression, you will get an error message." }], "Text"], Cell[TextData[{ "\tOnce the expression has been captured, you can find the position of \ subexpressions. In the new cell select the subexpression for which you want \ the position. Then use the ", StyleBox["Positions[\[SelectionPlaceholder]]", Background->RGBColor[0.820005, 0.945006, 0.988006]], " button. The position will be printed and the cell will be rewritten with \ the selected part highlighted in light blue." }], "Text"], Cell[TextData[{ "\tWhen the position is printed there is also a message that tells if this \ subexpression has a single position in the expression or multiple positions. \ In the case of multiple positions it tells how many positions it has. You can \ then use the ", StyleBox["NextPosition", Background->RGBColor[0.820005, 0.945006, 0.988006]], " button to cycle through the positions. It is important to note that the \ first position given may not be the one you selected. But each position given \ is also highlighted in the display so you can cycle through to get the one \ you want. (It is a much more difficult problem to make the selection unique \ while maintaining its position, which is why this approach is taken.)" }], "Text"], Cell[TextData[{ "\tBecause of the way that ", StyleBox["Mathematica", FontSlant->"Italic"], " formats expressions, it is not always possible to select certain \ expressions. The principal problem is with rational numbers and denominator \ items. Rational numbers are represented as ", Cell[BoxData[ \(Rational[a, b]\)]], " in the expression, but often the a is in the numerator and the b is in \ the denominator and they cannot be selected together. Actually, when this \ occurs the rational number is at position ", Cell[BoxData[ \({1}\)]], " in its subexpression. Similarly, denominator items are represented as ", Cell[BoxData[ \(Power[item, \ \(-n\)]\)]], " where n is a positive integer or rational number. This subexpression \ cannot be selected as a unit in the normal display. ", Cell[BoxData[ \(\@x\)]], " is not a subpart of ", Cell[BoxData[ \(a/\@x\)]], ". ", Cell[BoxData[ \(Power[x, \(-1\)/2]\)]], " is. To overcome these problems ", StyleBox["Explicit Format", Background->RGBColor[0.820005, 0.945006, 0.988006]], " is provided. Explicit format can be turned On and Off. With explicit \ format, the expression is displayed in such a way that these subparts can be \ selected. With explicit format on, the highlighted display often rearranges \ the position of the subexpression in the cell, but this does not affect the \ actual position found. Explicit format is not intended for general work, but \ only for finding positions. Explicit Format should be turned off when you \ wish to continue with your normal work." }], "Text"], Cell[TextData[{ "\tThe ", StyleBox["Restore", Background->RGBColor[0.820005, 0.945006, 0.988006]], " button is used to rewrite the original captured expression. The \ highlighting will be lost, and if explicit formatting is on, normal order \ will be restored. ", StyleBox["Restore", Background->RGBColor[0.820005, 0.945006, 0.988006]], " is most often used to redisplay the expression after explicit format is \ turned on or off." }], "Text"], Cell[TextData[{ "\tThe cursor should always be in the working cell when using the ", StyleBox["Positions[\[SelectionPlaceholder]]", Background->None], ", NextPosition or Restore buttons. These buttons rewrite the cell \ contents." }], "Text"], Cell[TextData[{ "\tThe positions palette works with StandardForm expressions. Captured \ expressions are not maintained in TraditionalForm. However you could work in \ TraditionalForm while finding positions in StandardForm. The positions \ palette does not always work properly with held expressions. This is because \ when ", StyleBox["Mathematica", FontSlant->"Italic"], " copies and pastes a cell with a held expression, the FullForm expression \ may be changed to a more explicit form which does not match the initial form. \ There are a few other cases where ", StyleBox["Mathematica", FontSlant->"Italic"], " does not maintain the form of an expression when it is copied and an \ incorrect position may be obtained." }], "Text"], Cell["The PositionsPalette does not find extended positions.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Positions Palette Example", "Subsection"], Cell["\<\ This section is just for reading. All the cells have been made nonevaluable \ so as to preserve the various displays you will obtain in working a real \ example.\ \>", "Text"], Cell[TextData[{ "Suppose that we have the following expression and its output cell and you \ want to find the position of ", Cell[BoxData[ \(Sin[a\ x]\)]], " in the denominator." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(y \[Rule] \(x\ Sin[a\ x] E\^\(\(-b\)\ x\^2\)\)\/\@\(2 + Sin[a\ x] + \ Cos[b\ x]\)\)], "Input", CellLabel->"In[10]:=", Evaluatable->False], Cell[BoxData[ \(y \[Rule] \(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\)\/\@\(2 + \ Cos[b\ x] + Sin[a\ x]\)\)], "Output", CellLabel->"Out[10]="] }, Open ]], Cell[TextData[{ "Select the entire output cell and use ", Cell[BoxData[ StyleBox[\(Capture[\[SelectionPlaceholder]]\), Background->RGBColor[0.820005, 0.945006, 0.988006]]]], ". " }], "Text"], Cell[BoxData[ StyleBox[\(y \[Rule] \(x\ Sin[a\ x] E\^\(\(-b\)\ x\^2\)\)\/\@\(2 + Sin[a\ \ x] + Cos[b\ x]\)\), FontColor->GrayLevel[1], Background->GrayLevel[0]]], "Input", Evaluatable->False], Cell["\<\ We then get a copy of the output cell which we can use to find the position. \ Everything will happen in the following cell, but I will copy it to show the \ various stages.\ \>", "Text"], Cell[BoxData[ \(y \[Rule] \(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\)\/\@\(2 + \ Cos[b\ x] + Sin[a\ x]\)\)], "Input", CellLabel->"Out[10]=", Evaluatable->False], Cell[TextData[{ "Now select ", Cell[BoxData[ \(Sin[a\ x]\)]], " in the denominator and use the ", Cell[BoxData[ StyleBox[\(Positions[\[SelectionPlaceholder]]\), Background->RGBColor[0.820005, 0.945006, 0.988006]]]], " button. " }], "Text"], Cell[BoxData[ RowBox[{"y", "\[Rule]", FractionBox[\(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\), SqrtBox[ RowBox[{"2", "+", \(Cos[b\ x]\), "+", StyleBox[\(Sin[a\ x]\), FontColor->GrayLevel[1], Background->GrayLevel[0]]}]]]}]], "Input", Evaluatable->False], Cell["We obtain....", "Text"], Cell[CellGroupData[{ Cell[BoxData[ TagBox[ RowBox[{"y", "\[Rule]", FractionBox[ RowBox[{\(\[ExponentialE]\^\(\(-b\)\ x\^2\)\), " ", "x", " ", TagBox[ StyleBox[\(Sin[a\ x]\), Background->RGBColor[0.691417, 0.98439, 0.992203]], ( StyleForm[ #, Background -> RGBColor[ .69141699999999995, .98438999999999999, \ .99220299999999995]]&)]}], \(\@\(2 + Cos[b\ x] + Sin[a\ x]\)\)]}], HoldForm]], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell[TextData[{ "This gives us a position for ", Cell[BoxData[ \(Sin[a\ x]\)]], " but not the one we want because there are actually two positions for the \ subexpression. Use the ", Cell[BoxData[ StyleBox["NextPosition", Background->RGBColor[0.820005, 0.945006, 0.988006]]]], " button to obtain the second position which is the one we want." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ TagBox[ RowBox[{"y", "\[Rule]", FractionBox[\(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\), SqrtBox[ RowBox[{"2", "+", \(Cos[b\ x]\), "+", TagBox[ StyleBox[\(Sin[a\ x]\), Background->RGBColor[0.691417, 0.98439, 0.992203]], ( StyleForm[ #, Background -> RGBColor[ .69141699999999995, .98438999999999999, \ .99220299999999995]]&)]}]]]}], HoldForm]], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 4, 1, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell[TextData[{ "So ", Cell[BoxData[ \({2, 4, 1, 3}\)]], " is the position that we want. Suppose instead that we wanted the position \ of the square root in the denominator. Select it..." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ TagBox[ RowBox[{"y", "\[Rule]", FractionBox[\(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\), StyleBox[ SqrtBox[ RowBox[{"2", "+", \(Cos[b\ x]\), "+", TagBox[\(Sin[a\ x]\), ( StyleForm[ #, Background -> RGBColor[ .69141699999999995, .98438999999999999, \ .99220299999999995]]&)]}]], FontColor->GrayLevel[1], Background->GrayLevel[0]]]}], HoldForm]], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 4, 1, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell[TextData[{ "... and use the ", Cell[BoxData[ StyleBox[\(Positions[\[SelectionPlaceholder]]\), Background->RGBColor[0.820005, 0.945006, 0.988006]]]], " button." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ TagBox[ RowBox[{"y", "\[Rule]", FractionBox[\(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\), SqrtBox[ RowBox[{"2", "+", \(Cos[b\ x]\), "+", TagBox[ StyleBox[\(Sin[a\ x]\), Background->RGBColor[0.691417, 0.98439, 0.992203]], ( StyleForm[ #, Background -> RGBColor[ .69141699999999995, .98438999999999999, \ .99220299999999995]]&)]}]]]}], HoldForm]], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 4, 1, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \("Selection does not have a position."\)], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell[TextData[{ "No such subexpression actually occurs in the expression and our display \ remained unchanged. To do this properly we must use explicit format. Click \ the ", Cell[BoxData[ StyleBox["On", Background->RGBColor[0.820005, 0.945006, 0.988006]]]], " button for Explicit Format. Then use the ", Cell[BoxData[ StyleBox["Restore", Background->RGBColor[0.820005, 0.945006, 0.988006]]]], " button. We now obtain a more explicit formatting of the expression." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(y \[Rule] \(\((2 + Cos[b\ x] + Sin[a\ x])\)\^\(-\(1\/2\)\)\) \[ExponentialE]\^\(\(-b\)\ x\^2\ \)\ x\ Sin[a\ x]\)], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 4, 1, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \("Selection does not have a position."\)], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell["\<\ We can now select the \"denominator\" subexpression and find its position.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ TagBox[ RowBox[{"y", "\[Rule]", RowBox[{\(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\), RowBox[{"(", TagBox[ StyleBox[\(\((2 + Cos[b\ x] + Sin[a\ x])\)\^\(-\(1\/2\)\)\), Background->RGBColor[0.691417, 0.98439, 0.992203]], ( StyleForm[ #, Background -> RGBColor[ .69141699999999995, .98438999999999999, \ .99220299999999995]]&)], ")"}]}]}], HoldForm]], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 4, 1, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \("Selection does not have a position."\)], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \({{2, 4}, "Single Position"}\)], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell[TextData[{ "Notice that the display order of the factors has been changed with \ highlighting in explicit format. However this does not change the correctness \ of the position obtained. We can even find the position of the exponent ", Cell[BoxData[ \(\(-1\)/2\)]], ", which was completely inaccessable with regular formatting." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ TagBox[ RowBox[{"y", "\[Rule]", RowBox[{\(\[ExponentialE]\^\(\(-b\)\ x\^2\)\), " ", "x", " ", \(Sin[a\ x]\), " ", SuperscriptBox[\((2 + Cos[b\ x] + Sin[a\ x])\), TagBox[ StyleBox[\(-\(1\/2\)\), Background->RGBColor[0.691417, 0.98439, 0.992203]], ( StyleForm[ #, Background -> RGBColor[ .69141699999999995, .98438999999999999, \ .99220299999999995]]&)]]}]}], HoldForm]], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 4, 1, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \("Selection does not have a position."\)], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \({{2, 4}, "Single Position"}\)], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \({{2, 4, 2}, "Single Position"}\)], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell[TextData[{ "If you want to switch back to regular format click the ", Cell[BoxData[ StyleBox["Off", Background->RGBColor[0.820005, 0.945006, 0.988006]]]], " button for explicit format and use ", Cell[BoxData[ StyleBox["Restore", Background->RGBColor[0.820005, 0.945006, 0.988006]]]], " again." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(y \[Rule] \(\[ExponentialE]\^\(\(-b\)\ x\^2\)\ x\ Sin[a\ x]\)\/\@\(2 + \ Cos[b\ x] + Sin[a\ x]\)\)], "Input", Evaluatable->False], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ RowBox[{"{", RowBox[{\({2, 4, 1, 3}\), ",", InterpretationBox["\<\" \\!\\(2\\) Positions\"\>", StringForm[ " `` Positions", 2], Editable->False]}], "}"}]], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \("Selection does not have a position."\)], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \({{2, 4}, "Single Position"}\)], "Print", CellLabel->"From In[2]:="], Cell[BoxData[ \({{2, 4, 2}, "Single Position"}\)], "Print", CellLabel->"From In[2]:="] }, Open ]], Cell["\<\ Once you have the position of the part you wish you can delete the entire \ working cell and use the position to modify your original expression.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["An Example for you to work", "Subsection"], Cell[TextData[{ "Find the positions of ", Cell[BoxData[ \(a\)]], " in the ", Cell[BoxData[ \(Sin[a\ x]\)]], " and in the ", Cell[BoxData[ \(\@\(a + x\)\)]], ". Also find the position of the rational number ", Cell[BoxData[ \(2/3\)]], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = y[x] \[Equal] 2 \((x + x\^2)\) Sin[a\ x]/\((3 \@\( a + x\))\)\)], "Input", CellLabel->"In[322]:="], Cell[BoxData[ \(y[x] == \(2\ \((x + x\^2)\)\ Sin[a\ x]\)\/\(3\ \@\(a + x\)\)\)], \ "Output", CellLabel->"Out[322]="] }, Open ]], Cell[CellGroupData[{ Cell["Answers", "Subsubsection"], Cell[TextData[{ "The ", Cell[BoxData[ \(a\)]], " in ", Cell[BoxData[ \(Sin[a\ x]\)]], " occurs at position ", Cell[BoxData[ \({2, 4, 1, 1}\)]], "." }], "Text"], Cell[TextData[{ "The ", Cell[BoxData[ \(a\)]], " in ", Cell[BoxData[ \(\@\(a + x\)\)]], " occurs at position ", Cell[BoxData[ \({2, 2, 1, 1}\)]], "." }], "Text"], Cell[TextData[{ "The rational number ", Cell[BoxData[ \(2/3\)]], " occurs at position ", Cell[BoxData[ \({2, 1}\)]] }], "Text"], Cell["Here the positions are used to replace the parts.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ReplacePart[expr, "\", {2, 4, 1, 1}]\)], "Input", CellLabel->"In[323]:="], Cell[BoxData[ \(y[x] == \(2\ \((x + x\^2)\)\ Sin["firsta"\ x]\)\/\(3\ \@\(a + x\)\)\)], \ "Output", CellLabel->"Out[323]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(ReplacePart[expr, "\", {2, 2, 1, 1}]\)], "Input", CellLabel->"In[324]:="], Cell[BoxData[ \(y[x] == \(2\ \((x + x\^2)\)\ Sin[a\ x]\)\/\(3\ \@\("seconda" + \ x\)\)\)], "Output", CellLabel->"Out[324]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(ReplacePart[expr, "\", {2, 1}]\)], "Input", CellLabel->"In[325]:="], Cell[BoxData[ \(y[x] == \("rational"\ \((x + x\^2)\)\ Sin[a\ x]\)\/\@\(a + x\)\)], \ "Output", CellLabel->"Out[325]="] }, Open ]] }, Closed]] }, Closed]] }, Closed]] }, Open ]] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 943}}, AutoGeneratedPackage->None, WindowSize->{735, 756}, WindowMargins->{{3, Automatic}, {Automatic, 0}}, ShowSelection->True, Magnification->1, StyleDefinitions -> "TutorialBook.nb" ] (******************************************************************* 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->{ "Info3195323465-9333467"->{ Cell[18495, 655, 351, 6, 66, "Print", CellTags->"Info3195323465-9333467"]}, "Info3196846179-1302708"->{ Cell[25602, 909, 678, 10, 161, "Print", CellTags->"Info3196846179-1302708"]}, "Info3196847581-4883457"->{ Cell[66282, 2096, 392, 6, 104, "Print", CellTags->"Info3196847581-4883457"]}, "Info3196850217-4712458"->{ Cell[79161, 2486, 421, 6, 85, "Print", CellTags->"Info3196850217-4712458"]}, "Info3195323592-9236389"->{ Cell[84403, 2647, 428, 6, 104, "Print", CellTags->"Info3195323592-9236389"]}, "Info3195323620-8066706"->{ Cell[89462, 2830, 635, 13, 104, "Print", CellTags->"Info3195323620-8066706"]}, "Info3195323635-2346324"->{ Cell[92462, 2937, 790, 15, 142, "Print", CellTags->"Info3195323635-2346324"]}, "Info3195323647-8764614"->{ Cell[94069, 2992, 698, 14, 123, "Print", CellTags->"Info3195323647-8764614"]}, "Info3196850340-4676273"->{ Cell[96232, 3064, 349, 5, 85, "Print", CellTags->"Info3196850340-4676273"]}, "Info3195323771-9489066"->{ Cell[119993, 3930, 193, 3, 47, "Print", CellTags->"Info3195323771-9489066"]}, "Info3195323872-6948727"->{ Cell[145154, 4776, 253, 4, 48, "Print", CellTags->"Info3195323872-6948727"]}, "Info3195323910-3120561"->{ Cell[155735, 5188, 309, 5, 66, "Print", CellTags->"Info3195323910-3120561"]}, "Info3195323919-8995725"->{ Cell[158466, 5285, 227, 4, 47, "Print", CellTags->"Info3195323919-8995725"]}, "Info3195323928-9062154"->{ Cell[160864, 5380, 193, 3, 47, "Print", CellTags->"Info3195323928-9062154"]}, "Info3195323940-8825526"->{ Cell[163921, 5495, 323, 5, 66, "Print", CellTags->"Info3195323940-8825526"]} } *) (*CellTagsIndex CellTagsIndex->{ {"Info3195323465-9333467", 187048, 6255}, {"Info3196846179-1302708", 187164, 6258}, {"Info3196847581-4883457", 187282, 6261}, {"Info3196850217-4712458", 187400, 6264}, {"Info3195323592-9236389", 187517, 6267}, {"Info3195323620-8066706", 187635, 6270}, {"Info3195323635-2346324", 187754, 6273}, {"Info3195323647-8764614", 187873, 6276}, {"Info3196850340-4676273", 187992, 6279}, {"Info3195323771-9489066", 188109, 6282}, {"Info3195323872-6948727", 188227, 6285}, {"Info3195323910-3120561", 188345, 6288}, {"Info3195323919-8995725", 188463, 6291}, {"Info3195323928-9062154", 188581, 6294}, {"Info3195323940-8825526", 188699, 6297} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1727, 52, 128, 5, 128, "Title"], Cell[1858, 59, 220, 6, 91, "Subtitle"], Cell[2081, 67, 360, 7, 120, "Subtitle"], Cell[2444, 76, 95, 2, 28, "Text"], Cell[CellGroupData[{ Cell[2564, 82, 33, 0, 92, "Section"], Cell[2600, 84, 185, 4, 48, "Text"], Cell[2788, 90, 101, 2, 31, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[2926, 97, 33, 0, 92, "Section"], Cell[2962, 99, 588, 13, 88, "Text"], Cell[3553, 114, 760, 11, 148, "Text"], Cell[4316, 127, 571, 16, 68, "Text"], Cell[4890, 145, 966, 21, 148, "Text"], Cell[5859, 168, 454, 11, 68, "Text"], Cell[6316, 181, 974, 29, 128, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[7327, 215, 57, 0, 60, "Section"], Cell[7387, 217, 120, 5, 28, "Text"], Cell[CellGroupData[{ Cell[7532, 226, 68, 2, 32, "Input"], Cell[7603, 230, 69, 2, 30, "Output"] }, Open ]], Cell[7687, 235, 578, 21, 68, "Text"], Cell[CellGroupData[{ Cell[8290, 260, 83, 2, 32, "Input"], Cell[8376, 264, 60, 2, 30, "Output"] }, Open ]], Cell[8451, 269, 420, 9, 68, "Text"], Cell[8874, 280, 183, 4, 48, "Text"], Cell[CellGroupData[{ Cell[9082, 288, 89, 2, 32, "Input"], Cell[9174, 292, 75, 2, 30, "Output"] }, Open ]], Cell[9264, 297, 318, 7, 68, "Text"], Cell[CellGroupData[{ Cell[9607, 308, 93, 2, 32, "Input"], Cell[9703, 312, 93, 3, 30, "Output"] }, Open ]], Cell[9811, 318, 348, 12, 48, "Text"], Cell[CellGroupData[{ Cell[10184, 334, 105, 2, 31, "Input"], Cell[10292, 338, 90, 3, 30, "Output"] }, Open ]], Cell[10397, 344, 57, 0, 28, "Text"], Cell[CellGroupData[{ Cell[10479, 348, 78, 2, 31, "Input"], Cell[10560, 352, 79, 2, 30, "Output"] }, Open ]], Cell[10654, 357, 372, 10, 68, "Text"], Cell[CellGroupData[{ Cell[11051, 371, 86, 2, 31, "Input"], Cell[11140, 375, 84, 2, 30, "Output"] }, Open ]], Cell[11239, 380, 135, 3, 28, "Text"], Cell[CellGroupData[{ Cell[11399, 387, 108, 2, 31, "Input"], Cell[11510, 391, 90, 3, 30, "Output"] }, Open ]], Cell[11615, 397, 182, 4, 48, "Text"], Cell[CellGroupData[{ Cell[11822, 405, 104, 2, 31, "Input"], Cell[11929, 409, 98, 2, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[12064, 416, 91, 2, 32, "Input"], Cell[12158, 420, 94, 3, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[12289, 428, 88, 2, 31, "Input"], Cell[12380, 432, 91, 3, 30, "Output"] }, Open ]], Cell[12486, 438, 106, 3, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[12629, 446, 45, 0, 60, "Section"], Cell[12677, 448, 680, 14, 108, "Text"], Cell[CellGroupData[{ Cell[13382, 466, 228, 5, 100, "Input"], Cell[13613, 473, 91, 3, 30, "Output"], Cell[13707, 478, 91, 3, 30, "Output"], Cell[13801, 483, 91, 3, 30, "Output"], Cell[13895, 488, 60, 2, 30, "Output"] }, Open ]], Cell[13970, 493, 1014, 18, 168, "Text"], Cell[14987, 513, 309, 7, 48, "Text"], Cell[15299, 522, 295, 5, 68, "Text"], Cell[CellGroupData[{ Cell[15619, 531, 127, 3, 55, "Input"], Cell[15749, 536, 67, 2, 30, "Output"], Cell[15819, 540, 113, 3, 44, "Output"] }, Open ]], Cell[15947, 546, 58, 0, 28, "Text"], Cell[CellGroupData[{ Cell[16030, 550, 142, 3, 55, "Input"], Cell[16175, 555, 67, 2, 30, "Output"], Cell[16245, 559, 126, 3, 44, "Output"] }, Open ]], Cell[16386, 565, 244, 7, 48, "Text"], Cell[CellGroupData[{ Cell[16655, 576, 145, 3, 55, "Input"], Cell[16803, 581, 67, 2, 30, "Output"], Cell[16873, 585, 126, 3, 44, "Output"] }, Open ]], Cell[17014, 591, 99, 2, 28, "Text"], Cell[CellGroupData[{ Cell[17138, 597, 94, 2, 31, "Input"], Cell[17235, 601, 100, 3, 30, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[17384, 610, 42, 0, 60, "Section"], Cell[17429, 612, 156, 7, 28, "Text"], Cell[CellGroupData[{ Cell[17610, 623, 162, 3, 54, "Input"], Cell[17775, 628, 101, 3, 30, "Output"], Cell[17879, 633, 101, 3, 30, "Output"] }, Open ]], Cell[17995, 639, 392, 8, 68, "Text"], Cell[CellGroupData[{ Cell[18412, 651, 80, 2, 31, "Input"], Cell[18495, 655, 351, 6, 66, "Print", CellTags->"Info3195323465-9333467"] }, Open ]], Cell[18861, 664, 395, 10, 68, "Text"], Cell[CellGroupData[{ Cell[19281, 678, 224, 4, 77, "Input"], Cell[19508, 684, 101, 3, 30, "Output"], Cell[19612, 689, 101, 3, 30, "Output"], Cell[19716, 694, 99, 3, 30, "Output"] }, Open ]], Cell[19830, 700, 305, 7, 48, "Text"], Cell[CellGroupData[{ Cell[20160, 711, 238, 4, 77, "Input"], Cell[20401, 717, 101, 3, 30, "Output"], Cell[20505, 722, 101, 3, 30, "Output"], Cell[20609, 727, 95, 3, 30, "Output"] }, Open ]], Cell[20719, 733, 955, 25, 128, "Text"], Cell[CellGroupData[{ Cell[21699, 762, 289, 5, 100, "Input"], Cell[21991, 769, 101, 3, 30, "Output"], Cell[22095, 774, 101, 3, 30, "Output"], Cell[22199, 779, 95, 3, 30, "Output"], Cell[22297, 784, 83, 3, 30, "Output"] }, Open ]], Cell[22395, 790, 313, 7, 48, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[22745, 802, 53, 0, 60, "Section"], Cell[22801, 804, 635, 9, 128, "Text"], Cell[23439, 815, 54, 0, 28, "Text"], Cell[CellGroupData[{ Cell[23518, 819, 72, 2, 31, "Input"], Cell[23593, 823, 66, 2, 30, "Output"] }, Open ]], Cell[23674, 828, 162, 5, 28, "Text"], Cell[CellGroupData[{ Cell[23861, 837, 71, 2, 31, "Input"], Cell[23935, 841, 230, 7, 44, "Output"] }, Open ]], Cell[24180, 851, 276, 7, 48, "Text"], Cell[CellGroupData[{ Cell[24481, 862, 80, 2, 31, "Input"], Cell[24564, 866, 66, 2, 30, "Output"] }, Open ]], Cell[24645, 871, 704, 23, 88, "Text"], Cell[25352, 896, 146, 5, 28, "Text"], Cell[CellGroupData[{ Cell[25523, 905, 76, 2, 31, "Input"], Cell[25602, 909, 678, 10, 161, "Print", CellTags->"Info3196846179-1302708"] }, Open ]], Cell[26295, 922, 221, 6, 48, "Text"], Cell[CellGroupData[{ Cell[26541, 932, 84, 2, 31, "Input"], Cell[26628, 936, 1144, 31, 32, "Output"] }, Open ]], Cell[27787, 970, 286, 7, 48, "Text"], Cell[CellGroupData[{ Cell[28098, 981, 106, 2, 31, "Input"], Cell[28207, 985, 59, 2, 30, "Output"] }, Open ]], Cell[28281, 990, 195, 6, 48, "Text"], Cell[CellGroupData[{ Cell[28501, 1000, 115, 2, 31, "Input"], Cell[28619, 1004, 907, 26, 31, "Output"] }, Open ]], Cell[29541, 1033, 257, 4, 48, "Text"], Cell[CellGroupData[{ Cell[29823, 1041, 112, 2, 31, "Input"], Cell[29938, 1045, 507, 16, 30, "Output"] }, Open ]], Cell[30460, 1064, 219, 4, 48, "Text"], Cell[CellGroupData[{ Cell[30704, 1072, 223, 5, 77, "Input"], Cell[30930, 1079, 67, 2, 30, "Output"], Cell[31000, 1083, 80, 2, 30, "Output"], Cell[31083, 1087, 3022, 81, 32, "Output"] }, Open ]], Cell[34120, 1171, 123, 3, 28, "Text"], Cell[CellGroupData[{ Cell[34268, 1178, 120, 3, 31, "Input"], Cell[34391, 1183, 3011, 81, 32, "Output"] }, Open ]], Cell[37417, 1267, 170, 6, 28, "Text"], Cell[CellGroupData[{ Cell[37612, 1277, 182, 4, 77, "Input"], Cell[37797, 1283, 67, 2, 30, "Output"], Cell[37867, 1287, 102, 2, 30, "Output"], Cell[37972, 1291, 13035, 266, 32, "Output"] }, Open ]], Cell[51022, 1560, 415, 11, 68, "Text"], Cell[CellGroupData[{ Cell[51462, 1575, 266, 6, 77, "Input"], Cell[51731, 1583, 67, 2, 30, "Output"], Cell[51801, 1587, 85, 2, 30, "Output"], Cell[51889, 1591, 5275, 127, 32, "Output"] }, Open ]], Cell[57179, 1721, 459, 15, 68, "Text"], Cell[57641, 1738, 216, 4, 48, "Text"], Cell[57860, 1744, 128, 3, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[58025, 1752, 59, 0, 60, "Section"], Cell[58087, 1754, 133, 3, 28, "Text"], Cell[CellGroupData[{ Cell[58245, 1761, 73, 2, 31, "Input"], Cell[58321, 1765, 67, 2, 30, "Output"] }, Open ]], Cell[58403, 1770, 144, 5, 28, "Text"], Cell[CellGroupData[{ Cell[58572, 1779, 154, 3, 54, "Input"], Cell[58729, 1784, 61, 2, 30, "Output"], Cell[58793, 1788, 91, 3, 30, "Output"] }, Open ]], Cell[58899, 1794, 171, 5, 28, "Text"], Cell[CellGroupData[{ Cell[59095, 1803, 69, 2, 31, "Input"], Cell[59167, 1807, 63, 2, 30, "Output"] }, Open ]], Cell[59245, 1812, 376, 7, 68, "Text"], Cell[CellGroupData[{ Cell[59646, 1823, 82, 2, 31, "Input"], Cell[59731, 1827, 76, 2, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[59844, 1834, 174, 4, 54, "Input"], Cell[60021, 1840, 64, 2, 30, "Output"], Cell[60088, 1844, 794, 24, 30, "Output"] }, Open ]], Cell[60897, 1871, 108, 3, 28, "Text"], Cell[CellGroupData[{ Cell[61030, 1878, 71, 2, 31, "Input"], Cell[61104, 1882, 65, 2, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[61206, 1889, 156, 3, 54, "Input"], Cell[61365, 1894, 64, 2, 30, "Output"], Cell[61432, 1898, 794, 24, 30, "Output"] }, Open ]], Cell[62241, 1925, 723, 14, 128, "Text"], Cell[CellGroupData[{ Cell[62989, 1943, 112, 3, 59, "Input"], Cell[63104, 1948, 65, 2, 49, "Output"], Cell[63172, 1952, 240, 7, 44, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[63449, 1964, 73, 2, 35, "Input"], Cell[63525, 1968, 235, 7, 44, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[63809, 1981, 39, 0, 60, "Section"], Cell[CellGroupData[{ Cell[63873, 1985, 38, 0, 44, "Subsection"], Cell[63914, 1987, 137, 3, 28, "Text"], Cell[CellGroupData[{ Cell[64076, 1994, 101, 2, 46, "Input"], Cell[64180, 1998, 95, 2, 44, "Output"] }, Open ]], Cell[64290, 2003, 235, 6, 48, "Text"], Cell[CellGroupData[{ Cell[64550, 2013, 95, 2, 31, "Input"], Cell[64648, 2017, 83, 2, 44, "Output"] }, Open ]], Cell[64746, 2022, 102, 5, 28, "Text"], Cell[CellGroupData[{ Cell[64873, 2031, 79, 2, 31, "Input"], Cell[64955, 2035, 61, 2, 30, "Output"] }, Open ]], Cell[65031, 2040, 241, 9, 48, "Text"], Cell[CellGroupData[{ Cell[65297, 2053, 87, 2, 31, "Input"], Cell[65387, 2057, 230, 7, 44, "Output"] }, Open ]], Cell[65632, 2067, 261, 8, 48, "Text"], Cell[CellGroupData[{ Cell[65918, 2079, 94, 2, 31, "Input"], Cell[66015, 2083, 96, 2, 30, "Output"] }, Open ]], Cell[66126, 2088, 63, 0, 28, "Text"], Cell[CellGroupData[{ Cell[66214, 2092, 65, 2, 31, "Input"], Cell[66282, 2096, 392, 6, 104, "Print", CellTags->"Info3196847581-4883457"] }, Open ]], Cell[66689, 2105, 109, 3, 28, "Text"], Cell[CellGroupData[{ Cell[66823, 2112, 95, 2, 31, "Input"], Cell[66921, 2116, 1950, 55, 52, "Output"] }, Open ]], Cell[68886, 2174, 442, 16, 68, "Text"], Cell[69331, 2192, 315, 10, 48, "Text"], Cell[CellGroupData[{ Cell[69671, 2206, 86, 2, 31, "Input"], Cell[69760, 2210, 2211, 60, 52, "Output"] }, Open ]], Cell[71986, 2273, 566, 22, 68, "Text"], Cell[CellGroupData[{ Cell[72577, 2299, 171, 4, 54, "Input"], Cell[72751, 2305, 95, 2, 44, "Output"], Cell[72849, 2309, 87, 2, 44, "Output"] }, Open ]], Cell[72951, 2314, 88, 2, 28, "Text"], Cell[73042, 2318, 252, 6, 48, "Text"], Cell[CellGroupData[{ Cell[73319, 2328, 186, 4, 54, "Input"], Cell[73508, 2334, 158, 4, 30, "Output"], Cell[73669, 2340, 5088, 126, 52, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[78806, 2472, 37, 0, 38, "Subsection"], Cell[78846, 2474, 209, 4, 48, "Text"], Cell[CellGroupData[{ Cell[79080, 2482, 78, 2, 31, "Input"], Cell[79161, 2486, 421, 6, 85, "Print", CellTags->"Info3196850217-4712458"] }, Open ]], Cell[79597, 2495, 88, 2, 28, "Text"], Cell[CellGroupData[{ Cell[79710, 2501, 274, 6, 96, "Input"], Cell[79987, 2509, 130, 3, 46, "Output"], Cell[80120, 2514, 96, 2, 30, "Output"], Cell[80219, 2518, 2656, 69, 52, "Output"] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[82936, 2594, 32, 0, 60, "Section"], Cell[82971, 2596, 398, 9, 68, "Text"], Cell[CellGroupData[{ Cell[83394, 2609, 191, 4, 77, "Input"], Cell[83588, 2615, 94, 3, 30, "Output"], Cell[83685, 2620, 106, 3, 30, "Output"], Cell[83794, 2625, 257, 7, 44, "Output"] }, Open ]], Cell[84066, 2635, 235, 4, 48, "Text"], Cell[CellGroupData[{ Cell[84326, 2643, 74, 2, 31, "Input"], Cell[84403, 2647, 428, 6, 104, "Print", CellTags->"Info3195323592-9236389"] }, Open ]], Cell[CellGroupData[{ Cell[84868, 2658, 257, 5, 100, "Input"], Cell[85128, 2665, 94, 3, 30, "Output"], Cell[85225, 2670, 106, 3, 30, "Output"], Cell[85334, 2675, 100, 3, 30, "Output"], Cell[85437, 2680, 79, 2, 30, "Output"] }, Open ]], Cell[85531, 2685, 133, 3, 28, "Text"], Cell[CellGroupData[{ Cell[85689, 2692, 392, 8, 123, "Input"], Cell[86084, 2702, 116, 3, 30, "Output"], Cell[86203, 2707, 138, 3, 30, "Output"], Cell[86344, 2712, 135, 3, 30, "Output"] }, Open ]], Cell[86494, 2718, 242, 4, 48, "Text"], Cell[CellGroupData[{ Cell[86761, 2726, 273, 6, 77, "Input"], Cell[87037, 2734, 116, 3, 30, "Output"], Cell[87156, 2739, 138, 3, 30, "Output"], Cell[87297, 2744, 135, 3, 30, "Output"] }, Open ]], Cell[87447, 2750, 43, 0, 28, "Text"], Cell[CellGroupData[{ Cell[87515, 2754, 341, 7, 100, "Input"], Cell[87859, 2763, 116, 3, 30, "Output"], Cell[87978, 2768, 138, 3, 30, "Output"], Cell[88119, 2773, 132, 3, 30, "Output"], Cell[88254, 2778, 79, 2, 30, "Output"] }, Open ]], Cell[88348, 2783, 208, 4, 48, "Text"], Cell[88559, 2789, 70, 2, 31, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[88666, 2796, 60, 0, 60, "Section"], Cell[88729, 2798, 145, 3, 28, "Text"], Cell[CellGroupData[{ Cell[88899, 2805, 120, 3, 48, "Input"], Cell[89022, 2810, 112, 2, 45, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[89171, 2817, 29, 0, 44, "Subsection"], Cell[89203, 2819, 160, 3, 48, "Text"], Cell[CellGroupData[{ Cell[89388, 2826, 71, 2, 31, "Input"], Cell[89462, 2830, 635, 13, 104, "Print", CellTags->"Info3195323620-8066706"] }, Open ]], Cell[90112, 2846, 92, 2, 28, "Text"], Cell[CellGroupData[{ Cell[90229, 2852, 286, 6, 100, "Input"], Cell[90518, 2860, 137, 3, 45, "Output"], Cell[90658, 2865, 137, 3, 45, "Output"], Cell[90798, 2870, 80, 2, 30, "Output"], Cell[90881, 2874, 68, 2, 30, "Output"] }, Open ]], Cell[90964, 2879, 262, 8, 48, "Text"], Cell[CellGroupData[{ Cell[91251, 2891, 296, 6, 100, "Input"], Cell[91550, 2899, 137, 3, 45, "Output"], Cell[91690, 2904, 137, 3, 45, "Output"], Cell[91830, 2909, 80, 2, 30, "Output"], Cell[91913, 2913, 121, 4, 30, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[92083, 2923, 33, 0, 38, "Subsection"], Cell[92119, 2925, 240, 4, 48, "Text"], Cell[CellGroupData[{ Cell[92384, 2933, 75, 2, 31, "Input"], Cell[92462, 2937, 790, 15, 142, "Print", CellTags->"Info3195323635-2346324"] }, Open ]], Cell[CellGroupData[{ Cell[93289, 2957, 195, 4, 77, "Input"], Cell[93487, 2963, 113, 2, 45, "Output"], Cell[93603, 2967, 77, 2, 30, "Output"], Cell[93683, 2971, 108, 2, 45, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[93840, 2979, 27, 0, 38, "Subsection"], Cell[93870, 2981, 102, 3, 28, "Text"], Cell[CellGroupData[{ Cell[93997, 2988, 69, 2, 31, "Input"], Cell[94069, 2992, 698, 14, 123, "Print", CellTags->"Info3195323647-8764614"] }, Open ]], Cell[94782, 3009, 224, 4, 48, "Text"], Cell[CellGroupData[{ Cell[95031, 3017, 347, 6, 123, "Input"], Cell[95381, 3025, 113, 2, 45, "Output"], Cell[95497, 3029, 77, 2, 30, "Output"], Cell[95577, 3033, 134, 3, 50, "Output"], Cell[95714, 3038, 80, 2, 30, "Output"], Cell[95797, 3042, 146, 3, 53, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[95992, 3051, 33, 0, 38, "Subsection"], Cell[96028, 3053, 103, 3, 28, "Text"], Cell[CellGroupData[{ Cell[96156, 3060, 73, 2, 31, "Input"], Cell[96232, 3064, 349, 5, 85, "Print", CellTags->"Info3196850340-4676273"] }, Open ]], Cell[96596, 3072, 139, 5, 28, "Text"], Cell[CellGroupData[{ Cell[96760, 3081, 242, 5, 75, "Input"], Cell[97005, 3088, 191, 4, 47, "Output"], Cell[97199, 3094, 88, 2, 44, "Output"] }, Open ]], Cell[97302, 3099, 605, 19, 88, "Text"], Cell[CellGroupData[{ Cell[97932, 3122, 519, 11, 144, "Input"], Cell[98454, 3135, 2541, 66, 47, "Output"], Cell[100998, 3203, 143, 3, 45, "Output"], Cell[101144, 3208, 207, 4, 45, "Output"], Cell[101354, 3214, 201, 4, 45, "Output"], Cell[101558, 3220, 88, 2, 44, "Output"] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[101707, 3229, 30, 0, 60, "Section"], Cell[101740, 3231, 115, 3, 28, "Text"], Cell[CellGroupData[{ Cell[101880, 3238, 61, 0, 44, "Subsection"], Cell[101944, 3240, 95, 2, 31, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[102076, 3247, 50, 0, 44, "Subsection"], Cell[102129, 3249, 107, 3, 28, "Text"], Cell[CellGroupData[{ Cell[102261, 3256, 97, 2, 31, "Input"], Cell[102361, 3260, 103, 3, 30, "Output"] }, Open ]], Cell[102479, 3266, 60, 0, 28, "Text"], Cell[CellGroupData[{ Cell[102564, 3270, 177, 3, 54, "Input"], Cell[102744, 3275, 100, 3, 30, "Output"], Cell[102847, 3280, 94, 3, 30, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[102990, 3289, 44, 0, 38, "Subsection"], Cell[103037, 3291, 665, 14, 108, "Text"], Cell[CellGroupData[{ Cell[103727, 3309, 98, 2, 31, "Input"], Cell[103828, 3313, 103, 3, 30, "Output"] }, Open ]], Cell[103946, 3319, 702, 17, 108, "Text"], Cell[104651, 3338, 130, 3, 31, "Input"], Cell[CellGroupData[{ Cell[104806, 3345, 75, 2, 31, "Input"], Cell[104884, 3349, 65, 2, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[104986, 3356, 67, 2, 31, "Input"], Cell[105056, 3360, 124, 4, 30, "Output"] }, Open ]], Cell[105195, 3367, 57, 0, 28, "Text"], Cell[CellGroupData[{ Cell[105277, 3371, 201, 4, 77, "Input"], Cell[105481, 3377, 159, 6, 30, "Output"], Cell[105643, 3385, 89, 3, 30, "Output"], Cell[105735, 3390, 83, 3, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[105855, 3398, 281, 5, 100, "Input"], Cell[106139, 3405, 245, 9, 30, "Output"], Cell[106387, 3416, 92, 3, 30, "Output"], Cell[106482, 3421, 90, 3, 30, "Output"], Cell[106575, 3426, 84, 3, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[106696, 3434, 389, 8, 123, "Input"], Cell[107088, 3444, 277, 10, 30, "Output"], Cell[107368, 3456, 169, 6, 30, "Output"], Cell[107540, 3464, 160, 6, 30, "Output"], Cell[107703, 3472, 88, 3, 30, "Output"] }, Open ]], Cell[107806, 3478, 70, 2, 31, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[107913, 3485, 55, 0, 38, "Subsection"], Cell[107971, 3487, 133, 5, 28, "Text"], Cell[CellGroupData[{ Cell[108129, 3496, 177, 4, 32, "Input"], Cell[108309, 3502, 179, 4, 47, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[108525, 3511, 490, 10, 169, "Input"], Cell[109018, 3523, 179, 4, 47, "Output"], Cell[109200, 3529, 120, 3, 44, "Output"], Cell[109323, 3534, 120, 3, 44, "Output"], Cell[109446, 3539, 117, 3, 44, "Output"], Cell[109566, 3544, 110, 3, 44, "Output"], Cell[109679, 3549, 89, 3, 43, "Output"], Cell[109771, 3554, 89, 3, 43, "Output"] }, Open ]], Cell[109875, 3560, 277, 6, 48, "Text"], Cell[CellGroupData[{ Cell[110177, 3570, 514, 9, 192, "Input"], Cell[110694, 3581, 179, 4, 47, "Output"], Cell[110876, 3587, 120, 3, 44, "Output"], Cell[110999, 3592, 120, 3, 44, "Output"], Cell[111122, 3597, 112, 3, 44, "Output"], Cell[111237, 3602, 102, 3, 44, "Output"], Cell[111342, 3607, 89, 3, 43, "Output"], Cell[111434, 3612, 89, 3, 43, "Output"], Cell[111526, 3617, 89, 3, 43, "Output"] }, Open ]], Cell[111630, 3623, 184, 4, 48, "Text"], Cell[CellGroupData[{ Cell[111839, 3631, 303, 7, 123, "Input"], Cell[112145, 3640, 179, 4, 47, "Output"], Cell[112327, 3646, 120, 3, 44, "Output"], Cell[112450, 3651, 120, 3, 44, "Output"], Cell[112573, 3656, 471, 15, 44, "Output"], Cell[113047, 3673, 1638, 48, 135, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[114734, 3727, 66, 0, 38, "Subsection"], Cell[114803, 3729, 132, 5, 28, "Text"], Cell[CellGroupData[{ Cell[114960, 3738, 177, 4, 32, "Input"], Cell[115140, 3744, 179, 4, 47, "Output"] }, Open ]], Cell[115334, 3751, 319, 11, 49, "Text"], Cell[CellGroupData[{ Cell[115678, 3766, 785, 14, 276, "Input"], Cell[116466, 3782, 179, 4, 47, "Output"], Cell[116648, 3788, 139, 3, 46, "Output"], Cell[116790, 3793, 120, 3, 44, "Output"], Cell[116913, 3798, 120, 3, 44, "Output"], Cell[117036, 3803, 117, 3, 44, "Output"], Cell[117156, 3808, 115, 3, 44, "Output"], Cell[117274, 3813, 113, 3, 44, "Output"], Cell[117390, 3818, 110, 3, 44, "Output"], Cell[117503, 3823, 102, 3, 44, "Output"], Cell[117608, 3828, 89, 3, 43, "Output"], Cell[117700, 3833, 89, 3, 43, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[117838, 3842, 75, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[117938, 3846, 35, 0, 37, "Subsubsection"], Cell[117976, 3848, 110, 3, 66, "Input"], Cell[CellGroupData[{ Cell[118111, 3855, 517, 10, 199, "Input"], Cell[118631, 3867, 106, 3, 43, "Output"], Cell[118740, 3872, 140, 3, 50, "Output"], Cell[118883, 3877, 143, 3, 46, "Output"], Cell[119029, 3882, 134, 3, 46, "Output"], Cell[119166, 3887, 134, 3, 46, "Output"], Cell[119303, 3892, 91, 2, 47, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[119431, 3899, 80, 2, 31, "Input"], Cell[119514, 3903, 91, 2, 47, "Output"] }, Open ]], Cell[119620, 3908, 67, 2, 31, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[119724, 3915, 34, 0, 31, "Subsubsection"], Cell[119761, 3917, 127, 5, 28, "Text"], Cell[CellGroupData[{ Cell[119913, 3926, 77, 2, 31, "Input"], Cell[119993, 3930, 193, 3, 47, "Print", CellTags->"Info3195323771-9489066"] }, Open ]], Cell[120201, 3936, 71, 2, 35, "Input"], Cell[CellGroupData[{ Cell[120297, 3942, 307, 6, 143, "Input"], Cell[120607, 3950, 106, 3, 43, "Output"], Cell[120716, 3955, 89, 2, 48, "Output"], Cell[120808, 3959, 90, 2, 49, "Output"], Cell[120901, 3963, 84, 2, 49, "Output"], Cell[120988, 3967, 73, 2, 49, "Output"] }, Open ]], Cell[121076, 3972, 67, 2, 31, "Input"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[121192, 3980, 55, 0, 38, "Subsection"], Cell[121250, 3982, 169, 3, 48, "Text"], Cell[CellGroupData[{ Cell[121444, 3989, 677, 12, 215, "Input"], Cell[122124, 4003, 113, 3, 46, "Output"], Cell[122240, 4008, 461, 13, 47, "Output"], Cell[122704, 4023, 507, 14, 49, "Output"], Cell[123214, 4039, 226, 5, 54, "Output"], Cell[123443, 4046, 176, 4, 57, "Output"], Cell[123622, 4052, 167, 4, 52, "Output"], Cell[123792, 4058, 131, 3, 44, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[123972, 4067, 47, 0, 38, "Subsection"], Cell[124022, 4069, 149, 5, 28, "Text"], Cell[CellGroupData[{ Cell[124196, 4078, 571, 11, 207, "Input"], Cell[124770, 4091, 104, 3, 43, "Output"], Cell[124877, 4096, 109, 3, 43, "Output"], Cell[124989, 4101, 88, 3, 43, "Output"], Cell[125080, 4106, 94, 3, 30, "Output"], Cell[125177, 4111, 94, 3, 30, "Output"], Cell[125274, 4116, 89, 3, 30, "Output"], Cell[125366, 4121, 83, 3, 30, "Output"] }, Open ]], Cell[125464, 4127, 45, 0, 28, "Text"], Cell[CellGroupData[{ Cell[125534, 4131, 597, 11, 207, "Input"], Cell[126134, 4144, 104, 3, 43, "Output"], Cell[126241, 4149, 109, 3, 43, "Output"], Cell[126353, 4154, 88, 3, 43, "Output"], Cell[126444, 4159, 135, 3, 45, "Output"], Cell[126582, 4164, 106, 3, 43, "Output"], Cell[126691, 4169, 106, 3, 43, "Output"], Cell[126800, 4174, 98, 3, 30, "Output"], Cell[126901, 4179, 83, 3, 30, "Output"] }, Open ]], Cell[126999, 4185, 68, 2, 31, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[127104, 4192, 63, 0, 38, "Subsection"], Cell[127170, 4194, 244, 6, 48, "Text"], Cell[CellGroupData[{ Cell[127439, 4204, 995, 18, 353, "Input"], Cell[128437, 4224, 95, 2, 28, "Print"], Cell[128535, 4228, 104, 3, 43, "Output"], Cell[128642, 4233, 83, 2, 28, "Print"], Cell[128728, 4237, 109, 3, 43, "Output"], Cell[128840, 4242, 96, 3, 43, "Output"], Cell[128939, 4247, 88, 3, 43, "Output"], Cell[129030, 4252, 147, 3, 28, "Print"], Cell[129180, 4257, 135, 3, 45, "Output"], Cell[129318, 4262, 106, 3, 43, "Output"], Cell[129427, 4267, 83, 2, 28, "Print"], Cell[129513, 4271, 106, 3, 43, "Output"], Cell[129622, 4276, 101, 3, 43, "Output"], Cell[129726, 4281, 61, 2, 30, "Output"] }, Open ]], Cell[129802, 4286, 72, 2, 31, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[129911, 4293, 56, 0, 38, "Subsection"], Cell[129970, 4295, 258, 7, 48, "Text"], Cell[CellGroupData[{ Cell[130253, 4306, 235, 5, 77, "Input"], Cell[130491, 4313, 95, 3, 43, "Output"], Cell[130589, 4318, 96, 3, 43, "Output"], Cell[130688, 4323, 88, 3, 43, "Output"] }, Open ]], Cell[130791, 4329, 174, 6, 28, "Text"], Cell[CellGroupData[{ Cell[130990, 4339, 535, 10, 169, "Input"], Cell[131528, 4351, 102, 3, 43, "Output"], Cell[131633, 4356, 103, 3, 43, "Output"], Cell[131739, 4361, 111, 3, 43, "Output"], Cell[131853, 4366, 96, 3, 43, "Output"], Cell[131952, 4371, 88, 3, 43, "Output"], Cell[132043, 4376, 64, 2, 43, "Output"], Cell[132110, 4380, 174, 5, 43, "Output"] }, Open ]], Cell[132299, 4388, 66, 0, 28, "Text"], Cell[CellGroupData[{ Cell[132390, 4392, 345, 7, 100, "Input"], Cell[132738, 4401, 95, 3, 43, "Output"], Cell[132836, 4406, 109, 3, 43, "Output"], Cell[132948, 4411, 97, 3, 43, "Output"], Cell[133048, 4416, 90, 3, 43, "Output"] }, Open ]], Cell[133153, 4422, 192, 4, 48, "Text"], Cell[CellGroupData[{ Cell[133370, 4430, 553, 12, 146, "Input"], Cell[133926, 4444, 103, 3, 43, "Output"], Cell[134032, 4449, 118, 3, 43, "Output"], Cell[134153, 4454, 137, 3, 46, "Output"], Cell[134293, 4459, 525, 15, 46, "Output"], Cell[134821, 4476, 66, 2, 43, "Output"], Cell[134890, 4480, 176, 5, 43, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[135115, 4491, 74, 0, 38, "Subsection"], Cell[135192, 4493, 76, 0, 28, "Text"], Cell[CellGroupData[{ Cell[135293, 4497, 147, 4, 48, "Input"], Cell[135443, 4503, 136, 3, 44, "Output"] }, Open ]], Cell[135594, 4509, 69, 0, 28, "Text"], Cell[CellGroupData[{ Cell[135688, 4513, 177, 4, 54, "Input"], Cell[135868, 4519, 75, 2, 30, "Output"], Cell[135946, 4523, 2343, 61, 34, "Output"] }, Open ]], Cell[138304, 4587, 382, 10, 68, "Text"], Cell[CellGroupData[{ Cell[138711, 4601, 289, 6, 78, "Input"], Cell[139003, 4609, 91, 2, 31, "Output"], Cell[139097, 4613, 113, 2, 49, "Output"], Cell[139213, 4617, 95, 2, 49, "Output"] }, Open ]], Cell[139323, 4622, 136, 3, 28, "Text"], Cell[CellGroupData[{ Cell[139484, 4629, 448, 8, 183, "Input"], Cell[139935, 4639, 137, 3, 44, "Output"], Cell[140075, 4644, 217, 4, 62, "Output"], Cell[140295, 4650, 120, 3, 44, "Output"], Cell[140418, 4655, 84, 2, 44, "Output"], Cell[140505, 4659, 93, 2, 43, "Output"] }, Open ]], Cell[140613, 4664, 60, 0, 28, "Text"], Cell[CellGroupData[{ Cell[140698, 4668, 474, 10, 180, "Input"], Cell[141175, 4680, 137, 3, 44, "Output"], Cell[141315, 4685, 217, 4, 62, "Output"], Cell[141535, 4691, 120, 3, 44, "Output"], Cell[141658, 4696, 84, 2, 44, "Output"], Cell[141745, 4700, 93, 2, 43, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[141887, 4708, 70, 0, 38, "Subsection"], Cell[141960, 4710, 503, 11, 88, "Text"], Cell[142466, 4723, 2573, 45, 953, "Input"], Cell[CellGroupData[{ Cell[145064, 4772, 87, 2, 31, "Input"], Cell[145154, 4776, 253, 4, 48, "Print", CellTags->"Info3195323872-6948727"] }, Open ]], Cell[CellGroupData[{ Cell[145444, 4785, 204, 5, 73, "Input"], Cell[145651, 4792, 141, 3, 41, "Print"], Cell[145795, 4797, 109, 2, 43, "Print"], Cell[145907, 4801, 124, 3, 40, "Print"], Cell[146034, 4806, 88, 2, 44, "Print"], Cell[146125, 4810, 93, 2, 43, "Output"] }, Open ]], Cell[146233, 4815, 136, 3, 28, "Text"], Cell[CellGroupData[{ Cell[146394, 4822, 217, 5, 79, "Input"], Cell[146614, 4829, 141, 3, 41, "Print"], Cell[146758, 4834, 137, 3, 48, "Print"], Cell[146898, 4839, 138, 3, 40, "Print"], Cell[147039, 4844, 193, 4, 28, "Message"], Cell[147235, 4850, 67, 2, 30, "Output"] }, Open ]], Cell[147317, 4855, 126, 5, 28, "Text"], Cell[CellGroupData[{ Cell[147468, 4864, 194, 4, 73, "Input"], Cell[147665, 4870, 141, 3, 40, "Print"], Cell[147809, 4875, 105, 2, 43, "Print"], Cell[147917, 4879, 128, 3, 40, "Print"], Cell[148048, 4884, 108, 2, 40, "Print"], Cell[148159, 4888, 167, 3, 28, "Message"] }, Open ]], Cell[CellGroupData[{ Cell[148363, 4896, 39, 0, 37, "Subsubsection"], Cell[CellGroupData[{ Cell[148427, 4900, 167, 3, 48, "Input"], Cell[148597, 4905, 135, 3, 40, "Print"], Cell[148735, 4910, 96, 2, 28, "Print"], Cell[148834, 4914, 125, 3, 40, "Print"], Cell[148962, 4919, 75, 2, 44, "Print"], Cell[149040, 4923, 84, 2, 43, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[149161, 4930, 170, 3, 48, "Input"], Cell[149334, 4935, 135, 3, 40, "Print"], Cell[149472, 4940, 107, 2, 41, "Print"], Cell[149582, 4944, 127, 3, 46, "Print"], Cell[149712, 4949, 81, 2, 44, "Print"], Cell[149796, 4953, 98, 2, 43, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[149931, 4960, 186, 3, 73, "Input"], Cell[150120, 4965, 144, 3, 40, "Print"], Cell[150267, 4970, 116, 2, 41, "Print"], Cell[150386, 4974, 130, 3, 41, "Print"], Cell[150519, 4979, 77, 2, 41, "Print"], Cell[150599, 4983, 90, 2, 43, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[150726, 4990, 166, 3, 48, "Input"], Cell[150895, 4995, 136, 3, 40, "Print"], Cell[151034, 5000, 108, 2, 41, "Print"], Cell[151145, 5004, 130, 3, 41, "Print"], Cell[151278, 5009, 77, 2, 41, "Print"], Cell[151358, 5013, 76, 2, 44, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[151471, 5020, 190, 4, 50, "Input"], Cell[151664, 5026, 157, 4, 43, "Print"], Cell[151824, 5032, 112, 2, 41, "Print"], Cell[151939, 5036, 133, 3, 44, "Print"], Cell[152075, 5041, 77, 2, 41, "Print"], Cell[152155, 5045, 86, 2, 43, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[152278, 5052, 216, 4, 73, "Input"], Cell[152497, 5058, 175, 4, 40, "Print"], Cell[152675, 5064, 134, 3, 41, "Print"], Cell[152812, 5069, 128, 3, 44, "Print"], Cell[152943, 5074, 75, 2, 44, "Print"], Cell[153021, 5078, 99, 2, 43, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[153157, 5085, 170, 3, 73, "Input"], Cell[153330, 5090, 138, 3, 40, "Print"], Cell[153471, 5095, 105, 2, 28, "Print"], Cell[153579, 5099, 125, 3, 40, "Print"], Cell[153707, 5104, 75, 2, 44, "Print"], Cell[153785, 5108, 76, 2, 44, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[153898, 5115, 183, 3, 55, "Input"], Cell[154084, 5120, 156, 4, 44, "Print"], Cell[154243, 5126, 109, 2, 41, "Print"], Cell[154355, 5130, 134, 3, 41, "Print"], Cell[154492, 5135, 88, 2, 44, "Print"], Cell[154583, 5139, 93, 2, 43, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[154713, 5146, 192, 3, 55, "Input"], Cell[154908, 5151, 156, 4, 44, "Print"], Cell[155067, 5157, 158, 3, 45, "Print"], Cell[155228, 5162, 125, 3, 40, "Print"], Cell[155356, 5167, 82, 2, 44, "Print"], Cell[155441, 5171, 93, 2, 43, "Output"] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[155595, 5180, 35, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[155655, 5184, 77, 2, 31, "Input"], Cell[155735, 5188, 309, 5, 66, "Print", CellTags->"Info3195323910-3120561"] }, Open ]], Cell[156059, 5196, 359, 9, 68, "Text"], Cell[CellGroupData[{ Cell[156443, 5209, 322, 6, 90, "Input"], Cell[156768, 5217, 92, 2, 54, "Output"], Cell[156863, 5221, 90, 2, 54, "Output"], Cell[156956, 5225, 116, 3, 55, "Output"] }, Open ]], Cell[157087, 5231, 225, 4, 48, "Text"], Cell[157315, 5237, 70, 0, 28, "Text"], Cell[CellGroupData[{ Cell[157410, 5241, 176, 4, 89, "Input"], Cell[157589, 5247, 133, 3, 55, "Output"], Cell[157725, 5252, 106, 2, 54, "Output"] }, Open ]], Cell[157846, 5257, 96, 2, 28, "Text"], Cell[CellGroupData[{ Cell[157967, 5263, 192, 4, 63, "Input"], Cell[158162, 5269, 106, 2, 54, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[158317, 5277, 40, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[158382, 5281, 81, 2, 31, "Input"], Cell[158466, 5285, 227, 4, 47, "Print", CellTags->"Info3195323919-8995725"] }, Open ]], Cell[CellGroupData[{ Cell[158730, 5294, 92, 2, 32, "Input"], Cell[158825, 5298, 105, 2, 44, "Output"] }, Open ]], Cell[158945, 5303, 112, 3, 28, "Text"], Cell[CellGroupData[{ Cell[159082, 5310, 97, 2, 32, "Input"], Cell[159182, 5314, 85, 2, 44, "Output"] }, Open ]], Cell[159282, 5319, 230, 6, 60, "Text"], Cell[CellGroupData[{ Cell[159537, 5329, 564, 12, 214, "Input"], Cell[160104, 5343, 80, 2, 49, "Output"], Cell[160187, 5347, 93, 2, 51, "Output"], Cell[160283, 5351, 78, 2, 49, "Output"], Cell[160364, 5355, 135, 3, 49, "Output"], Cell[160502, 5360, 76, 2, 40, "Output"], Cell[160581, 5364, 94, 2, 43, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[160724, 5372, 35, 0, 38, "Subsection"], Cell[CellGroupData[{ Cell[160784, 5376, 77, 2, 31, "Input"], Cell[160864, 5380, 193, 3, 47, "Print", CellTags->"Info3195323928-9062154"] }, Open ]], Cell[CellGroupData[{ Cell[161094, 5388, 93, 2, 46, "Input"], Cell[161190, 5392, 83, 2, 43, "Output"] }, Open ]], Cell[161288, 5397, 288, 9, 48, "Text"], Cell[CellGroupData[{ Cell[161601, 5410, 96, 2, 46, "Input"], Cell[161700, 5414, 72, 2, 43, "Output"] }, Open ]], Cell[161787, 5419, 149, 5, 28, "Text"], Cell[CellGroupData[{ Cell[161961, 5428, 559, 12, 190, "Input"], Cell[162523, 5442, 66, 2, 30, "Output"], Cell[162592, 5446, 111, 2, 47, "Output"], Cell[162706, 5450, 64, 2, 43, "Output"], Cell[162773, 5454, 121, 3, 45, "Output"], Cell[162897, 5459, 70, 2, 30, "Output"], Cell[162970, 5463, 84, 2, 30, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[163103, 5471, 37, 0, 38, "Subsection"], Cell[163143, 5473, 671, 14, 108, "Text"], Cell[CellGroupData[{ Cell[163839, 5491, 79, 2, 31, "Input"], Cell[163921, 5495, 323, 5, 66, "Print", CellTags->"Info3195323940-8825526"] }, Open ]], Cell[164259, 5503, 113, 3, 28, "Text"], Cell[CellGroupData[{ Cell[164397, 5510, 190, 3, 54, "Input"], Cell[164590, 5515, 188, 4, 51, "Output"] }, Open ]], Cell[164793, 5522, 71, 0, 28, "Text"], Cell[CellGroupData[{ Cell[164889, 5526, 265, 5, 77, "Input"], Cell[165157, 5533, 151, 3, 30, "Output"] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[165369, 5543, 48, 0, 60, "Section"], Cell[CellGroupData[{ Cell[165442, 5547, 66, 0, 44, "Subsection"], Cell[165511, 5549, 233, 4, 48, "Text"], Cell[165747, 5555, 881, 15, 128, "Text"], Cell[166631, 5572, 442, 8, 68, "Text"], Cell[167076, 5582, 749, 12, 128, "Text"], Cell[167828, 5596, 1621, 37, 228, "Text"], Cell[169452, 5635, 461, 11, 68, "Text"], Cell[169916, 5648, 252, 6, 48, "Text"], Cell[170171, 5656, 753, 15, 128, "Text"], Cell[170927, 5673, 70, 0, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[171034, 5678, 47, 0, 38, "Subsection"], Cell[171084, 5680, 185, 4, 48, "Text"], Cell[171272, 5686, 202, 6, 48, "Text"], Cell[CellGroupData[{ Cell[171499, 5696, 161, 4, 59, "Input", Evaluatable->False], Cell[171663, 5702, 155, 3, 55, "Output"] }, Open ]], Cell[171833, 5708, 210, 6, 28, "Text"], Cell[172046, 5716, 209, 5, 59, "Input", Evaluatable->False], Cell[172258, 5723, 197, 4, 48, "Text"], Cell[172458, 5729, 176, 4, 59, "Input", Evaluatable->False], Cell[172637, 5735, 269, 9, 28, "Text"], Cell[172909, 5746, 334, 8, 59, "Input", Evaluatable->False], Cell[173246, 5756, 29, 0, 28, "Text"], Cell[CellGroupData[{ Cell[173300, 5760, 519, 13, 59, "Input", Evaluatable->False], Cell[173822, 5775, 241, 6, 28, "Print"] }, Open ]], Cell[174078, 5784, 384, 10, 48, "Text"], Cell[CellGroupData[{ Cell[174487, 5798, 545, 14, 59, "Input", Evaluatable->False], Cell[175035, 5814, 241, 6, 28, "Print"], Cell[175279, 5822, 247, 6, 28, "Print"] }, Open ]], Cell[175541, 5831, 211, 6, 48, "Text"], Cell[CellGroupData[{ Cell[175777, 5841, 557, 15, 59, "Input", Evaluatable->False], Cell[176337, 5858, 241, 6, 28, "Print"], Cell[176581, 5866, 247, 6, 28, "Print"] }, Open ]], Cell[176843, 5875, 196, 6, 28, "Text"], Cell[CellGroupData[{ Cell[177064, 5885, 545, 14, 59, "Input", Evaluatable->False], Cell[177612, 5901, 241, 6, 28, "Print"], Cell[177856, 5909, 247, 6, 28, "Print"], Cell[178106, 5917, 99, 2, 28, "Print"] }, Open ]], Cell[178220, 5922, 514, 12, 68, "Text"], Cell[CellGroupData[{ Cell[178759, 5938, 182, 4, 36, "Input", Evaluatable->False], Cell[178944, 5944, 241, 6, 28, "Print"], Cell[179188, 5952, 247, 6, 28, "Print"], Cell[179438, 5960, 99, 2, 28, "Print"] }, Open ]], Cell[179552, 5965, 98, 2, 28, "Text"], Cell[CellGroupData[{ Cell[179675, 5971, 525, 13, 38, "Input", Evaluatable->False], Cell[180203, 5986, 241, 6, 28, "Print"], Cell[180447, 5994, 247, 6, 28, "Print"], Cell[180697, 6002, 99, 2, 28, "Print"], Cell[180799, 6006, 89, 2, 28, "Print"] }, Open ]], Cell[180903, 6011, 357, 7, 68, "Text"], Cell[CellGroupData[{ Cell[181285, 6022, 549, 14, 36, "Input", Evaluatable->False], Cell[181837, 6038, 241, 6, 28, "Print"], Cell[182081, 6046, 247, 6, 28, "Print"], Cell[182331, 6054, 99, 2, 28, "Print"], Cell[182433, 6058, 89, 2, 28, "Print"], Cell[182525, 6062, 92, 2, 28, "Print"] }, Open ]], Cell[182632, 6067, 348, 10, 28, "Text"], Cell[CellGroupData[{ Cell[183005, 6081, 151, 3, 59, "Input", Evaluatable->False], Cell[183159, 6086, 241, 6, 28, "Print"], Cell[183403, 6094, 247, 6, 28, "Print"], Cell[183653, 6102, 99, 2, 28, "Print"], Cell[183755, 6106, 89, 2, 28, "Print"], Cell[183847, 6110, 92, 2, 28, "Print"] }, Open ]], Cell[183954, 6115, 169, 3, 48, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[184160, 6123, 48, 0, 38, "Subsection"], Cell[184211, 6125, 291, 14, 28, "Text"], Cell[CellGroupData[{ Cell[184527, 6143, 143, 4, 37, "Input"], Cell[184673, 6149, 122, 3, 50, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[184832, 6157, 32, 0, 37, "Subsubsection"], Cell[184867, 6159, 191, 11, 28, "Text"], Cell[185061, 6172, 193, 11, 28, "Text"], Cell[185257, 6185, 147, 7, 28, "Text"], Cell[185407, 6194, 65, 0, 28, "Text"], Cell[CellGroupData[{ Cell[185497, 6198, 104, 2, 31, "Input"], Cell[185604, 6202, 129, 3, 50, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[185770, 6210, 105, 2, 31, "Input"], Cell[185878, 6214, 130, 3, 50, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[186045, 6222, 100, 2, 31, "Input"], Cell[186148, 6226, 124, 3, 50, "Output"] }, Open ]] }, Closed]] }, Closed]] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)