=
, _equal
Equations (equal)
MuPAD® notebooks will be removed in a future release. 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.
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. For example, 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
semantic comparing x
and y
applying
mathematical considerations.
Equations have two operands: the left side and the right side.
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 example, 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(%)
For equations with floatingpoint numbers, 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
In this example, use the operator =
to compare
nonmathematical objects:
if "text" = "t"."e"."x"."t" then "yes" else "no" end
Test equality of these expressions by using the syntactical
test via bool
and
the semantic test via testeq
:
bool(1 = x/(x + y) + y/(x + y)), testeq(1 = x/(x + y) + y/(x + y))
Equations are typical input objects for system functions, such
as solve
:
solve(x^2  2*x = 1, x)

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