I have an expression that involve variables and conjugate of the variables eg

exp = a + (b + Abs[ c + I Conjugate[d]^3 ])^2 Conjugate[e] Conjugate[f] + Conjugate[g] 

Now I want to
a) substitute the conjugates of the variables with new symbols;
b) return to the original expression with an "inverse" substitution.

This is my way to do it:
I can substitute the conjugates of the variables with new symbols in this way

AppendConj[x_] := Symbol[ToString[x] <> "Conj"]  

exp1 = exp/. Conjugate[x_] :> AppendConj[x]

and I can substitute these new symbols that end with "Conj" with the Conjugate of the symbol in this way:
first I define a function that find the variables in an expression

Var[x__] := Union[Cases[Level[x, {-1}], _Symbol]]  


exp1 /. Thread[Var[exp1] -> (Var[exp1] /. (x_ :> Conjugate[Symbol[StringDrop[ToString[x], -4]]] /; StringEndsQ[ToString[x], "Conj"]))]

The procedure works, but since naming of variables is a very common topic, I think there should be a more elegant way to do it.
How would you do it?

P. S.
I improved what I did before with these substitutions

/. Conjugate[y_Symbol] :> Symbol[SymbolName[y] <> "Conj"]  

/. (x_Symbol :> 
   Conjugate[Symbol[StringDrop[SymbolName[x], -4]]] /; 
    StringEndsQ[SymbolName[x], "Conj"])
  • $\begingroup$ Do the variables have to be called "aConj" etc? $\endgroup$
    – Feyre
    Oct 31, 2016 at 13:42
  • $\begingroup$ @ Feyre I call them in this way, aConj, bConj, ... but other way to solve the general problem are well accepted ;) $\endgroup$
    – Giancarlo
    Nov 1, 2016 at 3:32
  • $\begingroup$ Can you explain why you want to do this? The thing is: Conjugate[d] and d have a clear relation that Mathematica knows (something) about. If you change the variable names to dConj and d, then this link is broken. $\endgroup$
    – bill s
    Nov 1, 2016 at 14:55
  • $\begingroup$ accept the answer if it answers the question. $\endgroup$
    – William
    Feb 18, 2017 at 21:05

1 Answer 1


I normally dislike subscripts, but here it can work well:

exp /. Conjugate[x_] :> Subscript[con, x]
%/. Subscript[con, x_] :> Conjugate[x]
  • $\begingroup$ Yes, I generally prefer to have Symbols instead of Subscript too, but anyway it's a fast solutions, thanks :) $\endgroup$
    – Giancarlo
    Nov 1, 2016 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.