# How can I get Mathematica to recognize that $ab^* + ba^* = 2\Re(ab^*)$?

Mathematica understands that $$z + z^* = 2\Re(z)$$,

FullSimply[z + Conjugate[z]]
(* output: 2 Re[z] *)


However, Mathematica does not simplify the expression

Conjugate[a] b + Conjugate[b] a


Is there a way that I can get Mathematica to recognize these sorts of combinations?

Note that

ComplexExpand[Conjugate[a] b + Conjugate[b] a, {a,b}]


produces

2 Im[a] Im[b] + 2 Re[a] Re[b]


but I would prefer to simply have it in the more compact form 2 Re[Conjugate[a]b]

Edit:

Here's an example of something I'd like to simplify:

v = {a, b, c};
m = {{1, 1, 1 + I}, {1, 1, 1}, {1 - I, 1, 1}};
Expand[Conjugate[v].m.v]


Essentially an expansion of the form $$\vec{v}^\dagger H \,\vec{v}$$ where $$H$$ is a Hermitian matrix. The expression is manifestly real, and there will always be terms which combine to either the real or imaginary parts of terms like $$a^*b$$. I'd like to find all the pairs and combine them into either $$\Re(a^*b)$$ or $$\Im(a^*b)$$.

• Have you tried ComplexExpand? – Carl Woll May 9 at 18:54
• @CarlWoll I updated it, unfortunately, ComplexExpand produces twice as many terms as I would like in an already very cluttered expression – Kai May 9 at 19:04
• Conjugate[a] b + Conjugate[b] a /. Conjugate[a_] b_ + Conjugate[b_] a_ -> 2 Re[a Conjugate[b]]? – AccidentalFourierTransform May 9 at 19:07
• I don't understand... when I try: ComplexExpand[Conjugate[a] b + Conjugate[b] a], I get 2 a b as an answer, which makes sense because ComplexExpand effecitively assumes a and b are real-valued. – bill s May 9 at 19:11
• @Kai It'd be easier for everyone if you could include a MWE where my replacement above does not work. – AccidentalFourierTransform May 9 at 20:05