Dear mathgroup,
there is indeed a very elegant solution to these kind of problems. It took me some while (looking up the documentation center) but I think this works fine:
Step 1: define your notation (here on the output format of complex numbers):
In[1]:= format[c_Complex] :=
Interpretation[
Which[
Re[c] == 0 && Im[c] == 0, "0",
Re[c] == 0 && Im[c] != 0, ToString[Im[c] // N] <> "\[ImaginaryI]",
Re[c] != 0 && Im[c] == 0, ToString[Re[c] // N],
True, ToString[c // N, StandardForm]], c]
Step 2: Tell Mathematica to apply this functions to any output expression
In[2]:= $Post = # /. c_Complex :> format[c] &
Out[2]= #1 /. c_Complex :> format[c] &
Step 3: Work as usual, you will always see the format you defined in
Step 1....
In[4]:= x = {0. + I, 0 + 1. I, 1 + 0. I, 1. + 2. I}
Out[4]= {1.I,1.I,1.,1. +2. I}
...but you will always be able to continue your calculations independent
of the format you
may define:
In[5]:= Total[x]
Out[5]= Complex[2., 4.]
Step 4: clear $Post to return to normal Mathematica behaviour:
In[6]:= Clear[$Post]
Hope, that helps,
Christoph
PS: Here is a nice joke you can implement in your friends Mathematica
version:
In[1]:= format[c_Complex]:=
Interpretation[
Im[c]+Re[c]I,c]
In[2]:= $Post=#/.c_Complex:>format[c]&
Out[2]= #1/. c_Complex:>format[c]&
In[3]:= x={0.+I,0+1.I,1+0.I,1.+2.I}
Out[3]= {1. +0. I,1. +0. I,0. +1. I,2. +1. I}
In[4]:= y=Total[x]
Out[4]= 4. +2. I
Do not forget to release him! With
In[5]:= Clear[$Post]
In[6]:= x
Out[6]= {0. +1. I,0. +1. I,1. +0. I,1. +2. I}
In[7]:= y
Out[7]= 2. +4. I
...everything turns out to be fine ;o)