# Modify real part and leaves imaginary part unchanged

How can I flip the sign of the real part but not affect the imaginary part of a complex number:

a+bi => -a + bi

Example list:

list = {{-0.282095 + 0.282095 I, -0.27254 + 0.291336 I,
-0.262018 + 0.300835 I, -0.250437 + 0.310542 I}}


expected:

{{0.282095 + 0.282095 I, 0.27254 + 0.291336 I,
0.262018 + 0.300835 I, 0.250437 + 0.310542 I}}


So it's "similar" to conjugate but works on the real not imaginary.

-Conjugate[list]

(* {{0.282095 + 0.282095 I, 0.27254 + 0.291336 I,
0.262018 + 0.300835 I, 0.250437 + 0.310542 I}} *)

• This is not even a Mathematica but a Math answer. I like it – infinitezero Oct 2 '19 at 12:06
list /. Complex[x_, y_] :> Complex[-x, y]


{{0.282095 + 0.282095 I, 0.27254 + 0.291336 I, 0.262018 + 0.300835 I, 0.250437 + 0.310542 I, 2, 3 I}}

• This assumes that all entries are truly Complex[_,_]. But for a list {{-0.282095 + 0.282095 I, -0.3445}}, which also contains only complex numbers (although one of them happens to be purely real, and even have Real head), this won't work correctly. – Ruslan Oct 3 '19 at 5:20
• Agreed. This solution is for complex numbers of the form a + b i that was asked in the question. To include real numbers it needs to be modified to {Complex[x_,y_]:>Complex[-x,y], x_:>-x}. – Suba Thomas Oct 3 '19 at 14:21
• Actually this would also break for "complex" number like e.g. 1.234+0I, which actually collapses to a Real – Ruslan Oct 3 '19 at 14:23
f[z_] = -Re[z] + I Im[z]
f[list]

(* {{0.282095 + 0.282095 I, 0.27254 + 0.291336 I, 0.262018 + 0.300835 I, 0.250437 + 0.310542 I}} *)