** Next:** Example 2
** Up:** Examples
** Previous:** Examples
** Contents**

###

Example 1

This problem has been presented in section 2.3.5.1.

The `IntervalGradient` function is defined as:

INTERVAL_MATRIX IntervalGradient (int l1,int l2,INTERVAL_VECTOR & x)
{
INTERVAL_MATRIX Grad(3,3);
if(l1==1)
{
if(l2==1){Grad(1,1)=2*x(1)+2;return Grad;}
if(l2==2){Grad(1,2)=0;return Grad;}
if(l2==3){Grad(1,3)=0;return Grad;}
}
if(l1==2)
{
if(l2==1){Grad(2,1)=0;return Grad;}
if(l2==2){Grad(2,2)=2*x(2)+2;return Grad;}
if(l2==3){Grad(2,3)=0;return Grad;}
}
if(l1==3)
{
if(l2==1){Grad(3,1)=0;return Grad;}
if(l2==2){Grad(3,2)=0;return Grad;}
if(l2==3){Grad(3,3)=2*x(3)+2;return Grad;}
}
}

A test main program may now be written as:
INT main()
{
int Num,i,j,order,precision,Stop;
// accuracy of the solution either on the function or on the variable
double Accuracy,Accuracy_Variable,Diff_Sol;
INTERVAL_MATRIX SolutionList(200,3);//the list of solutions
INTERVAL_VECTOR TestDomain;//the input intervals for the variable
INTERVAL_VECTOR F(3);
//We set the value of the variable intervals
SetTestDomain (TestDomain);
cerr << "Accuracy on Function = "; cin >> Accuracy;
cerr << "Accuracy on Variable = "; cin >> Accuracy_Variable;
cerr << "Order (0,1)"; cin >>order;
cerr << "Stop at first solutions (0,1,2):";cin>>Stop_First_Sol;
cerr << "Separation between distincts solutions:";cin>> Diff_Sol;
//let's solve....
Num=Solve_General_Gradient_Interval(3,3,IntervalTestFunction,
IntervalGradient,TestDomain,order,10000,Stop,
Accuracy_Variable,Accuracy,Diff_Sol,SolutionList,1);
//too much intervals have been created, this is a failure
if(Num== -1)cout<<"Procedure has failed (too many iterations)"<<endl;
//otherwise print the solution intervals
for(i=1;i<=Num;i++)
{
cout << "solution " << i <<endl;
cout << "x(1)=" << SolutionList(i,1) << endl;
cout << "x(2)=" << SolutionList(i,2) << endl;
cout << "x(3)=" << SolutionList(i,3) << endl;
cout << "Function value at this point" <<endl;
for(j=1;j<=3;j++)F(j)=SolutionList(i,j);
cout << Compute_Interval_Function_Gradient(Dimension,Dimension_Eq,
IntervalTestFunction,
IntervalGradient,
F,1) << endl;
}
return 0;
}

A property of this problem is that the Jacobian of the system is
singular at the solution. Hence the unicity test cannot be verified as
it needs to evaluate the inverse of the jacobian matrix (as will fail
the classical Newton scheme, see section 2.9, that needs also
the inverse Jacobian). But even with
`epsilon`=`epsilonf`=1e-6 the algorithm is able to find an
approximation of the solution with 16 boxes only. Interestingly this
is a case where the 3B method is not efficient at all: with the 3B
method the number of boxes increases to over 100 000. This is quite
normal: as the 3B method is used before the interval Newton method it
reduces the range for the unknowns toward a region where the interval
Newton method will fail as the Jacobian is close to a singularity. We
therefore end up with a solving that is only based on the bisection
process and we have seen that this process behaves poorly for this
system. But if we mix the 3B method and the 2B filtering of
section 2.17 then the solving needs only 1 box.

** Next:** Example 2
** Up:** Examples
** Previous:** Examples
** Contents**
Jean-Pierre Merlet
2012-12-20