Approximate equality
This functionality does not run in MATLAB.
x ~= y
_approx(x
,y
)
x ~= y
symbolizes approximate equality.
x ~= y
is equivalent to the function call _approx(x,
y)
.
The operator ~=
returns a symbolic expression
representing an approximate equality for numerical values x
and y
.
The calls bool(x ~= y)
and is(x ~= y)
check
whether float((x  y)/x) < 10^(DIGITS)
is
satisfied, provided x ≠ 0
and y
≠ 0
. Thus, TRUE
is returned if x
and y
coincide
within the relative numerical precision specified by DIGITS
.
For x = 0
, the criterion is float(y)
< 10^(DIGITS)
. For y = 0
, the criterion
is float(x) < 10^(DIGITS)
. If either x
or y
contains
a symbolic object that cannot be converted to a real or complex floatingpoint
number, the functions bool
and is
return the value UNKNOWN
.
Approximate equalities have two operands: the left side and
the right side. Use lhs
and rhs
to extract these
operands.
Note:

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);

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