0
$\begingroup$

I want Mathematica to simplify my expression using MySymmetricFunction[x,y] = MySymmetricFunction[y,x], so that

expr = MySymmetricFunction[x,y]-MySymmetricFunction[y,x];
Simplify[expr]

yields 0.

I tried

MySymmetricFunction[x_, y_] = MySymmetricFunction[y,x] 

but here Mathematica assumes recursion.

Please note, that I don't want to implement an explicit version of MySymmetricFunction[x,y] as of yet.

edit:
As a follow up question:
Why does this give zero

SetAttributes[MySymmetricFunction, Orderless]
MySymmetricFunction[x,y]-MySymmetricFunction[y,x]

But this does not:

<<FeynCalc`
SetAttributes[MySymmetricFunction, Orderless]
Simplify[MySymmetricFunction[pResonance, pRho]*FV[NucleonOut, m] - MySymmetricFunction[pRho, pResonance]*FV[pNucleonOut, m]]

edit2 Thanks to @QuantomDot for pointing out my silly spelling mistake.

$\endgroup$
8
  • 3
    $\begingroup$ Could you give MySymmetricFunction the Orderless attribute? $\endgroup$
    – Carl Woll
    Mar 23, 2018 at 0:17
  • 2
    $\begingroup$ Set[MySymmetricFunction, Orderless] is a complete solution. $\endgroup$
    – evanb
    Mar 23, 2018 at 0:18
  • 3
    $\begingroup$ @evanb you mean SetAttributes. $\endgroup$
    – b3m2a1
    Mar 23, 2018 at 0:20
  • 1
    $\begingroup$ Orderless has interesting effects on pattern matching. $\endgroup$
    – rcollyer
    Mar 23, 2018 at 0:21
  • 3
    $\begingroup$ NucleonOut is not the same as pNucleonOut. $\endgroup$
    – QuantumDot
    Mar 23, 2018 at 0:33

1 Answer 1

5
$\begingroup$
SetAttributes[msf, Orderless]
msf[x, y] - msf[y, x]
(* 0 *)
$\endgroup$
1
  • $\begingroup$ Yes, this works, but please see my follow up question $\endgroup$ Mar 23, 2018 at 0:28

Your Answer

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

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