1) To’g’ri to’rtburchak usuli:
Algoritm
Boshlash
double s=0,x,f,h,a=exp,b=2*exp,n;
h=(b-a)/n
for(int i=1;i
x=a+h*i+h/2
F=ln(x-1)^2
s+=f
Cout<
Tamom
#include
using namespace std;
int main(){
double s=0,x,f,h,a=exp,b=2*exp,n;
cin>>n;
h=(b-a)/n;
for(int i=1;i<=n;i++){
x=a+h*i+h/2;
f=ln(x-1)*ln(x-1);
s+=f;
if(i%10==0){
cout< cout< cout< cout< }
}
cout< cout<}
2) Trapetsiya usuli:
Algoritm
Boshlash
double s=0,x,f,h,a=exp,b=2*exp,n;
h=(b-a)/n
for(int i=1;i
x=a+h*i+h/2
f=ln(x-1)^2
s+=f
Cout<
Tamom
#include
using namespace std;
int main(){
double s=0,x,f,h,a=exp,b=2*exp,n;
cin>>n;
h=(b-a)/n;
for(int i=1;i x=a+h*i+h/2;
f =ln(x-1)^2;
s+=f;
if(i%10==0){
cout< cout< cout< cout< }
}
cout< cout<}
3) Simpson usuli
Algoritm
Boshlash
double s=0,x,f,h,a=0,b=0.5,n;
h=(b-a)/n
s=sqrt((1+a)/(1-a))+sqrt((1+b)/(1-b));
for(int i=1;i
x=a+h*i+h/2
f=ln(x-1)^2
s+=f*4
for(int i=2;i
x=a+h*i+h/2
f=ln(x-1)^2
s+=f*2
Cout<
Tamom
#include
using namespace std;
int main(){
double s,x,f,h,a=0,b=0.5,n;
cin>>n;
h=(b-a)/n;
s=sqrt((1+a)/(1-a))+sqrt((1+b)/(1-b));
for(int i=1;i x=a+h*i+h/2;
f=ln(x-1)^2;
s+=f*4;
if(i%10==0){
cout< cout< cout< cout< }
}
for(int i=2;i x=a+h*i+h/2;
f= ln(x-1)^2;
s+=f*2;
if(i%10==0){
cout< cout< cout< cout< }
}
cout< cout<}
n
|
10
|
20
|
30
|
40
|
50
|
60
|
70
|
80
|
90
|
100
|
Integral qiymat
|
To’rtburchaklar usuli
|
|
0.0525
|
0.1025
|
0.1525
|
0.2025
|
0.2525
|
0.3025
|
0.3525
|
0.4025
|
0.4525
|
0.5025
|
|
f(x(i))/y(i)
|
1.0539
|
1.1083
|
1.1661
|
1.2279
|
1.2944
|
1.3665
|
1.4452
|
1.532
|
1.6287
|
1.7378
|
h*(f(x))
|
0.00526
|
0.0055
|
0.0058
|
0.0061
|
0.0064
|
0.0068
|
0.0072
|
0.0076
|
0.0081
|
0.0086
|
Trapetsiya usuli
|
|
0.0525
|
0.1025
|
0.1525
|
0.2025
|
0.2525
|
0.3025
|
0.3525
|
0.4025
|
0.4525
|
0.5025
|
|
f(x(i))/y(i)
|
2.1132
|
2.2222
|
2.3382
|
2.4623
|
2.5958
|
2.7406
|
2.8988
|
3.0733
|
3.2678
|
3.4873
|
h*(f(x))
|
0.01056
|
0.0111
|
0.0116
|
0.0123
|
0.0129
|
0.0137
|
0.0144
|
0.0153
|
0.0163
|
0.0174
|
Simpson usuli
|
|
0.0525
|
0.1025
|
0.1525
|
0.2025
|
0.2525
|
0.3025
|
0.3525
|
0.4025
|
0.4525
|
0.5025
|
|
f(x(i))/y(i)
|
1.0539
|
1.1083
|
1.1661
|
1.2279
|
1.2944
|
1.3665
|
1.4452
|
1.532
|
1.6287
|
1.7378
|
h/3*(f(x))
|
0.00527
|
0.00554
|
0.00583
|
0.00614
|
0.00647
|
0.00683
|
0.00723
|
0.00766
|
0.00814
|
0.00868
|
3. Berilgan algebraik va transsendent tenglamalarni yechishda oraliqni teng ikkiga
bo‘lish va vatarlar usullaridan foydalanib tenglamaning taqribiy ildizini 0.1, 0.01, 0.001,
0.0001, 0.00001, 0.000001 aniqliklarda hisoblansin. Olingan natijalar quyidagi jadvalga
to’ldirilib tahlil qilinsin.
1) Ikkiga bo’lish usuli:
Algoritm
Boshlash
double a,b,c,e,x; int s=0a[
a,b,e ni kiriting
If(funksiya(a) *funksiya(b)<0)
Tamom
x ni chiqar
“Oraliq noto’g’ri” deb chiqar
x=c
While((b-a)/2>e
c=(a+b)/2
s=s+1
b=c
a=c
If(funksiya(a) *funksiya(c)<0)
c=(a+b)/2
#include
using namespace std;
double funksiya(double x){
return log(1+8/(1+x*x*x*x))-x*x+16;
}
int main(){
double a,b,c,e,x; int s=0;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
cout<<"e="; cin>>e;
if(funksiya(a)*funksiya(b)<0){
c=(a+b)/2;
while((b-a)/2>e){
if(funksiya(a)*funksiya(c)<0)
b=c;
else
a=c;
c=(a+b)/2;
s+=1;
}
x=c;
cout<<"x="< cout< }
else
cout<<"oraliq noto'g'ri";
}
2) Vatarlar usuli:
Algoritm
#include
using namespace std;
double F(double x){
return log(1+8/(1+x*x*x*x))-x*x+16;
}
double F1(double x){
return log(1+8/(1+x*x*x*x))-x*x+16;
}
double F2(double x){
log(1+8/(1+x*x*x*x))-x*x+16;
}
int main(){
double a, b, S=0, x1, x2, e;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
cout<<"e="; cin>>e;
if(F1(a)*F2(a)>0) x1=a;
else goto _2;
_1:
x2=x1-F(x1)*(b-x1)/(F(b)-F(x1));
if(F1(a)*F2(a)<0) x1=b;
if(abs(x2-x1)>e){
x1=x2;
goto _1;
}
else goto _3;
_2:
if(F1(a)*F2(a)<0) x1=b;
_4:
x2=x1-F(x1)*(x1-a)/(F(x1)-F(a));
if(abs(x1-x2)>e){
x1=x2;
goto _4;
}
_3:
cout< return 0;
}
Usul \ e=
|
0.1
|
0.01
|
0.001
|
0.0001
|
0.00001
|
0.000001
|
Kesmani teng 2 ga bo’lish
|
-1.30
|
-1.331254
|
-1.333597
|
-1.333310
|
-1.3332714
|
-1.3332717
|
Vatarlar usuli
|
-1.32843
|
-1.32843
|
-1.3331
|
-1.33327
|
-1.33327
|
-1.3332723
|
Do'stlaringiz bilan baham: |