New Microsoft Word Document432

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

#include<stdio.

h>
#include<math.h>
//f(x)=x^4-6^x+9
float fx(float);
void bow(float, float, float);
char check(float);

int main(){
float a,b,x;
printf("Nhap can duoi: ");
scanf("%f",&a);
printf("Nhap can tren: ");
scanf("%f",&b);
x=a-((b-a)*fx(a))/(fx(b)-fx(a));
printf("a b x f(x)\n");
printf("----------------------------\n");
printf("%.3f %.3f %.3f %c\n",a,b,x,check(fx(x)));
bow(a,b,x);
}

float fx(float x){


return pow(x,4)-pow(6,x)+9;
}

char check(float fx){


if(fx<0) return '-';
else return '+';
}
void bow(float a, float b, float x){
while(fabs(fx(x))>1e-6){
x=a-((b-a)*fx(a))/(fx(b)-fx(a));
if(fx(x)*fx(a)<0){
b=x;
printf("----------------------------\n");
printf("%.3f %.3f %.3f %c\n",a,b,x,check(fx(x)));
}
else{
a=x;
printf("----------------------------\n");
printf("%.3f %.3f %.3f %c\n",a,b

You might also like