Documentation Center

  • Trial Software
  • Product Updates

<>, _unequal

Inequalities (unequal)

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.


x <> y
_unequal(x, y)


x <> y defines an inequality.

x <> y is equivalent to the function call _unequal(x, y).

The operator <> returns a symbolic expression representing an inequality.

The resulting expression can be evaluated to TRUE or FALSE by the function bool. It also serves as control conditions in if, repeat, and while statements. In all these cases, testing for equality or inequality is a purely syntactical test. E.g., bool(0.5 <> 1/2) returns TRUE although both numbers coincide numerically.

Further, Boolean expressions can be evaluated to TRUE, FALSE, or UNKNOWN by the function is. Tests using is are semantical comparing x and y subject to mathematical considerations.

Inequalities have two operands: the left hand side and the right hand side. One may use lhs and rhs to extract these operands.

The boolean expression not x = y is always converted to x <> y.

The expression not x <> y is always converted to x = y.


Example 1

In the following, note the difference between syntactical and numerical equality. The numbers 1.5 and coincide numerically. However, 1.5 is of domain type DOM_FLOAT, whereas is of domain type DOM_RAT. Consequently, they are not regarded as equal in the following syntactical test:

1.5 = 3/2; bool(%)

If floating-point numbers are involved, one should rather use the operator ~= instead of =. The functions bool and is test whether the floating-point approximations coincide up to the relative precision given by DIGITS:

1.5 ~= 3/2; 
bool(1.5 ~= 3/2);
is(1.5 ~= 3/2);

The following expressions coincide syntactically:

_equal(1/x, diff(ln(x),x)); bool(%)

The Boolean operator not converts equalities and inequalities:

not a = b, not a <> b

Example 2

The examples below demonstrate how = and <> deal with non-mathematical objects and data structures:

if "text" = "t"."e"."x"."t" then "yes" else "no" end

bool(table(a = PI) <> table(a = sqrt(2)))

Example 3

We demonstrate the difference between the syntactical test via bool and the semantical test via testeq:

bool(1 = x/(x + y) + y/(x + y)), testeq(1 = x/(x + y) + y/(x + y))

Example 4

Equations and inequalities are typical input objects for system functions such as solve:

solve(x^2 - 2*x = -1, x)

solve(x^2 - 2*x <> -1, x)


x, y

Arbitrary MuPAD® objects

Return Values

Expression of type "_unequal".

See Also

MuPAD Functions

Was this topic helpful?