Previous Page Next Page Contents

iszero -- generic zero test

Introduction

iszero(object) checks whether object is the zero element in the domain of object.

Call(s)

iszero(object)

Parameters

object - an arbitrary MuPAD object

Returns

either TRUE or FALSE

Overloadable:

object

Related Functions

_equal, Ax::normalRep, bool, is, normal, simplify, sign

Details

Example 1

iszero handles the basic data types:

>> iszero(0), iszero(1/2), iszero(0.0), iszero(I)
                         TRUE, FALSE, TRUE, FALSE

iszero works for polynomials:

>> p:= poly(x^2 + y, [x]):
   iszero(p)
                                   FALSE
>> iszero(poly(0, [x, y]))
                                   TRUE

iszero is more general than =:

>> bool(0 = 0), bool(0.0 = 0), bool(poly(0, [x]) = 0)
                            TRUE, FALSE, FALSE
>> iszero(0), iszero(0.0), iszero(poly(0, [x]))
                             TRUE, TRUE, TRUE

Example 2

iszero does not react to properties:

>> assume(a = b): is(a - b = 0)
                                   TRUE
>> iszero(a - b)
                                   FALSE

Example 3

Although iszero returns FALSE in the following example, the expression in question mathematically represents zero:

>> iszero(sin(x)^2 + cos(x)^2 - 1)
                                   FALSE

In this case simplify is able to decide this:

>> simplify(sin(x)^2 + cos(x)^2 - 1)
                                     0

Example 4

iszero should not be used in a condition passed to piecewise:

>> delete x:
   piecewise([iszero(x), 0], [x <> 0, 1])
                          piecewise(1 if x <> 0)

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])
                    piecewise(0 if x = 0, 1 if x <> 0)

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000