close

Вход

Забыли?

вход по аккаунту

?

приложения (2)

код для вставкиСкачать
ПРИЛОЖЕНИЕ А
Код программы задания 2
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, StdCtrls, XPMan, Grids,
Series, math, ComCtrls;
type
TForm1 = class(TForm)
XPManifest1: TXPManifest;
RadioGroup1: TRadioGroup;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Chart1: TChart;
Label1: TLabel;
Label2: TLabel;
StringGrid1: TStringGrid;
Series1: TLineSeries;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n, m: integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form4.Show;
Form4.Timer1.Enabled:=True;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
T:array [0..16]of extended;
C,A,X,Y:array [0..9]of extended;
B:array [0..9,0..10]of extended;
i,k,j,m,n: Integer;
z: Real;
Bik, Delta, S, h, X2, pol: extended;
begin
if RadioGroup1.ItemIndex= -1 then begin
form2.show;
end
else
begin
Form1.Width:=851;
Chart1.Visible:=True;
Series1.Clear;
m:=9;
for i := 1 to m do begin
X[i]:=strtofloat(stringgrid1.cells[0,i]);
Y[i]:=strtofloat(stringgrid1.cells[1,i]);
memo1.Lines.Add(floattostr(X[i]));
memo1.Lines.Add(floattostr(Y[i]));
memo1.Clear;
end;
case RadioGroup1.ItemIndex of
2: n:=6;
1: n:=5;
0: n:=3;
end;
for i := 1 to m do begin
for j := 1 to 2*n do T[j]:=T[j]+power(X[i],j);
for j := 0 to n do C[j]:=C[j]+Y[i]*power(X[i],j);
end;
T[0]:=m;
for i := 0 to n do
for j := 0 to n do
B[i,j]:=T[i+j];
for i := 0 to n do B[i,n+1]:=C[i];
for k := 0 to n-1 do
for i := k to n do begin
Bik:=B[i,k];
for j := k to n+1 do
if i=k then B[i,j]:=B[i,j]/Bik
else B[i,j]:=B[i,j]/Bik-B[k,j];
end;
Memo1.Lines.Add('Коэффициенты полинома степени '+IntToStr(n));
for i := n downto 0 do
A[i]:=(B[i,n+1]-B[i,1]*A[1]-B[i,2]*A[2]-B[i,3]*A[3]-B[i,4]*A[4]-B[i,5]*A[5]-B[i,6]*A[6]-B[i,7]*A[7]-B[i,8]*A[8]-B[i,9]*A[9])/B[i,i];
for i := 0 to n do begin
Memo1.Lines.Add('A['+IntToStr(i)+'] = '+FloatToStr(A[i]));
end;
for i := 1 to m do begin
S:=0;
for j := 0 to n do S:=S+A[j]*power(X[i],j);
Delta:=Delta+sqr(S-Y[i]);
end;
Delta:=sqrt(Delta/m);
Memo1.Lines.Add('Дельта = '+FloatToStr(Delta));
h:=0.1;
X2:=100;
z:=10;
while (z<=X2) do
begin
pol:=A[0];
for i := 1 to n do
pol:=pol+A[i]*power(z,i);
Series1.AddXY(z,pol);
z:=z+h;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Visible:=false;
Memo1.Clear;
StringGrid1.Cells[0,0] := 'X';
StringGrid1.Cells[0,1] := '2,57';
StringGrid1.Cells[0,2] := '3,87';
StringGrid1.Cells[0,3] := '5,67';
StringGrid1.Cells[0,4] := '8,39';
StringGrid1.Cells[0,5] := '12,9';
StringGrid1.Cells[0,6] := '20,47';
StringGrid1.Cells[0,7] := '32,84';
StringGrid1.Cells[0,8] := '52,17';
StringGrid1.Cells[0,9] := '81,1';
StringGrid1.Cells[1,0] := 'Y';
StringGrid1.Cells[1,1] := '2,98';
StringGrid1.Cells[1,2] := '3,45';
StringGrid1.Cells[1,3] := '3,84';
StringGrid1.Cells[1,4] := '3,87';
StringGrid1.Cells[1,5] := '3,24';
StringGrid1.Cells[1,6] := '1,73';
StringGrid1.Cells[1,7] := '-0,67';
StringGrid1.Cells[1,8] := '-3,78';
StringGrid1.Cells[1,9] := '-7,07';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Form3.Show;
end;
end.
Документ
Категория
Рефераты
Просмотров
33
Размер файла
18 Кб
Теги
приложение
1/--страниц
Пожаловаться на содержимое документа