Message Boards Message Boards

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

Regrouping infinite sums

Posted 9 years ago

Hi everyone. I'm doing a few tests with infinite sums in mathematica, but I have troubles. I want to manipulate formal power series with non fixed coefficient.

For exemple, defining $f(t)=\sum_{n=0}^\infty u_n t^n$ and $g(t)=\sum_{n=0}^\infty v_n t^n$. I would like Mathematica to regroup the sums when computing $f(t)+g(t)$, i.e. I would like Mathematica to give me the output :

$$\sum_{n=0}^\infty ( u_n + v_n ) t^n$$

I tried the following code :

f[t_]:=Sum[Subscript[u,n]*t^n,{n,1,Infinity}];
g[t_]:=Sum[Subscript[v,n]*t^n,{n,1,Infinity}];
f[t]+g[t]

But he give me the result as the sum of two separated infinite sums, without regrouping them. I also tried Simplify or FullSimplify, but it didn't give what I wanted. What surprizes me is that for example D[f[t],t] give the formal output I would expect : $$\sum_{n=0}^\infty n u_n t^{n-1}$$

In the end, I would also like Mathematica to be able to change the index and then regrouping the sums. Typically, I'm looking for things like : $$f(t)+f'(t)=\sum_{n=0}^\infty (u_n+(n+1)u_{n+1})t^n$$

Would this be possible ? Thank you.

POSTED BY: Sylvain Lacroix
6 Replies

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

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

POSTED BY: Sylvain Lacroix

Instead of MakeBoxes you can try with Inactive (new with Mathematica 10):

Inactive[Sum][u[n] t^n, {n, 0, Infinity}]

which formats fine. The rule for sums can be

collectSums = 
 Inactive[Sum][a_, b_] + Inactive[Sum][c_, b_] :> 
  Inactive[Sum][a + c, b];
Inactive[Sum][u[n] t^n, {n, 0, Infinity}] + 
  Inactive[Sum][v[n] t^n, {n, 0, Infinity}] /. collectSums

It becomes more complicated if you want to mix sums with different extrema.

POSTED BY: Gianluca Gorni

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

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.

enter image description here

POSTED BY: Simon Cadrin
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