Загрузил Ulug'bek Boboqulov

2-lab

реклама
//Kesmani teng ikkiga bo'lish usuli
#include<iostream>
#include<math.h>
using namespace std;
float F1(float x){
return 3*x - cos(x) - 1;
}
float F2(float x){
return pow(x,3) + 0.2*x*x +0.5*x - 1.2;
}
int main(){
float a,b,t,x,e=0.0001,c,d;
cout<<"\n birinchi funksiya uchun \n";
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
while(fabs(b-a)>=e){
t=(a+b)/2;
if (F1(t)==0) break;
if (F1(a)*F1(t)<0) b=t;
if (F1(b)*F1(t)<0) a=t;
}
x=(a+b)/2;
cout<<x;
cout<<"\n ikkinchi funksiya uchun \n";
cout<<"c="; cin>>c;
cout<<"d="; cin>>d;
while(fabs(d-c)>=e){
t=(c+d)/2;
if (F2(t)==0) break;
if (F2(c)*F2(t)<0) d=t;
if (F2(d)*F2(t)<0) c=t;
}
x=(c+d)/2;
cout<<x;
}
1) 3x-cosx-1=0
2) x3+0.2x2+0.5x-1.2=0
Скачать