midpnt.dem

来自「Delphi Pascal 数据挖掘领域算法包 数值算法大全」· DEM 代码 · 共 36 行

DEM
36
字号
PROGRAM d4r5(input,output);
(* driver for routine MIDPNT *)
CONST
   nmax=10;
VAR
   a,b,s : real;
   i,glit : integer;

FUNCTION func(x: real): real;
(* Function for testing integration *)
BEGIN
   func := 1.0/sqrt(x)
END;

FUNCTION fint(x: real): real;
(* Integral of 'func' *)
BEGIN
   fint := 2.0*sqrt(x)
END;

(*$I MODFILE.PAS *)
(*$I MIDPNT.PAS *)

BEGIN
   a := 0.0;
   b := 1.0;
   writeln;
   writeln ('Integral of func computed with MIDPNT');
   writeln ('Actual value of integral is',(fint(b)-fint(a)):7:4);
   writeln ('n':6,'Approx. integral':29);
   FOR i := 1 to nmax DO BEGIN
      midpnt(a,b,s,i);
      writeln (i:6,s:24:6)
   END
END.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?