# Problem with complex conjugation of series data in mathematica 10

ComplexExpand in Mathematica 10 doesn't work with series data:

Taylor = Series[Exp[I x], {x, 0, 4}]; ComplexExpand[Taylor\[Conjugate]]

gives

1+I x-x^2/2-(I x^3)/6+x^4/24+O[x]^5

(I is not changed to -I) whereas converting it to a normal expression first results in the correct answer:

ComplexExpand[Normal[Taylor]\[Conjugate]]

1-x^2/2+x^4/24+I (-x+x^3/6)

What's the easiest way to take the complex conjugate of a series expansion? Simply replacing I with -I (and vice versa) doesn't work either (coefficient of x^3 below doesn't change sign):

Taylor/.{I->-I, -I->I}

1-I x-x^2/2 -I x^3/6 + x^4/24 + O[x]^5

Edited after further exploration

Using Refine with assumptions, as suggested in question 77456, rather than ComplexExpand, seems to imply the root source of the problem is MMA not being able to conjugate series data:

Refine[Conjugate@Taylor, Assumptions->x\[Element]Reals]

gives

Conjugate[1+I X-x^2/2+I (x^3/6)+x^4/24+O[x]^5]

while

Refine[Conjugate@Normal@Taylor, Assumptions->x\[Element]Reals]

actually applies the conjugation correctly, giving

1-I X-x^2/2+I (x^3/6)+x^4/24

I tried to think why this might be a 'feature', but couldn't come up with any subtlety that would prevent you from naively conjugating order by order (assuming that the expansion parameter is small and real, of course). Anyone have any ideas?

## migrated from mathematica.meta.stackexchange.comDec 9 '15 at 17:13

This question came from our discussion, support, and feature requests site for users of Wolfram Mathematica.

• ComplexExpand is not documented to work with SeriesData, like in your example. Also in ComplexExpand@Conjugate@funky[x, 0, {I}, 0, 5, 1], Conjugate is simply removed, which is the same behaviour as in your example, only I wrote funky instead of SeriesData. – Jacob Akkerboom Dec 9 '15 at 17:56
• Ok, thanks, but this is very strange behaviour! I don't see why it couldn't just be applied naively order by order in a series expansion. Question updated above! – Rakhi Mahbubani Dec 10 '15 at 13:00

You could take the complex conjugate of the series expansion as follows

taylor = Series[Exp[I x], {x, 0, 4}]
seriesConjugationRule =
HoldPattern@SeriesData[xPatt__, coeffs_List, nPatt__] :>
SeriesData[xPatt, Conjugate@coeffs, nPatt];
taylor /. seriesConjugationRule

1+I x-x^2/2-(I x^3)/6+x^4/24+O[x]^5
1-I x-x^2/2+(I x^3)/6+x^4/24+O[x]^5


However, you should be very careful in trying to use replacements on expressions that you do not understand the structure of. Your attempt to replace I by -I is revealed to be misguided (for lack of a better word) by looking at the FullForm of Taylor. It also turns out that looking at the FullForm is not even enough, because the complex numbers in the expression are really atoms.

So I suppose you can use this, but be careful, especially when trying to implement something like this yourself.

For completeness, I think in ComplexExpand@Conjugate@funky[x, 0, {I}, 0, 5, 1] and your own example Conjugate may be discarded because ComplexExpand assumes the values of funky are real numbers, analogously to its behaviour to assume that variables are real unless states otherwise. That is just a theory, though.

• It really seems to be a problem with Conjugate not working with series data, see second edit above. I don't see any reason why this should, be since conjugation can be done order by order in some small parameter! – Rakhi Mahbubani Dec 11 '15 at 8:44