Amaliy ishi № 4. Iteratsion usullar: Nyuton(Urinmalar) va vatarlar usuli. Ularning yaqinlashish tezligini baholash.
Nyuton (Urinmalar) usuli. f(x)=0 tenglama berilgan. Biror [a;b] oraliqda f(a)*f(b)<0 bo’lsin. [a,b] oraliqdagi (b,f(b)) nuqtadan urinma o’tkazamiz.
Nyuton (Urinma) usuli yordamida [a;b] oraliqda aniqlida taqribiy ildizlarini topish algoritm blok sxemasi.
Misol. tenglama taqribiy yechimini =0.01 aniqlik bilan toping.
Yechish. funktsiya [-1;0] oraliqda 1.3-teoremaning barcha shartlarini qanoatlantiradi.
, x[-1;0] va f(-1)=8.386>0 dan
bo’lgani uchun a0=-1 deb olinadi. ni e’tiborga olib, birinchi yaqinlashish a1 ni hisoblaymiz:
Yaqinlashish shartini tekshiramiz:
a1- a0 = -0.131+1= 0.869>=0.01
bo’lgani uchun ikkinchi yaqinlashish a2 ni
formula bilan topamiz.
lar asosida: a2=-0.131- 0.1895/(-9.123) = -0.1104.
Yana a2- a1 = 0.0214 > bo’lgani uchun a3 ni topamiz.
lar asosida: yaqinlashish sharti a3-a2< =0.01 bajarilganligi uchun tenglamaning =0.01 aniqlikdagi taqribiy yechimi:
x a3= -0.11 bo’ladi.
Vatarlar usuli f(x)=0 tenglama berilgan. Biror [a;b] oraliqda f(a)*f(b)<0 bo’lsin. [a;b] oraliqdagi (a,f(a)) va (b,f(b)) nuqtalardan vatar o’tkazamiz.
Misol. tenglamaning =0. 01 aniqlikdagi taqribiy ildizi topilsin.
Yechish. Ma’lumki funksiya [-1;0] oraliqda teoremalarning hamma shartlarini bajaradi. x[-1;0] da ikkinchi tartibli hosila . Demak f(0)=-1, f(-1) = 8.368 bo`lganligi uchun, f(a)*f(b)<0 shartga asosan f(0)f''(0)<0 bo`lgani uchun {an} ketma-ketlik vatarni topish formulasi bilan topiladi.
Berilganlar: a=-1, b=0, =0. 01
f(x)= yex-10x-2, f(-1)=e-1 -10(-1) -2=8. 386, f(0)=e0-10*0-2=-1
vatar ildizlarini topish formulasiga asosan:
b0= 0 b 1= b0 - (a- b0) f(b0)/ (f(a)-f(b0))= -0.107
Yaqinlashish sharti b1 - b2> bo`lganligi uchun b2 yaqinlashishni hisoblaymiz. Buning uchun b1= -0.107, f(-0.107)=e-0.107-10(-0.107)-2 =-0.038 , f(a)=f(-1)=8.386
larga asosan:
b2= b1 - (a- b 1) f(b 1)/ (f(a)-f(b 1)) = 0.111
b2- b1+- 0.111+0.107=0.004<=0. 01
Demak taqribiy yechim deb t= bn =-0.111 ni olish mumkin.
Urinmalar usuli uchun dastur kodi: Program Urinma;
Label 1,2,3,4;
Var a,b,x1, x2, eps : real;
Function F (x: real): real; Begin F: = … end;
Function F 1(x: real): real; Begin F 1: = … end;
Function F 2(x: real): real; Begin F 2: = … end;
Begin
writeln(‘a,b=’); readln(a,b);
writeln(‘ aniqlikni kiriting'); readln( eps);
if F1(a)*F2(a)>0 then x1:=b else goto 2;
1: x2:=x1 – F(x1) / F1(x1);
If abs(x2-x1)>eps then begin x1:=x2;goto1 end else goto3;
2 : if F1(a)*F2(a)<0 then x1:=a;
4: x2:=x1 – F(x1) / F1(x1);
If abs(x2-x1)>eps then begin x1:=x2;goto 4 end ;
3 : Writeln (‘tenglama yechimi= ‘,x); End.
Vatarlar usuli uchun dastur kodi: Program Vatar;
Label 1,2,3,4;
Var a,b,x1, x2, eps : real;
Function F (x: real): real; Begin F: = … end;
Function F 1(x: real): real; Begin F 1: = … end;
Function F 2(x: real): real; Begin F 2: = … end;
Begin
writeln(‘a,b=’); readln(a,b);
writeln(‘ aniqlikni kiriting'); readln( eps);
if F1(a)*F2(a)>0 then x1:=a else goto 2;
1: x2:=x1 – F(x1)*(b-x1) /(F(b)-F(x1));
If abs(x2-x1)>eps then begin x1:=x2;goto 1 end else goto 3;
2 : if F1(a)*F2(a)<0 then x1:=b;
4: x2:=x1 – F(x1)*(x1-a) / (F(x1)-F(a));
If abs(x2-x1)>eps then begin x1:=x2;goto 4 end ;
3 : Writeln (‘tenglama yechimi= ‘,x);
End.