PROGRAM POLNML REAL C(50),X,Y INTEGER N, I C C Evaluates a polynomial of degree N: C C(1)*X^N + C(2)*X^(N-1) + ... + C(N)*X + C(N+1) C in NP equidistant points of an interval [A,B]. C N = 5 A = -2. B = 2. NP = 41 C C(1) = 0.5 C(2) = -0.25 C(3) = 4. C(4) = -2. C(5) = 0.6 C(6) = 1. C OPEN(1,FILE='respol.dat',STATUS='UNKNOWN') C H = (B - A)/FLOAT(NP-1) DO 10 I = 1,NP X = A + (I-1)* H CALL POLVAL(N,C,X,Y) WRITE(1,100) X,Y 10 CONTINUE 100 FORMAT(2F15.6) STOP END SUBROUTINE POLVAL(N,A,X,PX) C C Calculates the value of a polynomial of degree n evaluated at X, i.e. C PX = A(1)*X^N + A(2)*X^(N-1) + ... + A(N)*X + A(N+1) C REAL A(*), X, PX INTEGER N, I PX = A(N+1) DO 10 I = 1,N PX = PX + A(I) * X**(N-I+1) 10 CONTINUE RETURN END