    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)
{
if(l1==1)
{
}
if(l1==2)
{
}
if(l1==3)
{
}
}
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....
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);    