Re: Output complex numbers in polar (exponential) form?
- To: mathgroup at smc.vnet.net
- Subject: [mg121186] Re: Output complex numbers in polar (exponential) form?
- From: Simon <simonjtyler at gmail.com>
- Date: Sat, 3 Sep 2011 08:04:52 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j3q0pm$6fh$1@smc.vnet.net>
- Reply-to: comp.soft-sys.math.mathematica at googlegroups.com
Here's the answer I gave to a similar question (http://stackoverflow.com/q/3928489/421225) on stackoverflow. If you only need to do it occasionally, then you could just define a function like ComplexToPolar[z_] /; Element[z, Complexes] := Interpretation[ Grid[{{Abs[z], Superscript[E, Row[{I, Arg[z]}]]}}, Spacings -> .2], z] If always want objects with Head Complex, then something like Unprotect[Complex]; 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]}]]}]] Protect[Complex]; For complex numbers such as 3 + 4 Pi I, the first option works, but the second doesn't. This is clear from the FullForm.