Paper Menu >>
Journal Menu >>
J. Software Engineering & Applications, 2010, 3, 737-745 doi:10.4236/jsea.2010.38085 Published Online August 2010 (http://www.SciRP.org/journal/jsea) Copyright © 2010 SciRes. JSEA 737 A New Tool: Solution Boxes of Inequality Ferenc Kálovics Analysis Department, University of Miskolc, Miskolc-Egyetemváros, Hungary. Email: matkf@uni-miskolc.hu Received May 4th 2010; revised June 19th 2010; accepted June 23rd 2010. ABSTRACT Many numerical methods reduce the solving of a complicated problem to a set of elementary problems. In this way, the author reduced the finding of solution boxes of a system of inequalities, the computation of integral values with error bounds, the approximation of global maxima to computing solution boxes of one inequality. These previous papers pre- sented the mathematical aspects of the problems first of all. In this paper the computational handling of solution boxes of an inequality (as a new tool of computer methods) is discussed in detail. Keywords: Inequality, Solution Box, Coded Form of Expression 1. Introduction Let :RR m gD be a continuous multivariate real function, where 12 12 ,,,,...,, m m D xxxxx x is an open box. Define the box ,, ,Bgc D where ,R,cD as an open box around ,c in which the relation is the same as between () g c and (it is sup- posed that ()gc ). Thus, if () ,gc then ()gx for all ,, ,xBgc if () ,gc then ()gx for all ,, .xBgc Now consider a par- ticular case. Let 2 12 :RR,(,)gD gxx 12 sin( )xx 2 1 2 , ln x x where 0,,1, 4D is an open box. Try to give the box 2 12 12 sin()/ln, (1, 2),1.Bxxxx Since ( )2.351,gc an open box around point 1, 2 in which () 1gx is searched. Use the decom- position 2 12 12 2 121 2 sin()/ln, (1, 2),1 sin(),(1,2),/ln,(1, 2),. Bxxxx BxxBxx The spontaneous choice 0.5 is suitable be- cause sin(1 2)0.5 and 2 1/ln2 0.5, hence the boxes 12 sin(), (1, 2),0.5Bxx and 2 12 /ln,(1,2),0.5 ,Bx x around ,c satisfy the properties 12 sin()0.5xx and 2 12 /ln 0.5,xx respectively. Since the decompositions 12 12 12 sin(),(1, 2),0.5 ,(1,2),/6,(1,2),5 /6 Bxx Bxx Bxx 12 12 ,(1,2), /6,(1,2),1 ,(1,2),5/12,(1,2),5/3, Bx Bx Bx Bx where the first row shows that 12 /65 /6,xx the second row shows that 121 /6, 1, x xx 5/12, 25/3x in the box 12 sin( ),Bxx (1, 2), 0.5,and the decomposition 2 12 2 12 /ln,(1,2),0.5 ,(1,2),0.5ln,(1,2),1 Bx x BxB x where the formula shows that 2 12 0.5,ln 1xx in the box 2 12 /ln,(1,2),0.5 ,Bx x are also fortunate, there- fore 2 12 12 sin()/ln,(1,2),1Bxxxx /6,,1,4 0,,1,4 0,5/12, 1,40,, 1,5/3 0.5,,1,40, ,1,0.71,1.14,1,2.28.e To get the result, spontaneous rules were used for sum (), product (), quotient (/) and composit function (). In the last step the boxes were computed to some elementary functions. Naturally, the decomposition can break down with any spontaneous rule, e.g. the choice A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 738 0.95, 0.05 does not work in the first step, al- though 1. If the guaranteed rules of Theorem 1 of [1] are used, then 2 12 12 sin()/ln, (1,2),1 0.84,1.21,1,2.41. Bxxxx Our aim is to make a C++ program which can follow the above decomposition process. Suppose that the con- tinuous multivariate real function :RR, m gD where 12 12 , , ,,...,,, m m Dxxxx xx is built of the well-known (univariate real) elementary functions: , ,ln,,sin,cos,tan,cot, arcsin,arccos, arctan, arccot rx x exx xxxx xxxx by the function operations ,,/,. (It is supposed that r of r x is a positive integer or negative integer or re- ciprocal of a positive integer. This is only a formal re- striction because of 1/ /,, N. n kn k xx kn ) The functions ,log,sinh , x a axx etc. can be used by the connections ln,logln/ ln,sinh xxa a aexxax ()/2, xx ee etc., respectively, the operation of differ- ence can be used in form (1).ab ab Naturally, the program can be enlarged by further elementary func- tions, but we would like to make a program in a publish- able length. The notations, names, definitions and dis- cussions are simpler and clearer than they were in the former papers of the author (experience has slowly be- come knowledge). Using our new notations, the rules of Theorem 1 of [1] are as follows. (It is supposed that the functions ,pq satisfy the restrictions belonging to the function , g the function e is an allowed elementary function, furthermore /pq and eq are well-defined on .D) Rule of constant addition: ,,,, ,Bp cBpc where R, . Rule of constant multiplication: ,,,, ,Bpc Bpc where 0R,/. Rule of sum: ,,,,,,,B pqcB pcBqc where (()())/2, .pc qc Rule of quotient: /,, ,,0Bpqc Bpc if 0; /,,,,,, ,Bpqc BpcBqc where 2 (()())/(1 ),,pc qc if 0. Rule of product: ,,,,0 ,,0B pqcBpcBqc if 0 or ()()0;pcqc ,, ,,,, ,,,, , Bpqc BpcBpc Bqc Bqc where ,, if 0,( )0,( )0;pc qc ,,,,,,0,, ,B pqcBpcB pcBqc where 2(),/ ,pc if 0,()0,( )0;pcqc ,,,,,, ,,0,BpqcBpcBqc Bqc where 2(),/ ,qc if 0,( )0,( )0;pc qc ,,,,,,0,, ,BpqcBpcBpc Bqc where sgn( )()/( ),pcpc qc sgn( )( )/(),qcqc pc if ()() 0.pcqc Rule of composite function: ,,,,,, , cc lr BeqcDB qcB qc where c l is the maximum value for which () c l e ,() c lqc and c r is the minimum value for which () ,(). cc rr eqc If c l or c r does not exist, then the actual member is omitted. After the decomposition process the task is to evalu- ate the solution boxes belonging to elementary func- tions. The processes for the 12 cases (which are pub- lished now for the first time) can be obtained easily enough by the graphs of these functions. (The starting box is 1 1,,..., , ,...,, im im Dxxxx xx in every case.) Power function: 112 1 ,, ,,...,,,...,,,,, r i im i im i Bx c x xxxxxbxbx if Zr is odd, then 1/ 1; r b if Zr is even and 0, then1/ 1, r b 21 ;bb if Zr is odd and 0, then 1/ 1; r b if Zr is even and 0, then1/ 1, r b 21 ;bb if (0,1), 1/Zrr and 0, then 1/ 1; r b if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1, i x b if 2,, i i bxc then 2, i x b if 2,, ii bcx then 2. i x b A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 739 Exponential function: 11 1 , ,,,...,,,...,,,, i x im im i Becx xx xxxbx if 0, then 1ln;b if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1. i x b Logarithm function: 12 1 12 ln, ,,,,,...,,,; im m Bxcxxxxxxbe if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1. i x b Absolute value function: 112 1 ,, ,,...,,,...,,,,, i im i im i Bxc x xxxxxbxbx if 0, then 12 ,;bb if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1, i x b if 2,, i i bxc then 2, i x b if 2,, ii bcx then 2. i x b Sinus function: 112 1 sin, , ,,...,,,...,,,,, i im i im i Bxc x xxxxxbxbx arcsin ,2xper int (/2), i c if 0, i c then 2,per per if 0,1 , then 12 ,;bxperbxper if [1,0), then 12 ,bxperb 2 x ;per if 2, i bc then 1122 ,, 2;ybb bby if 1, i bc then 22 11 ,, 2;ybb bb y if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1, i x b if 2,, i i bxc then 2, i x b if 2,, ii bcx then 2. i x b Cosinus function: 112 1 cos, , ,,...,,,...,,,,, i im i imi Bxc x xxxxxbxbx arccos ,2xper int (/2), i c if 0, i c then 2,per per if 0,1 , then 12 ,2 ;bxperb xper if [1,0), then 12 ,;bxperb xper if 2, i bc then 1122 ,, 2;ybb bby if 1, i bc then 22 11 ,, 2;ybb bb y if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1, i x b if 2,, i i bxc then 2, i x b if 2,, ii bcx then 2. i x b Tangent function: 112 1 tan, , ,,...,,,...,,,,, i im i im i Bxc x xxxxxbxbx arctan,2int(/ 2), i xperc if 0, i c then 2,per per if 0, then 12 ,;bxperb xper if 0, then 12 ,2 ;bxperbxper if 2, i bc then 1221 ,;bbb b if 1, i bc then 2112 ,;bbbb if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1, i x b if 2,, i i bxc then 2, i x b if 2,, ii bcx then 2. i x b Cotangent function: 112 1 cot, , ,,...,,,...,,,,, i im i im i Bxc x xxxxxbxbx arccot,2int(/ 2), i xperc if 0, i c then 2,per per if 0, then 12 ,;bxperb xper if 0, then 12 ,2 ;bxperb xper if 2, i bc then 1221 ,;bbb b if 1, i bc then 2112 ,;bbbb if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1, i x b if 2,, i i bxc then 2, i x b if 2,, ii bcx then 2. i x b Arcus sinus function: 11 1 arcsin, , ,,...,,,...,,,, i im im i Bxc x xxxxxbx if /2,/2 , then 1sin ;b if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1. i x b Arcus cosinus function: 11 1 arccos, , ,,...,,,...,,,, i im im i Bxc x xxxxxbx if 0, , then 1cos ;b A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 740 if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1. i x b Arcus tangent function: 11 1 arctan, , ,,...,,,...,,,, i im imi Bxc x xxxxxbx if /2,/2 , then 1tan ;b if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1. i x b Arcus cotangent function: 11 1 arc cot,, ,,...,,,...,,,, i im imi Bxc x xxxxxbx if 0, , then 1cot;b if 1,, i i bxc then 1, i x b if 1,, ii bcx then 1. i x b Now we have 6 rules for decomposition and 12 proc- esses for elementary boxes. Since the application of the 6th rule (rule of composite function) requires the same investigation as the evaluation of elementary boxes, therefore the decomposition part of the program contains 17 different cases, and the evaluation part contains 12 cases. At the end of this section, let us emphasize some facts about solution boxes. 1) If () ,gc then (,,)xBgc implies ()gx . Consequently, the box (,,)Bgc of domain D is assigned to the interval (,) of function values. Similarly, if ()gc , then the box (,,)Bgc of domain D is assigned to the interval (, ) of function values. The so-called interval extension functions used in interval methods (see e.g. in [2]) are inverse type functions, they assign intervals of function values to boxes of domain. The handling and application of these two tools require a highly different mathematical and computational back- ground. 2) The decomposition of the expression (), g x the determination of the elementary boxes, uses only the structure of the expression () g x and supposes only the continuity of g on .D 3) The box (,, )Bgc is not a symmetrical box around .c Often it has a large volume, although () g c< or () g c> is only just satisfied. 2. Numerically Coded Form of Expression When the author introduced the above decomposition of expressions, the process was followed by a Maple pro- gram. This code computed a box (,,)Bgc very simi- larly as it is done in our numerical example. The program utilizes strongly the ability of Maple to give the type of an expression by the function (,)type e t where e is an expression and t is a type name, furthermore to give operands from an expression by the function (, )op i e where i is the position index and e is an expression. The use of our Maple program is very convenient be- cause we must only give the function g (the expression () g x) in a customary form. Unfortunately, the program is fairly slow. The conventional program languages (e.g. C++, Fortran) have no similar functions, but they can follow the decomposition, if a numerically coded form of the expression () g x is used. This form is built of triples of integer or real numbers. The first number in a triple is the so-called operation code (using the order of rules and elementary functions): const. add.1, const. mult.2, +3, /4, 5, power func.6,exp7,ln8, abs. func.9, sin10, cos11,tan12, cot 13,arcsin 14,arccos15,arctan 16, arccot 17. The second number in the triples is minus i if an elementary function uses the argument i x (the minus sign identifies the elementary funcions). If the operation uses a former triple as the first operand, then the ordinal number of this triple is the second number in the actual triple. The third number in the triples is the given con- stant or the exponent if the constant addition, constant multiplication or the power function is used, respectively. If the operation uses a former triple as a second operand (cases of ,/, ), then the ordinal number of this triple is the third number in the actual triple. If the operation is exp,ln,...,arccot (the first number in the triple is be- tween 7 and 17), then the third number in the actual triple is 0. To make the description of expressions by triples unique, we use the left-right rule in every choice. Exer- cise the description on the expression 12 (, )gx x 2 12 12 sin()/ln x xx x. The four elementary functions used in the build-up of 12 (, ) g xx (the elementary boxes be- long to these functions after the decomposition) are 112 112 212 (),(),,ln. x xxx xxTheir descriptions are: 12 2 12 (6, 1,1),(6,2,1), (6,1,2),ln (8,2,0). xx xx Now we have the sequence of triples: (6,1,1),(6,2,1),(6,1,2),(8,2,0). Using the elements of this sequence, the functions 1212 ,sin( ) x xxx and 2 12 /ln x x can be obtained in the form: A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 741 12 12 2 12 (5,1, 2),sin()(10,5,0), /ln (4,3,4). xx xx xx Since the last operation can be written in form (3,6,7), the complete description of 12 (, ) g xx is: {(6, 1,1),(6, 2,1),(6, 1,2),(8, 2,0), (5,1,2),(10,5, 0),(4, 3,4),(3,6,7)}. It can be seen that the preparation of numerically coded forms of expressions is easy enough, nevertheless the author has a short Maple program also for this one-off work. (But a numerically coded form can be used a thousand or a million times in an application.) The con- struction of our Maple program can be illustrated (on the former expression) by the Table 1. The 1st column shows the index (serial number) of the expression appearing in the 2nd column. The 4th column contains the temporary triples which use the indexes of the 1st column for identification. Going downwards the temporary triples, the elementary tripes receive their new indexes, and going backwards, the other triples receive their new indexes (6th column). Using these new indexes the final triples (7th column) are obtained. Ordering them by the indexes of the 6th column the result is ready (8th column). This result differs from our previous one forma- Table 1. Creation of numerically coded form iCompo- nents Triples ii New triples Result 112 2 12 sin( ) /ln xx x x (3,2,3) 8 (3,7,6)(6, 1,2) 212 sin( ) x x(10, 4, 0) 7 (10, 5, 0)(8,2, 0) 32 12 /ln x x(4,5,6) 6 (4,1,2) (6, 1,1) 412 x x (5,7,8) 5 (5,3, 4) (6, 2,1) 52 1 x (6,1, 2) 1 √ (5,3, 4) 62 ln x (8,2,0) 2 √ (4,1,2) 71 x (6, 1,1) 3 √ (10, 5,0) 82 x (6, 2,1) 4 √ (3,7,6) lly (here the left-right rule is omitted), but they are equivalent in essence. The arrays of Maple program resi i tr i com x ,,,, belong to vector x components of (), g x triples, new indexes and result, respectively. The array v is an auxiliary vector. The complete code is as follows. DECLARATIONS > x:=array(1..10): com:=array(1..10): tri:=array(1..10,1..3): > ii:=array(1..10): res:=array(1..10,1..3): v:=array(1..3): INITIAL VALUES > com[1]:=sin(x[1]*x[2])+x[1]^2 / ln(x[2]): > i:=0: imax:=1: COMPONENTS and TRIPLES > while i <= imax do > i:=i+1: g:=com[i]: > if type(g,name) then v:=[0,op(1,g),0]: fi: > if type(g,`+`) then > if type(op(1,g),numeric) then v:=[1,g-op(1,g),op(1,g)]: > elif type(g-op(1,g),numeric) then v:=[1,op(1,g),g-op(1,g)]: > else v:=[3,op(1,g),g-op(1,g)]: fi: fi: > if type(g,`*`) then > if type(op(1,g),numeric) then v:=[2,g/op(1,g),op(1,g)]: > elif type(g/op(1,g),numeric) then v:=[2,op(1,g),u/op(1,g)]: > elif type(op(2,g),`^`) and op(2,op(2,g)) < 0 then v:=[4,op(1,g),op(2,g)^(-1)]: > else v:=[5,op(1,g),g/op(1,g)]: fi: fi: > if type(g,`^`) then v:=[6,op(1,g),op(2,g)]: fi: > if type(g,function) then > if op(0,g)=exp then v:=[7,op(1,g),0]: fi: if op(0,g)=ln then v:=[8,op(1,g),0]: fi: > if op(0,g)=abs then v:=[9,op(1,g),0]: fi: if op(0,g)=sin then v:=[10,op(1,g),0]: fi: > if op(0,g)=cos then v:=[11,op(1,g),0]: fi: if op(0,g)=tan then v:=[12,op(1,g),0]: fi: > if op(0,g)=cot then v:=[13,op(1,g),0]: fi: if op(0,g)=arcsin then v:=[14,op(1,g),0]: fi: > if op(0,g)=arccos then v:=[15,op(1,g),0]: fi:if op(0,g)=arctan then v:=[16,op(1,g),0]: fi: > if op(0,g)=arccot then v:=[17,op(1,g),0]: fi: fi: > if v[1]=0 then tri[i,1]:=6: tri[i,2]:=-v[2]: tri[i,3]:=1: fi: > if v[1] > = 6 and v[1] < = 17 then > if type(v[2],name) then tri[i,1]:=v[1]: tri[i,2]:=-op(1,v[2]): tri[i,3]:=v[3]: > else imax:=imax+1: com[imax]:=v[2]: tri[i,1]:=v[1]: tri[i,2]:=imax: tri[i,3]:=v[3]: fi: fi: > if v[1]=1 or v[1]=2 then > imax:=imax+1: com[imax]:=v[2]: tri[i,1]:=v[1]: tri[i,2]:=imax: tri[i,3]:=v[3]: fi: > if v[1] > = 3 and v[1] < = 5 then > imax:=imax+1: com[imax]:=v[2]: imax:=imax+1: com[imax]:=v[3]: > tri[i,1]:=v[1]: tri[i,2]:=imax-1: tri[i,3]:=imax: fi: A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 742 > od: NEW INDEXES > ind:=1: > for i from 1 to imax do if tri[i,2] < 0 then ii[i]:=ind: ind:=ind+1: fi: od: > for i from imax by -1 to 1 do if tri[i,2] > 0 then ii[i]:=ind: ind:=ind+1: fi: od: RESULT > for ind from 1 to imax do > for i from 1 to imax do > if ii[i]=ind then res[ind,1]:=tri[i,1]: > if tri[i,2] < 0 then res[ind,2]:=tri[i,2]: res[ind,3]:=tri[i,3]: fi: > if tri[i,2] > 0 then res[ind,2]:=ii[tri[i,2]]: > if tri[i,1]=3 or tri[i,1]=4 or tri[i,1]=5 then res[ind,3]:=ii[tri[i,3]]: else res[ind,3]:=tri[i,3]: > fi: fi: fi: > od: od: > print(`The result`, res): Now we have a suitable form of expressions to make a fast program for our original problem. 3. A Complete C++ Program for Computation of Solution Boxes Here the function segment s olbox is made for the computation of solution box B[g,c,α] where 1 1 :RR, , ,...,,,,R m m m gDD xxx xc D have the former definitions. The headline of this segment contains the input parameters , (in tripleDDGg form),,,,number of triplesccalp mmnt . The result ,,Bgc (as output parameter) is placed into the array .B The segment contains 3 essential parts (great loops). In the first one the function values of components of () g x at point c are computed by using the triples in succession. These function values are placed into the array fv and will be used in the de- composition steps. In the second loop the decomposition (making elementary boxes) goes on. In the normal case (1),nt first the last triple (expression () g x) and are placed into the array of non-elementary expressions ().ne At this time the number of elements in this array is 1 (1).ine Applying the suitable rule for this element, new elements of the array ne or (and) those of the array of elementary expressions ()el are created. The values ,, etc. appearing in the rules are denoted by ,,,,begade ep and s shows the number of new boxes. The indexes ine and iel show the numbers of ele- ments in the arrays ne and . el The decomposition procedure is finished when there is no element for ex- amination in the array ,ne that is the necessary ele- mentary expressions are all in the array . el In the third great loop of segment s olbox the (iel pieces of) ele- mentary boxes are evaluated and the array B is made. As it was mentioned earlier, the application of the com- posite function rule requires the same investigation as the evaluation of elementary boxes. Therefore the second and third loops of the segment contain similar lines (only some parameters are different) between case 6 and case 17. #include <iostream.h> #include <math.h> double B[10][3]; /*DECLARATIONS*/ void solbox(double D[][3],double G[][4],double c[],double alp,int m,int nt) {double fv[100],ne[100][5],el[100][5],al,be,ga,de,ep,x,y,w,alf,per; int i,j,k,l,ii,jj,kk,ine,iel,s; const double Pi=3.14159265; /*FUNCTION VALUES TO COMPONENTS OF EXPRESSION g(x)*/ for (i=1; i<=nt; i++) {j=(int)G[i][1]; k=(int)G[i][2]; l=(int)G[i][3]; w=G[i][3]; if (k<0) x=c[-k]; else x=fv[k]; if (j>=3 && j<=5) y=fv[l]; switch (j) {case 1:fv[i]=x+w;break; case 2:fv[i]=x*w;break; case 3:fv[i]=x+y;break; case 4:fv[i]=x/y;break; case 5:fv[i]=x*y;break; case 6:fv[i]=pow(x,w);break; case 7:fv[i]=exp(x);break; case 8:fv[i]=log(x);break; case 9:fv[i]=fabs(x);break; case 10:fv[i]=sin(x);break; case 11:fv[i]=cos(x);break; case 12:fv[i]=tan(x);break; case 13:fv[i]=1/tan(x);break; case 14:fv[i]=asin(x);break; case 15:fv[i]=acos(x);break; case 16:fv[i]=atan(x);break; case 17:fv[i]=Pi/2-atan(x);break;}} /*DECOMPOSITION BY USING THE 6 RULES*/ for (i=1; i<=3; i++) ne[1][i]=G[nt][i]; ne[1][4]=alp; ine=1; iel=0; i=0; while (i<ine && nt>1) {i++; j=(int)ne[i][1]; k=(int)ne[i][2]; l=(int)ne[i][3]; w=ne[i][3]; al=ne[i][4]; s=0; A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 743 switch (j) {case 1: be=al-w;s=1;break; case 2: be=al/w;s=1;break; case 3: be=(al+fv[k]-fv[l])/2;ga=al-be;s=2;break; case 4: if (al==0) {be=0;s=1;}; if (al !=0) {ga=(al*fv[k]+fv[l])/(1+al*al);be=al*ga;s=2;};break; case 5: if (al==0 || fv[k]*fv[l]*al < 0) {be=0;ga=0;s=2;} if (al!=0 && fv[k]==0 && fv[l]==0) {be=sqrt(fabs(al));ga=be;de=-be;ep=de;s=4;} if (al!=0 && fv[k] !=0 && fv[l]==0) {be=2*fv[k];ga=al/be;de=0;s=3;} if (al!=0 && fv[k]==0 && fv[l]!=0) {ga=2*fv[l];be=al/ga;de=be;ep=0;s=4;} if (fv[k]*fv[l]*al>0) {be=fv[k]/fabs(fv[k])*sqrt(al*fv[k]/fv[l]); ga=fv[l]/fabs(fv[l])*sqrt(al*fv[l]/fv[k]);de=0;s=3;};break; case 6: if (w>0 && (l+1)/2*2==l+1) {be=pow(al,1/w); s=1;} if (w>0 && l/2*2==l && al>=0) {be=pow(al,1/w);ga=-be;s=2;} if (w<0 && (l-1)/2*2==l-1 && al !=0) {be=pow(al,1/w);s=1;} if (w<0 && l/2*2==l && al>0) {be=pow(al,1/w);ga=-be;s=2;} if (w>0 && w<1 && al>=0) {be=pow(al,1/w);s=1;};break; case 7: if (al > 0) {be=log(al);s=1;};break; case 8: be=exp(al);s=1;break; case 9: if (al >= 0) {be=al;ga=-al;s=2;};break; case 10:if (fabs(al)<=1) {x=asin(fabs(al));per=2*Pi*(int)(fv[k]/2/Pi); if(fv[k]<0) per=per-2*Pi; if (al>=0) {be=x+per;ga=Pi-x+per;}; if (al<0) {be=Pi+x+per;ga=2*Pi-x+per;} if (ga<fv[k]) {y=be;be=ga;ga=y+2*Pi;}; if (be>fv[k]) {y=ga;ga=be;be=y-2*Pi;}; s=2;};break; case 11:if (fabs(al)<=1) {x=acos(fabs(al));per=2*Pi*(int)(fv[k]/2/Pi); if(fv[k]<0) per=per-2*Pi; if (al>=0) {be=x+per;ga=2*Pi-x+per;}; if (al<0) {be=Pi-x+per;ga=Pi+x+per;} if (ga<fv[k]) {y=be;be=ga;ga=y+2*Pi;}; if (be>fv[k]) {y=ga;ga=be;be=y-2*Pi;}; s=2;};break; case 12:x=atan(fabs(al));per=2*Pi*(int)(fv[k]/2/Pi); if(fv[k]<0) per=per-2*Pi; if (al>=0) {be=x+per;ga=Pi+x+per;}; if (al<0) {be=Pi-x+per;ga=2*Pi-x+per;} if (ga<fv[k]) {be=ga;ga=be+Pi;}; if (be>fv[k]) {ga=be;be=ga-Pi;};s=2;break; case 13:x=Pi/2-atan(fabs(al));per=2*Pi*(int)(fv[k]/2/Pi); if(fv[k]<0) per=per-2*Pi; if (al>=0) {be=x+per;ga=Pi+x+per;}; if (al<0) {be=Pi-x+per;ga=2*Pi-x+per;} if (ga<fv[k]) {be=ga;ga=be+Pi;}; if (be>fv[k]) {ga=be;be=ga-Pi;};s=2;break; case 14:if (fabs(al)<=Pi/2) {be=sin(al);s=1;};break; case 15:if (al>=0 && al<=Pi) {be=cos(al);s=1;};break; case 16:if (fabs(al)<Pi/2) {be=tan(al);s=1;};break; case 17:if (al>0 && al<Pi) {be=1/tan(al);s=1;};break;} for (ii=1; ii<=s; ii++) {switch (ii) {case 1:alf=be;kk=k;break; case 2:alf=ga;if (j>=3 && j<=5) kk=l;break; case 3:alf=de;kk=k;break; case 4:alf=ep;if (j>=3 && j<=5) kk=l;break;} if (G[kk][2]<0) {iel++; for (jj=1; jj<=3; jj++) el[iel][jj]=G[kk][jj];el[iel][4]=alf;} if (G[kk][2]>0) {ine++; for (jj=1; jj<=3; jj++) ne[ine][jj]=G[kk][jj];ne[ine][4]=alf;}}} if (nt==1) {for (ii=1; ii<=4; ii++) el[1][ii]=ne[1][ii];iel=1;} /*EVALUATING THE ELEMENTARY BOXES BY USING THE 12 PROCESSES*/ for (i=1; i<=m; i++) {B[i][1]=D[i][1]; B[i][2]=D[i][2];} for (i=1; i<=iel; i++) {j=(int)el[i][1]; k=(int)-el[i][2]; l=(int)el[i][3]; w=el[i][3]; al=el[i][4]; s=0; switch (j) {case 6: if (w>0 && (l+1)/2*2==l+1) {be=pow(al,1/w);s=1;} if (w>0 && l/2*2==l && al>=0) {be=pow(al,1/w);ga=-be;s=2;} if (w<0 && (l-1)/2*2==l-1 && al!=0) {be=pow(al,1/w);s=1;} if (w<0 && l/2*2==l && al>0) {be=pow(al,1/w);ga=-be;s=2;} if (w>0 && w<1 && al>=0) {be=pow(al,1/w);s=1;};break; case 7: if (al > 0) {be=log(al);s=1;};break; case 8: be=exp(al);s=1;break; case 9: if (al >= 0) {be=al;ga=-al;s=2;};break; case 10:if (fabs(al)<=1) {x=asin(fabs(al));per=2*Pi*(int)(c[k]/2/Pi);if(c[k]<0) per=per-2*Pi; if (al>=0) {be=x+per;ga=Pi-x+per;}; if (al<0) {be=Pi+x+per;ga=2*Pi-x+per;} if (ga<c[k]) {y=be;be=ga;ga=y+2*Pi;}; if (be>c[k]) {y=ga;ga=be;be=y-2*Pi;}; s=2;};break; case 11:if (fabs(al)<=1) {x=acos(fabs(al)); per=2*Pi*(int)(c[k]/2/Pi);if(c[k]<0) per=per-2*Pi; if (al>=0) {be=x+per;ga=2*Pi-x+per;}; if (al<0) {be=Pi-x+per;ga=Pi+x+per;} if (ga<c[k]) {y=be;be=ga;ga=y+2*Pi;}; if (be>c[k]) {y=ga;ga=be;be=y-2*Pi;}; s=2;};break; case 12:x=atan(fabs(al));per=2*Pi*(int)(c[k]/2/Pi);if(c[k]<0) per=per-2*Pi; if (al>=0) {be=x+per;ga=Pi+x+per;}; if (al<0) {be=Pi-x+per;ga=2*Pi-x+per;} if (ga<c[k]) {be=ga;ga=be+Pi;}; if (be>c[k]) {ga=be;be=ga-Pi;};s=2;break; case 13:x=Pi/2-atan(fabs(al));per=2*Pi*(int)(c[k]/2/Pi);if(c[k]<0) per=per-2*Pi; A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 744 if (al>=0) {be=x+per;ga=Pi+x+per;}; if (al<0) {be=Pi-x+per;ga=2*Pi-x+per;} if (ga<c[k]) {be=ga;ga=be+Pi;}; if (be>c[k]) {ga=be;be=ga-Pi;};s=2;break; case 14:if (fabs(al)<=Pi/2) {be=sin(al);s=1;};break; case 15:if (al>=0 && al<=Pi) {be=cos(al);s=1;};break; case 16:if (fabs(al)<Pi/2) {be=tan(al);s=1;};break; case 17:if (al>0 && al<Pi) {be=1/tan(al);s=1;};break;} for (ii=1; ii<=s; ii++) { alf=be; if (ii==2) alf=ga; if (alf < c[k] && alf > B[k][1]) B[k][1]=alf; if (alf > c[k] && alf < B[k][2]) B[k][2]=alf;}}} /*THE CALLING SEGMENT WITH THE SAMPLE EXPRESSION*/ void main() {double D[10][3],G[100][4],c[10],alp; int m,nt,i,j; double g[][3]={{6,-1,1},{6,-2,1},{6,-1,2},{8,-2,0},{5,1,2},{10,5,0},{4,3,4},{3,6,7}}; D[1][1]=0.;D[1][2]=3.141593;D[2][1]=1.;D[2][2]=4.; c[1]=1.;c[2]=2.; alp=1.; m=2; nt=8; for (i=1; i<=nt; i++) {for (j=1; j<=3; j++) G[i][j]=g[i-1][j-1];}; solbox(D,G,c,alp,m,nt); for (i=1; i<=m; i++) {cout << B[i][1] << " " << B[i][2] << endl;}} The calling (main) segment uses a simple trick (push down of indexes) for the easy handling of triple forms. Using the form (produced by the Maple program) {(6,1,2), (8,2,0), (6,1,1),(6,2,1), (5,3,4),(4,1,2),(10,5,0),(3,7,6)} and the form (produced by us) {(6, 1,1),(6, 2,1),(6, 1,2),(8, 2,0), (5,1,2), (10, 5,0), (4,3, 4), (3,6,7)} of our sample expression 12 (, ) g xx , the result is the same: 2 12 12 sin()/ln, (1, 2),1 0.839584,1.20543, 1,2.41086, Bxxxx which was given (with rounded values) in the first sec- tion. 4. A numerical Example for Illustration The surfaces given by formulas 22 312312 2sin()2, 2xxxxxx have their intersection over the two dimensional interval 3, 3,3, 3. Maple 11 can produce Figure 1 with these data. Our aim is to give an approximating value for the volume of the section set S determined by the sur- faces. Since the set S is the solution set of the system of inequalities: Figure 1. Intersection 22 1233 12 2sin()20, 20,xxxx xx one of methods of [3] can be used. This method searches for disjunct open solution boxes of an inequality system and it is based on the following four principles. 1) If 1,,0Bfc is a solution box to the inequality 1() 0fx and 2,,0Bfc is a solution box to the inequality 2() 0,fx then the box 12 ,,0 ,,0BfcBf c is a solution box to the system of the two inequalities. 2) If 1 B and 2 B are m-dimensional boxes, then the set 12 BB can be divided into (at most) 2m boxes easily. In this way a sequence of solution boxes and another sequence of boxes waiting for examination can be gener- ated. 3) A boundary region is used to prevent the ap- pearance of too small boxes. Here this region is defined by the inequality 3 () 10fx and a cube with edges of 3 10 is excluded at a region point .c 4) The most promising box (the box with maximum volume) is cho- sen from boxes waiting for examination in every step. The essential input data are: 1123 ( )2sin()2 {(6,1,1),(6,2,1),..., (3,6,7),(1,8, 2.)}, fxxx x 22 2312 () 2 {(6,1,2),(6,2, 2),..., (3,3,5),(1,6, 2.)}, fxx xx the initial box (3,3),(3,3),(2,4)I which in- cludes the set , S and the number b N of solution boxes looked for, as stop criteria. For the values 445 10,510,10 b N the results are 27.0008,28.1484,28.4231, respectively. The running times are (with the original Lahey Fortran 90 version 4.5 code on a PC of two 2 GHz processor): 2sec,26sec,107sec, respectively. The fast increase of running time shows that neither the 3rd nor the 4th principle work well if b N is A New Tool: Solution Boxes of Inequality Copyright © 2010 SciRes. JSEA 745 large. (Only a few hundred solution boxes were searched for in [3].) Now consider another possibility. Since ()1 , S vol Sdxdydz and [4,5] contain methods for computation of integrals, perhaps better results can be obtained. The method of [5] is based on the following three principles. 1) The value of a (simple, double, triple, etc.) integral can be given by the volume of a suitable set T. If the box I contains this set, then a good scanning of T gives an approxima- tion of the integral value and the scanning of the set I T also facilitates computation of an error bound. Here the set T can be described by the system of ine- qualities 22 1233 124 2sin()20, 20,10,xxxxxxx and the scanning works by computing solution boxes. The scanning of the set I T is based on the examina- tion of “the worst inequality” at points .cIT 2) If 1 B and 2 B are m-dimensional boxes, then the set 12 BB can be divided into (at most) 2m boxes easily. 3) The too small boxes are filtered by the simple condi- tion ().vol B Naturally, the value has a strong influence on the available error bound. The program is stopped when there is no more box waiting for examina- tion. Now the essential input data are: the expressions 123 (),(), () f xfxfx in triple form, the initial box (3,3), (3,3),I (2,4), (0,1) which includes the set , T and the filter parameter . For the values 5 10 , 6 10 , 7 10, the results are 28.99531.0169, 29.04990.4840, 29.07050.2294, respectively. The running times are (with the original Visual C++ version 6.0 code on the former PC of two 2 GHz processor): 4sec,16sec,79sec, respectively. Since the difference between the third and first results is 0.0752 only, the third error bound sug- gests that all three of the results are good enough ap- proximations. The extra work of the second and third cases was spent mostly on improving the error bound. Now make a goal-oriented transformation of the method of [3]. If the third principle (boundary region) and the fourth principle (most promising box) are omitted and principles of method of [5] belonging to error bound and filter parameter are used, then the new method will be competitive. For the values 5 10 , 6 10 , 7 10 , the results are 29.08620.6765,29.08290.3124, 29.08260.1447, respectively. The running times are (with the new Lahey Fortran code): 1sec,5sec,24sec, respectively. These results are better from all points of view than the previous ones were. Since now the differ- ence between the first and third results is 0.0036 only, the 3 values suggest much more accurate approximation than the guaranteed error bounds do. On the other hand, by the geometrical meaning, here the solution (section) set S (and its complementary set) was covered with cuboids, while the solution set T (and its complemen- tary set) was covered with four-dimensional (abstract) boxes at the triple integral. It is not surprising that the computational effort increases with dimension. Finally some remarks are given. 1) The computation efforts (the evaluation times) be- longing to (,,)Bgc and () g c can be characterized well enough by the formula: effort (,, )10Bgc effort (), g c with respect to all three programming languages mentioned and problems of [1,3-5]. 2) The speeds belonging to the evaluation of (,,)Bgc satisfy the relations: speed(C++) 200 speed(Maple), speed(Fortran) 300 speed(Maple) for the examples of [1]. Nevertheless, the Fortran codes are hardly faster than the C++ ones ( differences of only 0-10 percent in running time) for the examples of [5]. 3) We always used floating point arithmetic for com- puting solution boxes (zone function values by former name). Since these boxes are computed by lower esti- mates (see proofs of [1]), we have never happened to obtain a faulty result because of the effect of rounding errors. 4) The author would gladly send the C++, Fortran, Maple codes mentioned to interested readers in e-mail as an attached file. REFERENCES [1] F. Kálovics, “Creating and Handling Box Valued Func- tions Used in Numerical Methods,” Journal of Computa- tional and Applied Mathematics, Vol. 147, No. 2, 2002, pp. 333-348. [2] R. Hammer, M. Hocks, U. Kulisch and D. Ratz, “Nu- merical Toolbox for Verified Computing,” Springer- Verlag, Berlin, 1993. [3] F. Kálovics and G. Mészáros, “Box Valued Functions in Solving Systems of Equations and Inequalities,” Numeri- cal Algorithms, Vol. 36, No. 1, 2004, pp. 1-12. [4] F. Kálovics, “Zones and Integrals,” Journal of Computa- tional and Applied Mathematics, Vol. 182, No. 2, 2005, pp. 243-251. [5] F. Kálovics, “Two Improved Zone Methods,” Miskolc Mathematical Notes, Vol. 8, No. 2, 2007, pp. 169-179. |