Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
курсач основ..docx
Скачиваний:
84
Добавлен:
04.03.2016
Размер:
664.9 Кб
Скачать

Список литературы

  1. Архангельский, А. Я. Программирование в Delphi 6 / А.Я. Архангельский – М.: ЗАО «Издательство БИНОМ», 2002 г. – 1120 с.

  2. Бобровский С. И. Delphi 7 : учебный курс / С.И.Бобровский. — СПб.: Питер, 2004. — 736 с.

  3. Епанешников, А. М. Программирование в среде Turbo Pascal 7.0 / А. М. Епанешников, В. А. Епанешников. - Москва: «Диалог – МИФИ», 2000г. − 368 с.

  4. Задания и методические указания по выполнению, оформлению и защите курсовых работ для студентов заочной и очной формы обучения специальностей 1-36 01 01, 1-36 01 03 / авт.-сост. О. И.Наранович. − Барановичи: БарГУ, 2009. – 20 с.

  5. Фаронов, В. В. Delphi 6 : учебный курс / под ред. С. В. Молгачев, 2001. – 672 с.

  6. Шейкер, Т. Д. Разработка приложений в системе Delphi : учеб. пособие / Т. Д. Шейкер. – Владивосток: Изд-во ДВГТУ, 2006. – 172 с.

ПРИЛОЖЕНИЕА

Полный код программы (задание 1):

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart;

type

TForm1 = class(TForm)

Button1: TButton;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Memo1: TMemo;

Button2: TButton;

Button3: TButton;

Button4: TButton;

Chart1: TChart;

Series1: TLineSeries;

Button5: TButton;

Button6: TButton;

Button7: TButton;

Button8: TButton;

procedure FormActivate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

procedure Button6Click(Sender: TObject);

procedure Button7Click(Sender: TObject);

procedure Button8Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);

begin

memo1.Lines.Clear;

end;

// метод деления пополам

procedure TForm1.Button1Click(Sender: TObject);

function f(x:real):real;

var a:real;

begin

a:=strtofloat(edit4.Text);

f:=a*(exp((a/2)*ln(x)))+exp((a/2)*ln(cos(x*x*x)))+ln(a*(sin(x)/ /cos(x)))+a*sqrt(exp(-x)/exp(a*ln(x)))+a;

end;

var a,x1,x2,c,e:real;

begin

a:=strtofloat(edit4.Text);

e:=strtofloat(edit3.text);

x1:=strtofloat(edit1.text);

x2:=strtofloat(edit2.text);

while abs(x2-x1)>e do

begin

c:=(x2+x1)/2;

if f(x1)*f(c)<0 then x2:=c else x1:=c; end;

c:= (x2+x1)/2;

memo1.lines.add('Корень по методу деления пополам: '+

floattostrf(c,ffgeneral,5,3));

end;

// метод касательных

procedure TForm1.Button3Click(Sender: TObject);

function f(x:real):real;

var a:real;

begin

a:=strtofloat(edit4.Text);

f:=a*(exp((a/2)*ln(x)))+exp((a/2)*ln(cos(x*x*x)))+ln(a*(sin(x)/cos(x)))+a*sqrt(exp(-x)/exp(a*ln(x)))+a;

end;

function p(x:real):real;

var a:real;

begin

a:=strtofloat(edit4.Text);

p:=(exp(2*ln(sin(x)/cos(x)))+1)/(sin(x)/cos(x))+(exp(2*ln(a))*exp((a-1)*ln(x)))/(2*exp((a/2)*ln(x)))-(3*a*exp(2*ln(x))*exp((a/2-1)*ln(cos(x*x*x)))*sin(x*x*x))/2 ;

end;

function pp(x:real):real;

var a:real;

begin

a:=strtofloat(edit4.Text);

pp:=2*exp(2*ln(sin(x)/cos(x)))-exp(2*ln(exp(2*ln(sin(x)/cos(x)))+1))/exp(2*ln(sin(x)/cos(x)))-(a*a*a*exp((2*a-2)*ln(x)))/4*exp(3/2*ln(exp(a*ln(x)))+(a*a*exp((a-2)*ln(x))*(a-1))/2*exp((a/2)*ln(x))-3*a*x*exp((a/2-1)*ln(cos(x*x*x)))*sin(x*x*x)-(9*a*x*x*x*x*cos(x*x*x)*exp((a/2-1)*ln(cos(x*x*x))))/2+(9*a*x*x*x*x*exp((a/2-2)*ln(cos(x*x*x)))*exp(2*ln(sin(x*x*x)))*(a/2-1))/2+2);

end;

var x1,x2,e,c,d,b,s:real;

begin

e:=strtofloat(edit3.text);

x1:=strtofloat(edit1.text);

x2:=strtofloat(edit2.text);

b:=x2;

if f(b)*pp(b)<0 then b:=x1;

repeat

s:=b-f(b)/p(b);

if abs(s)>1

then d:=abs((s-b)/s)

else d:=abs(s-b);

b:=s;

until (d<e);

memo1.Lines.add('Корень по методу касательных: '+floattostrf(s, ffgeneral,5,3));

end;

//метод хорд

procedure TForm1.Button4Click(Sender: TObject);

function f(x:real):real;

var a:real;

begin

a:=strtofloat(edit4.Text);

f:=a*(exp((a/2)*ln(x)))+exp((a/2)*ln(cos(x*x*x)))+ln(a*(sin(x)/cos(x)))+a*sqrt(exp(-x)/exp(a*ln(x)))+a;

end;

function p(x:real):real;

var a:real;

begin

a:=strtofloat(edit4.Text);

p:=(exp(2*ln(sin(x)/cos(x)))+1)/(sin(x)/cos(x))+(exp(2*ln(a))*exp((a-1)*ln(x)))/(2*exp((a/2)*ln(x)))-(3*a*exp(2*ln(x))*exp((a/2-1)*ln(cos(x*x*x)))*sin(x*x*x))/2 ;

end;

function pp(x:real):real;

var a:real;

begin

a:=strtofloat(edit4.Text);

pp:=2*exp(2*ln(sin(x)/cos(x)))-exp(2*ln(exp(2*ln(sin(x)/cos(x)))+1))/exp(2*ln(sin(x)/cos(x)))-(a*a*a*exp((2*a-2)*ln(x)))/4*exp(3/2*ln(exp(a*ln(x)))+(a*a*exp((a-2)*ln(x))*(a-1))/2*exp((a/2)*ln(x))-3*a*x*exp((a/2-1)*ln(cos(x*x*x)))*sin(x*x*x)-(9*a*x*x*x*x*cos(x*x*x)*exp((a/2-1)*ln(cos(x*x*x))))/2+(9*a*x*x*x*x*exp((a/2-2)*ln(cos(x*x*x)))*exp(2*ln(sin(x*x*x)))*(a/2-1))/2+2);

end;

var x1,x2,e,c,x0,x,s1:real;

begin

e:=strtofloat(edit3.text);

x1:=strtofloat(edit1.text);

x2:=strtofloat(edit2.text);

x:=x1;

c:=x2;

if f(c)*pp(c)<0 then begin c:=x1;x:=x2 end;

repeat

x0:=x;

x:=(c*f(x0)-x0*f(c))/(f(x0)-f(c));

until abs(f(x))/0.0001<=e;

s1:=x;

Memo1.lines.Add('Корень по методу хорд: '+floattostrf(s1,ffgeneral,5,3));

end;

//очистка данных

procedure TForm1.Button2Click(Sender: TObject);

begin

memo1.Lines.Clear;

end;

procedure TForm1.Button5Click(Sender: TObject);

var a,x1,x2,x,h,f,f1,f2:real;

begin

series1.Clear;

a:=strtofloat(edit4.Text);

x1 := strtofloat(Edit1.Text);

x2 := strtofloat(Edit2.Text);

h := 0.05;

x:=x1;

while x<=x2 do

begin

f:=a*(exp((a/2)*ln(x)))+exp((a/2)*ln(cos(x*x*x)))+ln(a*(sin(x)/cos(x)))+a*sqrt(exp(-x)/exp(a*ln(x)))+a; series1.addXY(x,f);

x:=x+h;

end;

end;

procedure TForm1.Button6Click(Sender: TObject);

begin

series1.Clear;

end;

procedure TForm1.Button7Click(Sender: TObject);

begin

close;

end;

procedure TForm1.Button8Click(Sender: TObject);

begin

Form2.Visible:=True;

end;

end.

ПРИЛОЖЕНИЕ Б

Полный код программы (задание 2):

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, TeEngine, Series, StdCtrls, ExtCtrls, TeeProcs, Chart;

type

TForm1 = class(TForm)

StringGrid1: TStringGrid;

Chart1: TChart;

Button1: TButton;

Button2: TButton;

Series1: TFastLineSeries;

Series2: TFastLineSeries;

Series3: TFastLineSeries;

Series4: TFastLineSeries;

Memo1: TMemo;

procedure ZXC(n:integer);

procedure ASD(n:integer);

procedure FormCreate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

T:array [0..14] of extended;

Yi,Xi,C,A:array[0..41] of extended;

B:array [0..7,0..8] of extended;

i,j,k,s:integer;

Y,St,Bik,Dt:extended;

uravn,plus:string;

implementation

{$R *.dfm}

procedure TForm1.ZXC(n:integer);

begin

//Обнуляем массивы

for i:=0 to 14 do T[i]:=0;

for i:=0 to 7 do begin C[i]:=0; A[i]:=0 end;

for i:=0 to 7 do

for j:=0 to 8 do B[i,j]:=0;

//Вводим исходные данные

for i:=1 to 40 do begin

Xi[i]:=Strtofloat(StringGrid1.Cells[1,i]);

Yi[i]:=Strtofloat(StringGrid1.Cells[2,i]); end;

//Вычисляем коэффициенты Т и С

for i:=1 to 2*n do begin

St:=0;

for j:=1 to 40 do

St:=St+exp(i*ln(abs(Xi[j])));

T[i]:=St;

end;

for i:=0 to n do begin

St:=0;

for j:=1 to 40 do

St:=St+(exp(i*ln(abs(Xi[j]))))*yi[j];

C[i]:=St;

end;

//end;

T[0]:=40;//Формируем расширенную матрицу системы уравнений

for i:=0 to n do

for j:=0 to n do

B[i,j]:=T[j+i];

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,i];

end;

procedure TForm1.ASD(n:integer);

begin

ZXC(n);

for i:=0 to n do

Memo1.Lines.Add('A['+inttostr(i)+']='+floattostr(A[i]));

Memo1.Lines.Add('Уравнение:');

uravn:='';

for i:=0 to n do

begin

if a[i]>0 then

plus:='+'

else plus:='';

uravn:=uravn+plus+floattostrf(A[i],fffixed,8,5)+'*x^'+floattostr(i)+' ';

end;

Memo1.Lines.Add('y='+uravn);

//Вычисляем среднеквадратичное отклонение

//И строим графики

Chart1.Series[3].Clear;

Memo1.Lines.Add('Среднеквадратичное отклонение');

Dt:=0;

case n of

2:s:=0;

3:s:=1;

4:s:=2;

end;

for i:=1 to 40 do begin

Xi[i]:=Strtofloat(StringGrid1.Cells[1,i]);

Yi[i]:=Strtofloat(StringGrid1.Cells[2,i]);

Y:=0;

for j:=0 to n do begin

St:=1;

for k:=1 to j do St:=St*Xi[i];

Y:=Y+A[j]*St

end;

Dt:=Dt+sqr(Y-Yi[i]);

Chart1.Series[s].AddXY(Xi[i],Y);

Chart1.Series[3].AddXY(Xi[i],Yi[i]);

end;

Dt:=sqrt(Dt/40);

Memo1.Lines.Add(floattostr(Dt));

Memo1.Lines.Add('');

end;

procedure TForm1.FormCreate(Sender: TObject);

var i:byte;

h,n,l,j:real;

begin

stringgrid1.Cells[1,0]:='Xi';

stringgrid1.Cells[2,0]:='ln|Yi|';

StringGrid1.Cells[3,0]:='Yi';

for i:=1 to 40 do

stringgrid1.Cells[0,i]:=inttostr(i);

stringgrid1.Cells[1,1]:='0,1'; stringgrid1.Cells[2,1]:=FloatToStr(ln(2.98));

stringgrid1.Cells[1,2]:='0,3'; stringgrid1.Cells[2,2]:=FloatToStr(ln(3.45));

stringgrid1.Cells[1,3]:='0,5'; stringgrid1.Cells[2,3]:=FloatToStr(ln(3.84));

stringgrid1.Cells[1,4]:='0,7'; stringgrid1.Cells[2,4]:=FloatToStr(ln(3.87));

stringgrid1.Cells[1,5]:='0,9'; stringgrid1.Cells[2,5]:=FloatToStr(ln(3.24));

stringgrid1.Cells[1,6]:='1,1'; stringgrid1.Cells[2,6]:=FloatToStr(ln(1.73));

stringgrid1.Cells[1,7]:='1,3'; stringgrid1.Cells[2,7]:=FloatToStr(ln(0.67));

stringgrid1.Cells[1,8]:='1,5'; stringgrid1.Cells[2,8]:=FloatToStr(ln(3.78));

stringgrid1.Cells[1,9]:='1,7'; stringgrid1.Cells[2,9]:=FloatToStr(ln(7.07));

stringgrid1.Cells[1,10]:='1,9'; stringgrid1.Cells[2,10]:=FloatToStr(ln(9.62));

stringgrid1.Cells[1,11]:='2,1'; stringgrid1.Cells[2,11]:=FloatToStr(ln(10.04));

stringgrid1.Cells[1,12]:='2,3'; stringgrid1.Cells[2,12]:=FloatToStr(ln(6.39));

stringgrid1.Cells[1,13]:='2,5'; stringgrid1.Cells[2,13]:=FloatToStr(ln(3.89));

stringgrid1.Cells[1,14]:='2,7'; stringgrid1.Cells[2,14]:=FloatToStr(ln(24.08));

stringgrid1.Cells[1,15]:='2,9'; stringgrid1.Cells[2,15]:=FloatToStr(ln(58.21));

stringgrid1.Cells[1,16]:='3,1'; stringgrid1.Cells[2,16]:=FloatToStr(ln(111.19));

stringgrid1.Cells[1,17]:='3,3'; stringgrid1.Cells[2,17]:=FloatToStr(ln(188.86));

stringgrid1.Cells[1,18]:='3,5'; stringgrid1.Cells[2,18]:=FloatToStr(ln(298.07));

stringgrid1.Cells[1,19]:='3,7'; stringgrid1.Cells[2,19]:=FloatToStr(ln(446.74));

stringgrid1.Cells[1,20]:='3,9'; stringgrid1.Cells[2,20]:=FloatToStr(ln(643.99));

stringgrid1.Cells[1,21]:='4,1'; stringgrid1.Cells[2,21]:=FloatToStr(ln(900.13));

stringgrid1.Cells[1,22]:='4,3'; stringgrid1.Cells[2,22]:=FloatToStr(ln(1226.83));

stringgrid1.Cells[1,23]:='4,5'; stringgrid1.Cells[2,23]:=FloatToStr(ln(1637.14));

stringgrid1.Cells[1,24]:='4,7'; stringgrid1.Cells[2,24]:=FloatToStr(ln(2145.58));

stringgrid1.Cells[1,25]:='4,9'; stringgrid1.Cells[2,25]:=FloatToStr(ln(2768.2));

stringgrid1.Cells[1,26]:='5,1'; stringgrid1.Cells[2,26]:=FloatToStr(ln(3532.71));

stringgrid1.Cells[1,27]:='5,3'; stringgrid1.Cells[2,27]:=FloatToStr(ln(4428.49));

stringgrid1.Cells[1,28]:='5,5'; stringgrid1.Cells[2,28]:=FloatToStr(ln(5506.72));

stringgrid1.Cells[1,29]:='5,7'; stringgrid1.Cells[2,29]:=FloatToStr(ln(6780.41));

stringgrid1.Cells[1,30]:='5,9'; stringgrid1.Cells[2,30]:=FloatToStr(ln(8274.53));

stringgrid1.Cells[1,31]:='6,1'; stringgrid1.Cells[2,31]:=FloatToStr(ln(10016.04));

stringgrid1.Cells[1,32]:='6,3'; stringgrid1.Cells[2,32]:=FloatToStr(ln(12033.99));

stringgrid1.Cells[1,33]:='6,5'; stringgrid1.Cells[2,33]:=FloatToStr(ln(14359.59));

stringgrid1.Cells[1,34]:='6,7'; stringgrid1.Cells[2,34]:=FloatToStr(ln(17026.29));

stringgrid1.Cells[1,35]:='6,9'; stringgrid1.Cells[2,35]:=FloatToStr(ln(20069.86));

stringgrid1.Cells[1,36]:='7,1'; stringgrid1.Cells[2,36]:=FloatToStr(ln(23528.45));

stringgrid1.Cells[1,37]:='7,3'; stringgrid1.Cells[2,37]:=FloatToStr(ln(27442.7));

stringgrid1.Cells[1,38]:='7,5'; stringgrid1.Cells[2,38]:=FloatToStr(ln(31855.77));

stringgrid1.Cells[1,39]:='7,7'; stringgrid1.Cells[2,39]:=FloatToStr(ln(36813.46));

stringgrid1.Cells[1,40]:='7,9'; stringgrid1.Cells[2,40]:=FloatToStr(ln(42364.27));

stringgrid1.Cells[3,1]:='2.98';

stringgrid1.Cells[3,2]:='3.45';

stringgrid1.Cells[3,3]:='3.84';

stringgrid1.Cells[3,4]:='3.87';

stringgrid1.Cells[3,5]:='3.24';

stringgrid1.Cells[3,6]:='1.73';

stringgrid1.Cells[3,7]:='-0.67';

stringgrid1.Cells[3,8]:='-3.78';

stringgrid1.Cells[3,9]:='-7.07';

stringgrid1.Cells[3,10]:='-9.62';

stringgrid1.Cells[3,11]:='-10.04';

stringgrid1.Cells[3,12]:='-6.39';

stringgrid1.Cells[3,13]:='3.89';

stringgrid1.Cells[3,14]:='24.08';

stringgrid1.Cells[3,15]:='58.21';

stringgrid1.Cells[3,16]:='111.19';

stringgrid1.Cells[3,17]:='188.86';

stringgrid1.Cells[3,18]:='298.07';

stringgrid1.Cells[3,19]:='446.74';

stringgrid1.Cells[3,20]:='643.99';

stringgrid1.Cells[3,21]:='900.13';

stringgrid1.Cells[3,22]:='1226.83';

stringgrid1.Cells[3,23]:='1637.14';

stringgrid1.Cells[3,24]:='2145.58';

stringgrid1.Cells[3,25]:='2768.2';

stringgrid1.Cells[3,26]:='3532.71';

stringgrid1.Cells[3,27]:='4428.49';

stringgrid1.Cells[3,28]:='5506.72';

stringgrid1.Cells[3,29]:='6780.41';

stringgrid1.Cells[3,30]:='8274.53';

stringgrid1.Cells[3,31]:='10016.04';

stringgrid1.Cells[3,32]:='12033.99';

stringgrid1.Cells[3,33]:='14359.59';

stringgrid1.Cells[3,34]:='17026.29';

stringgrid1.Cells[3,35]:='20069.86';

stringgrid1.Cells[3,36]:='23528.45';

stringgrid1.Cells[3,37]:='27442.7';

stringgrid1.Cells[3,38]:='31855.77';

stringgrid1.Cells[3,39]:='3613.46';

stringgrid1.Cells[3,40]:='42364.27';

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

ASD(2);

ASD(3);

ASD(4);

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

close;

end;

end.

ПРИЛОЖЕНИЕ В