erfc.f

Go to the documentation of this file.
00001 *DECK ERFC
00002       FUNCTION ERFC (X)
00003 C***BEGIN PROLOGUE  ERFC
00004 C***PURPOSE  Compute the complementary error function.
00005 C***LIBRARY   SLATEC (FNLIB)
00006 C***CATEGORY  C8A, L5A1E
00007 C***TYPE      SINGLE PRECISION (ERFC-S, DERFC-D)
00008 C***KEYWORDS  COMPLEMENTARY ERROR FUNCTION, ERFC, FNLIB,
00009 C             SPECIAL FUNCTIONS
00010 C***AUTHOR  Fullerton, W., (LANL)
00011 C***DESCRIPTION
00012 C
00013 C ERFC(X) calculates the single precision complementary error
00014 C function for single precision argument X.
00015 C
00016 C Series for ERF        on the interval  0.          to  1.00000D+00
00017 C                                        with weighted error   7.10E-18
00018 C                                         log weighted error  17.15
00019 C                               significant figures required  16.31
00020 C                                    decimal places required  17.71
00021 C
00022 C Series for ERFC       on the interval  0.          to  2.50000D-01
00023 C                                        with weighted error   4.81E-17
00024 C                                         log weighted error  16.32
00025 C                        approx significant figures required  15.0
00026 C
00027 C
00028 C Series for ERC2       on the interval  2.50000D-01 to  1.00000D+00
00029 C                                        with weighted error   5.22E-17
00030 C                                         log weighted error  16.28
00031 C                        approx significant figures required  15.0
00032 C                                    decimal places required  16.96
00033 C
00034 C***REFERENCES  (NONE)
00035 C***ROUTINES CALLED  CSEVL, INITS, R1MACH, XERMSG
00036 C***REVISION HISTORY  (YYMMDD)
00037 C   770701  DATE WRITTEN
00038 C   890531  Changed all specific intrinsics to generic.  (WRB)
00039 C   890531  REVISION DATE from Version 3.2
00040 C   891214  Prologue converted to Version 4.0 format.  (BAB)
00041 C   900315  CALLs to XERROR changed to CALLs to XERMSG.  (THJ)
00042 C   920618  Removed space from variable names.  (RWC, WRB)
00043 C***END PROLOGUE  ERFC
00044       DIMENSION ERFCS(13), ERFCCS(24), ERC2CS(23)
00045       LOGICAL FIRST
00046       SAVE ERFCS, ERC2CS, ERFCCS, SQRTPI, NTERF, NTERFC,
00047      1 NTERC2, XSML, XMAX, SQEPS, FIRST
00048       DATA ERFCS( 1) /   -.0490461212 34691808E0 /
00049       DATA ERFCS( 2) /   -.1422612051 0371364E0 /
00050       DATA ERFCS( 3) /    .0100355821 87599796E0 /
00051       DATA ERFCS( 4) /   -.0005768764 69976748E0 /
00052       DATA ERFCS( 5) /    .0000274199 31252196E0 /
00053       DATA ERFCS( 6) /   -.0000011043 17550734E0 /
00054       DATA ERFCS( 7) /    .0000000384 88755420E0 /
00055       DATA ERFCS( 8) /   -.0000000011 80858253E0 /
00056       DATA ERFCS( 9) /    .0000000000 32334215E0 /
00057       DATA ERFCS(10) /   -.0000000000 00799101E0 /
00058       DATA ERFCS(11) /    .0000000000 00017990E0 /
00059       DATA ERFCS(12) /   -.0000000000 00000371E0 /
00060       DATA ERFCS(13) /    .0000000000 00000007E0 /
00061       DATA ERC2CS( 1) /   -.0696013466 02309501E0 /
00062       DATA ERC2CS( 2) /   -.0411013393 62620893E0 /
00063       DATA ERC2CS( 3) /    .0039144958 66689626E0 /
00064       DATA ERC2CS( 4) /   -.0004906395 65054897E0 /
00065       DATA ERC2CS( 5) /    .0000715747 90013770E0 /
00066       DATA ERC2CS( 6) /   -.0000115307 16341312E0 /
00067       DATA ERC2CS( 7) /    .0000019946 70590201E0 /
00068       DATA ERC2CS( 8) /   -.0000003642 66647159E0 /
00069       DATA ERC2CS( 9) /    .0000000694 43726100E0 /
00070       DATA ERC2CS(10) /   -.0000000137 12209021E0 /
00071       DATA ERC2CS(11) /    .0000000027 88389661E0 /
00072       DATA ERC2CS(12) /   -.0000000005 81416472E0 /
00073       DATA ERC2CS(13) /    .0000000001 23892049E0 /
00074       DATA ERC2CS(14) /   -.0000000000 26906391E0 /
00075       DATA ERC2CS(15) /    .0000000000 05942614E0 /
00076       DATA ERC2CS(16) /   -.0000000000 01332386E0 /
00077       DATA ERC2CS(17) /    .0000000000 00302804E0 /
00078       DATA ERC2CS(18) /   -.0000000000 00069666E0 /
00079       DATA ERC2CS(19) /    .0000000000 00016208E0 /
00080       DATA ERC2CS(20) /   -.0000000000 00003809E0 /
00081       DATA ERC2CS(21) /    .0000000000 00000904E0 /
00082       DATA ERC2CS(22) /   -.0000000000 00000216E0 /
00083       DATA ERC2CS(23) /    .0000000000 00000052E0 /
00084       DATA ERFCCS( 1) /   0.0715179310 202925E0 /
00085       DATA ERFCCS( 2) /   -.0265324343 37606719E0 /
00086       DATA ERFCCS( 3) /    .0017111539 77920853E0 /
00087       DATA ERFCCS( 4) /   -.0001637516 63458512E0 /
00088       DATA ERFCCS( 5) /    .0000198712 93500549E0 /
00089       DATA ERFCCS( 6) /   -.0000028437 12412769E0 /
00090       DATA ERFCCS( 7) /    .0000004606 16130901E0 /
00091       DATA ERFCCS( 8) /   -.0000000822 77530261E0 /
00092       DATA ERFCCS( 9) /    .0000000159 21418724E0 /
00093       DATA ERFCCS(10) /   -.0000000032 95071356E0 /
00094       DATA ERFCCS(11) /    .0000000007 22343973E0 /
00095       DATA ERFCCS(12) /   -.0000000001 66485584E0 /
00096       DATA ERFCCS(13) /    .0000000000 40103931E0 /
00097       DATA ERFCCS(14) /   -.0000000000 10048164E0 /
00098       DATA ERFCCS(15) /    .0000000000 02608272E0 /
00099       DATA ERFCCS(16) /   -.0000000000 00699105E0 /
00100       DATA ERFCCS(17) /    .0000000000 00192946E0 /
00101       DATA ERFCCS(18) /   -.0000000000 00054704E0 /
00102       DATA ERFCCS(19) /    .0000000000 00015901E0 /
00103       DATA ERFCCS(20) /   -.0000000000 00004729E0 /
00104       DATA ERFCCS(21) /    .0000000000 00001432E0 /
00105       DATA ERFCCS(22) /   -.0000000000 00000439E0 /
00106       DATA ERFCCS(23) /    .0000000000 00000138E0 /
00107       DATA ERFCCS(24) /   -.0000000000 00000048E0 /
00108       DATA SQRTPI /1.772453850 9055160E0/
00109       DATA FIRST /.TRUE./
00110 C***FIRST EXECUTABLE STATEMENT  ERFC
00111       IF (FIRST) THEN
00112          ETA = 0.1*R1MACH(3)
00113          NTERF = INITS (ERFCS, 13, ETA)
00114          NTERFC = INITS (ERFCCS, 24, ETA)
00115          NTERC2 = INITS (ERC2CS, 23, ETA)
00116 C
00117          XSML = -SQRT (-LOG(SQRTPI*R1MACH(3)))
00118          TXMAX = SQRT (-LOG(SQRTPI*R1MACH(1)))
00119          XMAX = TXMAX - 0.5*LOG(TXMAX)/TXMAX - 0.01
00120          SQEPS = SQRT (2.0*R1MACH(3))
00121       ENDIF
00122       FIRST = .FALSE.
00123 C
00124       IF (X.GT.XSML) GO TO 20
00125 C
00126 C ERFC(X) = 1.0 - ERF(X) FOR X .LT. XSML
00127 C
00128       ERFC = 2.
00129       RETURN
00130 C
00131  20   IF (X.GT.XMAX) GO TO 40
00132       Y = ABS(X)
00133       IF (Y.GT.1.0) GO TO 30
00134 C
00135 C ERFC(X) = 1.0 - ERF(X) FOR -1. .LE. X .LE. 1.
00136 C
00137       IF (Y.LT.SQEPS) ERFC = 1.0 - 2.0*X/SQRTPI
00138       IF (Y.GE.SQEPS) ERFC = 1.0 -
00139      1  X*(1.0 + CSEVL (2.*X*X-1., ERFCS, NTERF) )
00140       RETURN
00141 C
00142 C ERFC(X) = 1.0 - ERF(X) FOR 1. .LT. ABS(X) .LE. XMAX
00143 C
00144  30   Y = Y*Y
00145       IF (Y.LE.4.) ERFC = EXP(-Y)/ABS(X) * (0.5 + CSEVL ((8./Y-5.)/3.,
00146      1  ERC2CS, NTERC2) )
00147       IF (Y.GT.4.) ERFC = EXP(-Y)/ABS(X) * (0.5 + CSEVL (8./Y-1.,
00148      1  ERFCCS, NTERFC) )
00149       IF (X.LT.0.) ERFC = 2.0 - ERFC
00150       RETURN
00151 C
00152  40   CALL XERMSG ('SLATEC', 'ERFC', 'X SO BIG ERFC UNDERFLOWS', 1, 1)
00153       ERFC = 0.
00154       RETURN
00155 C
00156       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines