IntervalType.mws

Interval type and basic interval operations

written by  Grimmer, Markus, Department of Mathematics, University of Wuppertal, Germany, http://www.math.uni-wuppertal.de/wrswt
<© 1999-2002 Scientific Computing/Software Engineering Research Group, University of Wuppertal, Germany>

NOTE: This worksheet demonstrates the use of the Maple package intpakX v1.0  for interval arithmetic.

This document is not the package.  It only shows how to work with the functions and types provided by intpakX v1.0 .  You must create the package in an empty directory before loading the package ( i.e., /usr/maple/intpakX/lib)  Once created, load the package as follows:

>    restart;
libname:="C:/mylib/interval", libname;
with(intpakX);

libname :=

Warning, the name changecoords has been redefined

Warning, the assigned name midpoint now has a global binding

Warning, the protected names ilog10, max and min have been redefined and unprotected

[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...
[`&*`, `&**`, `&+`, `&-`, `&/`, `&Convex_Hull`, `&arccos`, `&arcsin`, `&arctan`, `&cabs`, `&cadd`, `&cdiv`, `&cdiv_opt`, `&cmult`, `&cmult_opt`, `&cos`, `&cosh`, `&csub`, `&exp`, `&intersect`, `&intpow...

Interval type and basic interval operations

`type/interval`: An interval is defined to be a list with either zero elements,+/- infinity,FAIL

or a list with two floating point members.
You can define an interval in the following ways:

>    X:=[1.0,2.5];
type(X,interval);

X := [1.0, 2.5]

true

>    Y:=[0,infinity];
type(Y,interval);

Y := [0, infinity]

true

>    Z:=construct(1,2);
type(Z,interval);

Z := [1., 2.]

true

Procedures convert/inapply:

   Utility procedures to convert Maple expressions to interval arithmetic.  
   convert(1+x + x^2,'interval') returns (1 &+ x) &+ (x &^ 2),

   whereas inapply(1+x+x^2,x) yields the operator x -> (1 &+ x) etc.

>    convert(1+x + x^2,'interval');
inapply(1+x+x^2,x);

Interval_add(1,Interval_add(x,Interval_Integerpower(x,2)))

proc (x) options operator, arrow; Interval_add(1,Interval_add(x,Interval_Integerpower(x,2))) end proc

Procedures is_in, midpoint, width, &intersect, &union

>    A:=[1.,4.];
B:=[2.,3.];
is_in(B,A);

A := [1., 4.]

B := [2., 3.]

true

>    midpoint(A);
width(A);
A &union [5.,6.];
A &intersect [3.,5.];

[2.499999999, 2.500000001]

3.

[1., 4.], [5., 6.]

[3., 4.]

Arithmetic operations &+,&-,&*,&/
In addition to &/, there is the operator ext_int_div which can also handle "division by zero".

>    A &+ B;
A &- B;
A &* B;
A &/ B;

[2.999999999, 7.000000001]

[-2.000000001, 2.000000001]

[1.999999999, 12.00000001]

[.3333333331, 2.000000001]

>    C:=[-1.,1.];
A &/ C;
ext_int_div(A,C);

C := [-1., 1.]

[-infinity, infinity]

[-infinity, -.999999999], [.999999999, infinity]

Trigonometric operations:
&sin, &cos, &tan, &arcsin, &arccos, &arctan, &sinh, &cosh, &tanh

>    &sin(A);  # etc.

[-.7568024961, 1.]

Exponential Function and Logarithm:
&exp, &ln

>    &exp(A);  # etc.

[2.718281827, 54.59815004]

Square, square root and power functions:
&sqr, &sqrt, &intpower, &**
&intpower raises an interval to an integer power, while &** raises an interval to the power of another interval.
Note the difference between C*C and &sqr(C)!

>    E:=[1.9,2.1];
A &intpower 2;
A &** E;

E := [1.9, 2.1]

[.999999999, 16.00000001]

[.999999999, 18.37917369]

>    C&*C;
&sqr(C);

[-1.000000001, 1.000000001]

[0, 1.000000001]

>   

>   

Disclaimer:  While every effort has been made to validate the solutions in this worksheet, Waterloo Maple Inc. and the contributors are not responsible for any errors contained and are not liable for any damages resulting from the use of this material.