Message Boards Message Boards

0
|
1590 Views
|
3 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Convert a complex number into the exponent form

Posted 1 year ago

See my following code snippet:

In[344]:= (*
https://mathematica.stackexchange.com/questions/16414/how-can-i-convert-a-complex-number-into-an-exponent-form
*)
polarForm = Expand[# /. z_?NumericQ :> Abs[z] Exp[I Arg[z]]] &;
polarForm1 = ComplexExpand[# /. z_?NumericQ :> Abs[z] Exp[I Arg[z]], TargetFunctions -> {Re, Im}] &;
x1=Eigenvectors[gen1]
polarForm/@#&/@x1
polarForm1/@#&/@x1

Out[346]= {{1, 1, 1}, {1/2 (-1 - I Sqrt[3]), 1/2 (-1 + I Sqrt[3]), 
  1}, {1/2 (-1 + I Sqrt[3]), 1/2 (-1 - I Sqrt[3]), 1}}

Out[347]= {{1, 1, 1}, {E^(-((2 I \[Pi])/3)), E^((2 I \[Pi])/3), 
  1}, {E^((2 I \[Pi])/3), E^(-((2 I \[Pi])/3)), 1}}

Out[348]= {{1, 1, 1}, {-(1/2) - (I Sqrt[3])/2, -(1/2) + (I Sqrt[3])/2,
   1}, {-(1/2) + (I Sqrt[3])/2, -(1/2) - (I Sqrt[3])/2, 1}}

Why doesn't the second method work?

Regards,
Zhao

POSTED BY: Hongyi Zhao
3 Replies
Posted 1 year ago

Thank you, Eric,

This is exactly what I'm looking for.

POSTED BY: Hongyi Zhao
Posted 1 year ago

Based on your title,

Convert a complex number into the exponent form.

if you're just converting numbers, then you don't need to expand. You could just do this:

ToPolar[z_] := Abs[z] Exp[I Arg[z]]

Abs and Arg are listable, so you can apply it like this:

ToPolar[x1]

If this isn't what you're looking for, then provide more context. If your question is specifically about the behavior of ComplexExpand, then be explicit about your question (but Daniel's answer is likely what you're looking for).

Throwing some code at us and asking "why doesn't it work" imposes a burden on us to infer your objective and what you think is wrong.

POSTED BY: Eric Rimbey

ComplexExpand always separates real and imaginary parts. This is not what one wants in a polar form. So it cannot be used to create that form, or at least cannot be used in this particular manner.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract