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


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]


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}};

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)$.

  • 1
    $\begingroup$ Have you tried ComplexExpand? $\endgroup$ – Carl Woll May 9 at 18:54
  • $\begingroup$ @CarlWoll I updated it, unfortunately, ComplexExpand produces twice as many terms as I would like in an already very cluttered expression $\endgroup$ – Kai May 9 at 19:04
  • $\begingroup$ Conjugate[a] b + Conjugate[b] a /. Conjugate[a_] b_ + Conjugate[b_] a_ -> 2 Re[a Conjugate[b]]? $\endgroup$ – AccidentalFourierTransform May 9 at 19:07
  • $\begingroup$ 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. $\endgroup$ – bill s May 9 at 19:11
  • 1
    $\begingroup$ @Kai It'd be easier for everyone if you could include a MWE where my replacement above does not work. $\endgroup$ – AccidentalFourierTransform May 9 at 20:05

Your Answer

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

Browse other questions tagged or ask your own question.