Скачиваний:
14
Добавлен:
01.05.2014
Размер:
1.37 Кб
Скачать
#include <iostream.h>
#include <math.h>
#include <conio.h>
double l=0;
double x01=0,x02=3,p1=44,p2=-24;

double function(double x1, double x2) {
	l=l+0.001;
	x1=x01+l*p1;
	x2=x02+l*p2;
	return ((x1-2)*(x1-2)*(x1-2)*(x1-2)+(x1-2*x2)*(x1-2*x2));
	}

/*double SWANN(double& a, double& b,double& c) {
	double	shag=0.001,np=1;
	a=np;
	b=np+shag;
	if (function(a)<function(b)) {           //dvigenie nalevo
		shag=-shag;
		while (function(a)<function(b)) {
			shag=2*shag;
			np=np+shag;
			c=b;
			b=a;
			a=np;
		};

	} else
	if (function(a)>function(b)) {           //dvigenie napravo
		while (function(b)<function(a)) {
			shag=2*shag;
			np=np+shag;
			c=a;
			a=b;
			b=np;
			if (function(a)<function(b)) {
				a=c;
				c=b;
			};
		};

	}  //if


	return(0);
}


double bolciano(double a,double b) {
			double e=0.001,min;
			if (proizv(a)*proizv(b)<0) {
					do
						min=(a+b)/2;
						if (proizv(min)>0) b=min;
							else a=min;
					while ((fabs(proizv(min))<=e)&&(fabs(b-a)<=e))

			}

}             */
main(){
	double x,a,b,c,f;
	clrscr();
 //	x=4;
	//SWANN(a,b,c);
	b=c;
	do
		f=function(a,b);
	while (f<=function( a,b));

	cout<<f;
	//cout<<"znachenie funkcii:  "<<function(x1,x2)<<"\ninterval: "<<a<<" = "<<b<<" = "<<c<<"\n"<<"interpol minimum:  "<<dihotom(a,b)<<"\n";
			return(0);
}
Соседние файлы в папке all