Here's a simple Manipulate demonstration of complex values:
Manipulate[ ComplexPlot[zz, {zz, -2 - 2 I, 2 + 2 I}, Epilog -> {Arrow[{{0, 0}, z}]}], {z, {-2, -2}, {2, 2}}] The user adjusts the Control thereby placing the arrow tip at a complex point z.
I'd like to have text presumably exploiting Epilog that reads something like:
$z = 0.8 - 1.1 i$
$\quad = 1.36 e^{-0.94\ i}$
placed in the upper-left of the plot, with the equals signs aligned one atop the other (and small line spacing).
You'll recall from mathematics that if a complex number is $z = a + b i$, then its polar representation is $\sqrt{a^2 + b^2} e^{\tan^{-1} (b/a)}$.
I'd like the original $z$ in the text to be held fixed in place in the plot.
The problems that have stumped me are the following:
- Ensuring the original $z$ stays fixed in place on the ComplexPlot as the values (and width of text) changes. (Surely there must be a TextAlignment -> Left somewhere in the code.)
- Typesetting the "+" or "-" in the first row. The naive approach is to include ...<>"+"<>.... between the two entries in z, but then you sometimes get the ugly and incorrect $0.8 + - 1.1$
- Representing the magnitude on the second line ($\sqrt{a^2 + b^2}$) to two-digit accuracy. I've tried N[Norm[z],2] but somehow I always get five digits.
- Typesetting the $e^{\tan^{-1}(a/b) i}$. (Because the location of z in the complex quadrants is important for the angle, we should use ArcTan[z[[2]],z[[1]]])
I'd also like to use the special $i$ and $e$ typeset in Mathematica.
The whole task seems an exercise in frustration, and I was hoping there is some elegant approach that avoids all the calls of ToString, Superscript, Text, etc.
Here's code that doesn't work:
Epilog -> {Black, PointSize[0.02], Point[zz], Arrow[{{0, 0}, zz}], Text[Style[ "z = " <> ToString[zz[[1]]] <> "+" <> ToString[zz[[2]]] <> "\[ImaginaryI]" <> "\n =" <> ToString[N[Sqrt[zz . zz], 2]] <> "\!\(\*SuperscriptBox[\(\[ExponentialE]\), \(\[ImaginaryI]\)]\)" \ <> ToString[ArcTan[zz[[1]], zz[[2]]]], 20, Black, Italic, FontFamily -> "Latin Modern Roman", LineSpacing -> -10], {-1, 1.65}]} 




