Message Boards Message Boards

0
|
2676 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How can I expand a power series with power series coefficients?

Posted 10 years ago
If I type in a power series in which one of the coefficients is itself a power series, the appropriate simplifications happen automatically.  For example, typing
1 + (3 + 5 x + O[x]^3) x + O[x]^7
gives
1 + 3 x + 5 x^2 + O[x]^4
But if I instead substitute in the coefficient series after the fact, as in
(1 + a x + O[x]^7) /. a -> 3 + 5 x + O[x]^3
I end up with a SeriesData object whose coefficients are themselves SeriesData objects:
1 + (3 + 5 x + O[x]^3) x + O[x]^7
Given this structure, how can I now cause the appropriate simplifications to happen?  ExpandAll doesn't do it, and I don't know what else to try.

The attached notebook gives the same example,
Lyle Ramshaw
Attachments:
POSTED BY: Lyle Ramshaw
6 Replies
This does seem like less than desirable behavior. Will look into it.
POSTED BY: Daniel Lichtblau
You can define a function:
In[296]:= Clear[lyle]
lyle[a_] := 1 + a x + O[x]^7

In[298]:= lyle[3 + 5 x + O[x]^9]
Out[298]= SeriesData[x, 0, {1, 3, 5}, 0, 7, 1]

In[299]:= lyle[3 + 5 x + O[x]^3]
Out[299]= SeriesData[x, 0, {1, 3, 5}, 0, 4, 1]
lyle[] does the right thing without rule-driven programming exercises.

Sincerely
Udo.
POSTED BY: Udo Krause
Udo's clever idea of using a function application, rather than a transformation rule, in order to substitute one series in as a coefficient of another series has solved my immediate problem very neatly -- thank you!  But it might be nice if using a transformation rule also worked in this context,

Lyle
POSTED BY: Lyle Ramshaw
Sure:
      (i)                seemingly one has to use Normal[]
      (ii)               but in order to keep the error term one has to do the Normal[] on the non-dominant error term
In[294]:= 1+a x+O[x]^7/. a-> Normal[3+5 x+O[x]^9]
Out[294]= 1+3 x+5 x^2+O[x]^7

In[295]:= Normal[1+a x+O[x]^7]/. a-> 3+5 x+O[x]^3
Out[295]= 1+3 x+5 x^2+O[x]^4

it would be quite an exercise to apply Normal[] automatically to the  non-dominant error term - the goal is to avoid nested SeriesData[] expressions for the time being.
POSTED BY: Udo Krause
One has to use Normal[] 
 In[291]:= (1 + a x + O[x]^7) /. a -> 3 + 5 x + O[x]^3 // Normal
 
 Out[291]= 1 + 3 x + 5 x^2
 
 In[292]:= Normal[(1 + a x + O[x]^7)] /. a -> 3 + 5 x + O[x]^3
 Out[292]= SeriesData[x, 0, {1, 3, 5}, 0, 4, 1]
 
 In[293]:= FullForm[(1 + a x + O[x]^7) /. a -> 3 + 5 x + O[x]^3]
 Out[293]//FullForm= SeriesData[x,0,List[1,SeriesData[x,0,List[3,5],0,3,1]],0,7,1]
nested SeriesData[] seem not to Expand[], %292 does what you possibly  expect.
POSTED BY: Udo Krause
Udo, thanks for the tip; but Normal does not do what I want, since it truncates the series to which it is applied.  Truncating the outer series in the particular example that I gave happens to produce the correct answer, since the error term of O^7 in the outer series ends up being ignored.  But, in other examples, truncating would give the wrong answer.  I want to combine the inner and outer power series with the proper semantics, as happens correctly if both series are part of the initial typein.  For example, typing in
1 + (3 + 5 x + O[x]^9) x + O[x]^7
gives
1+ 3 x + 5 x^2 + O[x]^7
while typing in
1 + (3 + 5 x + O[x]^3) x + O[x]^7
gives
1+ 3 x + 5 x^2 + O[x]^4
Note that, in the first example, it is the error term of the outer series that dominates, while, in the second example, it is the error term of the inner series that dominates.  If I just apply Normal to either of the two series, I will lose this correct behavior.

Lyle
POSTED BY: Lyle Ramshaw
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