Evaluation polynomial and its derivatives simultaneously
PROBLEM
Compute the value of a given polynomial A.N*X**N+...+A.1*X+A.0 of degree N and its first derivative at a given point V.
IMPLEMENTATION
Unit: nonrecursive internal function
Global variables:
vector A.0,A.1,...,A.N of coefficients from the set of real numbers
Parameters:
a positive integer N  the degree of the polynomial, real number V  a given point
Returns:
A pair of values separated by blank, evaluating the polynomial and its first derivative
DDPOLY1: procedure expose A.
parse arg N, V
P = A.N; D = 0
do J = N  1 to 0 by 1
D = D * V + P; P = P * V + A.J
end
P = A.N; D = 0; J = N
do J = N  1 to 0 by 1
D = D * V + P; P = P * V + A.J
end
return P D

PROBLEM
Compute the value of a given polynomial A.N*X**N+...+A.1*X+A.0 of degree N and its D derivatives at a given point V.
IMPLEMENTATION
Unit:
nonrecursive internal subroutine
Global variables:
input vector A.0,A.1,...,A.N of coefficients from the set of real numbers, output vector Pd.0,Pd.1,...,Pd.D of derivatives
Parameters:
a positive integer N  the degree of the polynomial, a positive integer D  number of derivatives, real number V  a given point
Result:
This routine computes the polynomial evaluated at V as Pd.0 and D derivatives as Pd.1,...,Pd.D
DDPOLY: procedure expose A. Pd.
parse arg N, D, V
Const = 1; Pd. = 0; Pd.0 = A.N
do I = N  1 to 0 by 1
if D < N  I then Nd = D; else Nd = N  I
do J = Nd to 1 by 1
Jm1 = J  1; Pd.J = Pd.J * V + Pd.Jm1
end
Pd.0 = Pd.0 * V + A.I
end
do I = 2 to D
Const = Const * I; Pd.I = Pd.I * Const
end
return

EXAMPLE For given values
N = 5; D = 5; V = 2
A. = 0
A.5 = 1; A.3=4; A.2 = 6
A.1 = 8; A.0 = 10
the first elements (with index 0 to 5) of Pd. array will 18,48,124,216,240,120
after the interpretation of call DDPOLY N, D, V statement
CONNECTIONS
Literature
Press W.H., Teukolsky S.A., Vetterling W.T., Flannery B.P. Numerical Recipes in C : the art of scientific computing  2nd ed. University Press, Cambridge, 1992
Faddejev A.K., Sominskij J.S. Sbornik zadac po vyssej algebre Nauka, Moskva 1964
