Professional Documents
Culture Documents
Giải gần đúng phương trình (t.t)
Giải gần đúng phương trình (t.t)
t)
1. Phương pháp dây cung:
- Xét hàm số f(x)= x 4 −6 x +9
- Tách nghiệm: Phương trình có 1 nghiệm x(1;2)
- Chính xác hóa nghiệm:
o Ta có f(1) = 4 > 0 ; f(2) = -11 < 0
( 2−1 )∗4
o x 1=1− =1.267
−11−4
o f ( x )=f ( 1.267 )=1.896 >0
o Bảng kết quả:
a b x f(x)
1 2 1.267 +
1.267 1.267 +
1.375 1.375 +
1.419 1.419 +
1.436 1.436 +
1.444 1.444 +
1.447 1.447 +
1.448 1.448 +
1.448 1.448 +
1.448 1.448 +
1.449 1.449 +
1.449 1.449 +
1.449 1.449 +
1.449 1.449 +
1.449 1.449 +
#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);
}
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);
}
#include <stdio.h>
#include <math.h>
// f(x)=x^4-6^x+9
float fx(float);
float fdhx(float);
void tt(float);
int main()
{
float x;
printf("Nhap x: ");
scanf("%f", &x);
printf("x f(x)/f'(x)\n");
printf("----------------------------\n");
printf("%.3f %.3f\n",x,fx(x)/fdhx(x));
tt(x);
}
float fx(float x)
{
return pow(x, 4) - pow(6, x) + 9;
}
float fdhx(float x)
{
return 4 * pow(x, 3) - pow(6, x) * log(6);
}
void tt(float x)
{
float y = x;
x = y - fx(y) / fdhx(y);
while (fabs(x - y) > 1e-4)
{
y = x;
x = y - fx(y) / fdhx(y);
printf("%.3f %.3f\n",x,fx(y)/fdhx(y));
}
printf("Nghiem cua phuong trinh la: %.3f\n",x);
printf("Ket qua cua phuong trinh voi x= %.3f la: %.3f",x,fx(x));
}