Why doesn't the last command below split the complex number into its real and imaginary parts?
Complex[2,2]
(* 2 + 2 I *)
Complex[N[Exp[3]], N[Exp[3]]]
(* 20.0855 + 20.0855 I *)
Complex[Exp[3],Exp[3])
(* Complex[E^3,E^3] *)
I understand why this can be very confusing, but essentially
Complex[Exp[3],Exp[3]]
is invalid syntax. Do not do this.
Complex is an atomic type (AtomQ). It is not a compound expression with head Complex and two arguments. It is a fundamental type that is indivisible.
What happens when you evaluate Complex[1,2]? What you type here is indeed a compound expression with head Complex and two integer arguments. However, it evaluates to an atomic integer-based complex immediately.
AtomQ[Complex[1, 2]]
(* True *)
AtomQ[Unevaluated@Complex[1, 2]]
(* False *)
The fundamental complex type can be either integer-based or real-based, and that's it. It cannot contain arbitrary symbolic expressions.
If you put such symbolic expressions into Complex[...], it simply won't evaluate. What you get is a compound expression that is not usable as a complex number. It is not of the atomic Complex type. Im, Re, Abs, ComplexExpand, etc. won't handle it.
z = Complex[1, Sqrt[2]];
AtomQ[z]
(* False *)
{Re[z], Im[z], Abs[z]}
(* {Re[Complex[1, Sqrt[2]]], Im[Complex[1, Sqrt[2]]], Abs[Complex[1, Sqrt[2]]]} *)
The correct way to represent such number is Exp[3] + I*Exp[3] instead. The structure will then be like this:
Complexbehaves similarly toRationalfor the construction of the respective objects. Arguments of the former must beNumberQand arguments of the latter must beIntegerQfor the construction to take place. – Oct 08 '16 at 16:08With[{re = Re[#], im = Im[#]}, TraditionalForm[HoldForm[re + im I]]] &– LegionMammal978 Oct 08 '16 at 17:04