1
$\begingroup$

I am having some problems retrieving the real part of a complex function. I have a function which looks as follows:

$$ 2^{-\dfrac{4\left( \frac{x}{\sqrt{2}}+\frac{z}{\sqrt{2}} \right)^{2}}{w^2} } e^{-i\left(\dfrac{k*x}{\sqrt{2}}-\dfrac{k*z}{\sqrt{2}} +\phi+\omega t \right)} $$

Basically, I am only interested in the real part of this function. Thus the complex exponential part would turn into a Cosine function with the same argument. However, if I apply the $Re[\ ]$ operator onto this function I get:

$$ Re[2^{-\dfrac{4\left( \frac{x}{\sqrt{2}}+\frac{z}{\sqrt{2}} \right)^{2}}{w^2} } e^{-i\left(\dfrac{k*x}{\sqrt{2}}-\dfrac{k*z}{\sqrt{2}} +\phi+\omega t \right)} ] $$

I understand that I could just manually replace the complex exponential with a cosine but that would not be functional for my calculation program. Is there any way in which I can do this consistently and automatically?

The raw code looks as follows:

VectorValues = {E01x -> 0, E01y -> 1, E01z -> 0, E02x -> 0, 
   E02y -> 1, E02z -> 0, K1x -> Sin[θ/2] k, K1y -> 0, 
   K1z -> Cos[θ/2] k, K2x -> -Sin[θ/2] k, K2y -> 0, 
   K2z -> Cos[θ/2] k, B01x -> -Sin[θ/2], B01y -> 0, 
   B01z -> Cos[θ/2], B02x -> Cos[θ/2], B02y -> 0, 
   B02z -> Sin[θ/2]};

E01 = {E01x, E01y, E01z} //. VectorValues;
E02 = {E02x, E02y, E02z} //. VectorValues;
B01 = {B01x, B01y, B01z} //. VectorValues;
B02 = {B02x, B02y, B02z} //. VectorValues;
K1 = {K1x, K1y, K1z} //. VectorValues;
K2 = {K2x, K2y, K2z} //. VectorValues;
r = {x, y, z} //. VectorValues;


E1b = E01* Exp[-I (ω t0 - K1.r + ϕ)]*Exp[-((4 Log[2]*(-x*Sin[θ/2] + z*Cos[θ/2])^2)/w0^2)];

B1b = B01* Exp[-I (ω t0 - K1.r + ϕ)]*Exp[-((4 Log[2]*(-x*Sin[θ/2] + z*Cos[θ/2])^2)/w0^2)];

S1 = 1/μ0 (Re[E1b]\[Cross]Re[B1b]);

S1vec [x_, y_, z_, t0_] = S1 //. {θ -> -π/2};

S1vec[x, y, z, t][[1]]

Where S1vec [x_, y_, z_, t0_] is a vector containing 3 equations of which the part above (latex code) is a small part.

$\endgroup$

closed as off-topic by Bob Hanlon, Sektor, LCarvalho, m_goldberg, LLlAMnYP Dec 12 '17 at 10:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, Sektor, LCarvalho, m_goldberg, LLlAMnYP
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ please post the Mathematica input lines. We are very lazy people here who prefer copy-paste. And try using Simplify[...,Assumptions->Elements[{x,z,kx,kz},Reals]. $\endgroup$ – Sumit Dec 5 '17 at 10:41
  • $\begingroup$ @Sumit Thank you for your suggestion, I added the code, hope it helps to clarify what I mean. The Simplify expression including the assumption statement still does not work and the output remains the same. $\endgroup$ – Guido De Haan Dec 5 '17 at 11:03
2
$\begingroup$

Since your final expression is already Re[]

ComplexExpand[S1vec[x, y, z, t][[1]]]

$\frac{2^{-\frac{8 \left(\frac{x}{\sqrt{2}}+\frac{z}{\sqrt{2}}\right)^2}{\text{w0}^2}-\frac{ 1}{2}} \cos ^2\left(\frac{k x}{\sqrt{2}}-\frac{k z}{\sqrt{2}}+t \omega +\phi \right)}{\text{$\mu $0}}$

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.