Ask Your Question

Revision history [back]

You can do, for example :

sage: from sage.symbolic.operators import add_vararg as plus                                                                                                                                                 
sage: (x+y).operator() == plus                                                                                                                                                                               
True

sage: from sage.symbolic.operators import mul_vararg as multiply                                                                                                                                             
sage: (x*y).operator() == multiply                                                                                                                                                                           
True

You can do, for example define the plus and multiply operators as follows :

sage: from sage.symbolic.operators import add_vararg as plus                                                                                                                                                 
sage: (x+y).operator() == plus                                                                                                                                                                               
True

plus
sage: from sage.symbolic.operators import mul_vararg as multiply                                                                                                                                             multiply

Then,

sage: (x+y).operator() == plus
True

sage: (x*y).operator() == multiply                                                                                                                                                                           
multiply
True

You can define the plus and multiply operators as follows :

sage: from sage.symbolic.operators import add_vararg as plus
sage: from sage.symbolic.operators import mul_vararg as multiply

Then,

sage: (x+y).operator() == plus
True

sage: (x*y).operator() == multiply
True

Note that the operators are not duplicated, but are the same in memory:

sage: (x+y).operator()
<function add_vararg at 0x7fcf50e86e18>
sage: plus
<function add_vararg at 0x7fcf50e86e18>
sage: (x+y).operator() is plus
True

You can define the plus and multiply operators as follows :

sage: from sage.symbolic.operators import add_vararg as plus
sage: from sage.symbolic.operators import mul_vararg as multiply

Then,

sage: (x+y).operator() == plus
True

sage: (x*y).operator() == multiply
True

Note that the operators are not duplicated, but are the same in memory:

sage: (x+y).operator()
<function add_vararg at 0x7fcf50e86e18>
sage: plus
<function add_vararg at 0x7fcf50e86e18>
 sage: (x+y).operator() is plus
True