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); |
> |
Y:=[0,infinity];
type(Y,interval); |
> |
Z:=construct(1,2);
type(Z,interval); |
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); |
Procedures is_in, midpoint, width, &intersect, &union
> |
A:=[1.,4.];
B:=[2.,3.];
is_in(B,A); |
> |
midpoint(A);
width(A);
A &union [5.,6.];
A &intersect [3.,5.]; |
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; |
> |
C:=[-1.,1.];
A &/ C;
ext_int_div(A,C); |
Trigonometric operations:
&sin, &cos, &tan, &arcsin, &arccos, &arctan, &sinh, &cosh, &tanh
Exponential Function and Logarithm:
&exp, &ln
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; |
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:
> |
f3:=x->exp(-x^2)*sin(Pi*x^3); |
`Start range enclosure = `, [-.7788007834, .7788007834]
Range_enclosure after step 6 = [-0.2834388815,0.5563221619]
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.
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)]; |
> |
g:=(x,y)->exp(-x*y)*sin(Pi*x^2*y^2); |
> |
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]
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.]; |
> |
compute_all_zeros(f,X,0.001); |
`Digits = `, 10
` `
` `
`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]
`Iteration step `, 2
`xold=`, [9.289288474, 10.]
`xnew1=`, [9.462634907, 9.590834649]
`Iteration step `, 3
`xold=`, [9.462634907, 9.590834649]
`xnew1=`, [9.584440423, 9.590102302]
`Iteration step `, 4
`xold=`, [8., 8.710711526]
`xnew1=`, [8.401353569, 8.456507697]
`Iteration step `, 5
`xold=`, [8.401353569, 8.456507697]
`xnew1=`, [8.405771234, 8.406299399]
` `
`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.
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); |
> |
B1:=[1.,2.]; B2:=[3.,4.];
B3:=[B1,B2];
type(B3,complex_interval); |
Display complex disc intervals:
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; |
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); |
> |
complex_polynom_plot(p1,Z); |
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); |
> |
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); |
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:
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.