The easiest way is to define a Function subclass that sorts the arguments.

class F(Function):
    @classmethod
    def eval(cls, x, y):
        if default_sort_key(x) > default_sort_key(y):
            return cls(y, x)

For more than two variables, I would use the algorithm described by Francesco.

Aaron Meurer

On Tue, Nov 14, 2017 at 10:13 AM, Francesco Bonazzi
<[email protected]> wrote:
> Not in the functions, but there is a symmetry canonicalization algorithm in
> the tensor module:
>
> http://docs.sympy.org/latest/modules/tensor/tensor.html
>
> Unfortunately it's unrelated.
>
> On Tuesday, 14 November 2017 05:35:07 UTC-5, danabe wrote:
>>
>> Hi all,
>> Is it possible to define a general symmetric function of two variables,
>> let's say F(x,y) such that F(x,y)-F(y,x) would evaluate to zero?
>> Thanks
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/c472fbde-1640-4bc8-a0b6-563d37c2077f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6JnZK5gs1kggGxQQoz-MAVrvmPgGvTKTnbvLnTn%2Bvgzcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to