Message Boards Message Boards

0
|
5409 Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Regrouping infinite sums

Posted 9 years ago
POSTED BY: Sylvain Lacroix
6 Replies

enter image description here

POSTED BY: Simon Cadrin

I think this would constitute at least a medium size project if you were to do all that you might want. You can probably do a lot of things with the built-in SeriesCoefficient, SeriesData and ComposeSeries.

In any case, here is a start. In order to display manipulations of the series we need a function that mimics an infinite series without attempting evaluation. We would only evaluate when we wanted to - if ever. To follow this you should look at the Help for TemplateBox and MakeBoxes.

We define such an infiniteSum expression and MakeBoxes for it so it will display as a usual infinite sum. The we define a rule for summing two series and a routine to convert an infiniteSeries into a finite sum with a given number of terms. To get the DisplayFunction Boxes I typed the generic Sum expression into the notebook, evaluated it, and then used Show Expression from the Cell Menu to see the Box structure for the Mathematica expression. I then copied that into the TemplateBox code.

infiniteSum::usage = "infiniteSum[{n,t},term] represents the infinite sum of term[n]t^n";

infiniteSum /: 
 MakeBoxes[infiniteSum[{n_, t_}, u_], 
  form : (StandardForm | TraditionalForm) : StandardForm] :=
 TemplateBox[{MakeBoxes[n, form], MakeBoxes[t, form], 
   MakeBoxes[u, form]}, "infiniteSum",
  DisplayFunction :> (RowBox[{UnderoverscriptBox["\[Sum]", 
        RowBox[{#1, "=", "0"}], "\[Infinity]"], 
       RowBox[{SuperscriptBox[#2, #1], " ", #3}]}] &),
  InterpretationFunction :> (RowBox[{"infiniteSum", "[", "{", #1, 
       ",", #2, "}", "," #3, "]"}] &),
  Editable -> True,
  Selectable -> True]

sumRule = 
  infiniteSum[{n_, t_}, a_] + infiniteSum[{n_, t_}, b_] :> 
   infiniteSum[{n, t}, a + b];

infiniteSumSeries[terms_][expr_] :=
 expr /. infiniteSum[{n_, t_}, u_] :> 
   Sum[Evaluate[u t^n] /. n -> i, {i, 0, terms}]

Then as a demonstration let's do a Sin series, Cos series and their sum. I'm a little too lazy to copy all the formatted output into this posting, but if you copy to a notebook and evaluate everything should look good.

sinC = SeriesCoefficient[Sin[t], {t, 0, n}, Assumptions -> n >= 0];
cosC = SeriesCoefficient[Cos[t], {t, 0, n}, Assumptions -> n >= 0];
Series[Sin[t] + Cos[t], {t, 0, 10}]

The following starts with the sum of two generic series, combines them with the sumRule, substitutes the Sin and Cos coefficients and simplifies. Then we generate 10 terms of the series and see that they match the expected expression.

step1 = infiniteSum[{n, t}, u[n]] + infiniteSum[{n, t}, v[n]]
Print["Combine with the sumRule"]
step2 = step1 /. sumRule
Print["Substituting expressions for the Sin and Cos coefficients and \
Simplifying"]
step3 = step2 /. u -> Function[n, sinC] /. v -> Function[n, cosC]
step4 = FullSimplify[step3, n \[Element] Integers && n >= 0]
step4 // infiniteSumSeries[10]

That is just a start because there are sure to be a number of other operations you would need.

Wow it is much more complicated that I thought it would be. But thanks a lot for the answer David J M Park Jr. I'll take a look at all that, but indeed I'm not used to this TemplateBoxes and MakeBoxes, so for the moment I don't realyy understand what who you did. I'll try to figure it out. Thanks.

@ Simon Cadrin : I'm not really sure of what you meant by your answer ? Aren't you imposing the relation I was looking for ?

POSTED BY: Sylvain Lacroix
POSTED BY: Gianluca Gorni

Thank you for the answer Gianluca Gorni. I'll take a look at that too.

POSTED BY: Sylvain Lacroix

Many thanks Gianluca for reminding us of one more of the nice features in Mathematica 10 - Inactive, Activate and IgnoringInactive! These should be great for teaching and presenting detailed derivations.

For convenience, here's the same calculation I did above using Inactive and Activate.

sinC = SeriesCoefficient[Sin[t], {t, 0, n}, Assumptions -> n >= 0];
cosC = SeriesCoefficient[Cos[t], {t, 0, n}, Assumptions -> n >= 0];

collectSums = Inactive[Sum][a_, b_] + Inactive[Sum][c_, b_] :> Inactive[Sum][a + c, b];

step1 = Inactive[Sum][u[n] t^n, {n, 0, \[Infinity]}] + 
  Inactive[Sum][v[n] t^n, {n, 0, \[Infinity]}]
Print["Combine with the collectSums"]
step2 = step1 /. collectSums2 // Simplify
Print["Substituting expressions for the Sin and Cos coefficients and \
Simplifying"]
step3 = step2 /. u -> Function[n, sinC] /. v -> Function[n, cosC]
step4 = FullSimplify[step3, n \[Element] Integers && n >= 0]
Print["Evaluate, convert to trig and simplify"]
step5 = Activate[step4]
step5 // ExpToTrig // Simplify
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract