# Define symmetric function for a subset of variables

I apologize if this question has been asked already. I did some research and found some solutions but none of them was general enough for what I need.

So, I defined the following function:

g[i_][a_, b_, c_] := Subsuperscript[g, {a, b, c}, {i}]


and now I would like to specify that if the variable i is equal to 8 then the function is Orderless (symmetric) with respect to the variables a and b.

Is there any way of doing that?

Thanks a lot!

• Something like g[8][b_, a_, c_] /; ! OrderedQ[{b, a}] := Subsuperscript[g, {a, b, c}, {8}]? Apr 25, 2020 at 14:34

ClearAll[g]

g[8][OrderlessPatternSequence[a_, b_], c_] :=  Subsuperscript[g, {a, b, c}, {8}]

g[i_][a_, b_, c_] := Subsuperscript[g, {a, b, c}, {i}]


Examples:

{g[2][y, x, z], g[8][y, x, z], g[8][5, 1, u], g[8][3, 2, 1]}


• This works, thank you very much!
– Einj
Apr 26, 2020 at 10:30