Application Center - Maplesoft

App Preview:

Interval Arithmetic: Interval type and basic interval operations-V1.2

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

intpakX v1 - User's Guide 

written by  Grimmer, Markus, Department of Mathematics, University of Wuppertal, Germany,  

http://www.math.uni-wuppertal.de/wrswt  

<? 1999-2005 Scientific Computing/Software Engineering Research Group,  

University of Wuppertal, Germany> 

intpakX 

by Kr?mer, Walter, Geulig, Ilse and Grimmer, Markus, Department of Mathematics,  

University of Wuppertal, Germany, http://www.math.uni-wuppertal.de/wrswt  

<? 1999-2005 Scientific Computing/Software Engineering Research Group,  

University of Wuppertal, Germany> 

intpak 

by Corless, R. and Connell, A., University of Western Ontario, Canada  

<? 1992-1993 R. Corless and A. Connell> 

 

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

Important Hints 

This document is not the package, it only shows how to work with the functions and types provided by intpakX v1. 

You should have received the intpakX v1.x  worksheet together with this document.  

 

If you received intpakX as library files (maple.ind and maple.lib, (Maplesoft distributes them in a subdirectory ./interval/mylib)), put both of them together  in an empty  directory of your choice (if this is not yet the case) and proceed with "How to load intpakX once the library has been created." (see below). 

If you received intpakX as a worksheet only  (this should be the default if downloaded from www.math.uni-wuppertal.de/wrswt/...) and did not yet create the package library, proceed with "Using intpakX the first time (or 'How to create the package library')" (see below). 

 

Using intpakX the first time (or 'How to create the package library') 

Before you start using intpakX v1 the first time, you must create the intpakX package library  in a directory of your choice.  

The following steps have to be done to create the package library: 

 

i) Load the worksheet containing the package (intpakX-v1.x.mw)  into Maple. 

ii) Go to the very end of that worksheet and follow the instructions in the section "How to create the intpakX library from this worksheet". 

 

How to load intpakX once the library has been created 

Open a new, empty worksheet and load the library as follows, replacing
"<new-library-path>" by  the directory path you chose to save the library in  (e.g., "/usr/maple/intpakX/lib").
 

> restart;
libname := "<new-library-path>", libname:
with(intpakX):
 


! ATTENTION WINDOWS(TM) USERS:
! To make Maple (Windows(TM) version) interpret the path specification
! correctly, you have to modify the path specification by replacing each
! backslach ("\") by a double backslash ("\\")!
! For example, to specify "C:\Maple\intpakX\lib" as the
! desired directory, you'll have to modify the "libname" line to:
!
! libname:="C:\\Maple\\intpakX\\lib", libname;
 

 

Below, you will find an introduction into the most important functions and types provided by intpakX v1.. For a closer look at the auxiliary functions please see the  intpakX v1.x  main worksheet. 

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);
 

[1.0, 2.5] 

true
 

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

[0, infinity] 

true
 

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

[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);
 

intpakX:-Interval_add(1, intpakX:-Interval_add(x, intpakX:-Interval_Integerpower(x, 2))) 

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

 

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

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

[1., 4.] 

[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);
 

[-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;
 

[1.9, 2.1] 

[.999999999, 16.00000001] 

[.999999999, 18.37917369]
 

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

[-1.000000001, 1.000000001] 

[0, 1.000000001]
 

 

Range Enclosure with graphical representation 

With intpakX v1, you can enclose the ranges of two- or three-dimensional functions. 

 

Functions of one real variable 

The range enclosure is computed using a combination of the following methods each of which can be found as a separate procedure.
(For details, see the intpakX v1.x worksheet.)
 

Range enclosure using interval evaluation; Range enclosure using mean value form;
Range enclosure using monotony properties; Range enclosure using Taylor forms.
 

 

The range enclosure of a function can be computed as follows: 

> X:=[0.5,2.];
 

[.5, 2.]
 

> f3:=x->exp(-x^2)*sin(Pi*x^3);
 

proc (x) options operator, arrow; exp(-x^2)*sin(Pi*x^3) end proc
 

> compute_range(f3,X,6);
 

`Start range enclosure =  `, [-.7788007834, .7788007834] 

Range_enclosure after step 6 =  [-0.2834388815,0.5563221619] 

Plot
 

As parameters, you have to give the function, the range in which to evaluate the function, and the number of iteration steps to be done.  


The numerical results are stored in the list_of_ranges variable while the graphical output is directly displayed on the screen.
 

> list_of_ranges;
 

[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
[[.2980341562, .3311000926], [.3311000913, .3644580713], [.3644580699, .3975259470], [.3975259456, .4296256944], [.4296256931, .4599815135], [.4599815121, .4877217319], [.4877217307, .5118858738], [.5...
 


Optional parameters:
"linear" or "quadratic": Influences the method used for evaluation and yields linear or quadratic convergence.
"adaptive": Uses adaptive instead of uniform subdivision when subdividing intervals.
"Nx=n" with an integer number n: Subdivides the start interval into n parts before computation starts.
 

 

Functions of two real variables 

In the three dimensional case, interval evaluation is always used for computations.
The procedure call is similar to the 2D call.
 

> T:=[evalf(Pi/8),evalf(Pi/2)];
S:=[evalf(Pi/8),evalf(Pi/2)];
 

[.3926990818, 1.570796327] 

[.3926990818, 1.570796327]
 

> g:=(x,y)->exp(-x*y)*sin(Pi*x^2*y^2);
 

proc (x, y) options operator, arrow; exp(-y*x)*sin(Pi*x^2*y^2) end proc
 

> compute_range3d(g,T,S,4);
 

`Start range enclosure = `, [-.8570898115, .8570898115] 

Range enclosure after step 1 =  [-0.8570898115,0.8570898115]
Range enclosure after step 2 =  [-0.6800891262,0.8570898115]
Range enclosure after step 3 =  [-0.6800891262,0.8486122905]
 

Range enclosure after step 4 =  [-0.5093193829,0.7559256232] 

Plot
 

In addition, you can use the options of the plot3d maple command. 

 

Extended Interval Newton Method 

intpakX v1  offers the Interval Newton Method for the computation/enclosure of all zeros of a continuously differentiable real function.
You can do the computation with or without graphical output of the intervals computed in the iteration steps.
 

> f:=x->sin(exp(sqrt(x-2)));
X:=[8.,10.];
 

proc (x) options operator, arrow; sin(exp(sqrt(x-2))) end proc 

[8., 10.]
 

> compute_all_zeros(f,X,0.001);
 

`Digits = `, 10 

`       ` 

[9.584440423, 9.590102302] 

`contains exactly one zero.` 

[8.405771234, 8.406299399] 

`contains exactly one zero.` 

`       `
`Number of enclosures of zeros: `, 2
`Number of Iterations steps: `, 5
 

> compute_all_zeros_with_plot(f,X,0.001,10,10);
 

`Digits = `, 10 

`      `
`Iteration step `, 1
`xold=`, [8., 10.]
`xnew1=`, [9.289288474, 10.]
`xnew2=`, [8., 8.710711526]
 

Plot 

`Iteration step `, 2
`xold=`, [9.289288474, 10.]
`xnew1=`, [9.462634907, 9.590834649]
 

Plot 

`Iteration step `, 3
`xold=`, [9.462634907, 9.590834649]
`xnew1=`, [9.584440423, 9.590102302]
 

Plot 

`Iteration step `, 4
`xold=`, [8., 8.710711526]
`xnew1=`, [8.401353569, 8.456507697]
 

Plot 

`Iteration step `, 5
`xold=`, [8.401353569, 8.456507697]
`xnew1=`, [8.405771234, 8.406299399]
 

Plot 

[9.584440423, 9.590102302] 

` contains exactly one zero.` 

[8.405771234, 8.406299399] 

` contains exactly one zero.` 

`         `
`Number of enclosures of zeros: `, 2
`Number of iteration steps: `, 5
 


Optionally, you can specify values for the number of Digits used and for the number of iteration steps to be done
(the latter for the graphical version only; it's annoying to get heaps of graphics when you didn't want them.)
 


The enclosing intervals are stored in the global variable zeros.
 

> zeros[1]; zeros[2];
 

[9.584440423, 9.590102302] 

[8.405771234, 8.406299399]
 

 

 

Complex Disc Arithmetic 

In addition to real intervals, there are also types and procedures for complex interval arithmetic. 

Data Types and basic operations  

 

Data Types: type/complex_disc and type/complex_interval
A complex disc is given by a complex number (center of the disc) and a value for the radius. It is defined as a list of three entries, [z_re,z_im,r].
A complex interval is given by two real intervals specifying a rectangular area.
 

> A1:=[1,0,1];
type(A1,complex_disc);
 

[1, 0, 1] 

true
 

> B1:=[1.,2.]; B2:=[3.,4.];
B3:=[B1,B2];
type(B3,complex_interval);
 

[1., 2.] 

[3., 4.] 

[[1., 2.], [3., 4.]] 

true
 


Display complex disc intervals:
 

> complex_disc_plot(A1);
 

Plot
 


Arithmetical Operations:
&cadd, &csub, &cmult, &cdiv
As for real intervals, you can also do the basic arithmetics with disc intervals.
 


Area optimal multiplication and division:
You can also use area optimal multiplication and division instead of their centered counterparts (where you get the new center i.e. by  
multiplying the centers of the discs to be multiplied).
 

> A2:=[-1,1,1];
A3:=A1 &cmult A2;
A4:=A1 &cmult_opt A2;
 

[-1, 1, 1] 

[-1.000000000, 1.000000000, 3.414213579] 

[-1.390388204, 1.390388204, 2.969562256]
 

 

Range Enclosure for Complex Polynomials 

 

Define and display complex polynomials: 

> p1:=(0.1+0.1*I)*z^5+0.2*I*z^4-0.1*I*z^3+(-0.2-0.1*I)*z+2.0+1.0*I;
Z:=[-0.2,0.4,1];
type(Z,complex_disc);
type(p1,polynom);
 

(.1+.1*I)*z^5+.2*I*z^4-.1*I*z^3+(-.2-.1*I)*z+(2.0+1.0*I) 

[-.2, .4, 1] 

true 

true
 

> complex_polynom_plot(p1,Z);
 

Plot
 


There are three methods for enclosing the range of a complex polynomial, two based on a Horner-like evaluation with centered or area optimal multiplication, the third based on centered forms (similar to the mean value form for real numbers). Study the example for the differences:
 

> pH:=horner_eval_cent(p1,Z);
pO:=horner_eval_opt(p1,Z);
pC:=centred_form_eval(p1,Z);
 

[2.070624000, .9264320000, 2.045124573] 

[2.015564848, .6058466116, 1.733919747] 

[2.070624000, .9264320000, 1.850902850]
 

> c1:=complex_disc_plot(pH,color=blue,thickness=2,linestyle=4):
c2:=complex_disc_plot(pO,color=green,thickness=2,linestyle=3):
c3:=complex_disc_plot(pC,color=red,thickness=2,linestyle=2):
c4:=complexplot(subs(z=Z[1]+I*Z[2]+Z[3]*(cos(t)+I*sin(t)),p1),t=0..2*Pi,color=black,thickness=2):
 

> display([c1,c2,c3,c4],scaling=constrained);
 

Plot
 


The display command can be found in the Maple plots package. For the options cf. the plot command options.
 

 

The Complex Exponential Function 


Finally, there's the exponential function for complex discs:
 

> cexp(Z);
 

[.7541009612, .3188287726, 1.406810183]
 

 

Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities. 

 

Image