-- rderiv.adb compute coefficients for numerical derivatives a(0)... -- order is order of derivative, 1 = first derivative, 2 = second -- npoints is number of points where value of function is known -- f(x1), f(x2), f(x3) ... f(x npoints) -- xi+1 = xi + h -- term is the point where derivative is computed -- f'(xt) = aa(1) * f(x1) + aa(2) * f(x2) -- + ... + aa(points) * f(x points) -- see nuderiv for unequally spaced points with Ada.text_io; use Ada.text_io; with Real_Arrays; use Real_Arrays; with Nuderiv; procedure rderiv(order : integer; npoints : integer; point : integer; hx : Real; C : out Real_Vector) is xg : Real_Vector(1..npoints); a : Real_Vector(1..npoints); hpower : Real; begin for i in 1..npoints loop xg(i) := Real(i-1); end loop; Nuderiv(order, npoints, point, xg, a); hpower := hx; for i in 2..Order loop hpower := hpower * hx; end loop; for i in 1..npoints loop c(i) := a(i)/hpower; end loop; end rderiv;