erf.f

Go to the documentation of this file.
00001 *DECK ERF
00002       FUNCTION ERF (X)
00003 C***BEGIN PROLOGUE  ERF
00004 C***PURPOSE  Compute the error function.
00005 C***LIBRARY   SLATEC (FNLIB)
00006 C***CATEGORY  C8A, L5A1E
00007 C***TYPE      SINGLE 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 ERF(X) calculates the single precision error function for
00013 C single precision argument X.
00014 C
00015 C Series for ERF        on the interval  0.          to  1.00000D+00
00016 C                                        with weighted error   7.10E-18
00017 C                                         log weighted error  17.15
00018 C                               significant figures required  16.31
00019 C                                    decimal places required  17.71
00020 C
00021 C***REFERENCES  (NONE)
00022 C***ROUTINES CALLED  CSEVL, ERFC, INITS, R1MACH
00023 C***REVISION HISTORY  (YYMMDD)
00024 C   770401  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  ERF
00031       DIMENSION ERFCS(13)
00032       LOGICAL FIRST
00033       EXTERNAL ERFC
00034       SAVE ERFCS, SQRTPI, NTERF, XBIG, SQEPS, FIRST
00035       DATA ERFCS( 1) /   -.0490461212 34691808E0 /
00036       DATA ERFCS( 2) /   -.1422612051 0371364E0 /
00037       DATA ERFCS( 3) /    .0100355821 87599796E0 /
00038       DATA ERFCS( 4) /   -.0005768764 69976748E0 /
00039       DATA ERFCS( 5) /    .0000274199 31252196E0 /
00040       DATA ERFCS( 6) /   -.0000011043 17550734E0 /
00041       DATA ERFCS( 7) /    .0000000384 88755420E0 /
00042       DATA ERFCS( 8) /   -.0000000011 80858253E0 /
00043       DATA ERFCS( 9) /    .0000000000 32334215E0 /
00044       DATA ERFCS(10) /   -.0000000000 00799101E0 /
00045       DATA ERFCS(11) /    .0000000000 00017990E0 /
00046       DATA ERFCS(12) /   -.0000000000 00000371E0 /
00047       DATA ERFCS(13) /    .0000000000 00000007E0 /
00048       DATA SQRTPI /1.772453850 9055160E0/
00049       DATA FIRST /.TRUE./
00050 C***FIRST EXECUTABLE STATEMENT  ERF
00051       IF (FIRST) THEN
00052          NTERF = INITS (ERFCS, 13, 0.1*R1MACH(3))
00053          XBIG = SQRT(-LOG(SQRTPI*R1MACH(3)))
00054          SQEPS = SQRT(2.0*R1MACH(3))
00055       ENDIF
00056       FIRST = .FALSE.
00057 C
00058       Y = ABS(X)
00059       IF (Y.GT.1.) GO TO 20
00060 C
00061 C ERF(X) = 1. - ERFC(X) FOR -1. .LE. X .LE. 1.
00062 C
00063       IF (Y.LE.SQEPS) ERF = 2.0*X/SQRTPI
00064       IF (Y.GT.SQEPS) ERF = X*(1.0 + CSEVL(2.*X**2-1., ERFCS, NTERF))
00065       RETURN
00066 C
00067 C ERF(X) = 1. - ERFC(X) FOR  ABS(X) .GT. 1.
00068 C
00069  20   IF (Y.LE.XBIG) ERF = SIGN (1.0-ERFC(Y), X)
00070       IF (Y.GT.XBIG) ERF = SIGN (1.0, X)
00071 C
00072       RETURN
00073       END
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines