I want to simplify a complex expression like y * x * Conjugate[x] where y is a real number. Now mathematica is giving output as y x conjugate[x]. how can I get the answer as y abs[x]^2. "FullSimplify" command did not work though it has worked when input is given as x * Conjugate[x]. What should I do ? enter image description here

  • 1
    $\begingroup$ Simplify and FullSimplify roughly use a count of how many symbols and operators there are, fewer is assumed to be simpler. LeafCount[y*x*Conjugate[x]] returns 5, LeafCount[y*Abs[x]^2] returns 6 so FullSimplify doesn't think it would be simplifying if it made that change. But you can do y*x*Conjugate[x]/.x_*Conjugate[x_]->Abs[x]^2 which tells Mathematica to search the left part of that for anything that looks like the pattern in the middle of that and for each of those it finds to replace that with the right part of that. Thus it returns y*Abs[x]^2 Patterns can be challenging to learn. $\endgroup$ – Bill Jul 4 '19 at 7:43
  • $\begingroup$ Thank you for your help. Actually for big expressions with several complex and its conjugate, I think, would cumbersome to get expression in my desired form. Nevertheless what you have mentioned worked very well. $\endgroup$ – DEEP GHOSH Jul 4 '19 at 8:01
  • 2
    $\begingroup$ I understand. It is very common for people to post questions and get an answer and then reply that what they really wanted to do was very different from their question or the answer. If you could edit your question to include an example that was similar to what you really wanted to do, but not so complicated that it scared people off, then someone might be able to give a much better answer than I did. $\endgroup$ – Bill Jul 4 '19 at 8:06
  • 1
    $\begingroup$ y*x*Conjugate[x] // ComplexExpand[#, {x}, TargetFunctions -> {Abs, Arg}] & // Simplify $\endgroup$ – Bob Hanlon Jul 4 '19 at 14:02

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.