# How to get the real part of a complex expression

I am trying to get the real part of this expression given below. Using the Re command does not lead anywhere.

1/((2.6881 - 0.686385 I) E^(I x))^(
2/3) E^(-4 I x) ((0.00256727 +
0.000818759 I) + (0.00123498 +
0.000591567 I) ((2.6881 - 0.686385 I) E^(I x))^(2/3) +
E^(I x) ((0.00382662 -
0.00012753 I) + (0.00382139 +
0.000909473 I) ((2.6881 - 0.686385 I) E^(I x))^(2/3) +
E^(I x) ((0.0108048 -
0.00264035 I) + (0.0327023 - 0.0135913 I) E^(
I x) + (0.0119219 +
0.000622502 I) ((2.6881 - 0.686385 I) E^(I x))^(
2/3) + (0.0181462 + 0.00991331 I) ((2.6881 - 0.686385 I) E^(
I x))^(5/3))))


The expression looks like this:

Can you please help me get the real part of the above expression as Polynomial of x. I tried specifying x is real too, still no luck.

Edit: I tried using ComplexExpand as suggested in the first comment but it complicates the expression even further by introducing Arg terms.

Here is how the partial output after ComplexExpand looks like (The actual output is too long):

• Look at ComplexExpand – Lukas Lang Jun 30 '18 at 10:53
• @LukasLang I added the output after ComplexExpand in the question as a picture. It is even complex. – kasa Jun 30 '18 at 11:20
• Did you use CompexExpand[Re[expr]]? – Lukas Lang Jun 30 '18 at 11:28
• Re[expr] is only evaluated if expr is a numeric quantity! – Ulrich Neumann Jun 30 '18 at 13:31

Clear[expr, expr2]

expr[x_] =
1/((2.6881 - 0.686385 I) E^(I x))^(2/3) E^(-4 I x) ((0.00256727 +
0.000818759 I) + (0.00123498 +
0.000591567 I) ((2.6881 - 0.686385 I) E^(I x))^(2/3) +
E^(I x) ((0.00382662 -
0.00012753 I) + (0.00382139 +
0.000909473 I) ((2.6881 - 0.686385 I) E^(I x))^(2/3) +
E^(I x) ((0.0108048 -
0.00264035 I) + (0.0327023 -
0.0135913 I) E^(I x) + (0.0119219 +
0.000622502 I) ((2.6881 - 0.686385 I) E^(I x))^(2/
3) + (0.0181462 +
0.00991331 I) ((2.6881 - 0.686385 I) E^(I x))^(5/3))));

expr2[x_] =
expr[x] // Rationalize[#, 0] & // Re //
ComplexExpand[#, TargetFunctions -> {Re, Im}] & // FullSimplify

(* (Cos[2/3 ArcTan[
537620 Cos[x] + 137277 Sin[x], -137277 Cos[x] +
537620 Sin[x]]] (10 (3270230 Cos[x] + 1080480 Cos[2 x] +
382662 Cos[3 x] + 256727 Cos[4 x] - 1359130 Sin[x] -
264035 Sin[2 x] - 12753 Sin[3 x]) +
818759 Sin[4 x]))/(100000 5^(2/3) 307880239129^(
1/3)) + (1111662950087 Cos[x] +
80 (2980475000 Cos[2 x] + 955347500 Cos[3 x] +
308745000 Cos[4 x] + 3548172281 Sin[x] +
250 (622502 Sin[2 x] + 909473 Sin[3 x] + 591567 Sin[4 x])))/
20000000000000 - ((13591300 Cos[x] + 2640350 Cos[2 x] +
127530 Cos[3 x] - 818759 Cos[4 x] + 32702300 Sin[x] +
10804800 Sin[2 x] + 3826620 Sin[3 x] + 2567270 Sin[4 x]) Sin[
2/3 ArcTan[
537620 Cos[x] + 137277 Sin[x], -137277 Cos[x] +
537620 Sin[x]]])/(100000 5^(2/3) 307880239129^(1/3)) *)


EDIT: Looking at a plot of the real part

plt = Plot[expr2[x], {x, -2 Pi, 2 Pi}, MaxRecursion -> 5, PlotPoints -> 200]


The real part is periodic

FunctionPeriod[expr2[x], x]

(* 2 π *)


Verifying,

expr2[x] == expr2[x + 2 Pi] // Simplify

(* True *)


With the definition

z = 1/((2.6881 - 0.686385 I) E^(I x))^(2/3) E^(-4 I x) ((0.00256727 +
0.000818759 I) + (0.00123498 +
0.000591567 I) ((2.6881 - 0.686385 I) E^(I x))^(2/3) +
E^(I x) ((0.00382662 -
0.00012753 I) + (0.00382139 +
0.000909473 I) ((2.6881 - 0.686385 I) E^(I x))^(2/3) +
E^(I x) ((0.0108048 -
0.00264035 I) + (0.0327023 -
0.0135913 I) E^(I x) + (0.0119219 +
0.000622502 I) ((2.6881 - 0.686385 I) E^(I x))^(2/
3) + (0.0181462 +
0.00991331 I) ((2.6881 - 0.686385 I) E^(I x))^(5/3))))


Mathematica evaluates

expr=Expand[ ExpToTrig[PowerExpand[z  ]]  ]


an expression which seems to be linear in I. Now you have only to collect for the imaginary unit.

rez=Chop@Simplify[Expand[ ExpToTrig[PowerExpand[expr  ]]  ] /.Complex[re_, im_] -> re + ii im /. ii -> 0]
(*0.0555831 Cos[x] + 0.0174754 Cos[(5 x)/3] + 0.0119219 Cos[2 x] +
0.0056184 Cos[(8 x)/3] + 0.00382139 Cos[3 x] +
0.00192195 Cos[(11 x)/3] + 0.00123498 Cos[4 x] +
0.00121345 Cos[(14 x)/3] + 0.0141927 Sin[x] +
0.001245 Cos[x] Sin[x] - 0.00404056 Sin[(5 x)/3] -
0.000410898 Sin[(8 x)/3] + 0.000909473 Sin[3 x] +
0.000257826 Sin[(11 x)/3] + 0.000591567 Sin[4 x] +
0.000624645 Sin[(14 x)/3]*)


gives the real part you are asking for. Sorry for the last code line, I didn't find an easier way...

• Complex[re_, im_] -> re + ii im /. ii -> 0 can be simplified to Complex[re_, im_] -> re – Bob Hanlon Jun 30 '18 at 14:01