Previous Page Next Page Contents

Type::Interval -- a property representing intervals

Introduction

Type::Interval(a, b, ..) represents the interval (a, b).

Type::Interval([a], b, ..) represents the interval [a, b).

Type::Interval(a, [b], ..) represents the interval (a, b].

Type::Interval([a], [b], ..) represents the interval [a, b].

Type::Interval([a, b], ..) represents the interval [a, b].

Call(s)

Type::Interval(a, b <, domain>)
Type::Interval([a], b <, domain>)
Type::Interval(a, [b] <, domain>)
Type::Interval([a], [b] <, domain>)
Type::Interval([a, b] <, domain>)

Parameters

a, b - the borders of the interval: arithmetical objects
domain - a type object such as Type::Real, Type::Integer or Type::Rational representing a subset of the real numbers. The default domain is Type::Real.

Returns

a Type object

Related Functions

assume, is, testtype, Type::Integer, Type::Rational, Type::Real

Details

Example 1

The following type object represents the open interval (-1, 1):

>> Type::Interval(-1, 1)
                           ]-1, 1[ of Type::Real

The following calls are equivalent: both create the type representing a closed interval:

>> Type::Interval([-1], [1]), Type::Interval([-1, 1])
               [-1, 1] of Type::Real, [-1, 1] of Type::Real

The following call creates the type representing the set of all integers from -10 to 10:

>> Type::Interval([-10, 10], Type::Integer)
                        [-10, 10] of Type::Integer

The following call creates the type representing the set of all rational numbers in the interval [0,1):

>> Type::Interval([0], 1, Type::Rational)
                         [0, 1[ of Type::Rational

Example 2

We use intervals as a property. The following call marks x as a real number from the interval [0, 2):

>> assume(x, Type::Interval([0], 2)):

Consequently, x^2 + 1 lies in the interval [1, 5):

>> is(x^2 + 1 >= 1), is(x^2 + 1 < 5)
                                TRUE, TRUE

The following call marks x as an integer larger than -10 and smaller than 100:

>> assume(x, Type::Interval(-10, 100, Type::Integer)):

Consequently, x^3 is an integer larger than -730 and smaller than 970300:

>> is(x^3, Type::Integer), is(x^3 >= -729), is(x^3 < 970300),
   is(x^3, Type::Interval(-10^3, 100^3, Type::Integer))
                          TRUE, TRUE, TRUE, TRUE
>> is(x <= -730), is(x^3 >= 970300)
                               FALSE, FALSE
>> is(x > 0), is(x^3, Type::Interval(0, 10, Type::Integer))
                             UNKNOWN, UNKNOWN
>> unassume(x):

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000