home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
fortran
/
library
/
ssp
/
numdiff
/
det5.for
< prev
next >
Wrap
Text File
|
1985-11-29
|
3KB
|
89 lines
C
C ..................................................................
C
C SUBROUTINE DET5
C
C PURPOSE
C TO COMPUTE A VECTOR OF DERIVATIVE VALUES GIVEN A VECTOR OF
C FUNCTION VALUES WHOSE ENTRIES CORRESPOND TO EQUIDISTANTLY
C SPACED ARGUMENT VALUES.
C
C USAGE
C CALL DET5(H,Y,Z,NDIM,IER)
C
C DESCRIPTION OF PARAMETERS
C H - CONSTANT DIFFERENCE BETWEEN SUCCESSIVE ARGUMENT
C VALUES (H IS POSITIVE IF THE ARGUMENT VALUES
C INCREASE AND NEGATIVE OTHERWISE)
C Y - GIVEN VECTOR OF FUNCTION VALUES (DIMENSION NDIM)
C Z - RESULTING VECTOR OF DERIVATIVE VALUES (DIMENSION
C NDIM)
C NDIM - DIMENSION OF VECTORS Y AND Z
C IER - RESULTING ERROR PARAMETER
C IER = -1 - NDIM IS LESS THAN 5
C IER = 0 - NO ERROR
C IER = 1 - H = 0
C
C REMARKS
C (1) IF IER = -1,1, THEN THERE IS NO COMPUTATION.
C (2) Z CAN HAVE THE SAME STORAGE ALLOCATION AS Y. IF Y IS
C DISTINCT FROM Z, THEN IT IS NOT DESTROYED.
C
C SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C NONE
C
C METHOD
C IF X IS THE (SUPPRESSED) VECTOR OF ARGUMENT VALUES, THEN
C EXCEPT AT THE POINTS X(1),X(2),X(NDIM-1) AND X(NDIM), Z(I)
C IS THE DERIVATIVE AT X(I) OF THE LAGRANGIAN INTERPOLATION
C POLYNOMIAL OF DEGREE 4 RELEVANT TO THE 5 SUCCESSIVE POINTS
C (X(I+K),Y(I+K)) K = -2,-1,...,2. (SEE HILDEBRAND, F.B.,
C INTRODUCTION TO NUMERICAL ANALYSIS, MC GRAW-HILL, NEW YORK/
C TORONTO/LONDON, 1956, PP. 82-84.)
C
C ..................................................................
C
SUBROUTINE DET5(H,Y,Z,NDIM,IER)
C
C
DIMENSION Y(1),Z(1)
C
C TEST OF DIMENSION
IF(NDIM-5)4,1,1
C
C TEST OF STEPSIZE
1 IF(H)2,5,2
C
C PREPARE DIFFERENTIATION LOOP
2 HH=.08333333/H
YY=Y(NDIM-4)
B=HH*(-25.*Y(1)+48.*Y(2)-36.*Y(3)+16.*Y(4)-3.*Y(5))
C=HH*(-3.*Y(1)-10.*Y(2)+18.*Y(3)-6.*Y(4)+Y(5))
C
C START DIFFERENTIATION LOOP
DO 3 I=5,NDIM
A=B
B=C
C=HH*(Y(I-4)-Y(I)+8.*(Y(I-1)-Y(I-3)))
3 Z(I-4)=A
C END OF DIFFERENTIATION LOOP
C
C NORMAL EXIT
IER=0
A=HH*(-YY+6.*Y(NDIM-3)-18.*Y(NDIM-2)+10.*Y(NDIM-1)+3.*Y(NDIM))
0Z(NDIM)=HH*(3.*YY-16.*Y(NDIM-3)+36.*Y(NDIM-2)-48.*Y(NDIM-1)
1 +25.*Y(NDIM))
Z(NDIM-1)=A
Z(NDIM-2)=C
Z(NDIM-3)=B
RETURN
C
C ERROR EXIT IN CASE NDIM IS LESS THAN 5
4 IER=-1
RETURN
C
C ERROR EXIT IN CASE OF ZERO STEPSIZE
5 IER=1
RETURN
END