derf.f

Go to the documentation of this file.
00001 *DECK DERF
00002       DOUBLE PRECISION FUNCTION DERF (X)
00003 C***BEGIN PROLOGUE  DERF
00004 C***PURPOSE  Compute the error function.
00005 C***LIBRARY   SLATEC (FNLIB)
00006 C***CATEGORY  C8A, L5A1E
00007 C***TYPE      DOUBLE PRECISION (ERF-S, DERF-D)
00008 C***KEYWORDS  ERF, ERROR FUNCTION, FNLIB, SPECIAL FUNCTIONS
00009 C***AUTHOR  Fullerton, W., (LANL)
00010 C***DESCRIPTION
00011 C
00012 C DERF(X) calculates the double precision error function for double
00013 C precision argument X.
00014 C
00015 C Series for ERF        on the interval  0.          to  1.00000E+00
00016 C                                        with weighted error   1.28E-32
00017 C                                         log weighted error  31.89
00018 C                               significant figures required  31.05
00019 C                                    decimal places required  32.55
00020 C
00021 C***REFERENCES  (NONE)
00022 C***ROUTINES CALLED  D1MACH, DCSEVL, DERFC, INITDS
00023 C***REVISION HISTORY  (YYMMDD)
00024 C   770701  DATE WRITTEN
00025 C   890531  Changed all specific intrinsics to generic.  (WRB)
00026 C   890531  REVISION DATE from Version 3.2
00027 C   891214  Prologue converted to Version 4.0 format.  (BAB)
00028 C   900727  Added EXTERNAL statement.  (WRB)
00029 C   920618  Removed space from variable name.  (RWC, WRB)
00030 C***END PROLOGUE  DERF
00031       DOUBLE PRECISION X, ERFCS(21), SQEPS, SQRTPI, XBIG, Y, D1MACH,
00032      1  DCSEVL, DERFC
00033       LOGICAL FIRST
00034       EXTERNAL DERFC
00035       SAVE ERFCS, SQRTPI, NTERF, XBIG, SQEPS, FIRST
00036       DATA ERFCS(  1) / -.4904612123 4691808039 9845440333 76 D-1     /
00037       DATA ERFCS(  2) / -.1422612051 0371364237 8247418996 31 D+0     /
00038       DATA ERFCS(  3) / +.1003558218 7599795575 7546767129 33 D-1     /
00039       DATA ERFCS(  4) / -.5768764699 7674847650 8270255091 67 D-3     /
00040       DATA ERFCS(  5) / +.2741993125 2196061034 4221607914 71 D-4     /
00041       DATA ERFCS(  6) / -.1104317550 7344507604 1353812959 05 D-5     /
00042       DATA ERFCS(  7) / +.3848875542 0345036949 9613114981 74 D-7     /
00043       DATA ERFCS(  8) / -.1180858253 3875466969 6317518015 81 D-8     /
00044       DATA ERFCS(  9) / +.3233421582 6050909646 4029309533 54 D-10    /
00045       DATA ERFCS( 10) / -.7991015947 0045487581 6073747085 95 D-12    /
00046       DATA ERFCS( 11) / +.1799072511 3961455611 9672454866 34 D-13    /
00047       DATA ERFCS( 12) / -.3718635487 8186926382 3168282094 93 D-15    /
00048       DATA ERFCS( 13) / +.7103599003 7142529711 6899083946 66 D-17    /
00049       DATA ERFCS( 14) / -.1261245511 9155225832 4954248533 33 D-18    /
00050       DATA ERFCS( 15) / +.2091640694 1769294369 1705002666 66 D-20    /
00051       DATA ERFCS( 16) / -.3253973102 9314072982 3641600000 00 D-22    /
00052       DATA ERFCS( 17) / +.4766867209 7976748332 3733333333 33 D-24    /
00053       DATA ERFCS( 18) / -.6598012078 2851343155 1999999999 99 D-26    /
00054       DATA ERFCS( 19) / +.8655011469 9637626197 3333333333 33 D-28    /
00055       DATA ERFCS( 20) / -.1078892517 7498064213 3333333333 33 D-29    /
00056       DATA ERFCS( 21) / +.1281188399 3017002666 6666666666 66 D-31    /
00057       DATA SQRTPI / 1.772453850 9055160272 9816748334 115D0 /
00058       DATA FIRST /.TRUE./
00059 C***FIRST EXECUTABLE STATEMENT  DERF
00060       IF (FIRST) THEN
00061          NTERF = INITDS (ERFCS, 21, 0.1*REAL(D1MACH(3)))
00062          XBIG = SQRT(-LOG(SQRTPI*D1MACH(3)))
00063          SQEPS = SQRT(2.0D0*D1MACH(3))
00064       ENDIF
00065       FIRST = .FALSE.
00066 C
00067       Y = ABS(X)
00068       IF (Y.GT.1.D0) GO TO 20
00069 C
00070 C ERF(X) = 1.0 - ERFC(X)  FOR  -1.0 .LE. X .LE. 1.0
00071 C
00072       IF (Y.LE.SQEPS) DERF = 2.0D0*X*X/SQRTPI
00073       IF (Y.GT.SQEPS) DERF = X*(1.0D0 + DCSEVL (2.D0*X*X-1.D0,
00074      1  ERFCS, NTERF))
00075       RETURN
00076 C
00077 C ERF(X) = 1.0 - ERFC(X) FOR ABS(X) .GT. 1.0
00078 C
00079  20   IF (Y.LE.XBIG) DERF = SIGN (1.0D0-DERFC(Y), X)
00080       IF (Y.GT.XBIG) DERF = SIGN (1.0D0, X)
00081 C
00082       RETURN
00083       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines