(************** 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[ 31110, 1016]*) (*NotebookOutlinePosition[ 32025, 1048]*) (* CellTagsIndexPosition[ 31936, 1042]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Enhancing the Through Command", "Title"], Cell["\<\ by David Park djmp@earthlink.net http://home.earthlink.net/~djmp/\ \>", "Subsubtitle"], Cell["\<\ Some modifications suggested by Ted Ersek: ErsekTR@navair.navy.mil\ \>", "Subsubtitle"], Cell[CellGroupData[{ Cell["Improvements", "Section"], Cell["\<\ 23 March 2000 - Added enhanced internal documentation. 16 September 2000 - Added the PushOnto routine\ \>", "Text"], Cell["\<\ 10 Oct 2001 - Added the PushOut routine, which factors arguments from nested \ sums and products. Changed usage of PushThrough so that depth argument is now an option, \ PushThroughDepth. Extended usage of PushThrough and PushOnto so that for an expression with a \ single head expression and a single arguments bracket, the arguments may be \ omitted from the command and are picked up from the expression. This is much \ more convenient.\ \>", "Text"], Cell["\<\ 5 March 2002 - Added LinearPushOut and PushDerivative Routines\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Why Through Needs Extra Help", "Section"], Cell[TextData[{ "The ", StyleBox["Mathematica", FontSlant->"Italic"], " Through command does not operate in the way that one might expect and for \ that reason seems to be used less than it deserves to be. These work as \ expected:" }], "Text"], Cell[BoxData[ \(\((f + g)\)[x] // Through\)], "Input", CellLabel->"In[6]:="], Cell[BoxData[ \(\((f\ g)\)[x] // Through\)], "Input", CellLabel->"In[7]:="], Cell["\<\ But this requires extra work. You have to know or find the FullForm of the \ first result. Nor does Through quite give us the result we expected.\ \>", "Text"], Cell[BoxData[{ \(\((f - g)\)[x] // Through\ \), "\n", \(MapAt[Through, %, {2}]\)}], "Input", CellLabel->"In[8]:="], Cell["The same thing happens with this expression.", "Text"], Cell[BoxData[{ \(\((f\ g\^2)\)[x] // Through\ \), "\n", \(MapAt[Through, %, {2}]\)}], "Input", CellLabel->"In[10]:="], Cell[TextData[{ "When the head was ", Cell[BoxData[ \(Times[\(-1\), g]\)]], " it pushed through both the ", Cell[BoxData[ \(\(-1\)\)]], " and ", Cell[BoxData[ \(g\)]], ". When the head was ", Cell[BoxData[ \(Power[g, 2]\)]], " it pushed through both the ", Cell[BoxData[ \(g\)]], " and the ", Cell[BoxData[ \(2\)]], ". Of course, we can think of ", Cell[BoxData[ \(2[x]\)]], " as the constant function 2. But we have to do the extra simplification \ ourselves. Suppose that we have other symbols in our head expression which we \ intend to be constants? ", StyleBox["Mathematica", FontSlant->"Italic"], " will also push onto them. So there are two limitations to Through: It \ doesn't push through enough and requires repeated and selective application; \ It also pushes onto too many things." }], "Text"], Cell[TextData[{ "To overcome these types of problems I have written a ", Cell[BoxData["PushThrough"]], " pure function which produces the result usually intended. It contains as \ parameters the specific arguments on which the head function is to be pushed, \ and the number of applications to make. All numbers and ", StyleBox["Mathematica", FontSlant->"Italic"], " constants are automatically treated as constants. There are options which \ allow the user to supply a list of patterns which will not be pushed through, \ an additional list of constants, and a specification whether or not to push \ through rules." }], "Text"], Cell["\<\ While PushThrough pushes the arguments onto everything except a list of \ exceptions, a second routine PushOnto will push the arguments only onto a \ specificied list of patterns. It provides another controlled method of using \ Through.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Initializing", "Section"], Cell[TextData[{ "The following package should be placed in the ", Cell[BoxData[ RowBox[{"AddOns", "\\", "ExtraPackages", "\\", "Algebra"}]]], " directory. It is available at http://home.earthlink.net/~djmp/. It \ contains the PushThrough routine which can be used in place of Through or as \ a supplement to Through." }], "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input", CellLabel->"In[1]:="], Cell[CellGroupData[{ Cell[BoxData[ \(\(?Algebra`PushThrough`*\)\)], "Input", CellLabel->"In[2]:="], Cell[BoxData[GridBox[{ { StyleBox["Algebra`PushThrough`", FontFamily->"Helvetica", FontSize->12, FontWeight->"Bold"]}, {GridBox[{ { ButtonBox[ StyleBox["LinearPushOut", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`LinearPushOut"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], ButtonBox[ StyleBox["PushOnto", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`PushOnto"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], ButtonBox[ StyleBox["PushThrough", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`PushThrough"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], ButtonBox[ StyleBox["PushThroughRules", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`PushThroughRules"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], "", ""}, { ButtonBox[ StyleBox["PushDerivative", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`PushDerivative"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], ButtonBox[ StyleBox["PushOut", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`PushOut"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], ButtonBox[ StyleBox["PushThroughDepth", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`PushThroughDepth"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], ButtonBox[ StyleBox["StopPatterns", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}], ButtonFunction:>( Internal`PutInformation[ #, LongForm -> False]&), ButtonEvaluator->Automatic, ButtonData:>{"Info3224325605-2197440", "Algebra`PushThrough`StopPatterns"}, ButtonFrame->"None", ButtonNote->"Algebra`PushThrough`"], "", ""} }, RowMinHeight->{1, 1.05}]} }, RowSpacings->{2, 3}, ColumnAlignments->{Left}, ColumnsEqual->True]], "Print", CellMargins->{{20, Inherited}, {Inherited, Inherited}}, ShowCellLabel->False, CellFrameMargins->{{Inherited, Inherited}, {14, 14}}, Background->GrayLevel[0.930022], ButtonBoxOptions->{Active->True}], Cell[BoxData[ \("PushDerivative[f, g,...][expr] will simplify linear derivative \ expressions such as (a f + b g)'[t] where f and g are function names, which \ must be supplied as arguments."\)], "Print", CellTags->"Info3224325605-2197440"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Examples ", "Section"], Cell[CellGroupData[{ Cell["PushThrough", "Subsection"], Cell["Let's try the examples in the first section again.", "Text"], Cell[BoxData[ \(\((examples = {\((f + g)\)[x], \((f - g)\)[x], \((f\ g)\)[ x], \((f\ g\^2)\)[x]})\) // TableForm\)], "Input", CellLabel->"In[37]:="], Cell["\<\ PushThrough comes in two usages. The first usage is that the arguments to be \ pushed through must be stated in a list. This usage will apply PushThrough to \ subexpressions scattered through an expression. A newer usage of PushThrough \ can be used when the entire expression ends with a single argument bracket, a \ common case. Then the argument list can be omitted and is picked up from the \ expression.\ \>", "Text"], Cell["Here is the first usage...", "Text"], Cell[BoxData[ \(\((examples // PushThrough[{x}])\) // TableForm\)], "Input", CellLabel->"In[41]:="], Cell["Here is the second usage.", "Text"], Cell[BoxData[ \(\((PushThrough[] /@ examples)\) // TableForm\)], "Input", CellLabel->"In[39]:="], Cell[TextData[{ "Numbers and ", StyleBox["Mathematica", FontSlant->"Italic"], " constants are not pushed through." }], "Text"], Cell[BoxData[ \(\((2 + \[Pi] + Catalan + f)\)[x] // PushThrough[{x}]\)], "Input", CellLabel->"In[42]:="], Cell[BoxData[ \({f, $Failed, Null}[x] // PushThrough[{x}]\)], "Input", CellLabel->"In[43]:="], Cell[TextData[{ "We can use ", Cell[BoxData["Identity"]], " and derivative functions as expected." }], "Text"], Cell[BoxData[ \(\((Identity + f')\)[x] // PushThrough[]\)], "Input", CellLabel->"In[45]:="], Cell[TextData[{ "Instead of ", Cell[BoxData[ RowBox[{"f", "'"}]]], ", we can use Derivative." }], "Text"], Cell[BoxData[ \(\((Identity + \(Derivative[1]\)[f])\)[x] // PushThrough[]\)], "Input", CellLabel->"In[47]:="], Cell["\<\ Sometimes we will want symbols or parts of the head expression to be treated \ as constants. This can be done with the constants option. Here, a is treated \ as a constant.\ \>", "Text"], Cell[BoxData[ \(\((a\ f')\)[x] // PushThrough[Constants \[Rule] {a}]\)], "Input", CellLabel->"In[49]:="], Cell["\<\ If you will be using PushThrough often, and have a list of symbols which you \ wish treated as constants, you can set them once and for all.\ \>", "Text"], Cell[BoxData[ \(SetOptions[PushThrough, Constants \[Rule] {a}]\)], "Input", CellLabel->"In[50]:="], Cell[BoxData[ \(\((a\ f')\)[x] // PushThrough[]\)], "Input", CellLabel->"In[51]:="], Cell[BoxData[ \(SetOptions[PushThrough, Constants \[Rule] {}]\)], "Input", CellLabel->"In[52]:="], Cell[TextData[{ "Any symbol which has the attribute ", Cell[BoxData["Constant"]], " is not pushed through. This provides an alternative mechanism to stop the \ constant a from pushing through." }], "Text"], Cell[BoxData[{ \(\(SetAttributes[a, \ Constant];\)\), "\n", \(\((a\ f')\)[x] // PushThrough[]\)}], "Input", CellLabel->"In[55]:="], Cell[TextData[{ Cell[BoxData[ \(a\)]], " will be kept with the Attribute Constant for most of the rest of the \ examples." }], "Text"], Cell["\<\ We can also specify that some subexpressions are constant. Constants can be a \ list or a single item.\ \>", "Text"], Cell[BoxData[ \(\((a + Identity + \[Pi]\ f'' + g\ h\^2)\)[x] // PushThrough[Constants \[Rule] {g\ h\^2}]\)], "Input", CellLabel->"In[58]:="], Cell[BoxData[ \(\((h + g + g\ h\^2 + f)\)[x] // PushThrough[Constants \[Rule] {g, h}]\)], "Input", CellLabel->"In[60]:="], Cell[TextData[{ Cell[BoxData[ \(PushThrough\)]], " will repeatedly apply ", Cell[BoxData[ \(Through\)]], " to all subexpressions until a fixed point is reached, up to a depth of 20 \ applications. Sometimes we will want a more controlled application of \ PushThrough. Fewer, or more, applications can be specified by using the \ PushThroughDepth option. This does only one application." }], "Text"], Cell[BoxData[ \(\((2\ f + f\ g\^2)\)[x] // PushThrough[PushThroughDepth \[Rule] 1]\)], "Input", CellLabel->"In[61]:="], Cell[TextData[{ "An option for ", Cell[BoxData[ \(PushThrough\)]], ", ", Cell[BoxData[ \(StopPatterns\)]], ", allows patterns to be specified which will not be pushed through. Here \ we can obtain the same result as with the last example. (In some cases we \ will have to use HoldPattern to stop evaluation of the pattern.)" }], "Text"], Cell[BoxData[ \(\((2\ f + f\ g\^2)\)[x] // PushThrough[StopPatterns \[Rule] {HoldPattern[Times[_, _]]}]\)], "Input",\ CellLabel->"In[63]:="], Cell["Here Power was stopped from pushing through.", "Text"], Cell[BoxData[ \(\((2\ f + f\ g\^2)\)[x] // PushThrough[StopPatterns \[Rule] {Power[_, _]}]\)], "Input", CellLabel->"In[65]:="], Cell["\<\ We can, of course, also push onto multiple argument sequences.\ \>", "Text"], Cell[BoxData[ \(\((2 + a\ f + f\ g\^2 + \(Derivative[2, 3]\)[f])\)[x, y] // PushThrough[]\)], "Input", CellLabel->"In[67]:="], Cell[TextData[{ "You can use expressions like ", Cell[BoxData[ RowBox[{ RowBox[{"Derivative", "[", "1", "]"}], "[", "f", "]"}]]], " in heads but not expressions like ", Cell[BoxData[ RowBox[{"Derivative", "[", "1", "]"}]]], " as one might be tempted to use in the following expressions. Use the ", Cell[BoxData["D"]], " or partial derivative operator." }], "Text"], Cell[BoxData[ \(\((2 + Identity + \((\[PartialD]\_x\ # &)\))\)[f[x]] // PushThrough[]\)], "Input", CellLabel->"In[69]:="], Cell["We can push onto specific expressions.", "Text"], Cell[BoxData[{ \(\((\(2 + #\^2 &\) + Identity + \((\[PartialD]\_x\ # &)\))\)[x + x\^2] // PushThrough[]\ \), "\n", \(% // Expand\)}], "Input", CellLabel->"In[72]:="], Cell[BoxData[{ \(\(expr = x + x\^2;\)\), "\n", \(\((\(2 + #\^2 &\) + Identity + \((\[PartialD]\_x\ # &)\))\)[expr] // PushThrough[]\ \), "\n", \(% // Expand\)}], "Input", CellLabel->"In[74]:="], Cell[BoxData[{ \(\(f[x_] := x\^2;\)\), "\n", \(\((a\ f')\)[x] // PushThrough[]\)}], "Input", CellLabel->"In[79]:="], Cell[BoxData[ \(Clear[f]\)], "Input", CellLabel->"In[81]:="], Cell[TextData[{ "Here are a number of examples that test ", Cell[BoxData[ \(PushThrough\)]], " with derivatives and compositions on two variable functions." }], "Text"], Cell[BoxData[ \(\((2 + Identity + a \((\[PartialD]\_\(x, y\)\ # &)\))\)[f[x, y]] // PushThrough[]\)], "Input", CellLabel->"In[83]:="], Cell[BoxData[ \(\((2 + Identity + a \((\[PartialD]\_\(x, y\)\ # &)\) \((\[PartialD]\_\(x, y\)\ # &)\ \))\)[f[x, y]] // PushThrough[]\)], "Input", CellLabel->"In[85]:="], Cell[BoxData[ \(\((2 + Identity + a\ Composition[\((\[PartialD]\_\(x, y\)\ # &)\), \((\[PartialD]\_\ \(x, y\)\ # &)\)])\)[f[x, y]] // PushThrough[]\)], "Input", CellLabel->"In[87]:="], Cell[BoxData[ \(\((2 + Identity + a\ Composition[\((\[PartialD]\_x\ # &)\), \((\[PartialD]\_y\ # &)\ \)])\)[f[x, y]] // PushThrough[]\)], "Input", CellLabel->"In[89]:="], Cell["Again, using a specific function...", "Text"], Cell[BoxData[{ \(\(f[x_, y_] := \(x\^2\) y\^3;\)\), "\n", \(\((2 + Identity + a \((\[PartialD]\_\(x, y\)\ # &)\))\)[f[x, y]] // PushThrough[]\)}], "Input", CellLabel->"In[92]:="], Cell[BoxData[ \(Clear[f]\)], "Input", CellLabel->"In[94]:="], Cell["Some more examples...", "Text"], Cell[BoxData[ \(\((2 + Identity\ + Composition[f, g])\)[x] // PushThrough[]\)], "Input",\ CellLabel->"In[96]:="], Cell[BoxData[ \(\((\((Identity\ + f')\) \((Identity + g')\))\)[x] // PushThrough[]\)], "Input", CellLabel->"In[98]:="], Cell[TextData[{ "This shows how the ", Cell[BoxData[ \(PushThrough\)]], " works when applied one step at a time. In this case we must use the \ longer form, at least after the first step." }], "Text"], Cell[BoxData[{ \(\((\((Identity\ + f')\) \((Identity + g')\))\)[x]\ \), "\n", \(% // PushThrough[PushThroughDepth \[Rule] 1]\ \), "\n", \(% // PushThrough[{x}, PushThroughDepth \[Rule] 1]\ \), "\n", \(\(\(%\)\(//\)\(PushThrough[{x}, PushThroughDepth \[Rule] 1]\)\(\ \)\)\)}], "Input", CellLabel->"In[111]:="], Cell["This does the same...", "Text"], Cell[BoxData[ \(\(\((\((Identity\ + f')\) \((Identity + g')\))\)[x]\ // NestList[\(PushThrough[{x}, PushThroughDepth \[Rule] 1]\)[#] &, #, 3] &\) // TableForm\)], "Input", CellLabel->"In[115]:="], Cell["Through will do it with multiple applications.", "Text"], Cell[BoxData[{ \(\((\((Identity\ + f')\) \((Identity + g')\))\)[x]\ \), "\n", \(% // Through\ \), "\n", \(MapAt[Through, %, {{1}, {2}}]\)}], "Input", CellLabel->"In[116]:="], Cell["\<\ Although we had to push extra times with products above, with sums we \ don't.\ \>", "Text"], Cell[BoxData[ \(\((Identity\ + f')\)[x] + 3 \((Identity + g')\)[x] // PushThrough[{x}]\)], "Input", CellLabel->"In[119]:="], Cell[TextData[{ Cell[BoxData["Through"]], ", by itself, requires some gymnastics on the last expression." }], "Text"], Cell[BoxData[{ \(\((Identity\ + f')\)[x] + 3 \((Identity + g')\)[x] // Through[#, Plus] &\ \), "\n", \(MapAt[Through, %, {{1}, {2, 2}}]\)}], "Input", CellLabel->"In[120]:="], Cell[TextData[{ "Here, we deal with an expression with two different argument sequences. It \ requires two applications of ", Cell[BoxData["PushThrough"]], "." }], "Text"], Cell[BoxData[{ \(a \((Identity\ + f')\)[x] + \(\(3\) \(\((Identity + g')\)[ y]\)\(\ \)\)\), "\n", \(\(% // PushThrough[{x}]\) // PushThrough[{y}]\)}], "Input", CellLabel->"In[122]:="], Cell["We could also do it this way...", "Text"], Cell[BoxData[{ \(a \((Identity\ + f')\)[x] + 3 \((Identity + g')\)[y]\ \), "\[IndentingNewLine]", \(% /. a_[x_] \[RuleDelayed] \(PushThrough[]\)[a[x]]\)}], "Input", CellLabel->"In[126]:="], Cell["\<\ Through is about at easy but does require identifying the subexpression \ locations..\ \>", "Text"], Cell[BoxData[{ \(a \((Identity\ + f')\)[x] + \(\(3\) \(\((Identity + g')\)[ y]\)\(\ \)\)\), "\n", \(MapAt[Through, %, {{1, 2}, {2, 2}}]\)}], "Input", CellLabel->"In[128]:="], Cell[TextData[{ Cell[BoxData["PushThrough"]], " controls the application of Through by the argument sequence." }], "Text"], Cell[BoxData[{ \(\(\((f + f')\)[x]\)[y]\), "\n", \(% // PushThrough[{x}]\ \), "\n", \(% // PushThrough[{y}]\)}], "Input", CellLabel->"In[130]:="], Cell[BoxData[{ \(\(\((f + f')\)[x]\)[y]\), "\n", \(% // PushThrough[{y}]\ \), "\n", \(% // PushThrough[{x[y]}]\)}], "Input", CellLabel->"In[133]:="], Cell["\<\ Or we could do it this way if we don't want y to be pushed into x...\ \>", "Text"], Cell[BoxData[{ \(\(\((f + f')\)[x]\)[y]\), "\n", \(% // PushThrough[{x}]\ \), "\n", \(% // PushThrough[{y}, PushThroughDepth \[Rule] 1]\)}], "Input", CellLabel->"In[136]:="], Cell["\<\ Through, when it can be used, controls application by the head of the head \ function or applies it to the right most argument sequence.\ \>", "Text"], Cell[BoxData[{ \(\(\((f + f')\)[x]\)[y]\ \), "\n", \(% // Through[#, Plus] &\ \), "\n", \(% // Through\)}], "Input", CellLabel->"In[139]:="], Cell[BoxData[{ \(\(\((f + f')\)[x]\)[y]\ \), "\n", \(% // Through\ \), "\n", \(% // Through\)}], "Input", CellLabel->"In[142]:="], Cell[TextData[{ "Do we want to push rules or not? When a rule is an option in a function we \ probable don't want to push it, which is the default behavior. We no longer \ want ", Cell[BoxData["a"]], " to be a constant." }], "Text"], Cell[BoxData[ \(ClearAll[a]\)], "Input", CellLabel->"In[145]:="], Cell[BoxData[ \(\(foo[2, a, b, c -> True]\)[x] // PushThrough[{x}]\)], "Input", CellLabel->"In[146]:="], Cell["However, if we do want to push rules, we can.", "Text"], Cell[BoxData[ \(\(foo[2, a, b, c -> True]\)[x] // PushThrough[{x}, PushThroughRules \[Rule] True]\)], "Input", CellLabel->"In[147]:="], Cell[BoxData[ \(\((c \[Rule] True)\)[x] // PushThrough[{x}, PushThroughRules \[Rule] True]\)], "Input", CellLabel->"In[148]:="], Cell[TextData[{ Cell[BoxData["Root"]], " objects also represent numbers and are not pushed." }], "Text"], Cell[BoxData[{ \(\(soln = Part[Roots[3\ \ x^7 + 5\ x^2 == 1, x], 1, 2];\)\), "\n", \({soln, N[soln]}\)}], "Input", CellLabel->"In[149]:="], Cell[BoxData[{ \(\((f + soln\ g)\)[x] // PushThrough[{x}]\), "\[IndentingNewLine]", \(N[%]\)}], "Input", CellLabel->"In[151]:="], Cell["\<\ So with PushThrough as an extra help it will be easy to tackle many \ \"operator\" type problems.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["PushOnto", "Subsection"], Cell["\<\ PushOnto is useful when you want to push arguments only onto specific forms. \ It is rather the converse of specifying what things are constant.\ \>", "Text"], Cell[BoxData[{ \(\((3 p\_1 + a\ p\_2 + c)\)[x]\), "\[IndentingNewLine]", \(% // PushOnto[{x}, {p\__}]\)}], "Input", CellLabel->"In[10]:="], Cell[BoxData[{ \(\(\((3 p\_1 + a\ p\_2 + c)\)[x]\)[y]\), "\[IndentingNewLine]", \(% // PushOnto[{x}, {p\__}]\), "\[IndentingNewLine]", \(% // PushOnto[{y}, {a, c}]\)}], "Input", CellLabel->"In[14]:="], Cell[BoxData[{ \(\(\((3 p\_1 + a\ p\_2 + c)\)[x]\)[y]\), "\[IndentingNewLine]", \(% // PushOnto[{y}, {a, c}]\)}], "Input", CellLabel->"In[17]:="] }, Closed]], Cell[CellGroupData[{ Cell["PushOut", "Subsection"], Cell["\<\ PushOut will factor out the arguments from expressions which consist of \ nested sums, products and powers. It won't work beyond that.\ \>", "Text"], Cell["This factors the argument and then pushes it back onto f.", "Text"], Cell[BoxData[{ \(3 + a\ f[t] + 5 f[t]\), "\[IndentingNewLine]", \(% // PushOut[t]\), "\[IndentingNewLine]", \(% // PushOnto[{f}]\)}], "Input", CellLabel->"In[8]:="], Cell["This is for products.", "Text"], Cell[BoxData[{ \(5 f[t] g[t] h[t]\), "\[IndentingNewLine]", \(% // PushOut[t]\), "\[IndentingNewLine]", \(% // PushThrough[]\)}], "Input", CellLabel->"In[13]:="], Cell["Here are some more complicated expressions.", "Text"], Cell[BoxData[{ \(x[t] + 3 x[t] - a\ x[t] + 3 \((g1[t] + g2[t])\) h[t]\), "\[IndentingNewLine]", \(% // PushOut[t]\), "\[IndentingNewLine]", \(% // PushThrough[Constants \[Rule] {a}]\)}], "Input", CellLabel->"In[16]:="], Cell[BoxData[{ \(x[t] + 3 x[t] - a\ x[t] + 3 \((g1[t] x[t] + g2[t])\) h[t]\), "\[IndentingNewLine]", \(% // PushOut[t]\), "\[IndentingNewLine]", \(% // PushThrough[Constants \[Rule] {a}]\)}], "Input", CellLabel->"In[19]:="], Cell[BoxData[{ \(x[t] + 3 x[t] - a\ x[t] + 3 \((g1[t]/x[t] + g2[t])\) h[t]\), "\[IndentingNewLine]", \(% // PushOut[t]\), "\[IndentingNewLine]", \(% // PushThrough[Constants \[Rule] {a}]\)}], "Input", CellLabel->"In[22]:="], Cell[BoxData[{ \(5 \( f[t]\^3\) g[t]\), "\[IndentingNewLine]", \(% // PushOut[t]\), "\[IndentingNewLine]", \(% // PushThrough[]\)}], "Input", CellLabel->"In[27]:="], Cell[BoxData[{ \(x[t] + 3 x[t] - a\ x[t] + 3 \((\(g1[t]/x[t]\)/y[t] + g2[t])\) h[t]\), "\[IndentingNewLine]", \(% // PushOut[t]\), "\[IndentingNewLine]", \(% // PushThrough[Constants \[Rule] {a}]\)}], "Input", CellLabel->"In[30]:="], Cell["This is an example with multiple arguments.", "Text"], Cell[BoxData[{ \(x[t] + 3 x[t] - a\ x[t] + 3 \((\(g1[t]/x[t]\)/y[t] + g2[t])\) h[t]\), "\[IndentingNewLine]", \(% /. t \[RuleDelayed] Sequence[u, v, w]\), "\[IndentingNewLine]", \(% // PushOut[u, v, w]\), "\[IndentingNewLine]", \(% // PushThrough[Constants \[Rule] {a}]\)}], "Input", CellLabel->"In[33]:="] }, Closed]], Cell[CellGroupData[{ Cell["LinearPushOut", "Subsection"], Cell["\<\ LinearPushOut will do linear distributions of variables in functions. You \ name the functions that are linear, and the variables they are linear in and \ the linear breakout will be done.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(f[a\ x + b\ y] + g[Sin[z]\ x + \(w\^2\) y]\), "\[IndentingNewLine]", \(% // \(LinearPushOut[f, g]\)[x, y]\)}], "Input", CellLabel->"In[3]:="], Cell[BoxData[ \(f[a\ x + b\ y] + g[w\^2\ y + x\ Sin[z]]\)], "Output", CellLabel->"Out[3]="], Cell[BoxData[ \(a\ f[x] + b\ f[y] + w\^2\ g[y] + g[x]\ Sin[z]\)], "Output", CellLabel->"Out[4]="] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["PushDerivative", "Subsection"], Cell["\<\ PushDerivative will push arguments onto derivatives of functional sums.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(\((a\ f + b\ g + c\ h)\)''\)[t]\), "\[IndentingNewLine]", \(% // PushDerivative[f, g, h]\)}], "Input", CellLabel->"In[15]:="], Cell[BoxData[ RowBox[{ SuperscriptBox[\((a\ f + b\ g + c\ h)\), "\[Prime]\[Prime]", MultilineFunction->None], "[", "t", "]"}]], "Output", CellLabel->"Out[15]="], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", RowBox[{ SuperscriptBox["f", "\[Prime]\[Prime]", MultilineFunction->None], "[", "t", "]"}]}], "+", RowBox[{"b", " ", RowBox[{ SuperscriptBox["g", "\[Prime]\[Prime]", MultilineFunction->None], "[", "t", "]"}]}], "+", RowBox[{"c", " ", RowBox[{ SuperscriptBox["h", "\[Prime]\[Prime]", MultilineFunction->None], "[", "t", "]"}]}]}]], "Output", CellLabel->"Out[16]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(\(f = Sin;\)\), "\[IndentingNewLine]", \(\(g = Cos;\)\), "\[IndentingNewLine]", \(\(h = #\^2 &;\)\), "\[IndentingNewLine]", \(\(\((a\ f + b\ g\ + c\ h)\)'\)[t]\), "\[IndentingNewLine]", \(% // PushDerivative[f, g, h]\), "\[IndentingNewLine]", \(Clear[f, g, h]\)}], "Input", CellLabel->"In[19]:="], Cell[BoxData[ RowBox[{ SuperscriptBox[\((b\ Cos + a\ Sin + c\ \((#1\^2 &)\))\), "\[Prime]", MultilineFunction->None], "[", "t", "]"}]], "Output", CellLabel->"Out[22]="], Cell[BoxData[ \(2\ c\ t + a\ Cos[t] - b\ Sin[t]\)], "Output", CellLabel->"Out[23]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(\(\(Derivative[1, 2]\)[a\ f + \ b\ g]\)[x, y]\), "\[IndentingNewLine]", \(% // PushDerivative[f, g]\)}], "Input", CellLabel->"In[17]:="], Cell[BoxData[ RowBox[{ SuperscriptBox[\((a\ f + b\ g)\), TagBox[\((1, 2)\), Derivative], MultilineFunction->None], "[", \(x, y\), "]"}]], "Output", CellLabel->"Out[17]="], Cell[BoxData[ RowBox[{ RowBox[{"a", " ", RowBox[{ SuperscriptBox["f", TagBox[\((1, 2)\), Derivative], MultilineFunction->None], "[", \(x, y\), "]"}]}], "+", RowBox[{"b", " ", RowBox[{ SuperscriptBox["g", TagBox[\((1, 2)\), Derivative], MultilineFunction->None], "[", \(x, y\), "]"}]}]}]], "Output", CellLabel->"Out[18]="] }, Open ]] }, Closed]] }, Open ]] }, Open ]] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 943}}, WindowToolbars->"EditBar", WindowSize->{845, 875}, WindowMargins->{{Automatic, 173}, {Automatic, -39}}, 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->{ "Info3224325605-2197440"->{ Cell[11368, 329, 246, 4, 47, "Print", CellTags->"Info3224325605-2197440"]} } *) (*CellTagsIndex CellTagsIndex->{ {"Info3224325605-2197440", 31825, 1035} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1727, 52, 46, 0, 73, "Title"], Cell[1776, 54, 96, 4, 68, "Subsubtitle"], Cell[1875, 60, 98, 2, 32, "Subsubtitle"], Cell[CellGroupData[{ Cell[1998, 66, 31, 0, 92, "Section"], Cell[2032, 68, 125, 3, 60, "Text"], Cell[2160, 73, 463, 9, 112, "Text"], Cell[2626, 84, 86, 2, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[2749, 91, 47, 0, 60, "Section"], Cell[2799, 93, 254, 7, 48, "Text"], Cell[3056, 102, 82, 2, 31, "Input"], Cell[3141, 106, 81, 2, 31, "Input"], Cell[3225, 110, 169, 3, 48, "Text"], Cell[3397, 115, 125, 3, 54, "Input"], Cell[3525, 120, 60, 0, 28, "Text"], Cell[3588, 122, 128, 3, 55, "Input"], Cell[3719, 127, 885, 30, 108, "Text"], Cell[4607, 159, 643, 12, 88, "Text"], Cell[5253, 173, 261, 5, 48, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[5551, 183, 31, 0, 60, "Section"], Cell[5585, 185, 341, 7, 68, "Text"], Cell[5929, 194, 90, 2, 31, "Input"], Cell[CellGroupData[{ Cell[6044, 200, 83, 2, 31, "Input"], Cell[6130, 204, 5235, 123, 92, "Print"], Cell[11368, 329, 246, 4, 47, "Print", CellTags->"Info3224325605-2197440"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[11663, 339, 28, 0, 92, "Section"], Cell[CellGroupData[{ Cell[11716, 343, 33, 0, 44, "Subsection"], Cell[11752, 345, 66, 0, 28, "Text"], Cell[11821, 347, 168, 3, 32, "Input"], Cell[11992, 352, 432, 7, 88, "Text"], Cell[12427, 361, 42, 0, 28, "Text"], Cell[12472, 363, 105, 2, 31, "Input"], Cell[12580, 367, 41, 0, 28, "Text"], Cell[12624, 369, 102, 2, 31, "Input"], Cell[12729, 373, 136, 5, 28, "Text"], Cell[12868, 380, 110, 2, 31, "Input"], Cell[12981, 384, 99, 2, 31, "Input"], Cell[13083, 388, 116, 4, 28, "Text"], Cell[13202, 394, 97, 2, 31, "Input"], Cell[13302, 398, 117, 5, 28, "Text"], Cell[13422, 405, 115, 2, 31, "Input"], Cell[13540, 409, 196, 4, 48, "Text"], Cell[13739, 415, 110, 2, 31, "Input"], Cell[13852, 419, 164, 3, 48, "Text"], Cell[14019, 424, 104, 2, 31, "Input"], Cell[14126, 428, 89, 2, 31, "Input"], Cell[14218, 432, 103, 2, 31, "Input"], Cell[14324, 436, 211, 5, 48, "Text"], Cell[14538, 443, 141, 3, 54, "Input"], Cell[14682, 448, 144, 5, 28, "Text"], Cell[14829, 455, 126, 3, 28, "Text"], Cell[14958, 460, 153, 3, 32, "Input"], Cell[15114, 465, 134, 3, 32, "Input"], Cell[15251, 470, 418, 10, 68, "Text"], Cell[15672, 482, 131, 3, 32, "Input"], Cell[15806, 487, 358, 10, 48, "Text"], Cell[16167, 499, 154, 4, 32, "Input"], Cell[16324, 505, 60, 0, 28, "Text"], Cell[16387, 507, 139, 3, 32, "Input"], Cell[16529, 512, 86, 2, 28, "Text"], Cell[16618, 516, 138, 3, 32, "Input"], Cell[16759, 521, 398, 11, 48, "Text"], Cell[17160, 534, 134, 3, 31, "Input"], Cell[17297, 539, 54, 0, 28, "Text"], Cell[17354, 541, 183, 4, 55, "Input"], Cell[17540, 547, 216, 5, 78, "Input"], Cell[17759, 554, 126, 3, 55, "Input"], Cell[17888, 559, 66, 2, 31, "Input"], Cell[17957, 563, 180, 5, 28, "Text"], Cell[18140, 570, 146, 3, 31, "Input"], Cell[18289, 575, 187, 4, 31, "Input"], Cell[18479, 581, 202, 4, 54, "Input"], Cell[18684, 587, 188, 4, 54, "Input"], Cell[18875, 593, 51, 0, 28, "Text"], Cell[18929, 595, 196, 4, 55, "Input"], Cell[19128, 601, 66, 2, 31, "Input"], Cell[19197, 605, 37, 0, 28, "Text"], Cell[19237, 607, 120, 3, 31, "Input"], Cell[19360, 612, 132, 3, 31, "Input"], Cell[19495, 617, 212, 6, 48, "Text"], Cell[19710, 625, 339, 6, 100, "Input"], Cell[20052, 633, 37, 0, 28, "Text"], Cell[20092, 635, 225, 4, 77, "Input"], Cell[20320, 641, 62, 0, 28, "Text"], Cell[20385, 643, 190, 4, 77, "Input"], Cell[20578, 649, 102, 3, 28, "Text"], Cell[20683, 654, 137, 3, 31, "Input"], Cell[20823, 659, 121, 3, 28, "Text"], Cell[20947, 664, 192, 4, 54, "Input"], Cell[21142, 670, 177, 5, 28, "Text"], Cell[21322, 677, 205, 4, 54, "Input"], Cell[21530, 683, 47, 0, 28, "Text"], Cell[21580, 685, 207, 4, 54, "Input"], Cell[21790, 691, 109, 3, 28, "Text"], Cell[21902, 696, 195, 4, 54, "Input"], Cell[22100, 702, 126, 3, 28, "Text"], Cell[22229, 707, 161, 4, 77, "Input"], Cell[22393, 713, 164, 4, 77, "Input"], Cell[22560, 719, 92, 2, 28, "Text"], Cell[22655, 723, 189, 4, 77, "Input"], Cell[22847, 729, 160, 3, 28, "Text"], Cell[23010, 734, 156, 4, 77, "Input"], Cell[23169, 740, 145, 4, 77, "Input"], Cell[23317, 746, 238, 6, 48, "Text"], Cell[23558, 754, 70, 2, 31, "Input"], Cell[23631, 758, 109, 2, 31, "Input"], Cell[23743, 762, 61, 0, 28, "Text"], Cell[23807, 764, 147, 3, 31, "Input"], Cell[23957, 769, 140, 3, 31, "Input"], Cell[24100, 774, 108, 3, 28, "Text"], Cell[24211, 779, 149, 3, 54, "Input"], Cell[24363, 784, 139, 3, 54, "Input"], Cell[24505, 789, 121, 3, 28, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[24663, 797, 30, 0, 38, "Subsection"], Cell[24696, 799, 168, 3, 48, "Text"], Cell[24867, 804, 150, 3, 55, "Input"], Cell[25020, 809, 217, 4, 77, "Input"], Cell[25240, 815, 157, 3, 54, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[25434, 823, 29, 0, 38, "Subsection"], Cell[25466, 825, 158, 3, 28, "Text"], Cell[25627, 830, 73, 0, 28, "Text"], Cell[25703, 832, 181, 4, 77, "Input"], Cell[25887, 838, 37, 0, 28, "Text"], Cell[25927, 840, 178, 4, 77, "Input"], Cell[26108, 846, 59, 0, 28, "Text"], Cell[26170, 848, 242, 5, 77, "Input"], Cell[26415, 855, 247, 5, 77, "Input"], Cell[26665, 862, 247, 5, 77, "Input"], Cell[26915, 869, 180, 4, 78, "Input"], Cell[27098, 875, 256, 5, 77, "Input"], Cell[27357, 882, 59, 0, 28, "Text"], Cell[27419, 884, 335, 6, 100, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[27791, 895, 35, 0, 38, "Subsection"], Cell[27829, 897, 212, 4, 48, "Text"], Cell[CellGroupData[{ Cell[28066, 905, 169, 3, 55, "Input"], Cell[28238, 910, 97, 2, 30, "Output"], Cell[28338, 914, 103, 2, 30, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[28490, 922, 36, 0, 38, "Subsection"], Cell[28529, 924, 95, 2, 28, "Text"], Cell[CellGroupData[{ Cell[28649, 930, 155, 3, 54, "Input"], Cell[28807, 935, 180, 4, 30, "Output"], Cell[28990, 941, 523, 14, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[29550, 960, 345, 7, 146, "Input"], Cell[29898, 969, 188, 4, 30, "Output"], Cell[30089, 975, 90, 2, 30, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[30216, 982, 171, 4, 54, "Input"], Cell[30390, 988, 209, 6, 30, "Output"], Cell[30602, 996, 456, 14, 30, "Output"] }, Open ]] }, Closed]] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)