Subtract expressions
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
_subtract(x
, y
)
_subtract(x, y)
subtracts y
from x
.
The difference operator 
does not call _subtract(x,
y)
. The difference x  y
is equivalent
to x + (y) = _plus (x, _negate(y))
.
To implement the slot d::_subtract
for your
domain d
, use the following convention:
If both x
and y
are
elements of d
, the slot must return an appropriate
difference of type d
.
If x
or y
is
not an element of d
and cannot be converted to
an element of d
, the slot must return FAIL
.
If x
or y
is
not an element of d
, but can be converted to type d
,
use the following approach. This object must be converted to an element
of d
only if the mathematical semantics is obvious
to all users of d
, including the users who treat
this domain as a "black box". For example, you can regard
integers as rational numbers because of the natural mathematical embedding,
but you must make sure that all users are aware of this approach.
Otherwise, the "_subtract"
method must return FAIL
instead
of using implicit conversions. If you use implicit conversions for
the elements of your domain, document these conversions.
In the MuPAD^{®} standard installation, most of the library domains comply with this convention.
_subtract
can subtract polynomials of the DOM_POLY
type
from a polynomial of the same type. The polynomials must have the
same indeterminates and the same coefficient ring.
_subtract
can subtract finite sets from a
finite set. For finite sets X
and Y
,
the difference is the set
.
Compute the difference of the following arithmetical expressions
by using the _subtract
method. Then, compute the
difference of the same expressions by using the difference operator:
_subtract(x, y), x  y
Although both _subtract
and the difference
operator return the same result for these expressions, the _subtract
call
is not equivalent to x  y
:
type(hold(x  y)), type(hold(_subtract(x, y)))
Use the _subtract
function when combining
the following lists:
zip([a, b, c, d], [1, 2, 3, 4], _subtract)

arithmetical
expressions, polynomials of
type 
arithmetical expression, a polynomial, or a set.
x
, y