Notebook[{ Cell["Basic Usage of Summa.m ", "Title"], Cell["A package for Symbolic and Infinite Sums Manipulation", "Subtitle"], Cell["\<\ Package \t\tSumma.m \tVersion\t2.4e Author \t\tPeltio (peltio@despammed.com) Development \ton 2.2.1, refined on 3.0 and 4.x Date\t\t\tMarch 2005 Disclaimer\t\teverybody is free to use and modify the package provided that \t\t\t-the original author information is left intact \t\t\t-corrections and enhancements will be as free as this package and, \ possibly, sent to the author \t\t\tVersion 2.4e of the package Summa.m can contain slightly different \ procedures\ \>", "Copyright"], Cell[CellGroupData[{ Cell["Initialization", "Subsection"], Cell[TextData[{ "This loads the package from a location in the search path of ", StyleBox["Mathematica", FontSlant->"Italic"], " ." }], "Text"], Cell["<True], Cell["\<\ The symbols exported are given by ?Summa`*, but after the renaming \ occured in version 2.3 a more sensible list can be found with\ \>", "Text"], Cell[CellGroupData[{ Cell["?Summa`Sum*", "Input"], Cell["\<\ SumApply SumFullSimplify SumPosition SumApplyAt SumFullSimplifyEach SumReIndex SumCoefficient SumIndexAlign SumSimplify SumD SumIntegrate SumSimplifyEach SumDEach Summa SumSimplifySum SumEvaluationStatus SumMap SumSplit SumExpand SumMapAt SumToSumma SumExpandAll SummaToSum SumToTerm SumExponentAlign\ \>", "Print", CellMargins->{{20, Inherited}, {Inherited, Inherited}}, ShowCellLabel->False, CellFrameMargins->{{Inherited, Inherited}, {14, 14}}, Background->GrayLevel[0.930022], ButtonBoxOptions->{Active->True}] }, Open ]], Cell[TextData[{ "The basic object defined in the package is ", StyleBox["Summa", FontWeight->"Bold"], ", a container that substitutes Sum and prevents evaluation. If you choose \ to disable the built-in Sum Evaluation to perform your symbolic \ manipulations, you won't even need to know a thing about it since it will be \ used transparently to the user (who will operate on Sum objects and will see \ output formatted as Sums." }], "Text"], Cell[CellGroupData[{ Cell["?Summa", "Input"], Cell[BoxData[ \(TraditionalForm \`"Abstract type to denote a symbolic or infinite sum.\n \ s=Summa[element,{k,ki,kf}]\n Summa objects with one or both symbolic or \ infinite endpoint are left unevaluated (and displayed as formatted Sums) to \ allow further manipulation. Summa objects with integer endpoints are \ evaluated as built-in Sums. Summa object with symbolic or infinite \ endpoints whose closed form is known to Mathematica are kept internally \ unevaluated, but can be displayed either as unevaluated Sums or as the \ result of the evaluation (see help for SetSumFormat)."\)], "Print"] }, Open ]], Cell["\<\ The other two main functions are devoted to enabling and disabling \ (either locally and globally) the original built-in evaluation associated \ with Sum. They are described in the next section\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Setting the environment", "Section"], Cell[TextData[{ "Starting with version 2, once the package is loaded, the built-in \ evaluation of ", StyleBox["Sum", FontWeight->"Bold"], " is turned off by default for symbolic and infinite endpoints, while it is \ still active for numerical (integer) endpoints. This can be verified by \ displaying the value of the environmental variables $EnableSumEvaluation and \ $EnableNumericSum (it should've been called $EnableNumericSumEvaluation, but \ it was too long a name): " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(SumEvaluationStatus[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"$EnableSumEvaluation = False\n$EnableNumericSum = True"\)], "Output"] }, Open ]], Cell[TextData[{ "Actually, built-in evaluation rules are still alive and kicking, but they \ will never have the chance to see a symbolic ", StyleBox["Sum", FontWeight->"Bold"], ", because when the endpoints are not numeric (not integers, to be exact) \ they will be automatically converted to ", StyleBox["Summa", FontWeight->"Bold"], " objects." }], "Text"], Cell[TextData[{ "Normal evaluation can be restored by means of ", StyleBox["EnableSumEvalution[Extent\[Rule]All]", FontWeight->"Bold"], ". To manually switch off the built-in ", StyleBox["Sum", FontWeight->"Bold"], " evaluation process, the package offers the command ", StyleBox["DisableSumEvaluation[opt]", FontWeight->"Bold"], ". The option ", StyleBox["Verbose", FontWeight->"Bold"], " can be used to issue a warning message to the user." }], "Text"], Cell[TextData[{ StyleBox["EnableSumEvaluation[]", FontFamily->"Courier New", FontWeight->"Bold"], "\tenables the built-in evalution process associated with Sum; only Summa \ objects ca be used to represent sums without being automatically evaluated. \ This behaviour is analogous to what happend with version 1.x of the package.\n\ ", StyleBox["DisableSumEvaluation[]", FontFamily->"Courier New", FontWeight->"Bold"], "\tdisables the built-in evaluation process associated with Sum: every Sum \ is automatically converted into a Summa object (but it is displayed in all \ forms but InputForm as a sum) in order to allow the manipulation routines of \ the package to act on it.\n", StyleBox["Extent\[Rule]Symbolic", FontFamily->"Courier New", FontWeight->"Bold"], "\t\tExtent allows the user to specify if ", StyleBox["Mathematica ", FontSlant->"Italic"], "has to take control over Sums with symbolic and/or numerical endpoints. It \ is possibile to have four cases, by combining the option values {Symbolic, \ Numeric, All, None} and the two procedures - these are not the four possible \ case one would expect, though, since Extent->Symbolic does affect every Sum \ and not only thse with symbolic endpoints (Numeric affects Summas, in a \ subsequent stage of the evaluation chain) . By default EnableSumEvaluation \ has Extent->All (which means that when it is invoked without options every \ sum is evaluated by ", StyleBox["Mathematica)", FontSlant->"Italic"], " and DisableSumEvaluation has Extent->Symbolic (which means that when \ called without parameters, it will pass to ", StyleBox["Mathematica'", FontSlant->"Italic"], "s evaluator only the sums with numerical endpoints).\n", StyleBox["Verbose\[Rule]True", FontFamily->"Courier New", FontWeight->"Bold"], "\t\t\tVerbose is an option for the above two commands that can switch on \ and off a brief message warning the user on how the Sum will behavbe \ thereafter. It is by default set to True." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell["\<\ There are four possible states that can be reached invoking the \ enabling and disabling procedures with the corresponding value for the \ options Extent. Please note the disabling options are not fully independent: \ numerical evaluation can be disabled only on Summa objects, hence its effects \ on Sums is subordinated to the disabling of Sum Evaluation (this is a remnant \ of previous version of the package and is not reflected in the warning \ messages printed by the procedures - it will be fixed in a future release).\ \ \>", "Text"], Cell[TextData[Cell[BoxData[ FormBox[GridBox[{ { StyleBox[\(Case\ \), FontWeight->"Bold", GridBoxOptions->{ColumnAlignments->{Left}}], StyleBox[\(Enable\ ""\), FontWeight->"Bold"], " ", StyleBox["Disable", FontWeight->"Bold"], StyleBox["$EnableSumEvaluation", FontWeight->"Bold"], StyleBox["$EnableNumericSum", FontWeight->"Bold"]}, { StyleBox[ \(Sums\ with\ symbolic\ or\ \ numeric \[IndentingNewLine]endpoints\ are\ evaluated\ by\ Mathematica \[IndentingNewLine]\((default\ Mathematica\ behavior)\)\), FontSize->10, GridBoxOptions->{ColumnAlignments->{Left}, RowLines->True}], StyleBox["All", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["or", FontSize->10, FontSlant->"Italic", GridBoxOptions->{RowLines->True}], StyleBox["None", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["True", GridBoxOptions->{RowLines->True}], StyleBox["True", GridBoxOptions->{RowLines->True}]}, { StyleBox[ \(Sums\ with\ symbolic\ or\ \ numeric\ \[IndentingNewLine]\(endpoints\ are\ \ evaluated\ by\ Mathematica; \)\[IndentingNewLine]\ Summa\ objects\ with\ symbolic\ or\ numeric\ \[IndentingNewLine]endpoints\ are\ not \ \(\((that\ is\ Summa\ \ evaluation\[IndentingNewLine]is\ \ totally\ inhibited)\) . \)\), FontSize->10, GridBoxOptions->{ColumnAlignments->{Left}, RowLines->True}], StyleBox["Symbolic", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["and", FontSize->10, FontSlant->"Italic", GridBoxOptions->{RowLines->True}], StyleBox["Numeric", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["True", GridBoxOptions->{RowLines->True}], StyleBox["False", GridBoxOptions->{RowLines->True}]}, { StyleBox[ \(Sums\ \ are\ not\ evaluated\ by\ Mathematica \[IndentingNewLine]unless\ their\ endpoints\ are\ numerical . \[IndentingNewLine]\((default\ Summa . m\ behavior)\)\), FontSize->10, GridBoxOptions->{ColumnAlignments->{Left}, RowLines->True}], StyleBox["Numeric", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["and", FontSize->10, FontSlant->"Italic", GridBoxOptions->{RowLines->True}], StyleBox["Symbolic", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["False", GridBoxOptions->{RowLines->True}], StyleBox["True", GridBoxOptions->{RowLines->True}]}, { StyleBox[\(Sum\ Evaluation\ is\ totally\ inhibited, \ either\[IndentingNewLine]for\ symbolic\ and\ for\ numerical\ \(endpoints . \)\), FontSize->10, GridBoxOptions->{ColumnAlignments->{Left}, RowLines->True}], StyleBox["None", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["or", FontSize->10, FontSlant->"Italic", GridBoxOptions->{RowLines->True}], StyleBox["All", FontFamily->"Courier New", FontWeight->"Bold", GridBoxOptions->{RowLines->True}], StyleBox["False", GridBoxOptions->{RowLines->True}], StyleBox["False", GridBoxOptions->{RowLines->True}]} }], TraditionalForm]], TextAlignment->Left]], "Text", GridBoxOptions->{GridFrame->True, RowLines->True}], Cell[TextData[ "Specifying Extent\[Rule]Symbolic in one of the two procedures won't alter \ the evaluation of Numeric sums, and viceversa.Certain states may require the \ application of two such procedures to be attained."], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Options[EnableSumEvaluation]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`{Scope \[Rule] Local, Extent \[Rule] All, Verbose \[Rule] True}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Options[DisableSumEvaluation]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`{Scope \[Rule] Local, Extent \[Rule] Symbolic, Verbose \[Rule] True} \)], "Output"] }, Open ]], Cell[TextData[{ "\nIt is possible to enable or disable the evaluation only for a given \ expression, converting all the ", StyleBox["Summa", FontWeight->"Bold"], " into ", StyleBox["Sum", FontWeight->"Bold"], " and viceversa, before evaluating the expression. This behaviour can be \ accomplished by passing the expression to ", StyleBox["EnableSumEvaluation", FontWeight->"Bold"], " or ", StyleBox["DisableSumEvaluation", FontWeight->"Bold"], ". " }], "Text"], Cell[TextData[{ StyleBox["EnableSumEvaluation[expr]\t", FontFamily->"Courier New", FontWeight->"Bold"], "enables the built-in evalution process associated with Sum, substitutes \ every occurence of Summa in expr with Sum, and returns the expression over \ which ", StyleBox["Mathematica", FontSlant->"Italic"], " had performed its transformations. If the Scope is set to Local, as by \ default, Sum evaluation is turned off and every survived Sum is turned into a \ Summa. If the Scope is set to Global, the built-in evaluation is left \ enabled, with a warning message to the user (if Verbose is True).\n", StyleBox["DisableSumEvaluation[expr]\t", FontFamily->"Courier New", FontWeight->"Bold"], "disables the built-in evalution process associated with Sum, substitutes \ every occurence of Sum in expr with Summa, and returns expr. If the Scope is \ set to Local, as by default, Sum evaluation is turned off and every survived \ Sum is turned into a Summa. If the Scope is set to Global, the built-in \ evaluation is left enabled, with a warning message to the user (if Verbose is \ True)..\n", StyleBox["Scope\[Rule]Local\t\t\t\t\t", FontFamily->"Courier New", FontWeight->"Bold"], "Scope is an option for the above two commands that states whether the \ change of environment should affect only the expression passed to them or \ every subsequent input of the user. It is by default set to Local." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell["\<\ Hence, there are several different ways to use this package and the \ functions it provides. \tThe default method consist in working with symbolic and infinite Sums as if \ there were no built-in evaluation associated to them: unless both endpoints \ be numeric, Sums don't evaluate and the manipulation routines of the package \ (for simplifying, reindexing, differentiation and integration) can be applied \ to them directly. Some care must be exerted when the user want to apply the \ built-in evaluation, since it has to turn it on, first, either globaly or \ locally, as described later on. \tAnother way to use the package consist in turning on the built-in \ evaluation and do the symbolic manipulations on Summa objects only, as it \ happened with versions prior to 2.x of Summa.m \tA third way consist in switching from one environment to the other as the \ user sees fit. The package provides two functons that can be used to enabing \ or disabling the built-in evaluation process for all the subsequent input or \ only with respect to a single expression. \tWhen needed, even the evaluation for numerical endpoints can be \ inhibited.\ \>", "Text"], Cell[CellGroupData[{ Cell["Working with Sum objects directly: DisableSumEvalutation[]", "Subsection"], Cell[TextData[{ "Once the package is loaded, the built-in evaluation of Sum is turned off \ by default ($EnableSumEvaluation=False). Actually, the evaluation process is \ still there, but it won't have a chace to see a symbolic Sum, because every \ occurence of Sum will be automatically converted to Summa, over which the \ package manpulating function can operate. By default, Summa object with \ numerical (integers, to be exact) endpoints are reverted back to ordinary \ Sums and passed on to ", StyleBox["Mathematica'", FontSlant->"Italic"], "s evaluator ($EnableNumericSum=True). " }], "Text"], Cell["\<\ Normal evaluation can be restored by means of \ EnableSumEvalution[]. To manually switch off the built-in Sum evaluation \ process, the package offers the command DisableSumEvaluation[]\ \>", "Text"], Cell[TextData[{ StyleBox["DisableSumEvaluation[]", FontWeight->"Bold"], " disables the built-in mechanism of evaluation for the Sum objects in \ Mathematica, allowing Sum to be treated as a Summa object (see help for \ Summa). When this function is invoked it prevents Mathematica from \ evaluating infinite and symbolic sums as it would normally do. The function \ sets the (protected) variable $EnableSumEvaluation to False and prevents \ Summa behavior from acting on Sum.\n", StyleBox["DisableSumEvaluation[expr]", FontWeight->"Bold"], " disables the built-in Sum evaluation and then substitutes every \ occurrence of Sum in expr with Summa . It switches the standard evaluation \ on if the option Scope is set to Local, as by default; with Scope->Global, \ builtin Sum evaluation is left off, as after DisableSumEvaluation[]. The \ option Verbose is used to choose whether to display or not a message when \ the effect is global. It is by default set to True.\"" }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Sums with Symbolic endpoints will be turned into Summa \ objects that will not be evaluated by Mathematica. Summa objects are \ formatted and shown as ordinary Sums (provided there are no explicit \ instructions to evaluate them)."\)], "Print"] }, Open ]], Cell["\<\ For example, this sum, that would ordinarily evaluate to (Pi^2)/6, \ is now left intact\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[1/k^2, {k, 1, \[Infinity]}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Please note that, despite the output and traditional form of this \ expression look like a Sum, the internal representation (and its input form) \ show that there's a Summa object taking over in order to prevent \ evaluation.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[1/k^2, {k, 1, \[Infinity]}] // OutputForm\)], "Input"], Cell[OutputFormData["\<\ Summa[k^(-2), {k, 1, Infinity}]\ \>", "\<\ -2 Sum[k , {k, 1, \[Infinity]}]\ \>"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[1/k^2, {k, 1, \[Infinity]}] // InputForm\)], "Input"], Cell["Summa[k^(-2), {k, 1, Infinity}]", "Output"] }, Open ]], Cell[" In fact the previous sum can be input in this way:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Summa[1/k^2, {k, 1, \[Infinity]}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Since Sum is automatically replaced by Summa, we can input \ expressions using Sum and not worry about Summa objects anymore.\ \>", "Text"], Cell[TextData[{ "Obviously, the package can still work with Summa objects in the same way \ version 1.x did. The only difference, when DisableSumEvaluation[] has been \ invoked is that it necessary to tell ", StyleBox["Mathematica", FontSlant->"Italic"], " when we want the built-in Sum evaluation process to be re-estabilished, \ either locally (applied to a single expression) or globally. The procedures \ SummaToSum and EnableSumEvaluation take care of these tasks." }], "Text"], Cell["\<\ DisableSumEvaluation can be used to turn off the built-in \ evaluation of summas with numerical endpoints (it will affect Sums too only \ if their evaluation has been disabled with Extent->Symbolic). This is how to \ do it globally\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[Extent \[Rule] Numeric]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Summa objects with numerical endpoints will not be \ evaluated by Mathematica. This will affects Sums only if their evaluation \ has already been inhibited."\)], "Print"] }, Open ]], Cell["For example", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = Sum[1/k^2, {k, 1, 3}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%3 1\/k\^2\), HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(InputForm[%]\)], "Input"], Cell["Summa[k^(-2), {k, 1, 3}]", "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(expr == EnableSumEvaluation[expr, Extent \[Rule] Numeric]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%3 1\/k\^2\), HoldForm], "TraditionalForm"], "==", \(49\/36\)}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Here we re-enable Numeric sum evaluation.Symbolic sum evaluation is \ left in its previuos state\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(EnableSumEvaluation[Extent \[Rule] Numeric]\), \(SumEvaluationStatus[]\)}], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Sums and Summa objects with numerical endpoints will be \ passed to Mathematica for evaluation."\)], "Print"], Cell[BoxData[ \(TraditionalForm \`"$EnableSumEvaluation = False\n$EnableNumericSum = True"\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Working with Summa objects only: EnableSumEvalutation[]", "Subsection"], Cell["\<\ It is possibile to let the functions of the package operate on \ Summa objects only, leaving the built-in Sum evaluation process unaltered. \ This can be achieved by means of the command EnableSumEvaluation[] (the \ default value for option Extent is All) and results in the same functionalty \ of older versions of the package.\ \>", "Text"], Cell[TextData[{ StyleBox["EnableSumEvaluation[]", FontWeight->"Bold"], " enables the built-in mechanism of evaluation for Sum objects with \ symbolic endpoints in Mathematica. When this function is invoked it causes \ Mathematica to evaluate sums as with a fresh kernel. Summa objects are still \ available. EnableSumEvaluation[] sets the (protected) variable \ $EnableSumEvaluation to True and allows Summa behavior to ovveride Sum.\n", StyleBox["EnableSumEvaluation[expr]", FontWeight->"Bold"], " enables the built-in Sum evaluation and then substitutes every \ occurrence of Summa in expr with Sum. It switches the standard evaluation \ off if the option Scope is set to Local, as by default; with Scope->Global, \ built-in Sum evaluation is left on, as after EnableSumEvaluation[]. The \ option Verbose is used to choose whether to display or not a message when \ the effect is global. It is by default set to True." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell["\<\ After invoking the procedure the (protected) variable \ $EnableSumEvaluation - whose value is by default set to 0 - is set to 1, and \ the added definition of Sum that made it act as a Summa object, won't apply \ anymore.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on not only all Sums, but also Summa objects with numerical \ endpoints will be passed to Mathematica for evaluation."\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SumEvaluationStatus[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"$EnableSumEvaluation = True\n$EnableNumericSum = True"\)], "Output"] }, Open ]], Cell["\<\ We can see that Sum is working as it would in a fresh Mathematica \ session: \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \({Sum[1/k^2, {k, 1, \[Infinity]}], Sum[1/k^2, {k, 1, 3}]}\)], "Input"], Cell[BoxData[ \(TraditionalForm\`{\[Pi]\^2\/6, 49\/36}\)], "Output"] }, Open ]], Cell["\<\ Hence, if we want to perform the symbolic manipulations allowed by \ the package we have to explicitly use Summa objects. When \ $EnableSumEvaluation and $EnableNumericSum are set to True, version 2.x of \ the Summa.m package acts in the same way version 1.x did. There is , though, \ a subtlety: Summas with numerical endpoint are automatically converted to Sum \ and evaluated.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \({Summa[1/k^2, {k, 1, \[Infinity]}], Summa[1/k^2, {k, 1, 3}]}\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], "TraditionalForm"], ",", \(49\/36\)}], "}"}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We can disable that behavior too by setting $EnableNumericSum to \ False (the warning message is not adequate, and it will be rewrintten in a \ future release). \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[Extent \[Rule] Numeric]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Summa objects with numerical endpoints will not be \ evaluated by Mathematica. This will affects Sums only if their evaluation \ has already been inhibited."\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \({Summa[1/k^2, {k, 1, \[Infinity]}], Summa[1/k^2, {k, 1, 3}]}\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], "TraditionalForm"], ",", FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%3 1\/k\^2\), HoldForm], "TraditionalForm"]}], "}"}], TraditionalForm]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Switching the environment, either globally or locally", "Subsection"], Cell[CellGroupData[{ Cell["Globally enabling and disabling Sum evaluation", "Subsubsection"], Cell["\<\ It possible to switch from one environment to the other by issuing \ the corresponding enabling or disabling command. For example, this set the \ environment to the default condition after having loaded the package.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(DisableSumEvaluation[]; \)\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Sums with Symbolic endpoints will be turned into Summa \ objects that will not be evaluated by Mathematica. Summa objects are \ formatted and shown as ordinary Sums (provided there are no explicit \ instructions to evaluate them)."\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(expr = Sum[\((a\_k + 3/k)\)/k, {k, 1, Infinity}] + Sum[1/2\^n, {n, 0, \[Infinity]}]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(2\^\(-n\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(a\_k + 3\/k\)\/k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["expr=BringOut[SumExpand[expr]]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(2\^\(-n\)\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"3", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We know that the internal representation of the above sums is in \ term of Summa object. We might want mathematica to act upon the convergent \ series obtained: it is no use, tohogh, trying to substitute Summa occurences \ with Sum since every instance of Sum will be evaluated as Summa and nothing \ will happen\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr /. Summa \[Rule] Sum\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(2\^\(-n\)\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"3", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ "We have to stop Summa from taking control over Sum: to do this we use the \ command ", StyleBox["EnableSumEvalutation[]", FontWeight->"Bold"], " that restores the built-in evaluation process associated with Sum." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on not only all Sums, but also Summa objects with numerical \ endpoints will be passed to Mathematica for evaluation."\)], "Print"] }, Open ]], Cell["\<\ Note that, even if we have enabled the Sum evaluation process, expr \ is still internally expressed in terms of Summa objects, to which Sum does \ not apply. We must then manually substitute the occurences of Summa we want \ to evaluate (we can choose with pattern matching those we want to act upon) \ with Sum e let Mathematica perform its magic:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr /. Summa \[Rule] Sum\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], "+", \(\[Pi]\^2\/2\), "+", "2"}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ New inputs will of course be treated as conventional Mathematica \ Sum object.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[1/k^2, {k, 1, \[Infinity]}]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`\[Pi]\^2\/6\)], "Output"] }, Open ]], Cell["\<\ The enabling and disabling procedures can be prevented from \ printing warning messages specifying a proper value for the option Verbose.\ \ \>", "Text"], Cell[BoxData[ \(\(DisableSumEvaluation[Verbose \[Rule] False]; \)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Locally enabling Sum evaluation", "Subsubsection"], Cell["\<\ It is also possible to enable Sum evaluation in a single \ espression, automatically substituting every occurence of Summa with Sum or \ vice versa. This is useful when, after having manipulated the expressions by \ means of the functions supplied with the package, we want Mathematica to \ perform some of its magic over what we obtained.\ \>", "Text"], Cell[TextData[{ "When ", StyleBox["$EnableSumEvaluation\[Equal]False", FontFamily->"Courier New", FontWeight->"Bold"], "\n", StyleBox["SumManipulation", FontFamily->"Courier New", FontSlant->"Italic"], StyleBox["[expr]", FontFamily->"Courier New", FontWeight->"Bold"], "\tPerforms the manipulations on expressions containg Summa objects and \ Sums that are automatically evaluated to Summa.\n", StyleBox["EnableSumEvaluation[expr]", FontFamily->"Courier New", FontWeight->"Bold"], "\tTemporarily restores the built-in evaluation process associated to Sum \ and evaluate the expression passed as if all the sums contained were Sum. It \ returns the object simplified by mathematica with all the instaces of Sum \ replaced by Summa (as it happens in the environment with $EnableSumEvalution \ set to False)." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell[BoxData[ \(expr = Sum[\((a\_k + 3/k)\)/k, {k, 1, Infinity}] + Sum[1/2\^n, {n, 0, \[Infinity]}]; \n expr = BringOut[SumExpand[expr]]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(2\^\(-n\)\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"3", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ The first two series converge and can be simplified (the first \ being a geometric series and the second converging to (Pi^2)/6). So we let \ mathemtica take care of them:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = EnableSumEvaluation[expr]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], HoldForm], "TraditionalForm"], "+", \(\[Pi]\^2\/2\), "+", "2"}], TraditionalForm]], "Output"] }, Open ]], Cell["The previous command is in fact equivalent to ", "Text"], Cell[BoxData[ \(EnableSumEvaluation[Verbose \[Rule] False]; \n expr = expr /. Summa \[Rule] Sum; \n DisableSumEvaluation[Verbose \[Rule] False]; \n expr /. Sum \[Rule] Summa\)], "Input", Evaluatable->False], Cell["\<\ As we can see the sum evaluation process is still disabled (and all \ Sums are replaced by Summa in order to let the manipulation routine act on \ them) but the simplification has already taken place\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // InputForm\)], "Input"], Cell["2 + Pi^2/2 + Summa[Subscript[a, k]/k, {k, 1, Infinity}]", "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[1/k^2, {k, 1, \[Infinity]}] // InputForm\)], "Input"], Cell["Summa[k^(-2), {k, 1, Infinity}]", "Output"] }, Open ]], Cell["\<\ If we set the option Scope to Global the expression is returned in \ terms of plain Sum(s) in the traditional Mathematica environment with Sum \ evaluation enabled.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Locally disabling Sum evaluation", "Subsubsection"], Cell["\<\ The reverse operation, temporarily disabiling Sum evaluation and \ substituting every occurence of Sum with Summa, can be used with expressions \ that contains commands to perform simplifications and manipulations over \ Sums. The HoldFirst attribute of DisableSumEvaluation prevents these \ procedures to be applied on conventional Sums before the environment has been \ properly set. The result is returned in terms of Sum objects in an \ environment with Sum evaluation enabled. \ \>", "Text"], Cell[TextData[{ "When ", StyleBox["$EnableSumEvaluation\[Equal]True", FontFamily->"Courier New", FontWeight->"Bold"], "\n", StyleBox["SumManipulation", FontFamily->"Courier New", FontSlant->"Italic"], StyleBox["[expr]", FontFamily->"Courier New", FontWeight->"Bold"], "\tMust not be used, since the manipulation command are set to act on Summa \ objects and the Sums will evaluate before being passed to thema, generating \ error messages.\n", StyleBox["DisableSumEvaluation[", FontFamily->"Courier New", FontWeight->"Bold"], StyleBox["SumManipulation", FontFamily->"Courier New", FontSlant->"Italic"], StyleBox["[expr]]", FontFamily->"Courier New", FontWeight->"Bold"], "\t\tTemporarily disables the built-in evaluation process associated to Sum \ and performs the simplifications expressed by the Sum manipulation commands \ as if all the sums contained were Summa object. It returns the object with \ all the instaces of Summa replaced by Sum (as it happens in the environment \ with $EnableSumEvalution set to True) thus allowing ", StyleBox["Mathematica", FontSlant->"Italic"], " to perform further simplifications on it before giving it back to the \ user." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell["\<\ Suppose we are in an environment that allows to manipulate Summa \ objects but let the Sum objects be evaluated by the Mathematica kernel: \ \>", "Text"], Cell[BoxData[ \(EnableSumEvaluation[Verbose \[Rule] False]\)], "Input"], Cell["\<\ Suppose, also, that we have the following sum, a part of which does \ not evaluate because Mathematica does not recognize any known pattern (note \ that the second series, a geometric series, is immediatly evaluated)\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ expr = Sum[\((a\_k + 3/k)\)/k, {k, 1, Infinity}] + Sum[1/2\^n, {n, 0, \[Infinity]}]\)\)], "Input"], Cell[BoxData[ \(TraditionalForm \`\[Sum]\+\(k = 1\)\%\[Infinity]\( a\_k + 3\/k\)\/k + 2\)], "Output"] }, Open ]], Cell["\<\ We might want to manipulate the first series by expanding its term \ and by extracting the constant factors. We can do this by simply wrapping the \ manipulation commands with DisableSumEvaluation, or by passing them to the \ procedure like this \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = BringOut[SumExpand[expr]] // DisableSumEvaluation\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], "+", \(\[Pi]\^2\/2\), "+", "2"}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ As we can see, we had only Sum symbols in expr before evaluation \ and we have only Sum symbols in expr after evaluation\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(InputForm[expr]\)], "Input"], Cell["2 + Pi^2/2 + Sum[Subscript[a, k]/k, {k, 1, Infinity}]", "Output"] }, Open ]], Cell["\<\ The above command is in fact equivalent to the sequence of \ statements\ \>", "Text"], Cell[BoxData[ \(DisableSumEvaluation[Verbose \[Rule] False]; \n expr = expr /. Sum \[Rule] Summa; \n EnableSumEvaluation[Verbose \[Rule] False]; \n expr /. Summa \[Rule] Sum\)], "Input", Evaluatable->False], Cell["\<\ If we pass the expression to DisableSumEvaluation with the option \ Scope set to Global the last two command are not issued and the expression is \ returned in terms of Summa objects in an evnironment where sum evaluation is \ disabled.\ \>", "Text"] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Basic Usage", "Section"], Cell["\<\ To demonstrate the features of version 2 of the package Summa.m, we \ will work directly with Sum's signature. To use Summa objects while letting \ Sum evaluate as usual, please refer to section \"Setting the environment\".\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Sums with Symbolic endpoints will be turned into Summa \ objects that will not be evaluated by Mathematica. Summa objects are \ formatted and shown as ordinary Sums (provided there are no explicit \ instructions to evaluate them)."\)], "Print"] }, Open ]], Cell["\<\ First thing first, we create a few sums. In the default environment \ after loading the package they are automatically converted into Summa objects\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ \(( lista\ = \ {\n\t\t\ts1\ = \ Sum\ [\(a\_k\) x^k, \ {k, \ 0, \ Infinity}], \n \t\t\t\ s2\ = \ Sum[a\_k\ x^\((k\ - \ 3)\), \ {k, \ 0, \ Infinity}], \n\t\t\t\ s3\ = \ Sum[\((x\ - \ 1)\)\ b\_k\ x^k, \ {k, \ 0, \ Infinity}]\n \t\t\t})\) // ColumnForm\)\)], "Input"], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { FormBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], "TraditionalForm"]}, { FormBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k - 3\)\ a\_k\)}], "TraditionalForm"]}, { FormBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((x - 1)\)\ x\^k\ b\_k\)}], "TraditionalForm"]} }, GridBaseline->{Baseline, {1, 1}}, ColumnAlignments->{Left}], ColumnForm[ { Summa[ Times[ Power[ x, k], Subscript[ a, k]], {k, 0, DirectedInfinity[ 1]}], Summa[ Times[ Power[ x, Plus[ -3, k]], Subscript[ a, k]], {k, 0, DirectedInfinity[ 1]}], Summa[ Times[ Plus[ -1, x], Power[ x, k], Subscript[ b, k]], {k, 0, DirectedInfinity[ 1]}]}], Editable->False], TraditionalForm]], "Output"] }, Open ]], Cell["We can see that the InputForm is indeed that of a Summa:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(s1 // InputForm\)], "Input"], Cell["Summa[x^k*Subscript[a, k], {k, 0, Infinity}]", "Output"] }, Open ]], Cell["\<\ Now we can explore the manipulation functions. They are for the \ most part rule based., so it is possible to apply them to general expressions \ (such as lists or equations) containing sums to have them automatically \ applied to every single sum contained therein. This is a feature chosen at \ design stage because the package was meant to operate on differential \ equations, and at the time it was deeemed to be more useful than overloading \ Expand, Simplify, D and Integrate to let them operate properly on Summa \ objects.\ \>", "Text"], Cell[CellGroupData[{ Cell["Element extraction (version dependent, at present)", "Subsection"], Cell[TextData[{ "\nThe following function extracts the coefficients of ", Cell[BoxData[ \(TraditionalForm\`x\^k\)]], " inside the Summa objects: it is quite rude, but its purpose is to get the \ coefficients at the end of a simplification." }], "Text"], Cell[TextData[{ StyleBox["SumCoefficient[Summa[el,it],x]", FontWeight->"Bold"], " returns Coefficient[el,x].\n", StyleBox["SumCoefficient[expr,x,0]", FontWeight->"Bold"], " returns expr when all the powers of x are set to zero." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["SumCoefficient[#,x^k]&/@ lista", "Input"], Cell[BoxData[ \(TraditionalForm\`{a\_k, a\_k\/x\^3, x\ b\_k - b\_k}\)], "Output"] }, Open ]], Cell["Mma v4 gets a different coefficients, ", "Text"], Cell[BoxData[ \(TraditionalForm\`{a\_k, 0, \((x - 1)\)\ b\_k}\)], "Output"], Cell[TextData[StyleBox[ "probably because of the modified simplification procedures.Have to check \ this out and provide a patch and make the results consistent. What is better? \ 0 or a power of x? I guess 0 is better. I wonder what the results on version \ 5 and 5.1 are.", FontSlant->"Italic"]], "Text", FontColor->GrayLevel[0.500008]], Cell["\<\ SumToTerm (GetElement) takes whatever is inside Summa objects, but \ leaves untouched whatever is outside. This is not a bug: it's a feature.\ \>", "Text"], Cell[TextData[{ StyleBox["SumToTerm[expr]", FontWeight->"Bold"], " replace the sums with their terms, by simply dropping the Sum structure \ and the iterator." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["SumToTerm[{lista,lista+5-Sin[x]}]", "Input"], Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {\(x\^k\ a\_k\), \(x\^\(k - 3\)\ a\_k\), \(\((x - 1)\)\ x\^k\ b\_k\)}, {\(a\_k\ x\^k - sin(x) + 5\), \(a\_k\ x\^\(k - 3\) - sin(x) + 5\), \(\((x - 1)\)\ b\_k\ x\^k - sin(x) + 5\)} }], ")"}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ The reason for this bug, er.. feature, is that when we have to \ apply the principle of identity of polynomials to an equation line this \ one:\ \>", "Text"], Cell[BoxData[ \(\(eq = a\_0 + \(a\_1\) x + \(a\_2\) x^2 + Sum[\(a\_k\) x^k, {k, 3, \[Infinity]}] == 0; \)\)], "Input"], Cell["\<\ it may be easier to proceed by simply suppressing the Summa \ structure\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(SumToTerm[eq]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`a\_k\ x\^k + a\_2\ x\^2 + a\_1\ x + a\_0 == 0\)], "Output"] }, Open ]], Cell[TextData[{ "despite mathematically abominable, if we keep in mind that k may vary from \ 3 to infinity, this trick will lead to the correct result, i.e. ", Cell[BoxData[ \(TraditionalForm\`a\_k\)]], "=0 for k=0,1,2,.." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Expansion and simplification", "Subsection"], Cell["Here is a more complex espression to handle", "Text"], Cell[CellGroupData[{ Cell["espr=(1-x^2)s1-2s2+s3", "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{\(-2\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], "+", RowBox[{\((1 - x\^2)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((x - 1)\)\ x\^k\ b\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Let's expand it\ \>", "Text"], Cell[TextData[{ StyleBox["SumExpand[expr]", FontWeight->"Bold"], " expands what is inside every sum and makes a separate sum for each term. \ It is usually used in connection with BringIn. This function shares the same \ options as Expand." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["espr2=SumExpand[espr]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ RowBox[{"-", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"]}], " ", \(x\^2\)}], "+", RowBox[{ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ b\_k\)}], HoldForm], "TraditionalForm"], ")"}], " ", "x"}], "-", RowBox[{"2", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"], "-", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ b\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ "Here's another example, that exploits the built-in evaluation of Sum of ", StyleBox["Mathematica,", FontSlant->"Italic"], " wrapping EnableSumEvaluation around the expression to enable it locally. \ If we specify the object directly in the body of EnableSumEvaluation we have \ to use Summa instead of Sum because the substitution Sum\[Rule]Summa wouldn't \ take place inside that bounds." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"SumExpand", "[", StyleBox[\(Summa[a\ k^2\ + \ g[k], \ {k, 1, \ n}]\), FormatType->StandardForm], StyleBox["]", FormatType->StandardForm]}], StyleBox["//", FormatType->StandardForm], "EnableSumEvaluation"}]], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(1\/6\ a\ n\ \((n + 1)\)\ \((2\ n + 1)\)\), "+", FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%n g(k)\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We can use Sum when the object is evaluated externally to the \ EnableSumEvaluation[] 'walls'.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ RowBox[{"temp", "=", StyleBox[\(Sum[a\ k^2\ + \ g[k], \ {k, 1, \ n}]\), FormatType->StandardForm]}], StyleBox[";", FormatType->StandardForm], "\n", RowBox[{ RowBox[{"SumExpand", "[", "temp", StyleBox["]", FormatType->StandardForm]}], StyleBox["//", FormatType->StandardForm], "EnableSumEvaluation"}]}]], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(1\/6\ a\ n\ \((n + 1)\)\ \((2\ n + 1)\)\), "+", FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%n g(k)\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Sometimes a single expansion is not enough. SumExpandAll performs \ the expansion until the result no longer change. And it applies BringIn at \ the end of this process\ \>", "Text"], Cell[TextData[{ StyleBox["SumExpandAll[expr]", FontWeight->"Bold"], " repeatedly expands what is inside every sum and makes a separate sum for \ each term until the expression no longer changes. It also brings \ premultiplying factors inside the sums. This function shares the same \ options as ExpandAll." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["SumExpandAll[espr]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-2\)\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^\(k + 2\)\)\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^k\)\ b\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k + 1\)\ b\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ If we bring the factors inside the Summa objects in espr2 we obtain the same \ result\ \>", "Text"], Cell[TextData[{ StyleBox["BringIn[expr]", FontWeight->"Bold"], " brings the eventual factor pre-multiplying a sum inside the sum \ symbol.In doing so, if the internal variable $Explode is set to True, it \ performs an automatic expansion of what is inside.\\n BringIn[expr, c] \ multiplies the addendum of the sum by c and divides the whole sum by the \ same amount. The quantity c must not depend on the index." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["espr3=BringIn[espr2]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-2\)\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^\(k + 2\)\)\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^k\)\ b\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k + 1\)\ b\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ BringIn has no effect on functions of the index that are outside \ the Sum: that is a function of k will not be brought inside a sum with index \ k. To force this behavior it is necessary to give another name to the \ index.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(espr4 = {f[k] Sum[\(a\_k\) x^k, {k, 0, \[Infinity]}], f[j] Sum[\(a\_k\) x^k, {k, 0, \[Infinity]}]}\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ RowBox[{\(f(k)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"]}], ",", RowBox[{\(f(j)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"]}]}], "}"}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BringIn[espr4]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ RowBox[{\(f(k)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"]}], ",", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ \(f(j)\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], "}"}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ >From version 2.2 of the package, BringIn can take a second argument \ c that specifies a quantity to be brought inside the sum. In order not to \ change the value of a sum, since the addendum is multiplied by c, the sum is \ divided by the same amount. The quantity c must not depend on the index of \ the sum; if it does, the sum is left untouched. Please note: if you apply \ this function to an expression with several sums the transformation will be \ carried out only for those sums whose index is not contained in the factor c. \ Also, BringIn[expr, c] is strictly targeted on the quantity c, and does not \ perform the operation carried out by BringIn without arguments.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BringIn[espr4, x^2]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ FractionBox[ RowBox[{\(f(k)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k + 2\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], \(x\^2\)], ",", FractionBox[ RowBox[{\(f(j)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k + 2\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], \(x\^2\)]}], "}"}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ BringOut takes out of the sum everything that does not explicitly depend on \ the index \ \>", "Text"], Cell[TextData[{ StyleBox["BringOut[expr]", FontWeight->"Bold"], " brings out of every sum in expr everything that does not contains the \ index of the sum.\n", StyleBox["BringOut[expr,c]", FontWeight->"Bold"], " divides the addendum of the sum by c and multiplies the whole sum by the \ same amount.The quantity c must not depend on the index." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ s = Sum[3\ \(a\_k\) x^2\ y\ x^k + 2 x\ b\_k + 1/k, {k, 1, Infinity}]\)\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \((3\ y\ a\_k\ x\^\(k + 2\) + 2\ b\_k\ x + 1\/k)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["BringOut[s]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"3", " ", "y", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k + 2\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], "+", RowBox[{"2", " ", "x", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(b\_k\)}], HoldForm], "TraditionalForm"]}]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ When the element that remains inside the sum does not depend upon the index \ k, a sum of ones will be produced (this has been added since v1.2.1)\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[Sum[f[x], {k, 0, \[Infinity]}]]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(f(x)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], "1"}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ "Since evaluation is inhibithed for symbolic and infinite results, the Sum \ will not simplify even if it is convergent or ", StyleBox["Mathematica", FontSlant->"Italic"], " could find the sum. Consider for example the case of the sum of of finite \ number n of items of the series above:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[Sum[f[x], {k, 0, n}]]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(f(x)\), " ", FormBox[ TagBox[\(\[Sum]\+\(k = 0\)\%n 1\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ "Sometimes it is advisable to let ", StyleBox["Mathematica", FontSlant->"Italic"], " operate on partial results. In the default environment set up after \ loading the package, $EnableSumEvaluation is set to False, so we must resort \ to EnableSumEvaluation to let ", StyleBox["Mathematica", FontSlant->"Italic"], " perform its magic (while when $EnableBuiltin is True we can substitute \ Summa with Sum by means of a simple replacement rule (targeted by pattern \ matching, if needed) ). " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[%]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`\((n + 1)\)\ \(f(x)\)\)], "Output"] }, Open ]], Cell["\<\ Like BringIn, BringOut allows for a second argument, to specify \ what (index-free) factor should be brought out of the sum. BringOut[expr, c] \ divides the addendum of the sum by c and multiplies the whole sum by the same \ amount. This manipulation can prove useful in several circumstances (see for \ example the perturbation method to compute a finite sum in closed form).\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[Sum[x^k, {k, 0, n}], x]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"x", " ", FormBox[ TagBox[\(\[Sum]\+\(k = 0\)\%n x\^\(k - 1\)\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Sometimes it is necessary to expand or simpify the terms of the sum before \ applying BringIn or BringOut\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[Sum[\((a\_k + 3/k)\)/k, {k, 1, Infinity}]]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(a\_k + 3\/k\)\/k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[SumExpand[Sum[\((a\_k + 3/k)\)/k, {k, 1, Infinity}]]]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"3", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(1\/k\^2\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ "The first Sum is known to converge to ", Cell[BoxData[ \(TraditionalForm\`\[Pi]\^2\/6\)]], ". We leave that simplification to the built-in evaluator of ", StyleBox["Mathematica.", FontSlant->"Italic"] }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[%]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/k\)}], HoldForm], "TraditionalForm"], "+", \(\[Pi]\^2\/2\)}], TraditionalForm]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Reindexing and the such", "Subsection"], Cell["\<\ We can align all the exponents of x, by using SumExponentAlign \ (AlignExponent): the indexes are adjusted accordingly\ \>", "Text"], Cell[TextData[{ StyleBox["SumExponentAlign[expr,x,k->L[k]]", FontWeight->"Bold"], " shifts the index of every sum that is in expr, has index k and contains \ x^(f[k]) in order to have all of them with the same power of x: x^L[k]. It \ is not allowed to change the index identifier. x may be (x-x0) or whatever.\n\ This procedure automatically expands the elements of each sum before \ searching for the exponent of x. The default expansion can be avoided by \ setting the option Explode->False. This is advisable when coping with powers \ of (x-x0)." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["espr4=SumExponentAlign[espr3,x,k->k-3]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^\(k - 3\)\)\ a\_\(k - 5\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 3\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k - 3\)\ a\_\(k - 3\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-2\)\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 4\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k - 3\)\ b\_\(k - 4\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 3\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^\(k - 3\)\)\ b\_\(k - 3\)\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[ "SumExponentAlign performs an automatic expansion and simplification of the \ objects passed to it. In certain cases this is not advisable, since the \ automatic simplification performed by Mathematica can cause problems, as is \ shown below. It is useful in these cases to set the option \ Explode\[Rule]False"], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ s0 = Summa[\(a\_k\) \((x - 1)\)^\((k - 2)\), {k, 0, Infinity}]\)\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((x - 1)\)\^\(k - 2\)\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumExponentAlign[s0,x-1,k->k+1]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = \(-1\)\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(\((x - 1)\)\^\(k + 1\)\ a\_\(k + 1\)\)\/\(x\^2 - 2\ x + 1 \)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumExponentAlign[s0,x-1,k->k+1,Explode->False]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = \(-3\)\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((x - 1)\)\^\(k + 1\)\ a\_\(k + 3\)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ SumIndexAlign (AlignIndex) can make every Summa object with index k start \ from the same initial value\ \>", "Text"], Cell[TextData[{ StyleBox["SumIndexAlign[expr,{k,k0}]", FontWeight->"Bold"], " shifts the index of every sum that is in expr and has index k, in order \ to have them all to start from value k0." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell["\<\ Suppose we want to see all the Sums starting from k=0. Here's what \ we need to do:\ \>", "Text"], Cell[CellGroupData[{ Cell["SumIndexAlign[%,{k,0}]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((x - 1)\)\^\(k - 2\)\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ And we can change the index by shifting its value by calling \ SumReIndex (ReIndexSum)\ \>", "Text"], Cell[TextData[{ StyleBox["SumReIndex[expr,k->L[k]]", FontWeight->"Bold"], " shifts the index as indicated in L[k]. The shift affects every sum \ contained in expr that has index k. It is not allowed to change the index \ identificator.\nExample: SumReIndex[expr,k->k-2]" }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["SumReIndex[%,k->k+2]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = \(-2\)\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((x - 1)\)\^k\ a\_\(k + 2\)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ SumSplit[sum,n0] (BreakSum[sum,n0]) can be used to split a Sum in two. The \ first part will have index ranging from the original initial value up to \ (n0-1), while the second part will have it start from n0 and up to the \ original end value. If one of the two parts as numerical (integer for the \ time being) endpoints, it will be automatically expanded\ \>", "Text"], Cell[TextData[{ StyleBox["SumSplit[expr,n0]", FontWeight->"Bold"], " breaks in two all the sums contained in expr so that one of them will \ start from the value n0. The sums with numerical starting and ending points \ are automatically expanded (as is for Sum)." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell["\<\ This explicit the first few terms of each sum, leaving the Summa \ objects to start with the value 5\ \>", "Text"], Cell[CellGroupData[{ Cell["espr5=SumSplit[espr4,5]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ \(-\(\(2\ a\_0\)\/x\^3\)\), "+", \(a\_0\), "+", \(x\ a\_1\), "-", \(\(2\ a\_1\)\/x\^2\), "-", \(\(2\ a\_2\)\/x\), "-", \(2\ a\_3\), "-", \(2\ x\ a\_4\), "+", \(x\ b\_0\), "-", \(b\_0\), "-", \(x\ b\_1\), "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^\(k - 3\)\)\ a\_\(k - 5\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k - 3\)\ a\_\(k - 3\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-2\)\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(k - 3\)\ b\_\(k - 4\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^\(k - 3\)\)\ b\_\(k - 3\)\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Simplification", "Subsection"], Cell["\<\ SumSimplify (SimplifySum) simplifies the espression passed to it, \ consolidating separated Summa objects with the same index into a single \ Summa.\ \>", "Text"], Cell[TextData[{ StyleBox["SumSimplify[expr]", FontWeight->"Bold"], " reduce all the sums with the same indexes (that is with the same index \ name, start and final values) to one single sum. This function shares the \ same options as Simplify." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell["espr=SumSimplify[espr5]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ \(-\(\(2\ a\_0\)\/x\^3\)\), "+", \(a\_0\), "+", \(x\ a\_1\), "-", \(\(2\ a\_1\)\/x\^2\), "-", \(\(2\ a\_2\)\/x\), "-", \(2\ a\_3\), "-", \(2\ x\ a\_4\), "+", \(x\ b\_0\), "-", \(b\_0\), "-", \(x\ b\_1\), "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-x\^\(k - 3\)\)\ \((a\_\(k - 5\) - a\_\(k - 3\) + 2\ a\_k - b\_\(k - 4\) + b\_\(k - 3\))\)\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ The command SumSimplifyEach (SimplifyEachSum) may be useful when it \ is needed to simplify the terms inside each Sum.\ \>", "Text"], Cell[TextData[{ StyleBox["SumSimplifyEach[expr]", FontWeight->"Bold"], " simply maps Simplify onto the elements of each sum in expr. It does not \ affect whatever is outside. This function shares the same options as \ Simplify" }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ SumSimplifyEach[ \((x^2 - 3 x + 2)\)/\((x - 1)\) + Summa[\((x - 1)\) \((x - 2)\)/\((x - 1)\) a\_k, {k, 0, \[Infinity]}]] \)\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(\(x\^2 - 3\ x + 2\)\/\(x - 1\)\), "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((x - 2)\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ If FullSimplify is what we need to trat certain expressions, we can \ resort to the other two simplifying functions: SumFullSimplify and Sum \ FullSimplifyEach. all the simplifying functions accepts as second argument \ the same options as Simplify and FullSimplify, plus those for Expand (only \ Modulus, since Trig is already available in Simplify and FullSimplify) that \ is internally used by some rules.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Options[SumSimplify]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`{ComplexityFunction \[Rule] Automatic, Modulus \[Rule] 0, TimeConstraint \[Rule] 300, Trig \[Rule] True}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Options[SumFullSimplify]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ \(ComplexityFunction \[Rule] Automatic\), ",", \(ExcludedForms \[Rule] {}\), ",", \(Modulus \[Rule] 0\), ",", RowBox[{"TimeConstraint", "\[Rule]", InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]}], ",", \(Trig \[Rule] True\)}], "}"}], TraditionalForm]], "Output"] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Elementary Differentiation and Integration", "Section"], Cell["\<\ Please note: the differentiation and integration procedures do not \ check for the required convergence of infinite series prior to perform their \ tasks. The user must know when it is possible to differentiate or integrate a \ series term by term. As usual the rule is: if you really want to use this \ weapon, make sure not to aim at your foot.\ \>", "Text"], Cell[CellGroupData[{ Cell["Term by term Differentiation", "Subsection"], Cell["\<\ Differentiation can be applied to object such as equations without the need \ to map it onto the separate sides. It has to be noted that both the \ differentiation and the integration procedures were developed to cope with \ simple polynomial expressions, as they arise in the application of power \ methods to ordinary differential equations. Also, no attempt is made to \ verify that the conditions to operate a term by term differentiation are met. \ Checking due convergence is up to the user.\ \>", "Text"], Cell[TextData[{ StyleBox["SumD[expr,x]", FontWeight->"Bold"], " (and ", StyleBox["SumD[expr,{x,n}]", FontWeight->"Bold"], ") differentiate with respect to x (n times). This procedure can be \ applied directly to equations. It has an option Inside that when set to \ False avoids to automatically bring inside the factors premultiplying the \ sums. This function shares the same options as D." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ s = x^2\ Sum[\(a\_k\) x^k, {k, 0, Infinity}]\)\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(x\^2\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumD[s,x]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k + 2)\)\ x\^\(k + 1\)\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ When Inside is set to False, the factors in front of sums are not \ taken inside\ \>", "Text"], Cell[CellGroupData[{ Cell["SumD[s,x,Inside->False]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(k\ x\^\(k - 1\)\ a\_k\)}], HoldForm], "TraditionalForm"], ")"}], " ", \(x\^2\)}], "+", RowBox[{"2", " ", RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"], ")"}], " ", "x"}]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We can see that the result is indeed the same as before by bringing \ them in and simplifying the result\ \>", "Text"], Cell[CellGroupData[{ Cell["BringIn[%]//SumSimplify", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k + 2)\)\ x\^\(k + 1\)\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["These are other examples", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(SumD[Summa[\(a\_k\) x^k, {k, 0, Infinity}], {x, 3}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 2)\)\ \((k - 1)\)\ k\ x\^\(k - 3\)\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumD[f[x]+g[x]Sum[h[x],{k,0,Infinity}],x]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], RowBox[{"(", RowBox[{ RowBox[{\(h(x)\), " ", RowBox[{ SuperscriptBox["g", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}], "+", RowBox[{\(g(x)\), " ", RowBox[{ SuperscriptBox["h", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}]}], ")"}]}], HoldForm], "TraditionalForm"], "+", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumD[f[x]+g[x]Sum[h[x],{k,0,Infinity}],x,Inside->False]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{\(g(x)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], RowBox[{ SuperscriptBox["h", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}], HoldForm], "TraditionalForm"]}], "+", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "(", "x", ")"}], "+", RowBox[{ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(h(x)\)}], HoldForm], "TraditionalForm"], ")"}], " ", RowBox[{ SuperscriptBox["g", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumD[f[x](g[x]+Sum[h[x],{k,0,Infinity}]),x]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ RowBox[{"(", RowBox[{\(g(x)\), "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(h(x)\)}], HoldForm], "TraditionalForm"]}], ")"}], " ", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}], "+", RowBox[{\(f(x)\), " ", RowBox[{"(", RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], RowBox[{ SuperscriptBox["h", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}], HoldForm], "TraditionalForm"], "+", RowBox[{ SuperscriptBox["g", "\[Prime]", MultilineFunction->None], "(", "x", ")"}]}], ")"}]}]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumD[espr,x]", "Input"], Cell[BoxData[ FormBox[ RowBox[{ \(\(6\ a\_0\)\/x\^4\), "+", \(\(4\ a\_1\)\/x\^3\), "+", \(a\_1\), "+", \(\(2\ a\_2\)\/x\^2\), "-", \(2\ a\_4\), "+", \(b\_0\), "-", \(b\_1\), "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 5\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(-\((k - 3)\)\)\ x\^\(k - 4\)\ \((a\_\(k - 5\) - a\_\(k - 3\) + 2\ a\_k - b\_\(k - 4\) + b\_\(k - 3\))\)\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ It is possible to employ SumD to perform differentiation of more involved \ expressions, but it has to be clear that this was not what it was written \ for, and that whenever the expression contain a Summa object only the basic \ differentiation rules are tried. It is possible to add more elaborated ones, \ though, by modifying diffRule2 inside the package.\ \>", "Text"], Cell[BoxData[ \(s1 = Sum[\(a\_n\) x^n, {n, 0, \[Infinity]}]; s2 = Sum[\(b\_n\) x^n, {n, 0, \[Infinity]}]; \)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(SumD[s1\ s2, x]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], ")"}], " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(n\ x\^\(n - 1\)\ b\_n\)}], HoldForm], "TraditionalForm"]}], "+", RowBox[{ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(n\ x\^\(n - 1\)\ a\_n\)}], HoldForm], "TraditionalForm"], ")"}], " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ b\_n\)}], HoldForm], "TraditionalForm"]}]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SumD[1/s1, x]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"-", FractionBox[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(n\ x\^\(n - 1\)\ a\_n\)}], HoldForm], "TraditionalForm"], SuperscriptBox[ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], ")"}], "2"]]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SumD[s2/s1, x]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FractionBox[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(n\ x\^\(n - 1\)\ b\_n\)}], HoldForm], "TraditionalForm"], FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"]], "-", FractionBox[ RowBox[{ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(n\ x\^\(n - 1\)\ a\_n\)}], HoldForm], "TraditionalForm"], ")"}], " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ b\_n\)}], HoldForm], "TraditionalForm"]}], SuperscriptBox[ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], ")"}], "2"]]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SumD[f[s1], x]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(n\ x\^\(n - 1\)\ a\_n\)}], HoldForm], "TraditionalForm"], ")"}], " ", RowBox[{ SuperscriptBox["f", "\[Prime]", MultilineFunction->None], "(", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], ")"}]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ There is another function that differentiates exclusively what is inside \ Summa objects, and for this reason it has to be used with great care. It's \ exitence is jstified by the fact that it may prove faster in certain \ circumstances (alas, its name did not come out well from the renaming \ frenzy).\ \>", "Text"], Cell[TextData[{ StyleBox["SumDEach[s,x]", FontWeight->"Bold"], " and (", StyleBox["SumDEach[s,{x,n}]", FontWeight->"Bold"], ") differentiate with respect to x, n times. This procedure can be applied \ only to sums (and sums of sums) since it operates exclusively by moving D \ inside the sum symbol. When used with mixed expressions it gives wrong \ results:\n\tSumDEach[f[x] + Summa[g[x],{k,n1,n2}]=f[x] + \ Summa[g'[x],{k,n1,n2}]. \nThis function shares the same options as D" }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell[BoxData[ \(SumDEach[1/x + Sum[\(a\_k\) x^k, {k, 0, \[Infinity]}] + Cos[x^2], x] \)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(cos(x\^2)\), "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(k\ x\^\(k - 1\)\ a\_k\)}], HoldForm], "TraditionalForm"], "+", \(1\/x\)}], TraditionalForm]], "Output"] }, Open ]], Cell["Confront this with the output from SumD", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ DSum[1/x + Sum[\(a\_k\) x^k, {k, 0, \[Infinity]}] + Cos[x^2], x] \)\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(\(-2\)\ x\ \(sin(x\^2)\)\), "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(k\ x\^\(k - 1\)\ a\_k\)}], HoldForm], "TraditionalForm"], "-", \(1\/x\^2\)}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ SumDEach can be used to steadily aim at one's foot. One has to be \ careful when they choose to pull the trigger.\ \>", "Text"], Cell["\<\ We end this short introduction by mentioning a very common side effect of \ differentiation: when dealing with power series, differentiation has an \ indirect effect on the startign value of the summation index. By removing \ constant terms, \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ys = Sum[\(a\_k\) x^k, {k, 0, \[Infinity]}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\((y1s = SumD[ys, x])\) == SumSplit[SumD[ys, x], 1]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(k\ x\^\(k - 1\)\ a\_k\)}], HoldForm], "TraditionalForm"], "==", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(k\ x\^\(k - 1\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\((y2s = SumD[ys, {x, 2}])\) == SumSplit[SumD[y1s, x], 1] == SumSplit[SumD[ys, {x, 2}], 2]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 1)\)\ k\ x\^\(k - 2\)\ a\_k\)}], HoldForm], "TraditionalForm"], "==", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 1)\)\ k\ x\^\(k - 2\)\ a\_k\)}], HoldForm], "TraditionalForm"], "==", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 1)\)\ k\ x\^\(k - 2\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SumD[ys, {x, 3}] == SumSplit[SumD[y2s, x], 1] == SumSplit[SumD[y1s, {x, 2}], 2] == SumSplit[SumD[ys, {x, 3}], 3]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 2)\)\ \((k - 1)\)\ k\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"], "==", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 1\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 2)\)\ \((k - 1)\)\ k\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"], "==", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 2)\)\ \((k - 1)\)\ k\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"], "==", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 3\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((k - 2)\)\ \((k - 1)\)\ k\ x\^\(k - 3\)\ a\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Term by term Integration", "Subsection"], Cell["\<\ A rude procedure to perform term by term integration is provided by \ SumIntegrate (IntegrateSum)\ \>", "Text"], Cell[TextData[{ StyleBox["SumIntegrate[expr,x]", FontWeight->"Bold"], " and ", StyleBox["SumIntegrate[expr,{x,a,b}]", FontWeight->"Bold"], " integrate term by term with respect to x. When the option Inside is set \ to False integrals not depending on the index variable are brought outside \ the summa objects. This function shares the same options as Integrate." }], "Text", CellFrame->True, Background->GrayLevel[0.833326]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ s = x^2\ Sum[\(a\_k\) x^k, {k, 0, Infinity}]\)\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\(x\^2\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^k\ a\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["SumIntegrate[s,x]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(x\^\(k + 3\)\ a\_k\)\/\(k + 3\)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ The implementation of IntegrateSum mimicks the one previously \ adopted for DSum: an automatic application of the linearity property of the \ integral is performed. Automatic threading over equations is allowed.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(SumIntegrate[\ f[x] g[x] + a\ h[x] == Cos[x] - w[x]\ , x]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`\[Integral]\(\(f(x)\)\ \(g(x)\)\) \[DifferentialD]x + a\ \(\[Integral]\(h(x)\) \[DifferentialD]x\) == sin(x) - \[Integral]\(w(x)\) \[DifferentialD]x\)], "Output"] }, Open ]], Cell["Here's another example", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(y = Sum[\(a\_n\) Exp[I\ n\ \[Pi]\ x], {n, 0, \[Infinity]}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\[ExponentialE]\^\(\[ImaginaryI]\ n\ \[Pi]\ x\)\ a\_n\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(DSum[y, x]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\[ImaginaryI]\ \[ExponentialE]\^\(\[ImaginaryI]\ n\ \[Pi]\ x\)\ n \ \[Pi]\ a\_n\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(SumIntegrate[%, x]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\[ExponentialE]\^\(\[ImaginaryI]\ n\ \[Pi]\ x\)\ a\_n\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ This shows a definite integration leading to conditioned integral \ (in v3)\ \>", "Text"], Cell[CellGroupData[{ Cell["SumIntegrate[s,{x,0,1}]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(If[Re(k) > \(-3\), a\_k\/\(k + 3\), \[Integral]\_0\%1\( x\^\(k + 2\)\ a\_k\) \[DifferentialD]x]\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We can feed SumIntegrate the same options we would have fed to \ Integrate\ \>", "Text"], Cell[CellGroupData[{ Cell["SumIntegrate[s,{x,0,1},GenerateConditions->False]", "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/\(k + 3\)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Older versions of Summa.m did not pass options to Integrate, and it \ was necessary to force the evaluation of the If structure with the desired \ condition\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(%\ /. \ Re[k] > \(-3\) -> True\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\/\(k + 3\)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Here we compute the integral\ \>", "Text"], Cell[BoxData[ \(TraditionalForm \`\[Integral]\_0 \%\[Infinity]\(\( x\^\(2\ n + 1\)\ \(\[Sum]\[ExponentialE]\^\(\(-k\)\ \[Pi]\ x\)\)\+\(k = 0 \)\%\[Infinity]\)\/\[ExponentialE]\^\(\[Pi]\ x\)\) \[DifferentialD]x\)], "Text", Evaluatable->False, TextAlignment->Center], Cell[CellGroupData[{ Cell[BoxData[ \(SumIntegrate[ x^\((2 n + 1)\)/Exp[Pi\ x] Sum[Exp[\(-k\)\ Pi\ x], {k, 0, \[Infinity]}], {x, 0, \[Infinity]}, GenerateConditions \[Rule] False]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((\[Pi]\ k + \[Pi])\)\^\(\(-2\)\ n - 2\)\ \(\[CapitalGamma](2\ n + 2)\)\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We can let Mathematica further elaborate the result by appending \ //EnableSumEvaluation\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(%\ // EnableSumEvaluation\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ \(\[Pi]\^\(\(-2\)\ n - 2\)\), " ", \(\[CapitalGamma](2\ n + 2)\), " ", TagBox[ RowBox[{"\[Zeta]", "(", TagBox[\(2\ n + 2\), (Editable -> True)], ")"}], InterpretTemplate[ Zeta[ #]&]]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ The option Inside allows to bring index independent quantities outside Summa \ objects. In a way it is equivalent to the application of BringOut at the end \ of the integration process\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(SumIntegrate[Sum[\(a\_k\) f[x], {k, 0, \[Infinity]}], {x, a, b}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((\[Integral]\_a\%b\( f(x)\) \[DifferentialD]x)\)\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(\ SumIntegrate[Sum[\(a\_k\) f[x], {k, 0, \[Infinity]}], {x, a, b}, Inside -> False]\)\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\((\[Integral]\_a\%b\( f(x)\) \[DifferentialD]x)\), " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(a\_k\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Should the integral depend on the index k, BringOut would sort no \ effect.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(SumIntegrate[Sum[\(a\_k\) f[x, b\_k], {k, 0, \[Infinity]}], {x, a, b}, Inside -> False]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(k = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\((\[Integral]\_a\%b\( f(x, b\_k)\) \[DifferentialD]x)\)\ a\_k\)}], HoldForm], TraditionalForm]], "Output"] }, Open ]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Applying Summa to 'separable nested sums'", "Section"], Cell["\<\ The package Summa was developed for 'one-dimensional' sums and \ would require a substantial rewriting of most functions to allow sensible \ manipulation of multiple sums. Anyway, by strectching a bit the rules given \ for simple sums, it is possible to operate a few simplifications on \ multidimensionals problems as well. With due attention, Summa can be applied \ to problems involving a certain kind of nested sums.\ \>", "Text"], Cell[CellGroupData[{ Cell["Handling multiple sums", "Subsection"], Cell[CellGroupData[{ Cell["Sums with multiple iterators in Summa.m", "Subsubsection"], Cell[TextData[{ "In ", StyleBox["Mathematica,", FontSlant->"Italic"], " multiple sums require a specific signature: " }], "Text"], Cell[BoxData[ \(\(Sum[el \((i, j, ... )\), {i, i0, n}, {j, j0, m}, ... ] . \)\)], "Input", CellFrame->True, Background->GrayLevel[0.833326]], Cell["\<\ We can see how Mathematica behaves by re-enabling built-in sum \ evaluation\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[Verbose \[Rule] False]; \n Sum[a\_\(j, k\), {j, 0, 3}, {k, 2}]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`a\_\(0, 1\) + a\_\(0, 2\) + a\_\(1, 1\) + a\_\(1, 2\) + a\_\(2, 1\) + a\_\(2, 2\) + a\_\(3, 1\) + a\_\(3, 2\)\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \({Sum[a\_\(j, k\), {j, 0, n}, {k, 2}], Sum[a\_\(j, k\), {k, 2}, {j, 0, n}]}\)], "Input"], Cell[BoxData[ \(TraditionalForm \`{\[Sum]\+\(j = 0\)\%n\(\[Sum]\+\(k = 1\)\%2 a\_\(j, k\)\), \[Sum]\+\(k = 1\)\%2\(\[Sum]\+\(j = 0\)\%n a\_\(j, k\)\)}\)], "Output"] }, Open ]], Cell["\<\ In the most general case, the terms to be summed over the indices \ depend on the indices themselves in a non separable manner. For example:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[\(a\_j\) b\_\(k - j\), {j, 0, 2}, {k, 2}] // Simplify\)], "Input"], Cell[BoxData[ \(TraditionalForm \`a\_2\ \((b\_\(-1\) + b\_0)\) + a\_1\ \((b\_0 + b\_1)\) + a\_0\ \((b\_1 + b\_2)\)\)], "Output"] }, Open ]], Cell["\<\ When Summa is loaded and the built-in sum evaluation is overridden, \ multiple indices sums with numerical (integer) endpoints are automatically \ passed to Sum for evaluation, as it happens with simple sums. For example \ consider the triple sum\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[Verbose \[Rule] False]; \n Sum[\(a\_j\) \(b\_k\) c\_l, {j, 1, 2}, {k, 0, 3}, {l, 0, 2}] // Simplify \)], "Input"], Cell[BoxData[ \(TraditionalForm \`\((a\_1 + a\_2)\)\ \((b\_0 + b\_1 + b\_2 + b\_3)\)\ \((c\_0 + c\_1 + c\_2)\)\)], "Output"] }, Open ]], Cell["\<\ With the default setting of Summa.m, multiple sums with at least \ one symbolic or infinite endpoint are converted to Summa objects and are left \ unevaluated.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[\(a\_j\) \(b\_k\) c\_l, {j, 1, 3}, {k, 0, n}, {l, 0, 2}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ \(\[Sum]\+\(j = 1\)\%3 \(\[Sum]\+\(k = 0\)\%n \(\[Sum]\+\(l = 0\)\%2 a\_j\ b\_k\ c\_l\)\)\), HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We can see that this is indeed a Summa object, as shown by its \ InputForm.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(InputForm[%]\)], "Input"], Cell["\<\ Summa[Subscript[a, j]*Subscript[b, k]*Subscript[c, l], {j, 1, 3}, {k, 0, n}, {l, 0, 2}]\ \>", "Output"] }, Open ]], Cell["\<\ At present, formatting is the only facility provided by the Summa \ package that is oriented towards sums with multiple iterators. No \ simplification procedure is designed to be used on multiple sums with that \ kind of signature.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["The problem with nested sums: localization of the indices", "Subsubsection"], Cell["\<\ It is nonetheless possible, though, to manually manipulate a \ certain kind of nested (simple) sums. In fact, when the it is possibile to \ express the summand as a product of factors each depending on a single index, \ the sum can be cast into a nested form (with each factor pertaining to the \ sum over the corresponding index)\ \>", "Text"], Cell[BoxData[{ StyleBox[\(el[i, j, \( ... \(, k\)\)]\ = \ \(f[i] g[j] ... \) h[k]\), FontWeight->"Bold"], \(Sum[\ f[i] g[j] h[k], {i, i0, n}, {j, j0, m}, {k, k0, p}]\), \(Sum[Sum[\ Sum[f[i] g[j] h[k], {i, i0, n}], {j, j0, m}], {k, k0, p}]\), \(Sum[h[k] Sum[\ g[j] Sum[f[i], {i, i0, n}], {j, j0, m}], {k, k0, p}]\)}], "Input", CellFrame->True, Background->GrayLevel[0.833326]], Cell[TextData[{ "This approach is limited by the fact that when sums of this kind are \ passed to ", StyleBox["Mathematica'", FontSlant->"Italic"], "s evaluator their indices are treated as local to each nested Sum \ structure.For this reason, ", StyleBox["Mathematica ", FontSlant->"Italic"], "won't be able to recognize the dependence from indices that belong to \ outer Sums. Nested one-dimensional sums are thus a source of potential \ problems and it is imperative not to let ", StyleBox["Mathematica", FontSlant->"Italic"], " evaluate them in the standard way. For example, the evaluation of a \ nested sum depending on three indices can lead to incorrect results:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[Verbose \[Rule] False]; \nSumEvaluationStatus[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"$EnableSumEvaluation = True\n$EnableNumericSum = True"\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(expr = Sum[\ Sum[\ Sum[\ \(a\_j\) \(b\_k\) c\_l, {j, 1, n}]\ , {k, 0, 3}]\ , { l, 1, 2}]\), \(expr /. n \[Rule] 2 // Simplify\)}], "Input"], Cell[BoxData[ \(TraditionalForm\`8\ \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\)\)], "Output"], Cell[BoxData[ \(TraditionalForm\`8\ \((a\_1 + a\_2)\)\ b\_k\ c\_l\)], "Output"] }, Open ]], Cell[TextData[{ "The correct result can be obtained with correct ", StyleBox["Mathematica", FontSlant->"Italic"], " syntax and is:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(expr = Sum[\(a\_j\) \(b\_k\) c\_l, {l, 1, 2}, {k, 0, 3}, {j, 1, n}] // Simplify \), \(expr /. n \[Rule] 2 // Simplify\)}], "Input"], Cell[BoxData[ \(TraditionalForm \`\[Sum]\+\(l = 1\)\%2 \(\[Sum]\+\(k = 0\)\%3\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\)\)\)], "Output"], Cell[BoxData[ \(TraditionalForm \`\((a\_1 + a\_2)\)\ \((b\_0 + b\_1 + b\_2 + b\_3)\)\ \((c\_1 + c\_2)\)\)], "Output"] }, Open ]], Cell["\<\ We can see where the 'nested sums problem' is with a simple Trace: \ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Trace[ Sum[Sum[Sum[\(a\_j\) \(b\_k\) c\_l, {j, 1, n}], {k, 0, 3}], {l, 1, 2}], Sum] // ColumnForm\)], "Input"], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { \(\[Sum]\+\(l = 1\)\%2 \(\[Sum]\+\(k = 0\)\%3 \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\)\)\)}, { \({\[Sum]\+\(k = 0\)\%3 \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\), \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l + \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l + \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l + \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l}\)}, { \({\[Sum]\+\(k = 0\)\%3 \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\), \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l + \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l + \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l + \[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l}\)}, { \(4\ \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\) + 4\ \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\)\)} }, GridBaseline->{Baseline, {1, 1}}, ColumnAlignments->{Left}], ColumnForm[ { HoldForm[ Sum[ Sum[ Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], {k, 0, 3}], {l, 1, 2}]], { HoldForm[ Sum[ Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], {k, 0, 3}]], HoldForm[ Plus[ Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}]]]}, { HoldForm[ Sum[ Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], {k, 0, 3}]], HoldForm[ Plus[ Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}], Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}]]]}, HoldForm[ Plus[ Times[ 4, Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}]], Times[ 4, Sum[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 1, n}]]]]}], Editable->False], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Basically, this is what happened: only the innermost sum recognizes \ j as the legitimate index; the outer sums consider their elements as \ constants and perform a simple sum of those constants over the range of their \ indices.Here's how we can exploit the HoldAll attribute of Sum to mimick this \ behavior step by step:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \({t1 = Sum[\(a\_j\) \(b\_k\) c\_l, {j, 1, n}], t2 = Sum[t1, {k, 0, 3}], t3 = Sum[t2, {l, 1, 2}], t3 /. n \[Rule] 2 // Simplify}\)], "Input"], Cell[BoxData[ \(TraditionalForm \`{\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l, 4\ \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\), 8\ \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\), 8\ \((a\_1 + a\_2)\)\ b\_k\ c\_l}\)], "Output"] }, Open ]], Cell["\<\ If we really insist in using nested sum for multiple sums with \ separable summands, there are two possibile workarounds.\ \>", "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["First workaround: manually distribute the factors", "Subsection"], Cell["\<\ The first workaround consists in embedding each factor in the \ nested sum with respect to the corresponding index. Once we have separated \ the summand into factors that depend on one index each, and rewrite the sum \ in the following manner (that we could call a separable nested sum):\ \>", "Text"], Cell[BoxData[ \(TraditionalForm\`\(\t \[Sum]\+\(j = 0\)\%n \(\[Sum]\+\(k = 0\)\%3\(\[Sum]\+\(l = 1\)\%2 a\_j\ b\_k\ c\_l\)\) = \[Sum]\+\(l = 0\)\%2\(( c\_l\ \(\[Sum]\+\(k = 0\)\%3\((b\_k\ \(\[Sum]\+\(j = 1\)\%n a\_j\)) \)\))\)\)\)], "Text"], Cell[TextData[{ "In the latter form, ", StyleBox["Mathematica", FontSlant->"Italic"], " can give the correct result for the sum" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[c\_l\ Sum[\(b\_k\) Sum[a\_j, {j, 1, n}], {k, 0, 3}], {l, 1, 2}] // Simplify\)], "Input"], Cell[BoxData[ \(TraditionalForm \`\((b\_0 + b\_1 + b\_2 + b\_3)\)\ \((c\_1 + c\_2)\)\ \(\[Sum]\+\(j = 1\)\%n a\_j\)\)], "Output"] }, Open ]], Cell[TextData[{ "We can verify that by using a numerical value for n. The result is indeed \ equal to that obtained when ", StyleBox["Mathematica", FontSlant->"Italic"], " is fed the correct form for multiple sums." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Simplify[% /. n \[Rule] 2]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`\((a\_1 + a\_2)\)\ \((b\_0 + b\_1 + b\_2 + b\_3)\)\ \((c\_1 + c\_2)\)\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Second workaround: disabling every form of sum evaluation", "Subsection"], Cell[TextData[{ "The second way is to disable automatic multiple Sum evaluation ", StyleBox["even", FontSlant->"Italic"], " when the endpoints are numerical. This will allow the user to perform \ every single simplification he or she needs step after step, keeping ", StyleBox["Mathematica", FontSlant->"Italic"], "'s evaluator away from nested sums until they are cast into their final \ form. DisableSumEvaluation and EnableSumEvaluation have an option Extent that \ can be use to switch on and off the evaluation of Numeric and or Symbolic \ sums." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[Extent \[Rule] All]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on all Sums will be turned into Summa objects that will not \ be evaluated by Mathematica. Summa objects are formatted and shown as \ ordinary Sums."\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell["Usage examples", "Subsubsection"], Cell["\<\ Nested separable sums with symbolic or infinite endpoints can be \ manipulated as Summa objects. We already know that Mathematica is not \ designed to cope with sums in nested forms.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(EnableSumEvaluation[Verbose -> False]\), \(Sum[Sum[Sum[\(a\_j\) \(b\_k\) c\_l, {j, 1, n}], {k, 0, 3}], {l, 1, 2}] \), \(% /. n \[Rule] 2\)}], "Input"], Cell[BoxData[ \(TraditionalForm\`8\ \(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\)\)], "Output"], Cell[BoxData[ \(TraditionalForm\`8\ \((a\_1\ b\_k\ c\_l + a\_2\ b\_k\ c\_l)\)\)], "Output"] }, Open ]], Cell["\<\ But, after loading Summa.m the evaluation of sums with symbolic or infinite \ endpoints is disabled by default, and so we can perform the simplifications \ we need prior to pass the result to the evaluator.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Sums with Symbolic endpoints will be turned into Summa \ objects that will not be evaluated by Mathematica. Summa objects are \ formatted and shown as ordinary Sums (provided there are no explicit \ instructions to evaluate them)."\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[Sum[Sum[\(a\_j\) \(b\_k\) c\_l, {j, 1, n}], {k, 0, n}], {l, 1, n}] \)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(l = 1\)\%n\), FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(k = 0\)\%n\), FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_k\ c\_l\), HoldForm], "TraditionalForm"]}], HoldForm], "TraditionalForm"]}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[%]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"(", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\), HoldForm], "TraditionalForm"], ")"}], " ", RowBox[{"(", FormBox[ TagBox[\(\[Sum]\+\(k = 0\)\%n b\_k\), HoldForm], "TraditionalForm"], ")"}], " ", FormBox[ TagBox[\(\[Sum]\+\(l = 1\)\%n c\_l\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["We can see that the following result happens to be correct", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(Sum[Sum[Sum[\(a\_j\) \(b\_k\) c\_l, {j, 1, n}], {k, 0, 3}], {l, 1, 2}] \), \(% /. n \[Rule] 2 // Simplify\)}], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_0\ c\_1\), HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_1\ c\_1\), HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_2\ c\_1\), HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_3\ c\_1\), HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_0\ c\_2\), HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_1\ c\_2\), HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_2\ c\_2\), HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_3\ c\_2\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"], Cell[BoxData[ \(TraditionalForm \`\((a\_1 + a\_2)\)\ \((b\_0 + b\_1 + b\_2 + b\_3)\)\ \((c\_1 + c\_2)\)\)], "Output"] }, Open ]], Cell["Non separable summands can't be separated.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[ Sum[Sum[\(a\_j\) \(b\_\(k - j\)\) c\_l, {j, 1, n}], {k, 1, n}], {l, 1, n}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(l = 1\)\%n\), FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(k = 1\)\%n\), FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_\(k - j\)\ c\_l\), HoldForm], "TraditionalForm"]}], HoldForm], "TraditionalForm"]}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["At least not completely", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[%]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"(", FormBox[ TagBox[\(\[Sum]\+\(l = 1\)\%n c\_l\), HoldForm], "TraditionalForm"], ")"}], " ", FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(k = 1\)\%n\), FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a\_j\ b\_\(k - j\)\), HoldForm], "TraditionalForm"]}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Here is another example\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(nested = Sum[n\ a[k] - Sum[a[j], {j, 1, n}], {k, 1, n}]\)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(k = 1\)\%n\), RowBox[{"(", RowBox[{\(n\ \(a(k)\)\), "-", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a(j)\), HoldForm], "TraditionalForm"]}], ")"}]}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ We can expand the sum and extract the factors that do not depend on \ each sum's index. A single function, SumExpand, can do that for us. \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(sep = nested // SumExpand\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"n", " ", FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%n a(k)\), HoldForm], "TraditionalForm"]}], "-", RowBox[{ RowBox[{"(", FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%n 1\), HoldForm], "TraditionalForm"], ")"}], " ", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a(j)\), HoldForm], "TraditionalForm"]}]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ The sum of 1's from 1 to n is easily managed by mma's evaluator. We \ pass the expresssion to it, locally\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation\ [sep] // Simplify\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"n", " ", RowBox[{"(", RowBox[{ FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%n a(k)\), HoldForm], "TraditionalForm"], "-", FormBox[ TagBox[\(\[Sum]\+\(j = 1\)\%n a(j)\), HoldForm], "TraditionalForm"]}], ")"}]}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ " now we can tell ", StyleBox["Mathematica", FontSlant->"Italic"], " that an index is an index by any other name." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(% /. j \[Rule] k\)], "Input"], Cell[BoxData[ \(TraditionalForm\`0\)], "Output"] }, Open ]], Cell["A quicker way to get the same result is this:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation\ [sep /. j \[Rule] k]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`0\)], "Output"] }, Open ]], Cell["\<\ Multiple sums with mixed numerical and symbolical endpoints can lead to \ incorrect results if their evaluation is not inhibited. Please use this \ package with the utmost care when dealing with nested sums whose endpoint \ could be made numeric at some point of the computation. Always make sure that \ the sum has been thoroughly simplified before enabling evaluation! \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(DisableSumEvaluation[Extent \[Rule] All]\)], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on all Sums will be turned into Summa objects that will not \ be evaluated by Mathematica. Summa objects are formatted and shown as \ ordinary Sums."\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Sum[Sum[Sum[\(a\_j\) \(a\_k\) a\_l, {j, 0, n}], {k, 1, 3}], {l, 1, 2}] \)], "Input"], Cell[BoxData[ FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(l = 1\)\%2\), FormBox[ TagBox[ RowBox[{\(\[Sum]\+\(k = 1\)\%3\), FormBox[ TagBox[\(\[Sum]\+\(j = 0\)\%n a\_j\ a\_k\ a\_l\), HoldForm], "TraditionalForm"]}], HoldForm], "TraditionalForm"]}], HoldForm], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BringOut[%]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"(", FormBox[ TagBox[\(\[Sum]\+\(j = 0\)\%n a\_j\), HoldForm], "TraditionalForm"], ")"}], " ", RowBox[{"(", FormBox[ TagBox[\(\[Sum]\+\(k = 1\)\%3 a\_k\), HoldForm], "TraditionalForm"], ")"}], " ", FormBox[ TagBox[\(\[Sum]\+\(l = 1\)\%2 a\_l\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[%]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{\((a\_1 + a\_2)\), " ", \((a\_1 + a\_2 + a\_3)\), " ", FormBox[ TagBox[\(\[Sum]\+\(j = 0\)\%n a\_j\), HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \({Sum[\ Sum[\ Sum[\ \(a\_j\) \(b\_k\) c\_l, {j, 0, n}]\ , {k, 1, 3}] \ , {l, 1, 2}] /. n \[Rule] 2 // Simplify, \[IndentingNewLine]Sum[ Sum[Sum[\(a\_j\) \(b\_k\) c\_l, {j, 0, 2}], {k, 1, 3}], {l, 1, 2}] // Simplify} // ColumnForm\)], "Input"], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { FormBox[ RowBox[{\(\[Sum]\+\(l = 1\)\%2\), FormBox[ RowBox[{\(\[Sum]\+\(k = 1\)\%3\), FormBox[\(\[Sum]\+\(j = 0\)\%2 a\_j\ b\_k\ c\_l\), "TraditionalForm"]}], "TraditionalForm"]}], "TraditionalForm"]}, { FormBox[ RowBox[{\(\[Sum]\+\(l = 1\)\%2\), FormBox[ RowBox[{\(\[Sum]\+\(k = 1\)\%3\), FormBox[\(\[Sum]\+\(j = 0\)\%2 a\_j\ b\_k\ c\_l\), "TraditionalForm"]}], "TraditionalForm"]}], "TraditionalForm"]} }, GridBaseline->{Baseline, {1, 1}}, ColumnAlignments->{Left}], ColumnForm[ { Summa[ Summa[ Summa[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 0, 2}], {k, 1, 3}], {l, 1, 2}], Summa[ Summa[ Summa[ Times[ Subscript[ a, j], Subscript[ b, k], Subscript[ c, l]], {j, 0, 2}], {k, 1, 3}], {l, 1, 2}]}], Editable->False], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(EnableSumEvaluation[%, Extent \[Rule] Numeric] // Simplify\)], "Input"], Cell[BoxData[ FormBox[ InterpretationBox[GridBox[{ { \(\((a\_0 + a\_1 + a\_2)\)\ \((b\_1 + b\_2 + b\_3)\)\ \((c\_1 + c\_2)\)\)}, { \(\((a\_0 + a\_1 + a\_2)\)\ \((b\_1 + b\_2 + b\_3)\)\ \((c\_1 + c\_2)\)\)} }, GridBaseline->{Baseline, {1, 1}}, ColumnAlignments->{Left}], ColumnForm[ { Times[ Plus[ Subscript[ a, 0], Subscript[ a, 1], Subscript[ a, 2]], Plus[ Subscript[ b, 1], Subscript[ b, 2], Subscript[ b, 3]], Plus[ Subscript[ c, 1], Subscript[ c, 2]]], Times[ Plus[ Subscript[ a, 0], Subscript[ a, 1], Subscript[ a, 2]], Plus[ Subscript[ b, 1], Subscript[ b, 2], Subscript[ b, 3]], Plus[ Subscript[ c, 1], Subscript[ c, 2]]]}], Editable->False], TraditionalForm]], "Output"] }, Open ]], Cell["Let's restore the evaluation for numerical endpoints.", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(EnableSumEvaluation[Extent \[Rule] Numeric]\), \(SumEvaluationStatus[]\)}], "Input"], Cell[BoxData[ \(TraditionalForm \`"From now on Sums and Summa objects with numerical endpoints will be \ passed to Mathematica for evaluation."\)], "Print"], Cell[BoxData[ \(TraditionalForm \`"$EnableSumEvaluation = False\n$EnableNumericSum = True"\)], "Output"] }, Open ]] }, Closed]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Putting things together", "Section"], Cell[CellGroupData[{ Cell["Combining different procedures", "Subsection"], Cell["\<\ Starting with a single expression, many possible results can be \ obtained by combining different procedures in different ways. Consider for \ example the simple Sum\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr = Sum[\((a\_n + 4 x^2)\) x^n, {n, 0, \[Infinity]}] + x\ Sum[\((b\_n - x^2)\) x^n, {n, 2, \[Infinity]}]\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ \((4\ x\^2 + a\_n)\)\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"x", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ \((b\_n - x\^2)\)\)}], HoldForm], "TraditionalForm"]}]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ SumExpand will expand the term inside each sum, while SumExpand all \ will reiterate this procedure and will ultimately break apart every possibile \ sum\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(expr // SumExpand\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \((a\_n\ x\^n + 4\ x\^\(n + 2\))\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"x", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \((x\^n\ b\_n - x\^\(n + 2\))\)}], HoldForm], "TraditionalForm"]}]}], TraditionalForm]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(expr // SumExpandAll\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(4\ x\^\(n + 2\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(-x\^\(n + 3\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 1\)\ b\_n\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Applying BringOut to the result from SumExpand gives a result that \ differs from those obtained above\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(expr // SumExpand\) // BringOut\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"4", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 2\)\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"x", " ", RowBox[{"(", RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ b\_n\)}], HoldForm], "TraditionalForm"], "-", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 2\)\)}], HoldForm], "TraditionalForm"]}], ")"}]}]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ And different is also the result obtained by swapping the \ procedures. \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(expr // BringOut\) // SumExpand\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \((a\_n\ x\^n + 4\ x\^\(n + 2\))\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"x", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \((x\^n\ b\_n - x\^\(n + 2\))\)}], HoldForm], "TraditionalForm"]}]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Another different form for the result is obtained with SumExpandAll\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(expr // SumExpandAll\) // BringOut\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"4", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 2\)\)}], HoldForm], "TraditionalForm"]}], "-", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 3\)\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 1\)\ b\_n\)}], HoldForm], "TraditionalForm"]}], TraditionalForm]], "Output"] }, Open ]], Cell["\<\ Sometimes it's useful to apply the same procedure more than once.\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(expr // SumExpand\) // BringOut\) // SumExpand\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"4", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 2\)\)}], HoldForm], "TraditionalForm"]}], "-", RowBox[{"x", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^\(n + 2\)\)}], HoldForm], "TraditionalForm"]}], "+", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 0\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ a\_n\)}], HoldForm], "TraditionalForm"], "+", RowBox[{"x", " ", FormBox[ TagBox[ RowBox[{ UnderoverscriptBox["\[Sum]", \(n = 2\), InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(x\^n\ b\_n\)}], HoldForm], "TraditionalForm"]}]}], TraditionalForm]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Limiting the scope of the functions applied to Sums (*)", "Subsection"], Cell["\<\ This is an undocumented feature. See the commands SumMap, \ SumMapAt...in the notebook \"The making of Summa\".\ \>", "SmallText"] }, Closed]] }, Closed]] }, FrontEndVersion->"X 3.0", ScreenRectangle->{{0, 1152}, {0, 900}}, WindowToolbars->{}, WindowSize->{664, 517}, WindowMargins->{{153, Automatic}, {Automatic, 81}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, StyleDefinitions -> "Classroom.nb" ]