⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rk4.pas

📁 Delphi Pascal 数据挖掘领域算法包 数值算法大全
💻 PAS
字号:
PROCEDURE rk4(y,dydx: glnarray; n: integer; x,h: real; VAR yout: glnarray);
(* Programs using routine RK4 must provide a
PROCEDURE derivs(x:real; y:glnarray; VAR dydx:glnarray);
which returns the derivatives dydx at location x, given both x and the
function values y. The calling program must also define the types
TYPE
   glnarray = ARRAY [1..nvar] OF real;
where nvar is the number of variables y. *)
VAR
   i: integer;
   xh,hh,h6: real;
   dym,dyt,yt: glnarray;
BEGIN
   hh := h*0.5;
   h6 := h/6.0;
   xh := x+hh;
   FOR i := 1 TO n DO BEGIN
      yt[i] := y[i]+hh*dydx[i]
   END;
   derivs(xh,yt,dyt);
   FOR i := 1 TO n DO BEGIN
      yt[i] := y[i]+hh*dyt[i]
   END;
   derivs(xh,yt,dym);
   FOR i := 1 TO n DO BEGIN
      yt[i] := y[i]+h*dym[i];
      dym[i] := dyt[i]+dym[i]
   END;
   derivs(x+h,yt,dyt);
   FOR i := 1 TO n DO BEGIN
      yout[i] := y[i]+h6*(dydx[i]+dyt[i]+2.0*dym[i])
   END
END;

⌨️ 快捷键说明

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