views:

116

answers:

3

I want to display complex numbers in trig form. For example:

z = (-4)^(1/4);

I'm not sure what the command for that is, and its silly to write:

alt text

I thought, that the command was ExpToTrig, but solution can't possibly be just 1+i (Or can it, and I'm misusing it?). How do display complex number in trig form.

Edit:

Command is ExpToTrig, it just does not give all the solutions (or i have failed to find out how). Finally solved my problem with writing a pure function NrootZpolar[n][z]:

NrootZpolar := 
 Function[x, 
  Function[y, 
       ( Abs[y] ^ (1/x) *
       ( Cos[((Arg[y] + 360° * Range[0, x - 1]) / x)] + 
       I*Sin[((Arg[y] + 360° * Range[0, x - 1]) / x)]))
  ]
 ]

And use:

In[689]:= FullSimplify[NrootZpolar1[4][-4]]
Out[689]= {1 + I, -1 + I, -1 - I, 1 - I}

To visualize:

ComplexListPlot[list_] := ListPlot[Transpose[{Re[list], Im[list]}], AxesLabel -> {Re, Im}, PlotLabel -> list, PlotMarkers -> Automatic]
Manipulate[ComplexListPlot[FullSimplify[NrootZpolar1[n][z]]], {z, -10, 10}, {n, 1, 20}]

alt text

A: 

You can express a complex number z in polar form r(cos theta + i sin theta) where r = Abs[z] and theta = Arg[z]. So the only Mathematica commands you need are Abs[] and Arg[].

John D. Cook
+1  A: 

If you only need to do it occasionally, then you could just define a function like

In[1]:= ComplexToPolar[z_] /; z \[Element] Complexes := Abs[z] Exp[I Arg[z]]

so that

In[2]:= z = (-4)^(1/4);
In[3]:= ComplexToPolar[z]
Out[3]= Sqrt[2] E^((I \[Pi])/4)

In[4]:= ComplexToPolar[z] == z // FullSimplify
Out[4]= True

For expanding out functions (not that this was part of your question) you use

In[5]:= ComplexExpand[, TargetFunctions -> {Abs, Arg}]

Finally, if you always want complex numbers written in polar form then something like

In[6]:= Unprotect[Complex];
In[7]:= Complex /: MakeBoxes[Complex[a_, b_], StandardForm] := 
 With[{abs = Abs[Complex[a, b]], arg = Arg[Complex[a, b]]}, 
  RowBox[{MakeBoxes[abs, StandardForm], 
    SuperscriptBox["\[ExponentialE]", 
      RowBox[{"\[ImaginaryI]", MakeBoxes[arg, StandardForm]}]]}]]

will make the conversion automatic

In[8]:= 1 + I
Out[8]= Sqrt[2]*E^(I*(Pi/4))

Note that this will only work on explicitly complex numbers -- ie those with the FullForm of Complex[a,b]. It will fail on the z defined above unless you use something like Simpify on it.

Simon
A: 

Mathematically speaking, (-1)^(1/4) is an abuse on notation. There is no such a number.

What you are expressing using that abomination ( :) ) are the roots of an equation:

z^4 == 1  

In Mathematica (as in math in general) is more convenient to use radians than degrees. Expressed in radians, you may define for example

 f[z1_,n_] := Abs[z] (Cos[Arg[z]] + I Sin[Arg[z]]) /.Solve[z^n+z1 == 0, z,Complex]

or

g[z1_,n_] := Abs[z] (Exp [I Arg[z]]) /.Solve[z^n+z1 == 0, z,Complex]  

depending on your notation preference (trig or exponential ... but the last is preferred).

To get your desired expression for (-4)^(1/5) just type

g[4,5] or f[4,5]
belisarius
Yours is the only answer which addressed the probable underlying question that the OP had. i.e. the n different roots of w=z^n
Simon
@Simon I guess the problem there is not with Mathematica itself, but with understanding the "radix" operator as a multivalued inverse of the exponentiation. I tried to address that ...
belisarius