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

### Example 3

This example is derived from example 2 and has been presented in section 2.3.5.3. The test program is Test_Solve_JH_General2. The IntervalFunction and IntervalGradient have been presented before. The IntervalHessian is:

INTERVAL_MATRIX IntervalHessian (int l1,int l2,INTERVAL_VECTOR & in)
{
INTERVAL_MATRIX Hess(1,1);
Hess(1,1)=39320.0+(-3128.0+(-78640.0+43560.0*Cos(in(1)))*
Cos(in(1)))*Cos(in(1))+(-2692.0+(-15152.0+14400.0*Cos(in(1)))*
Cos(in(1)))*Sin(in(1));
return Hess;
}

A test main program may be written as:

INT main()
{
int Iterations,Dimension,Dimension_Eq,Apply_Kanto;
int Num,i,j,order,Stop_First_Sol,precision,niter,nn;
double Accuracy,Accuracy_Variable,eps;
INTERVAL_MATRIX SolutionList(200,3);
INTERVAL_VECTOR TestDomain,F(1),P(1),H(3);
VECTOR TR(1),Residu(1);
INTEGER_VECTOR Is_Kanto(6);

Dimension_Eq=Dimension=1;SetTestDomain (TestDomain);

cerr << "Number of iteration = "; cin >> Iterations;
cerr << "Accuracy on Function = "; cin >> Accuracy;
cerr << "Accuracy on Variable = "; cin >> Accuracy_Variable;
cerr << "Debug Level (0,1,2)="; cin >> Debug_Level_Solve_General_Interval;
cerr << "Order (0,1)="; cin >>order;
cerr << "Stop at first solutions (0,1,2)=";cin>>Stop_First_Sol;
cerr << "Apply Kanto (0,1)=";cin>>Apply_Kanto;

Num=Solve_General_JH_Interval(Dimension,Dimension_Eq,
TestDomain,order,Iterations,Stop_First_Sol,Accuracy_Variable,
Accuracy,SolutionList,Is_Kanto,Apply_Kanto,6);

if(Num== -1){cout << "The procedure has failed (too many iterations)"<<endl;return 0;}
cout << Num << " solution(s)" << endl;
for(i=1;i<=Num;i++)
{
cout<<"solution "<<i<<endl;cout<<"teta="<<SolutionList(i,1)<<endl;
cout << "Function value at this point" <<endl;F(1)=SolutionList(i,1);
IntervalHessian,F,1) << endl;
cout << "Function value at middle interval" <<endl;
P(1)=Mid(SolutionList(i,1));    F=IntervalTestFunction(1,Dimension_Eq,P);
cout << Sup(F(1)) << endl;    TR(1)=Mid(SolutionList(i,1));
if(Is_Kanto(i)==1)cout << "This solution is Kanto" <<endl;
else cout << "This solution is not Kanto" << endl;
IntervalHessian,TR,&eps)==1)
{
P(1)=INTERVAL(TR(1)-eps,TR(1)+eps);
cout << "Unique solution in: " <<P << endl;
}
if(Is_Kanto(i)==1)
{
if(nn>0)
{
cout << "Newton iteration converge toward: " << endl;
cout << TR << "with residu= " << Residu<< endl;
}
else
{
if(nn==0)cout << "Newton does not converge" << endl;
if(nn== -1)cout<<"Newton has encountered a singular matrix"<<endl;
}
}
}
return 0;
}

With epsilonf=0.0001 and epsilon=0.001 , using Kantorovitch at level 1, we get the solution intervals, using 4 boxes:

Newton method initialized with the center of these boxes converge toward 4.08282e-15 and -0.8067834.

Jean-Pierre Merlet 2012-12-20