Post by Gordon SmithSuppose s = Series[Cosh[(x + I y)u, {u,0,2}]. How can I get the real part 1 + 1/2(x^2 - y^2) u^2 + O(u^3) and the imaginary part x y u^2 + O(u^3) ? I thought ComplexExpand[Re[s]] should give me the real part of s, but it just gives me s unchanged. (Mathematica newbie here!)
Since you are a newbie, the folowing will be very useful.
Say,
In[46]:=
o=Series[f[x],{x,0,3}];
Then note the interpetation of this expression
In[50]:=
o//FullForm
Out[50]//FullForm=
SeriesData[x,0,List[f[0],Derivative[1][
f][0],Times[Rational[1,2],Derivative[2][f][0]],Times[Rational[
1,6],Derivative[3][f][0]]],0,4,1]
Understanding this structure is essential to figure out the solution
below:
In[57]:=
s = Series[Cosh[(x + I*y)*u], {u, 0, 6}]
Out[57]=
SeriesData[u, 0, {1, 0, (x + I*y)^2/2, 0, (x + I*y)^4/24, 0, (x +
I*y)^6/720}, 0, 7, 1]
In[53]:=
(ComplexExpand[#1[Normal[s]]] + SeriesData[u, 0, {}, s[[5]], s[[5]],
1] & ) /@ {Re, Im}
Out[53]=
{SeriesData[u, 0, {1, 0, x^2/2 - y^2/2, 0, x^4/24 - (x^2*y^2)/4 +
y^4/24, 0, x^6/720 - (x^4*y^2)/48 + (x^2*y^4)/48 - y^6/720}, 0, 7, 1],
SeriesData[u, 0, {x*y, 0, (x^3*y)/6 - (x*y^3)/6, 0, (x^5*y)/120 -
(x^3*y^3)/36 + (x*y^5)/120}, 2, 7, 1]}
Cheers
Dimitris