Лабы / 4
.docxЗадание:
2 |
Хорд, |
Код:
Function f(x:real):real;
begin
F:=x*x*x*x+7*x*x*x-x+12;
//F:=x*x*x*x-x*x*x+x*x-63;
end;
procedure TForm6.Button2Click(Sender: TObject);
var
i:integer;
x,e,a,b,c,y:real;
label l;
begin
e:=strtofloat(edit2.text);
a:=strtofloat(edit5.text);
b:=strtofloat(edit1.text);
l:c:=a-f(a)*(b-a)/(f(b)-f(a));
if abs(f(c))>e then begin
if f(a)*f(c)<0 then begin
b:=c;
goto l
end else begin
a:=c;
goto l;
end;
end;
//вывод
edit7.Text:=floattostr(c);
edit8.Text:=floattostr(f(c));
end;
procedure TForm6.Button1Click(Sender: TObject);
var o,u,h:real;
begin
o:=strtofloat(edit3.text);
u:=strtofloat(edit4.text);
while o<u do begin
h:=f(o);
series1.addxy(o,h);
o:=o+0.01;
end;
end;
end.
Результат:
Блок схема: