# Define new symbols and “inverse” function

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]]


After

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"])

• Do the variables have to be called "aConj" etc? – Feyre Oct 31 '16 at 13:42
• @ Feyre I call them in this way, aConj, bConj, ... but other way to solve the general problem are well accepted ;) – Giancarlo Nov 1 '16 at 3:32
• 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. – bill s Nov 1 '16 at 14:55
• accept the answer if it answers the question. – William Feb 18 '17 at 21:05

## 1 Answer

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

exp /. Conjugate[x_] :> Subscript[con, x]
%/. Subscript[con, x_] :> Conjugate[x]

• Yes, I generally prefer to have Symbols instead of Subscript too, but anyway it's a fast solutions, thanks :) – Giancarlo Nov 1 '16 at 14:10