delphi数值算法集光盘源代码,用于delphi7科学出版社出版.

源代码在线查看: d3r1.txt

软件大小: 1429 K
上传用户: awake2
关键词: delphi7 delphi 数值算法 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

				implementation
				//PROGRAM D3R1
				//Driver for routine TRAPZD
				uses
				  unit2;
				  {$R *.DFM}
				Function FUNC(X:real):real;
				begin
				    FUNC:= Sqr(X) * (Sqr(x) - 2) * Sin(X);
				end;
				
				Function FINT(X:real):real;
				//Integral of FUNC
				var
				    AAA:real;
				begin
				    AAA:= 4 * X * (Sqr(x) - 7) * Sin(X);
				    FINT:= AAA - (Sqr(Sqr(x)) - 14 * Sqr(x) + 28) * Cos(X);
				end;
				
				procedure TForm1.Button1Click(Sender: TObject);
				var
				  F:TextFile;   I:Integer;
				  A,B,S:real;
				const
				  s1='%16.6f'; s2='###';s3='%9.6f';
				  NMAX = 14; PIO2=1.5707963;
				begin
				  A:=0;
				  B:=PIO2;
				  //输出计算结果到文件
				  AssignFile(F, 'd:\delphi_shu\p3\d3r1.dat');
				  Rewrite(F);
				  Writeln(F, 'Integral of FUNC with 2^(n-1) points');
				  Writeln(F, 'Actual value of integral is: ',
				            format(s3,[(fint(b)-fint(a))]));
				  Writeln(F, '    n     Approx. Integral');
				  For I:= 1 To NMAX do
				  begin
				      TRAPZD(A,B,S,I);
				      Writeln(F,'    ',FormatFloat(s2,I),Format(s1,[s]));
				  end;
				  CloseFile(F);
				  //屏幕显示计算结果
				  memo1.Lines.LoadFromFile('d:\delphi_shu\p3\d3r1.dat');
				end;			

相关资源