Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4714
| From | Simon <simonjtyler@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Output complex numbers in polar (exponential) form? |
| Date | 2011-09-03 12:08 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j3t5bg$57f$1@smc.vnet.net> (permalink) |
| References | <j3q0pm$6fh$1@smc.vnet.net> |
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.
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Output complex numbers in polar (exponential) form? "Mr.CRC" <crobcBOGUS@REMOVETHISsbcglobal.net> - 2011-09-02 07:32 +0000
Re: Output complex numbers in polar (exponential) form? Simon <simonjtyler@gmail.com> - 2011-09-03 12:08 +0000
Re: Output complex numbers in polar (exponential) form? "Mr.CRC" <crobcBOGUS@REMOVETHISsbcglobal.net> - 2011-09-08 09:27 +0000
csiph-web