I want to apply Conjugate[] to a certain quite long rational function of some parameters. My problem is that although it evaluates perfectly fine on each single part of the expression, Mathematica does not like to handle the whole thing. Rather than describe the problem in more words, let me demonstrate by example:

Refine[Conjugate[(9 + 6 (-1 + n))/(20 + 6 (-1 + n)) + (I n)/(
   2 (-1 + n)^2)], Element[n, Integers]]

evaluates to

Conjugate[(9 + 6 (-1 + n))/(20 + 6 (-1 + n)) + (I n)/(2 (-1 + n)^2)]

which is not very helpful, whereas if I only give Mathematica one part of the expression, say the second summand only,

Refine[Conjugate[(I n)/(
   2 (-1 + n)^2)], Element[n, Integers]]

it correctly evaluates to

-((I n)/(2 (-1 + n)^2))

Unfortunately, the expression is much more complicated so splitting it up and doing it by hand would be a lot of work. What is going on here?

  • 1
    $\begingroup$ Hi Max, ComplexExpand (in place of Refine) should be enough here, since the integer property is not as important as that n is purely real, which ComplexExpand assumes by default. E.g. ComplexExpand[ Conjugate[(9 + 6 (-1 + n))/(20 + 6 (-1 + n)) + (I n)/(2 (-1 + n)^2)]] evaluates to (9 + 6*(-1 + n))/(20 + 6*(-1 + n)) - ((I/2)*n)/(-1 + n)^2. $\endgroup$ – Thies Heidecke Sep 9 at 17:02
  • $\begingroup$ Hi Thies, alright thank you! Since I have some more variables in my actual expression, using this together with Refine and specifying that those variables are also Real should do the trick. $\endgroup$ – Max Sep 9 at 17:09
  • $\begingroup$ Nonetheless, I would be interested in understanding why Mathematica does that? Is there a way to tell it to keep going, in a sense? $\endgroup$ – Max Sep 9 at 17:11
  • $\begingroup$ No one but you can know if your much more complicated problem will work, but for the example you show Apart[(9+6(-1+n))/(20+6(-1+n))+(I n)/(2(-1+n)^2)] is 1+(I/2)/(-1+n)^2+(I/2)/(-1+n)-11/(2*(7+3*n)) and Refine[Conjugate[Apart[(9+6(-1+n))/(20+6(-1+n))+(I n)/(2(-1+n)^2)]],Element[n,Integers]] returns 1-(I/2)/(-1+n)^2-(I/2)/(-1+n)-11/(2*(7+3*n)) which does appear to be the conjugate because the signs of the complex have flipped. I am guessing that the answer to your question "why didn't conjugate work" might be if it is complicated enough it can't find the conjugate. Apart simpler. $\endgroup$ – Bill Sep 9 at 20:07
  • $\begingroup$ Hi Bill, thank you for the suggestion! I assume this could make it work - however ComplexExpand followed by a Simplify at the end of the computation also does the job nicely. I was more wondering why Mathematica does this... $\endgroup$ – Max Sep 10 at 6:51

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.