=,
<>
-- equations and inequalitiesx = y
defines an equation.
x <> y
defines an inequality.
x = y _equal(x, y)
x <> y _unequal(x, y)
x, y |
- | arbitrary MuPAD objects |
an expression of type "_equal"
or
"_unequal"
, respectively.
<
, <=
, >
, >=
, and
, bool
, FALSE
, if
, lhs
, not
, or
, repeat
, rhs
, solve
, TRUE
, while
, UNKNOWN
x = y
is equivalent to the function call
_equal(x, y)
.x <> y
is equivalent to the function call
_unequal(x, y)
.=
and <>
return
symbolic expressions representing equations and inequalities,
respectively.
The resulting expressions can be evaluated to TRUE
or FALSE
by the function bool
. They also serve 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 FALSE
although both numbers coincide
numerically. Correspondingly, bool(0.5 <> 1/2)
returns TRUE
.
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.
lhs
and rhs
to extract these operands.not x = y
is always converted to x <>
y
.not x <> y
is always converted to x =
y
._equal
is a function of the system kernel._unequal
is a function of the system kernel.In the following, note the difference between
syntactical and numerical equality. The numbers 1.5 and 3/2
coincide numerically. However, 1.5 is of domain type
DOM_FLOAT
, whereas
3/2 is of domain type DOM_RAT
. Consequently, they are not
regarded as equal in the following syntactical test:
>> 1.5 = 3/2; bool(%)
1.5 = 3/2 FALSE
The following expressions coincide syntactically:
>> _equal(1/x, diff(ln(x),x)); bool(%)
1 1 - = - x x TRUE
The Boolean operator not
converts equalities and
inequalities:
>> not a = b, not a <> b
a <> b, a = b
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
"yes"
>> bool(table(a = PI) <> table(a = E))
TRUE
We demonstrate the difference between the syntactical
test via bool
and the
semantical test via is
:
>> bool(1 = x/(x + y) + y/(x + y)), is(1 = x/(x + y) + y/(x + y))
FALSE, TRUE
Equations and inequalities are typical input objects for
system functions such as solve
:
>> solve(x^2 - 2*x = -1, x)
{1}
>> solve(x^2 - 2*x <> -1, x)
C_ minus {1}