## Documentation |

Negative of an expression

This functionality does not run in MATLAB.

- x_negate(x)

`- x` computes the negative of `x`.

`-x` is equivalent to the function call `_negate(x)`.
Both calls represent the inverse of the element `x` of
an additive group.

The negative of a number of type `Type::Numeric` is also
a number.

If `x` is an element of a domain that does
not have the `_negate` method
(slot), MuPAD^{®} internally represents `-x` as `x*(-1)
= _mult(x, -1)`.

If `x` is an element of a domain that has the `_negate` method (slot), MuPAD uses this method to compute `-x`.

The difference `x - y` is equivalent to `x
+ (-y) = _plus (x, _negate(y))`.

The negative of a polynomial of type `DOM_POLY` produces a polynomial.
The coefficients of the resulting polynomial are the negatives of
the original coefficients.

For finite sets, `-X` is the set
.

Compute the negatives of the following expressions. The negative
of an expression is the inverse with respect to `+` (`_plus`):

x - x = x + _negate(x)

-1 + x - 2*x + 23

Internally, MuPAD represents `-x` as `_mult(x,
-1)`:

type(-x), op(-x, 0), op(-x, 1), op(-x, 2)

Compute the negative of a polynomial. The result is a polynomial with the coefficients that are the negatives of the coefficients of the original polynomial:

-poly(x^2 + x - 1, [x])

-poly(x, [x], Dom::Integer)

Compute the negative of a finite set. For finite sets, `-X` is
the set
:

-{a, b, c}

Various library domains such as matrix domains
or residue class domains overload `_negate`:

x := Dom::Matrix(Dom::IntegerMod(7))([2, 10]): x, -x, x + (-x)

delete x:

Was this topic helpful?