# How to write an easy Conjugate Function that just replaces i -> -i [closed]

I have a complicated complex expression that can Mathematica can't simplify using neither FullSimplify, Simplify nor Refine.

I tried something very naive

myConjugate[expr_] := expr /. {a_ I :> - a I}
expr = I (a + 0.5123 I b - 1.2332 I c);
myConjugate[expr]
Refine[Conjugate[expr], Element[{a, b, c}, Reals]]
% - %% // Simplify


which should give 0, but doesn't.

So my question becomes,

how can I flip the signs of all Is in an expression? The faster the better.

Replace acts on the full form of an expression, not the displayed form. The full form of your expression:

expr = I (a + 0.5123 I b - 1.2332 I c); expr // FullForm Therefore a complex number is represented by: Complex[..,..]. Therefore to make your "myConjugate" work you need to write:

myConjugate[expr_] := expr /. { Complex[x_, y_] -> Complex[x, -y]}
expr = I (a + 0.5123 I b - 1.2332 I c);
myConjugate[expr]
Refine[Conjugate[expr], Element[{a, b, c}, Reals]]
% - %% // Simplify


(* 0 *)