Equations (equal)
This functionality does not run in MATLAB.
x = y
_equal(x
,y
)
x = y
defines an equation.
x = y
is equivalent to the function call _equal(x,
y)
.
The operator =
returns a symbolic expression
representing an equation.
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 is a purely syntactical test. E.g., bool(0.5
= 1/2)
returns FALSE
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.
Equations 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
.
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 floatingpoint numbers are involved, one should rather use
the operator ~=
instead of =
.
The functions bool
and is
test whether the
floatingpoint 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
The examples below demonstrate how =
and <>
deal
with nonmathematical objects and data structures:
if "text" = "t"."e"."x"."t" then "yes" else "no" end
bool(table(a = PI) <> table(a = sqrt(2)))
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))
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)

Arbitrary MuPAD^{®} objects 
Expression of type "_equal"
.