I want do get the imaginary part of


I've tried to do this


but the result still contains

Im[Cos[t]/((1 - Cos[t])^2 + Sin[t]^2) - 
   Cos[t]^2/((1 - Cos[t])^2 + Sin[t]^2) - 
   Sin[t]^2/((1 - Cos[t])^2 + Sin[t]^2)] 

which in fact is 0 (t is a real variable). How can I convince Mathematica to get rid of this part of the expression?

  • 1
    $\begingroup$ While I don't know much about Mathematica, that expression, as written, is -1/2, for all t where f[t] is defined, not 0. $\endgroup$
    – Zéychin
    Jul 6 '14 at 10:32
  • $\begingroup$ Did you know there's a mathematica.stackexchange? I've flagged for migrating it there. $\endgroup$
    – stevenvh
    Jul 6 '14 at 10:38
  • $\begingroup$ Mathematica doesn't know you are assuming t is Real until you tell it. Simplify[Im[ComplexExpand[Exp[It]/(1-Exp[It])]],t \[Element] Reals] and then you are assuming that the denominator is not zero. Simplify[Im[ComplexExpand[Exp[It]/(1 - Exp[It])]], t \[Element] Reals && Cos[t] != 1] $\endgroup$
    – Bill
    Jul 6 '14 at 13:24
  • 3
    $\begingroup$ Simplify @ ComplexExpand[Im[Exp[I*t]/(1 - Exp[I*t])]]? $\endgroup$
    – Kuba
    Jul 8 '14 at 10:06

You can simplify the procedure:

Putting Im under ComplexExpand you get immediately

In[182]:= ComplexExpand[Im[Exp[I*t]/(1 - Exp[I*t])]]

Out[182]= Sin[t]/((1 - Cos[t])^2 + Sin[t]^2)

Simplifying this leads to the final result

In[183]:= Simplify[%]

Out[183]= 1/2 Cot[t/2]

Treating the real part similarly leads to

In[184]:= ComplexExpand[Re[Exp[I*t]/(1 - Exp[I*t])]]//Simplify

Out[185]= -(1/2)

Regards, Wolfgang

  • $\begingroup$ It would be educational to mention why :) $\endgroup$
    – Kuba
    Jul 8 '14 at 18:01
  • $\begingroup$ @Kuba: It is requested to calculate the imaginary part of a complex function f(t) of the real argument t. This can be done efficiently in MMA as shown. Notice that ComplexExpand simplifies a function assuming all its parameters to be real. $\endgroup$ Jul 8 '14 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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