0
$\begingroup$

Consider some symbols piplus, piminus, eta. Let us assume that they appear as conjugated, e.g., Conjugate[piplus]. Could you please tell me whether it is possible to define a rule which would automatically replace Conjugate[piplus] with piminus, and Conjugate[piminus] with piplus, and Conjugate[eta] with eta?

Say, I may use

rule := {Conjugate[piplus] :> piminus, Conjugate[piminus] -> piplus}
Conjugate[piplus] + Conjugate[piminus] /. Evaluate[rule]

But I do not want to always add /. Evaluate[rule] in the given notebook.

$\endgroup$
1
  • 2
    $\begingroup$ Use multiple TagSetDelayed definitions, such as: piminus /: Conjugate[piminus] := piplus $\endgroup$
    – MarcoB
    Jul 27, 2023 at 13:11

1 Answer 1

3
$\begingroup$

Apply the rules once and globally using multiple TagSetDelayed definitions:

piminus /: Conjugate[piminus] := piplus
piplus /: Conjugate[piplus] := piminus
eta /: Conjugate[eta] := eta

Conjugate[piplus] + 2 Conjugate[piminus] + Conjugate[eta]

(* Out: eta + piminus + 2 piplus *)
$\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.