# Recombine separated complex variables back into single variable

I have variables in an expression that have been previously expanded into their real and imaginary parts, that I later wish to recombine to a single variable. For example, a function or operation that would be able to convert $\sqrt{2} \,\textrm{Re}(a) - i \sqrt{2} \,\textrm{Im}(a)$ back to $\sqrt{2} \,a^*$, etc.

Is there a function I am missing that already does this? FullSimplify does achieve this, but also converts the $\sqrt{2}$ into a decimal and takes a lot of time for longer expressions, which is not ideal.

This should be pretty fast:

replaceReIm = {Re[x_] :> (x + Conjugate[x])/2,
Im[x_] :> (x - Conjugate[x])/(2 I)};

Simplify[Sqrt Re[a] - I Sqrt Im[a] /. replaceReIm]

(* ==> Sqrt Conjugate[a] *)


ComplexExpand is good for the rewriting part and following up with Expand combines like terms. For ComplexExpand one needs to specify that the variable is explicitly complex-valued, and also one needs to give desired "target" functions.

Expand[
ComplexExpand[Sqrt Re[a] - I Sqrt Im[a], {a},
TargetFunctions -> {Conjugate}]]

(* Out= Sqrt Conjugate[a] *)


The following works:

Sqrt Re[a] - I Sqrt Im[a] // FullSimplify


This yields:

Sqrt Conjugate[a]

• Correct, FullSimplify does work, but as mentioned above, is not ideal. The expression I am applying FullSimplify to is quite complicated and large, and FullSimplify tries to do much more than just look for much more than is required, causing it to have a very long runtime. Also, when I execute the above operation, I do not receive Sqrt Conjugate[a] but 1.41421 Conjugate[a], which is not ideal. – SLesslyTall Aug 15 '16 at 17:04
• Then, I guess, there must be some other reason why it converts this to a numeric expression. For example, if you type 2. instead of 2, it treats the expression numerically. – andy269 Aug 15 '16 at 17:09