Mathematica Asked by Chong Wang on December 28, 2020
I want to automatically transform Conjugate[a CenterDot[x, y, z]]
to Conjugate[a] Conjugate[CenterDot[x, y, z]]
. However, the following rule doesn’t work:
CenterDot /: Conjugate[coeff_ CenterDot[content___]] := Conjugate[coeff] Conjugate[CenterDot[content]]
and the error message is TagSetDelayed::tagpos: Tag CenterDot in Conjugate[CenterDot[content___] coeff_] is too deep for an assigned rule to be found.
How to achieve my original transformation?
This is a complete hack, but maybe you could try:
Clear[CenterDot]
CenterDot /: a_ b_CenterDot := Module[{stack=Stack[_]},
foo[a, b] /; MatchQ[stack, {___, HoldForm[_Conjugate], _, _}]
]
foo /: Conjugate[foo[a_, b_]] := Conjugate[a] Conjugate[b]
Example:
Conjugate[x CenterDot[a, b, c] z + 3]
3 + Conjugate[x z] Conjugate[CenterDot[a, b, c]]
Correct answer by Carl Woll on December 28, 2020
Times is not too deep.
Unprotect[Times];
Times /: Conjugate[coeff_ CenterDot[content___]] :=
Conjugate[coeff] Conjugate[CenterDot[content]]
Answered by Suba Thomas on December 28, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP