## `Type::NonNegative` -- a type and a property representing nonnegative numbers

#### Introduction

`Type::NonNegative` represents nonnegative numbers. `Type::NonNegative` is a property, too, which can be used in an `assume` call.

#### Call(s)

`testtype(obj,` Type::NonNegative)
`assume(x,` Type::NonNegative)
`is(ex,` Type::NonNegative)

#### Parameters

`obj` | - | any MuPAD object
`x` | - | an identifier or one of the expressions `Re(u)` or `Im(u)` with an identifier `u`
`ex` | - | an arithmetical expression

#### Returns

see `testtype`, `assume` and `is`

#### Related Functions

`testtype`, `is`, `assume`, `Type::Real`, `Type::Property`

#### Details

- The call `testtype(obj,` Type::NonNegative) checks, whether `obj` is a nonnegative real number and returns `TRUE`, if it holds, otherwise `FALSE`.
- `testtype` only performs a syntactical test identifying MuPAD objects of type `DOM_INT`, `DOM_RAT` and `DOM_FLOAT` and checks, if `bool(obj >= 0)` holds. This does not include arithmetical expressions such as `exp(1)`, which are not identified as of type `Type::NonNegative`.
- The call `assume(x,` Type::NonNegative) marks the identifier `x` as a nonnegative real number.

  The call `is(ex,` Type::NonNegative) derives, whether the expression `ex` is a nonnegative real number (or this property can be derived).

- This type represents a property that can be used in `assume` and `is`.
- Instead of `Type::NonNegative` the assumption can also be `assume(x >= 0)`.

#### Example 1

The following numbers are of type `Type::NonNegative`:

    >> testtype(2, Type::NonNegative),
       testtype(3/4, Type::NonNegative),
       testtype(0.123, Type::NonNegative),
       testtype(0, Type::NonNegative),
       testtype(1.02, Type::NonNegative)

                           TRUE, TRUE, TRUE, TRUE, TRUE

The following expressions are exact representations of nonnegative numbers, but syntactically they are not of `Type::NonNegative`:

    >> testtype(exp(1), Type::NonNegative),
       testtype(PI^2 + 5, Type::NonNegative),
       testtype(sin(2), Type::NonNegative)

                                FALSE, FALSE, FALSE

The function `is`, however, can find these expressions to be nonnegative:

    >> is(exp(1), Type::NonNegative),
       is(PI^2 + 5, Type::NonNegative),
       is(sin(2), Type::NonNegative)

                                 TRUE, TRUE, TRUE

#### Example 2

Assume an identifier is nonnegative:

    >> assume(x, Type::NonNegative):
       is(x, Type::NonNegative)

                                       TRUE

This is equal to:

    >> assume(x >= 0):
       is(x >= 0)

                                       TRUE

Also nonnegative numbers are real:

    >> assume(x, Type::NonNegative):
       is(x, Type::Real)

                                       TRUE

But real numbers can be nonnegative or not:

    >> assume(x, Type::Real):
       is(x, Type::NonNegative)

                                      UNKNOWN

    >> delete x:

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000