Лабораторная работа: Градієнтні методи
alpmin=zsech (a,b,x [k] [1],x [k] [2],z1,z2);
cout<<"\nk="<<k+1<<endl;
x [k+1] [1] =x [k] [1] - alpmin*z1; cout<<"\nx [1] [1] ="<<x [k+1] [1];
x [k+1] [2] =x [k] [2] - alpmin*z2; cout<<"\nx [1] [2] ="<<x [k+1] [2] <<endl; // getch ();
z1=df1 (x [k+1] [1],x [k+1] [2]);
z2=df2 (x [k+1] [1],x [k+1] [2]);
N1=N1+2;
d=pow (z1*z1+z2*z2,0.5);
if (d>e2)
{k++; goto mm1; }
else {xmin1=x [k+1] [1];
xmin2=x [k+1] [2];
ymin=f (xmin1,xmin2);
cout<<"x1="<<xmin1<<" x2="<<xmin2<<" ymin="<<ymin<<endl<<"N1="<<N1;
cout<<" N0="<<N0<<" k="<<k+1<<endl;
}
// return 0;
getch ();
}
Метод2
include "iostream"
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#include "iomanip"
#include <stdio.h>
using namespace std;
int N0=0, N1=0;
double a=3, b=-1.2, c=0.02, d=1.3;