iszero
Generic zero test
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.
iszero(object
)
iszero(object)
checks whether object
is
the zero element in the domain of object
.
Use the condition iszero(object)
instead
of object = 0
to decide whether object
is
the zero element, because iszero(object)
is more
general than object = 0
. If the call bool(object
= 0)
returns TRUE
, then iszero(object)
returns TRUE
as
well, but in general not vice versa (see Example 1).
If object
is an element of a basic type,
then iszero
returns TRUE
precisely if one
of the following is true: object
is the integer 0
(of
domain type DOM_INT
),
the floatingpoint value 0.0
(of domain type DOM_FLOAT
),
the floatingpoint interval (of domain type DOM_INTERVAL
) 0...0
,
or the zero polynomial (of domain type DOM_POLY
). In the case
of a polynomial, the result FALSE
is
guaranteed to be correct only if the coefficients of the polynomial
are in normal form (i.e., if zero has a unique representation in the
coefficient ring). See also Ax::normalRep
.
If object
is an element of a library domain, then
the method "iszero"
of the domain is called and
the result is returned. If this method does not exist, then the function iszero
returns FALSE
.
iszero
performs a purely syntactical zero
test. If iszero
returns TRUE
, then the answer
is always correct. If iszero
returns FALSE
,
however, then it may still be true that mathematically object
represents
zero (see Example 3). In such
cases, the MuPAD^{®} functions normal
or simplify
may be able to recognize this.
iszero
does not take
into account properties of
identifiers in object
that have been set via assume
. In particular,
you should not use iszero
in an argument passed
to assume
or is
; use the form object
= 0
instead (see Example 2).
Do not use iszero
in a condition passed to piecewise
. In contrast
to object = 0
, the command iszero(object)
is
evaluated immediately, before it is passed to piecewise
, while the evaluation of object
= 0
is handled by piecewise
itself.
Thus using iszero
in a piecewise
command usually leads to unwanted
effects (see Example 4).
iszero
handles the basic data types:
iszero(0), iszero(1/2), iszero(0.0), iszero(I), iszero(1...1)
iszero
works for polynomials:
p:= poly(x^2 + y, [x]): iszero(p)
iszero(poly(0, [x, y]))
iszero
is more general than =
:
bool(0 = 0), bool(0.0 = 0), bool(poly(0, [x]) = 0)
iszero(0), iszero(0.0), iszero(poly(0, [x]))
Although iszero
returns FALSE
in the following
example, the expression in question mathematically represents zero:
iszero(sin(x)^2 + cos(x)^2  1)
In this case simplify
is
able to decide this:
simplify(sin(x)^2 + cos(x)^2  1)
iszero
should not be used in a condition
passed to piecewise
:
delete x: piecewise([iszero(x), 0], [x <> 0, 1])
The first branch was discarded because iszero(x)
immediately
evaluates to FALSE
.
Instead, use the condition x = 0
, which is passed
unevaluated to piecewise
:
piecewise([x = 0, 0], [x <> 0, 1])

An arbitrary MuPAD object 
object