 UnaryPredicates - Maple Help

RealBox

 UnaryPredicates
 unary predicates for RealBox objects
 IsZero
 check whether a RealBox is zero
 IsNonzero
 check whether a RealBox is nonzero
 IsOne
 check whether a RealBox is one
 IsFinite
 check whether a RealBox is finite
 IsExact
 check whether a RealBox is exact
 IsInteger
 check whether a RealBox is an integer
 IsPositive
 check whether a RealBox is positive
 IsNegative
 check whether a RealBox is negative
 IsNonPositive
 check whether a RealBox is non-positive
 IsNonNegative
 check whether a RealBox is non-negative
 HasInteger
 check whether a RealBox contains an integer value
 HasZero
 check whether a RealBox contains the value zero
 HasPositive
 check whether a RealBox contains a positive value
 HasNegative
 check whether a RealBox contains a negative value
 HasNonNegative
 check whether a RealBox contains a non-negative value
 HasNonPositive
 check whether a RealBox contains a non-positive value
 IsInfinity
 check whether a RealBox is positive infinity
 IsNegInfinity
 check whether a RealBox is negative infinity
 IsUndefined
 check whether a RealBox is undefined Calling Sequence IsZero( b ) IsNonzero( b ) IsOne( b ) IsFinite( b ) IsExact( b ) IsInteger( b ) IsPositive( b ) IsNegative( b ) IsNonPositive( b ) IsNonNegative( b ) IsUndefined( b ) IsInfinity( b ) IsNegInfinity( b ) HasInteger( b ) HasZero( b ) HasPositive( b ) HasNegative( b ) HasNonNegative( b ) HasNonPositive( b ) Parameters

 b - RealBox object precopt - (optional) equation of the form precision = n, where n is a positive integer Description

 • Each RealBox object defines a number of predicates that can be used to query various properties of the box.
 • Predicates may be further sub-divided into unary predicates (of a single RealBox object) or binary (for comparing two RealBox objects).
 • The following table describes briefly the unary predicate methods defined for RealBox objects.

 Predicate Description IsZero returns true if the RealBox represents an exact zero (center and radius are both $0$) IsNonzero returns true if the RealBox does not contain $0$ IsOne returns true if the RealBox represents $1$ exactly IsFinite returns true if the RealBox has finite center and radius IsExact returns true if the RealBox has zero radius IsInteger returns true if the RealBox has zero radius and integer center IsPositive returns true if every member of the RealBox is positive (false if it contains undefined) IsNegative returns true if every member of the RealBox is negative (false if it contains undefined) IsNonNegative returns true if every member of the RealBox is non-negative (false if it contains undefined) IsNonPositive returns true if every member of the RealBox is non-positive (false if it contains undefined) IsInfinity returns true if the RealBox is positive infinity IsNegInfinity returns true if the RealBox is negative infinity IsUndefined returns true if the RealBox is an undefined (NaN) HasInteger returns true if the RealBox contains an integer value HasZero returns true if the RealBox contains $0$ HasPositive returns true if the RealBox contains a positive value HasNegative returns true if the RealBox contains a negative value HasNonNegative returns true if the RealBox contains a non-negative value HasNonPositive returns true if the RealBox contains a non-positive value

 • Use the 'precision' = n option to control the precision used in these methods. For more details on precision, see BoxPrecision. Examples

The following results are not surprising.

 > $\mathrm{IsZero}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{IsZero}\left(\mathrm{RealBox}\left(0.0\right)\right)$
 ${\mathrm{true}}$ (2)

This returns false because the box is not an exact zero.

 > $\mathrm{IsZero}\left(\mathrm{RealBox}\left(0.0,1.{10}^{-30}\right)\right)$
 ${\mathrm{false}}$ (3)

Clearly, $0$ is contained in the following box.

 > $\mathrm{IsNonzero}\left(\mathrm{RealBox}\left(0.0,1.{10}^{-30}\right)\right)$
 ${\mathrm{false}}$ (4)

That zero belongs to the next box is due to the box being closed.

 > $\mathrm{IsNonzero}\left(\mathrm{RealBox}\left(1.{10}^{-30},1.{10}^{-30}\right)\right)$
 ${\mathrm{false}}$ (5)
 > $\mathrm{IsNonzero}\left(\mathrm{RealBox}\left(1.{10}^{-30},1.{10}^{-31}\right)\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{IsOne}\left(\mathrm{RealBox}\left(1\right)\right)$
 ${\mathrm{true}}$ (7)
 > $\mathrm{IsOne}\left(\mathrm{RealBox}\left(1.0\right)\right)$
 ${\mathrm{true}}$ (8)

This returns false because the box is not an exact box.

 > $\mathrm{IsOne}\left(\mathrm{RealBox}\left(1.0,1.{10}^{-30}\right)\right)$
 ${\mathrm{false}}$ (9)
 > $\mathrm{IsFinite}\left(\mathrm{RealBox}\left(2.3\right)\right)$
 ${\mathrm{true}}$ (10)

A box is not finite despite having a finite center if its radius is infinite.

 > $\mathrm{IsFinite}\left(\mathrm{RealBox}\left(2.3,\mathrm{∞}\right)\right)$
 ${\mathrm{false}}$ (11)

Negative infinities are also not "finite".

 > $\mathrm{IsFinite}\left(\mathrm{RealBox}\left(-\mathrm{∞}\right)\right)$
 ${\mathrm{false}}$ (12)
 > $\mathrm{IsFinite}\left(\mathrm{RealBox}\left(\mathrm{Float}\left(-\mathrm{∞}\right)\right)\right)$
 ${\mathrm{false}}$ (13)

Undefined values for the center also cause the IsFinite method to return false.

 > $\mathrm{IsFinite}\left(\mathrm{RealBox}\left(\mathrm{undefined}\right)\right)$
 ${\mathrm{false}}$ (14)

The IsExact method checks that a RealBox object represents its center exactly in the sense that that radius is equal to $0$.

 > $\mathrm{IsExact}\left(\mathrm{RealBox}\left(0.5\right)\right)$
 ${\mathrm{true}}$ (15)
 > $\mathrm{IsExact}\left(\mathrm{RealBox}\left(0.5,1.{10}^{-50}\right)\right)$
 ${\mathrm{false}}$ (16)
 > $\mathrm{IsExact}\left(\mathrm{RealBox}\left(\mathrm{∞}\right)\right)$
 ${\mathrm{true}}$ (17)
 > $\mathrm{IsExact}\left(\mathrm{RealBox}\left(-\mathrm{∞}\right)\right)$
 ${\mathrm{true}}$ (18)
 > $\mathrm{IsExact}\left(\mathrm{RealBox}\left(\mathrm{undefined}\right)\right)$
 ${\mathrm{false}}$ (19)

Whether a RealBox object is exact may depend not only on the passed radius (which is $0$ by default), but also on the representability of the center as an exact float. In these examples, the rational number $\frac{3}{2}$ can be represented exactly as a float, while $\frac{2}{3}$ cannot.

 > $\mathrm{IsExact}\left(\mathrm{RealBox}\left(\frac{3}{2}\right)\right)$
 ${\mathrm{true}}$ (20)
 > $\mathrm{IsExact}\left(\mathrm{RealBox}\left(\frac{2}{3}\right)\right)$
 ${\mathrm{false}}$ (21)

Notice that IsInteger returns true only if the RealBox is exact in the sense that the radius is equal to $0$.

 > $\mathrm{IsInteger}\left(\mathrm{RealBox}\left(44\right)\right)$
 ${\mathrm{true}}$ (22)
 > $\mathrm{IsInteger}\left(\mathrm{RealBox}\left(44,1.{10}^{-40}\right)\right)$
 ${\mathrm{false}}$ (23)

Of course, it returns false for (exact) non-integral values.

 > $\mathrm{IsInteger}\left(\mathrm{RealBox}\left(\frac{3}{2}\right)\right)$
 ${\mathrm{false}}$ (24)
 > $\mathrm{IsInteger}\left(\mathrm{RealBox}\left(\mathrm{∞}\right)\right)$
 ${\mathrm{false}}$ (25)
 > $\mathrm{IsInteger}\left(\mathrm{RealBox}\left(-\mathrm{∞}\right)\right)$
 ${\mathrm{false}}$ (26)
 > $\mathrm{IsInteger}\left(\mathrm{RealBox}\left(\mathrm{undefined}\right)\right)$
 ${\mathrm{false}}$ (27)

The following returns true because the default user-specified radius of zero results in an ultimate radius that is very small relative to the size of the center.

 > $\mathrm{IsPositive}\left(\mathrm{RealBox}\left(0.0001\right)\right)$
 ${\mathrm{true}}$ (28)
 > $\mathrm{Radius}\left(\mathrm{RealBox}\left(0.0001\right)\right)$
 ${7.10542735760100}{×}{{10}}^{{-15}}$ (29)

Here, the radius is larger than the center, so the box represents a set containing non-positive values.

 > $\mathrm{IsPositive}\left(\mathrm{RealBox}\left(0.0001,0.001\right)\right)$
 ${\mathrm{false}}$ (30)

Similar results are obtained for testing whether a box is "negative".

 > $\mathrm{IsNegative}\left(\mathrm{RealBox}\left(0.001\right)\right)$
 ${\mathrm{false}}$ (31)
 > $\mathrm{IsNegative}\left(\mathrm{RealBox}\left(-0.001\right)\right)$
 ${\mathrm{true}}$ (32)
 > $\mathrm{IsNegative}\left(\mathrm{RealBox}\left(-0.001,0.02\right)\right)$
 ${\mathrm{false}}$ (33)
 > $\mathrm{IsNonNegative}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{true}}$ (34)
 > $\mathrm{IsNonNegative}\left(\mathrm{RealBox}\left(0,1.{10}^{-34}\right)\right)$
 ${\mathrm{false}}$ (35)
 > $\mathrm{IsNonNegative}\left(\mathrm{RealBox}\left(1.{10}^{-34},1.{10}^{-35}\right)\right)$
 ${\mathrm{true}}$ (36)
 > $\mathrm{IsNonNegative}\left(\mathrm{RealBox}\left(1.{10}^{-34},1.{10}^{-34}\right)\right)$
 ${\mathrm{false}}$ (37)
 > $\mathrm{IsNonPositive}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{true}}$ (38)

Note the result for a negative zero:

 > $\mathrm{IsNonPositive}\left(\mathrm{RealBox}\left(-0.0\right)\right)$
 ${\mathrm{true}}$ (39)
 > $\mathrm{IsNonPositive}\left(\mathrm{RealBox}\left(0,1.{10}^{-20}\right)\right)$
 ${\mathrm{false}}$ (40)
 > $\mathrm{IsNonPositive}\left(\mathrm{RealBox}\left(-1.{10}^{-20},1.{10}^{-20}\right)\right)$
 ${\mathrm{false}}$ (41)
 > $\mathrm{IsNonPositive}\left(\mathrm{RealBox}\left(-1.{10}^{-20},1.{10}^{-21}\right)\right)$
 ${\mathrm{true}}$ (42)
 > $\mathrm{HasInteger}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{true}}$ (43)
 > $\mathrm{HasInteger}\left(\mathrm{RealBox}\left(0,1.{10}^{-30}\right)\right)$
 ${\mathrm{true}}$ (44)
 > $\mathrm{HasInteger}\left(\mathrm{RealBox}\left(-273.15,0.00001\right)\right)$
 ${\mathrm{false}}$ (45)
 > $\mathrm{HasInteger}\left(\mathrm{RealBox}\left(-273.15,0.2\right)\right)$
 ${\mathrm{true}}$ (46)
 > $\mathrm{HasInteger}\left(\mathrm{RealBox}\left(808017424794512875886459904961710757005754368000000000,1.{10}^{-40}\right)\right)$
 ${\mathrm{true}}$ (47)
 > $\mathrm{HasInteger}\left(\mathrm{RealBox}\left(\left({10}^{6}\right)!,1.{10}^{-1000}\right)\right)$
 ${\mathrm{true}}$ (48)
 > $\mathrm{HasZero}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{true}}$ (49)
 > $\mathrm{HasZero}\left(\mathrm{RealBox}\left(-0.0\right)\right)$
 ${\mathrm{true}}$ (50)
 > $\mathrm{HasZero}\left(\mathrm{RealBox}\left(1.{10}^{-30},1.{10}^{-31}\right)\right)$
 ${\mathrm{false}}$ (51)
 > $\mathrm{HasZero}\left(\mathrm{RealBox}\left(1.{10}^{-30},1.{10}^{-30}\right)\right)$
 ${\mathrm{true}}$ (52)
 > $\mathrm{HasPositive}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{false}}$ (53)
 > $\mathrm{HasPositive}\left(\mathrm{RealBox}\left(0,1.{10}^{-30}\right)\right)$
 ${\mathrm{true}}$ (54)
 > $\mathrm{HasPositive}\left(\mathrm{RealBox}\left(-1.{10}^{-29},1.{10}^{-30}\right)\right)$
 ${\mathrm{false}}$ (55)

Because neither the center nor radius can be represented exactly in floating point, the following returns true.

 > $\mathrm{HasPositive}\left(\mathrm{RealBox}\left(-1.{10}^{-20},1.{10}^{-20}\right)\right)$
 ${\mathrm{true}}$ (56)

Similarly, we have the following result.

 > $\mathrm{HasNegative}\left(\mathrm{RealBox}\left(1.{10}^{-20},1.{10}^{-20}\right)\right)$
 ${\mathrm{true}}$ (57)
 > $\mathrm{HasNegative}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{false}}$ (58)
 > $\mathrm{HasNegative}\left(\mathrm{RealBox}\left(0,1.{10}^{-40}\right)\right)$
 ${\mathrm{true}}$ (59)
 > $\mathrm{HasNegative}\left(\mathrm{RealBox}\left(1.{10}^{-39},1.{10}^{-40}\right)\right)$
 ${\mathrm{false}}$ (60)
 > $\mathrm{HasNonNegative}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{true}}$ (61)
 > $\mathrm{HasNonNegative}\left(\mathrm{RealBox}\left(-1.{10}^{-20},1.{10}^{-20}\right)\right)$
 ${\mathrm{true}}$ (62)
 > $\mathrm{HasNonNegative}\left(\mathrm{RealBox}\left(-1.{10}^{-20},1.{10}^{-21}\right)\right)$
 ${\mathrm{false}}$ (63)
 > $\mathrm{HasNonPositive}\left(\mathrm{RealBox}\left(0\right)\right)$
 ${\mathrm{true}}$ (64)
 > $\mathrm{IsInfinity}\left(\mathrm{RealBox}\left(\mathrm{∞}\right)\right)$
 ${\mathrm{true}}$ (65)
 > $\mathrm{IsInfinity}\left(\mathrm{RealBox}\left(0,\mathrm{∞}\right)\right)$
 ${\mathrm{false}}$ (66)
 > $\mathrm{IsInfinity}\left(\mathrm{RealBox}\left(-\mathrm{∞}\right)\right)$
 ${\mathrm{false}}$ (67)
 > $\mathrm{IsNegInfinity}\left(\mathrm{RealBox}\left(-\mathrm{∞}\right)\right)$
 ${\mathrm{true}}$ (68)
 > $\mathrm{IsUndefined}\left(\mathrm{RealBox}\left(\mathrm{Float}\left(\mathrm{undefined}\right)\right)\right)$
 ${\mathrm{true}}$ (69) Compatibility

 • The RealBox[UnaryPredicates], RealBox:-IsZero, RealBox:-IsNonzero, RealBox:-IsOne, RealBox:-IsFinite, RealBox:-IsExact, RealBox:-IsInteger, RealBox:-IsPositive, RealBox:-IsNegative, RealBox:-IsNonPositive, RealBox:-IsNonNegative, RealBox:-HasInteger, RealBox:-HasZero, RealBox:-HasPositive, RealBox:-HasNegative, RealBox:-HasNonNegative, RealBox:-HasNonPositive, RealBox:-IsInfinity, RealBox:-IsNegInfinity and RealBox:-IsUndefined commands were introduced in Maple 2022.