Лабораторная работа: Градієнтні методи
h [1] =fdx1 (x1 [k],x2 [k]);
if (fabs (h [1]) >del1) {g [1] =h [1]; }
else {g [1] =0; }
h [2] =fdx2 (x1 [k],x2 [k]);
if (fabs (h [2]) >del1) {g [2] =h [2]; }
else {g [2] =0; }
x1 [k+1] =x1 [k] - A1*g [1];
x2 [k+1] =x2 [k] - A1*g [2];
// cout<<":: "<<x1 [k] <<":: "<<x2 [k] <<endl;
f1=f (x1 [k+1],x2 [k+1]);
f2=f (x1 [k],x2 [k]);
k++;
}
while (f1<f2);
k--;
do{
r [1] =fdx1 (x1 [k],x2 [k]);
if (fabs (r [1]) >del2) {b [1] =0; }
else {b [1] =r [1]; }
r [2] =fdx2 (x1 [k],x2 [k]);
if (fabs (r [2]) >del2) {b [2] =0; }
else {b [2] =r [2]; }
x1 [k+1] =x1 [k] - A2*b [1];
x2 [k+1] =x2 [k] - A2*b [2];
cout<<x1 [k+1] <<":: "<<x2 [k+1] <<endl;
f1=f (x1 [k+1],x2 [k+1]);
f2=f (x1 [k],x2 [k]);
k++;
}while (f1<f2);