Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to simplify my expression to the style of "a+b*I"?

Expand[(E^(I θ) (-1 + E^(I n θ)))/(-1 + E^(I θ))]
-(E^(I θ)/(-1 + E^(I θ))) + E^(I θ + I n θ)/(-1 + E^(I θ))

the result I want to achieve

share|improve this question
up vote 4 down vote accepted

As shown by others, you are looking for a combination of ComplexExpand and Collect. In your case, ComplexExpand does a good job of separating the real and imaginary components of your expression.

enter image description here

In general, you will end up with a number of terms, and you will need to use Collect to merge them together. However, using Collect on I does not usually work

Collect[a I + (1 + I) b, I]
(* I a + (1 + I) b *)

because I is interpreted as Complex[0, 1], so Collect will not break up numbers like 1 + I. So, the most effective method I have found is to replace I with some other symbol, like q.

   ComplexExpand[expr] /. Complex[a_, b_] :> a + q b, 
   q, Simplify
  ] /. q -> I
    Cos[1/2 (1 + n) θ] Csc[θ/2] Sin[(n θ)/2] 
+ I Csc[θ/2] Sin[(n θ)/2] Sin[1/2 (1 + n) θ]

where expr is your expression. Note I set the third argument of Collect to Simplify which reduced the complexity of the real and imaginary parts quite well.

share|improve this answer

I hope this is what you need:

Collect[Expand[(E^(I \[Theta]) (-1 + E^(I n \[Theta])))/(-1 + 
      E^(I \[Theta]))] // ComplexExpand, I]

enter image description here

share|improve this answer
exp = Expand[(E^(I \[Theta]) (-1 + E^(I n \[Theta])))/(-1 +E^(I \[Theta]))]

Mathematica graphics

r = Simplify@ComplexExpand@Re@exp + I*Simplify@ComplexExpand@Im@exp

Mathematica graphics

it is now in the form a+I b

{a, b} = First@Cases[r, Plus[a_, I b_] :> {a, b}, {0}];

Mathematica graphics


Mathematica graphics

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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