You are on page 1of 7

Bài 1: Chính xác hoá nghiệm (Phương pháp chia đôi):

A, f (x)=x3 −2∗x−2
- Tách nghiệm: từ đồ thị -> phương trình có một nghiệm x ϵ (1 ,2)
- Chính xác hoá nghiệm : f (x)=x3 −2∗x−2
Áp dụng phương pháp chia đôi :

n a b c f(c)
1 1 2 1.5 -
2 1.5 2 1.75 -
3 1.75 2 1.875 +
4 1.75 1.875 1,8125 +
5 1.75 1.8125 1.781 +
6 1.75 1.781 1.765 -
7 1.765 1.781 1.773 +
8 1.765 1.773 1.769
lim an=lim b n=¿ 1.769
n→ 8 n→8
Kết luận : Nghiệm của phương trình : x = 1.66

CODE:
#include <stdio.h>
#include <math.h>
double fx(double x) {
return pow(x, 3) - 2*x - 2;
}
double function(double a, double b){
double c;
do {
c = (a + b) / 2;
if (fx(c) > 0) {
b = c;
} else {
a = c;
}
} while (fabs(a - b) > 0.00001 && fx(c) != 0);
return c;
}
int main() {
double a, b;
printf("Nhap a: ");
scanf("%lf", &a);
printf("Nhap b: ");
scanf("%lf", &b);
double result = function(a, b);
printf("Ket qua: %lf\n", result);
return 0;
}

B, f ( x)=x5 −3 x 2−1
- Tách nghiệm: từ đồ thị -> phương trình có một nghiệm x ϵ (1 ,2)
- Chính xác hoá nghiệm : f ( x)=x5 −3 x 2−1

Áp dụng phương pháp chia đôi :

n a b c f(c)

1 1 2 1.5 -

2 1.5 2 1.75 +

3 1.5 1.75 1.625 +

4 1.5 1.625 1,562 +

5 1,5 1.562 1.531 +

6 1.5 1.531 1,515 +

7 1,5 1.515 1.507 -

8 1.507 1.515 1,511 +


9 1.507 1.511 1,509

lim an=lim b n=1.509


n→ 9 n→9
Kết luận: Nghiệm của phương trình : x≈ 1.509.
Code:
#include <stdio.h>
#include <math.h>
double fx(double x) {
return pow(x, 5) - 3*pow(x, 2) -1 ;
}
double function(double a, double b){
double c;
do {
c = (a + b) / 2;
if (fx(c) > 0) {
b = c;
} else {
a = c;
}
} while (fabs(a - b) > 0.00001 && fx(c) != 0);
return c;
}
int main() {
double a, b;
printf("Nhap a: ");
scanf("%lf", &a);
printf("Nhap b: ");
scanf("%lf", &b);
double result = function(a, b);
printf("Ket qua: %lf\n", result);
return 0;
}
Bài 2: Chính xác hoá nghiệm (Phương pháp lặp):
A, f (x)=√3 2 x +2
2
f ' (x)= 3 <1 ∀ x ϵ (1 , 2)
3 √¿¿¿
Áp dụng phương pháp lặp ( thoả mãn định lý điều kiện đủ ):
Chọn x 0=2 ta có bảng giá trị sau :

f (x)=√ 2 x +2
x 3

2 1.817

1.817 1.779

1.779 1.771

1.771 1.77

1.77 1.769

=> Nghiệm phương trình x ≈1.769 .

Code:
#include <stdio.h>
#include <math.h>
double gx(double x) {
return pow(2*x + 2, 1.00/3) ;
}
double function(double x) {
double y;
do {
y = x;
x = gx(y);
} while (fabs(x - y) > 0.0001);
return x;
}
int main() {
double x;
printf("Nhap x: ");
scanf("%lf", &x);
double result = function(x);
printf("Ket qua: %lf\n", result);
return 0;
}

B, f (x)=√3 x 2 +1
5
6x
Ta có : f ' (x)= 5
5 √¿ ¿ ¿
Áp dụng phương pháp lặp ( thoả mãn định lý điều kiện đủ ):
Chọn x 0 = 1 ta có bảng giá trị sau :

x f (x)=√ 3 x 2 +1
5

1 1.319

1.319 1.441

1.441 1.485

1.485 1.501

1.501 1.506

1.506 1.508

1.508 1.509

=> Nghiệm phương trình x ≈1.509 .


Code:
#include <stdio.h>
#include <math.h>
double gx(double x) {
return pow((3*pow(x,2))+1, 1.00/5) ;
}
double function(double x) {
double y;
do {
y = x;
x = gx(y);
} while (fabs(x - y) > 0.0001);
return x;
}
int main() {
double x;
printf("Nhap x: ");
scanf("%lf", &x);
double result = function(x);
printf("Ket qua: %lf\n", result);
return 0;
}

You might also like