Ketma-ket yaqinlashish (iteratsiya) usuli. Kesmani ikkiga bo’lish usuli.
1) tg(0.44x+0.3)=x2
2) x3-0.1x2+0.4x+1.2=0
#include
#include
using namespace std;
float F(float x){
return tan (0.44*x+0.3)-x*x;
}
int main(){
float a,b,t,x,e=0.0001;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
while(fabs(b-a)>=e){
t=(a+b)/2;
if (F(t)==0) break;
if (F(a)*F(t)<0) b=t;
if (F(b)*F(t)<0) a=t;
}
x=(a+b)/2;
cout<
2)
Dastur kodi
/*
) 2) x3-0.1x2+0.4x+1.2=0
*/
#include
#include
using namespace std;
float F(float x){
return x*x*-0.1*x*x+0.4*x+1.2;
}
int main(){
float a,b,t,x,e=0.0001;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
while(fabs(b-a)<=e){
t=(a+b)/2;
if (F(t)==0) break;
if (F(a)*F(t)<0) b=t;
if (F(b)*F(t)<0) a=t;
}
x=(a+b)/2;
cout<
}
Shomurodov yaxshiboy
Di 11 19
Do'stlaringiz bilan baham: |