__add__
compute sum including Expression
__mul__
compute product including Expression
__pow__
compute power including Expression
__sub__
compute difference including Expression
__floordiv__
compute floor division including Expression
__truediv__
compute true division including Expression
__mod__
compute modulus of Expression
__radd__
compute sum including Expression from the right
__rmul__
compute product including Expression from the right
__rsub__
compute difference including Expression from the right
__rpow__
compute power including Expression from the right
__rfloordiv__
compute floor division including Expression from the right
__rtruediv__
compute true division including Expression from the right
__rmod__
compute modulus of Expression from the right
|
Calling Sequence
|
|
x.__add__(y)
x + y
x.__mul__(y)
x y
x.__pow__(y)
x y
x.__sub__(y)
x - y
x.__floordiv__(y)
floordiv(x, y)
x.__truediv__(y)
truediv(x, y)
x.__mod__(y)
x mod y
x.__radd__(y)
y + x
x.__rmul__(y)
y x
x.__rpow__(y)
y x
x.__rsub__(y)
y - x
x.__rfloordiv__(y)
rfloordiv(x, y)
x.__rtruediv__(y)
rtruediv(x, y)
x.__rmod__(y)
|
|
Parameters
|
|
x
|
-
|
Expression object
|
y
|
-
|
numeric or Expression object
|
|
|
|
|
Description
|
|
•
|
__add__ returns the sum of x and y.
|
•
|
This function can also be called by simply entering x + y.
|
•
|
__mul__ returns the product of x and y.
|
•
|
This function can also be called by simply entering x * y.
|
•
|
__pow__ returns x to the power of y.
|
•
|
This function can also be called by simply entering x ** y.
|
•
|
__sub__ returns the difference of x and y.
|
•
|
This function can also be called by simply entering x - y.
|
•
|
__floordiv__ returns the remainder of x divided by y.
|
•
|
This function can also be called by simply entering x // y.
|
•
|
__truediv__ returns the remainder of x divided by y.
|
•
|
This function can also be called by simply entering x / y.
|
•
|
__mod__ returns x modulo y.
|
•
|
This function can also be called by simply entering x mod y.
|
•
|
__radd__ returns the sum of y and x.
|
•
|
This function can also be called by simply entering y + x.
|
•
|
__rmul__ returns the product of y and x.
|
•
|
This function can also be called by simply entering y * x.
|
•
|
__rpow__ returns y to the power of y
|
•
|
This function can also be called by simply entering y ** x.
|
•
|
__rsub__ returns the difference of y and x.
|
•
|
This function can also be called by simply entering y - x.
|
•
|
__rfloordiv__ returns the remainder of y divided by x.
|
•
|
This function can also be called by simply entering y // x.
|
•
|
__rtruediv__ returns the remainder of x divided by y.
|
•
|
This function can also be called by simply entering y / x.
|
•
|
__rmod__ returns y modulo x.
|
•
|
This function can also be called by simply entering y mod x.
|
|
|
Examples
|
|
The following interactive session illustrates the use of these operators:
>>> import maple
|
>>> import maple.namespace
|
>>> x = maple.namespace.x
|
>>> # It is most natural to use these as infix operators
|
>>> x + 2
|
x+2
|
>>> x 2
|
2x
|
>>> 2 x
|
2x
|
>>> x - 2
|
x-2
|
>>> 2 - x
|
2-x
|
>>> x 2
|
x^2
|
>>> 2 x
|
x^2
|
>>> # They may, however, also be used with the expr.methodName syntax
|
>>> x.__add__(2)
|
x+2
|
>>> x.__mul__(2)
|
2x
|
>>> x.__rmul__(2)
|
2x
|
>>> x.__sub__(2)
|
x-2
|
>>> x.__rsub__(2)
|
2-x
|
>>> x.__pow__(2)
|
x^2
|
>>> x.__rpow__(2)
|
x^2
|
|
|
|
|
|
|
|
|