1
$\begingroup$

Is it possible to easily simplify the difference of conjugate pairs?

In particular, if there's just a single variable, then

FullSimplify[a - Conjugate[a]]
2 I Im[a]

But trying to do the same thing with a slightly more complex expression fails:

FullSimplify[a Conjugate[b] - Conjugate[a] b]
a Conjugate[b] - Conjugate[a] b

I have found one solution (answered below) but it relies on a FullSimplify which doesn't seem very optimal.

$\endgroup$
2
  • 3
    $\begingroup$ ComplexExpand[a Conjugate[b] - Conjugate[a] b, {a, b}] ? $\endgroup$
    – LouisB
    Jun 1, 2020 at 8:55
  • $\begingroup$ That is indeed mathematically equivalent, but it usually results in quite a large expression. I was really hoping to get the result as 2 I Im[...]. $\endgroup$
    – JP-Ellis
    Jun 1, 2020 at 9:01

1 Answer 1

1
$\begingroup$

Here is one solution which works to some extent, though it relies on a FullSimplify to determine whether the rule should be applied which could be quite slow.

1 / (2 I) {
  a - Conjugate[a],
  a Conjugate[b] - Conjugate[a] b,
  a b Conjugate[c] Conjugate[d] - c d Conjugate[a] Conjugate[b],
  a b c d - Conjugate[a b c d]
  } /. {
   a_ - b_ :> 2 I Im[a] /; FullSimplify[Conjugate[a] == b]
 }
{Im[a], Im[a Conjugate[b]], Im[a b Conjugate[c] Conjugate[d]], Im[a b c d]}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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