Berilgan tenglamani oddiy iteratsiya usulidan foydalanib algoritmini va


Download 8.88 Kb.
Sana22.06.2020
Hajmi8.88 Kb.

4-Labaratoriya

Berilgan tenglamani oddiy iteratsiya usulidan foydalanib algoritmini va

dasturini tuzib yechimini toping

Masalaning Packal dasturida ishlanishi



Dastur kodi

Program Tenglama;

Uses Crt;

const

n=1; Eps=0.001;

var

i,j: integer;

a1: real;

a,b : array[1..5] of real;

x : array[0..100] of real;

f1 : text;

Function F(x1:real): real;

Begin

F:=sqr(x1)*x1+x1+a1;

end;

Begin

ClrScr;

assign(f1,'d:\javoblar.txt'); rewrite(f1);

a1:=-3;

a[1]:=-3;

For j:=1 to n do BEGIN

if F(a[j])<0 then Begin

x[0]:=a[j]; i:=0;

Repeat

x[i+1]:=x[i]-(F(x[i])/(F(a[j+1])-F(x[i])))*(a[j+1]-x[i]);

i:=i+1;

until Abs(x[i]-x[i-1])>Eps; End

else Begin

x[0]:=a[j+1]; i:=0;

Repeat

x[i+1]:=x[i]-(F(x[i])/(F(x[i])-F(a[j])))*(x[i]-a[j]);

i:=i+1;

until Abs(x[i]-x[i-1])>Eps; End;

Writeln(f1,'Ildiz yotgan oraliq [',a[j]:6:4,' ; ',a[j+1]:6:4,']');

Writeln(f1,'Tenglamaning ildizi = ',x[i]);

END;

Close(f1);

End.

Tenglamaning javobi D diskdagi javoblar.txt fayliga yoziladi.
Download 8.88 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2020
ma'muriyatiga murojaat qiling