Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
34
Добавлен:
25.03.2015
Размер:
3 Кб
Скачать
☆
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Menus, TeEngine, Series, ExtCtrls, TeeProcs,
  Chart, OleCtnrs;

type
  TForm1 = class(TForm)
    mm1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    btn1: TBitBtn;
    lbl1: TLabel;
    lbl2: TLabel;
    lbl3: TLabel;
    edt1: TEdit;
    edt2: TEdit;
    edt3: TEdit;
    cht1: TChart;
    Series1: TLineSeries;
    Series2: TLineSeries;
    lbl4: TLabel;
    olcntnr1: TOleContainer;
    Label1: TLabel;
    edt4: TEdit;
    lbl5: TLabel;
    lbl6: TLabel;
    lbl7: TLabel;
    lbl8: TLabel;
    lbl9: TLabel;
    lbl10: TLabel;
    lbl11: TLabel;
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  a,b,x,h,e:Real;
  i:Byte;

implementation

{$R *.dfm}

function f(x:Real):real;
begin
f:=4*x-5;
end;

function f1(x:Real):Real;
begin
f1:=5*ln(x);
end;

function f2(x:Real):real;
begin
f2:=4*x-5*ln(x)-5;
end;


//Ввод интервалов и шага
procedure TForm1.N1Click(Sender: TObject);
begin
if (edt1.text='') or (edt2.text='') or (edt3.text='') then lbl4.caption:='Введите значения a и b!'
                        else begin
a:=strtofloat(edt1.text);
b:=strtofloat(edt2.text);
h:=strtofloat(edt3.text);
if (a>b) or (a=0) then lbl4.caption:='Введены неверные значения a и b!'
       else begin lbl4.caption:='';
end;
end;
end;

//Построение графика
procedure TForm1.N2Click(Sender: TObject);
begin
Series1.Clear;
Series2.Clear;
x:=a;
if a>b then lbl4.caption:='Введены неверные значения a и b!'
       else begin lbl4.caption:='';
repeat
Series1.AddXY(x,f(x));
Series2.AddXY(x,f1(x));
x:=x+h;
until x>b;
end;
end;

//Ввод точности
procedure TForm1.N3Click(Sender: TObject);
begin
e:=strtofloat(edt4.text);
end;

//Метод половинных делений
procedure TForm1.N4Click(Sender: TObject);
var x,a,b,n:Real; k:Byte;
begin
a:=2;
b:=3;
k:=0;
repeat
x:=(a+b)/2;
k:=k+1;
if f2(a)*f2(x)<0 then b:=x
                 else a:=x;
until b-a<e;
n:=4*x-5*ln(x)-5;
lbl5.Caption:=lbl5.Caption+'  '+format('%5.4f',[x]);
lbl6.Caption:=lbl6.Caption+'  '+floattostr(k);
lbl7.Caption:=lbl7.Caption+'  '+format('%5.4f',[n]);
end;

//Метод хорд
procedure TForm1.N5Click(Sender: TObject);
var x,n,a,b:Real; k:Byte;
begin
a:=2;
b:=3;
x:=2;
k:=0;
repeat
k:=k+1;
x:=a-(b-a)*f2(a)/(f2(b)-f2(a));
if f2(a)*f2(x)<0 then b:=x
                 else a:=x;

until( Abs(f2(x))<e) or (k>20);

n:=4*x-5*ln(x)-5;
lbl8.Caption:=lbl8.Caption+'  '+format('%5.4f',[x]);
lbl9.Caption:=lbl9.Caption+'  '+floattostr(k);
lbl10.Caption:=lbl10.Caption+'  '+format('%5.6f',[n]);
end;
end.
Соседние файлы в папке Лабораторная работа №6
  • #
    25.03.2015188 б33Project1.dpr
  • #
    25.03.2015876 б33Project1.res
  • #
    25.03.20159 Кб33Unit1.dcu
  • #
    25.03.201551 б33Unit1.ddp
  • #
    25.03.201542 Кб33Unit1.dfm
  • #
    25.03.20153 Кб34Unit1.pas
  • #
    25.03.201521 Кб33Лаб 4 Mathcad.xmcd
  • #
    25.03.201538 Кб36Лабораторная работы №1,2,3,4.xlsx