Chebyshev Expansions for the Error and Related Functions

MATHEMATICS OF COMPUTATION, VOLUME 32, NUMBER 144
OCTOBER 1978, PAGES 1232-1240
Chebyshev Expansions for the Error
and Related Functions
By J. L. Schonfelder
Abstract.
New 30 decimal
approximations
place Chebyshev
up to that accuracy,
sented.
Bilinear and biquadratic
mappings
ployed,
in one case to improve
convergence
proximation
method
presented
range.
expansions,
which can be used to obtain
for the error function
and its complement
of the independent
are pre-
variable have been em-
and in the other to increase the basic ap-
The practical effects of these mappings are discussed, and the
used to generate
the tabulated
form the basis of the routines
expansions
is outlined.
in the SI5 chapter
The expansions
here
of the NAG library.
Introduction. Clenshaw [1] presents Chebyshev expansions, accurate to twenty
decimal places, 20D, for the error function, erffx). These expansions are of the form*
^fix)=\Y.'arTrit),
|jc|<4,
t = 2Q)2-l,
and
x2
erffx) = 1 - e-—
x
N,
X «,rr(r),
r=0
/4\2
x > 4, t = 2(^)2 - 1.
yx/
In the first expansion to obtain 20D accuracy 33 terms are required; in the second, 18
terms. Luke [2] presents expansions which differ from the above only in trivial detail but which use a break point of three rather than four. For these expansions, which
are given up to 20D, 25 terms are required for the small x region and 22 for the large
x. The SI 5 chapter of the NAG library had a requirement for routines to approximate
the functions erf(x), erfcfx), P(x) and ß(x), the error function, its complement and
the cumulative normal distribution function and its complement.** All of these functions can be obtained simply from the basic erf(x) approximations since
Received September
14, 1977.
AMS (MOS) subject classifications (1970). Primary 33A20, 41A10, 65D20, 60E05.
Key words and phrases. Special function
approximation,
error functions,
Chebyshev
expan-
sions.
"The symmetry of the function erf(-x) = -erf(;c) means that the function need only be
approximated
for positive x.
Note. The notation 2J_q denotes the summation is performed
with the term in r = 0
divided by 2.
The Chebyshev polynomials
Tr(t) are those defined on the range t 6 (-1, +1) i.e. Tr(t) =
Cos[r arccos(r)].
**The notation for functions and their definitions is that used in M. ABRAMOWITZ & I.
STEGUN, Editors, Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical
Tables, Nat. Bur. Standards Appl. Math. Series, No. 55, U.S. Government Printing Office, Wash-
ington, D.C., 1965.
Copyright
© 1978, American
1232
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
Mathematical
Society
CHEBYSHEV EXPANSIONS
1233
erfc(x) = 1 - erf(xr),
Pix) = tt [1 + erf(+x/V2)] = &erfc(-x/V2),
Qix) = Vi[1 - erf(x/v/2~)] = ^erfc(x/\/2).
However, serious loss of accuracy is involved in some regions of x in all these forms
due to the subtraction. Therefore, it was decided to produce an approximation for
erfc directly. Also, the NAG library is implemented on machines with precisions ranging from 7D to 18D with a possible future requirement of up to 28D.*** Hence, it
was decided to produce new expansions for up to 30D. Following a suggestion by
Miller [3] it was decided to look at alternative mappings of the expansion variable
t(x) to see if any significant improvement in convergence could be obtained.
In the next section the final expansion forms used are presented and tabulated.
The effect of the bilinear and biquadratic mappings employed are discussed. In the
following section a brief outline of the techniques employed to generate and check
these expansions is provided.
The Expansions. For the error function itself, which has a zero at the origin, it is
desirable to extract this zero explicitly. This allows relative accuracy to be maintained
even for very small arguments. Hence, it was decided to use two approximation ranges
on the pattern of Clenshaw [1]. However, the choice of subdivision at x = 4 results
in an excessively long small x expansion if 30D is required. The subdivision was, therefore, moved to a smaller value ofx; x = 2 was in fact found to be adequate. It is to
some extent questionable whether a break point as low as two is necessary. The expansions of Luke [2] which use three may well be superior for some purposes. However, the expansions presented here are fairly well balanced in the most important
8-18D accuracy range and the extra efficiency thus produced for arguments less than
two, which are somewhat more common than larger arguments, could be useful in
practice. The extra length thereby introduced into the large x expansion was compensated by use of a biquadratic mapping for x —►t to improve convergence.
The expansion for small x has the form
erffx) =xy(/),
where
y(t)=í'QarTr(t),
r = 2(|)2
-1,
and
re(-i,+l)
if* e (0,2).
The coefficients ar correct to 30D are tabulated below.t
***8D is single precision on PDP10 machines and 18D is double precision on Univac. 28D
is the possible double precision on CDC equipment. This work was done before the possibility of
extended precisions on IBM 370 and ICL 2900 machines was considered and hence allowance has
not been made for this 35D working. However, the expansions presented here could be extended
to 35 or 40D if the need arises.
tThe tables have been reproduced
from card decks containing the coefficients
directly from the generating programs. If any reader wishes to use these coefficients
author is willing to supply copies of these card decks.
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
produced
directly the
J. L. SCHONFELDER
1234
Table
V=ERF(X>/X
*AX.ORD.=
Q
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
X=(0,A>
27
T=2(X/A>»2
KAX.ACC.=
1
-1
A= 2
30
+1.4831105640848035818894480790578+0
-3.010710733865949424707310463118-1
+6.89948306898315
66 2466 031807188-2
-1.3916271264722187
68 2 5 465256878-2
+2.4207995 22433463 6628916782398-3
-5.6 5 863968 584808 6446493825778-4
+4.8 62098443 2319 04 82828875688-5
-5,7492565580356848350542158-6
+6.113243578434764697067588-7
-5.89910153129584343908468-8
+5.2070090920686482404558-9
-4.232975879965543268108-10
+3.18811350664917497488-11
-2.2361550188326842738-12
+1.467329847991084928-13
-9.0440019853817478-15
+5.254813715470928-16
-2.88742612228498-17
+1.5047851875588-18
-7.45728928218-20
+3.5225638108-21
-1.589446448-22
+6.8643658-24
-2.842578-25
+1.13068-26
-4.338-28
+1.68-29
-1.08-30
Table 2
y=x*exp(x*x)*(1-erf(x))
x=(2,inf)
max.0rd.=
43
max.acc.=
30
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
t=(k-x*x)/(k-8+x*x)
k=10.5
+1.0779778 5 20723831511683359103488+0
-2.6559 8904091486 73 3721465009048-2
-1.48707314669
8099 5096 050463338-3
-1.38 040145 41414385 96077089208-4
-1.128 03 0333 22 87 491498 5 073668-5
-1.172869842743725224053739R-6
-1.034761503933046155373828-7
-1.18991140858924382544478-8
-1.0162225449894986404768-9
-1.378957161^69656921698-10
-9.3696130337373033358-12
-1.9188095839595253498-12
-3.7S730172019937078-14
-3.70537260269833578-14
+2.6275654234903718-15
-1.1213228764379338-15
+1.841360289225388-16
-4.91302565748868-17
+1.07044551673738-17
-2.6718936624058-18
+6.493268679768-19
-1.653993531838-19
+4.26056266048-20
-1.12558407658-20
+3.0256174488-21
-8.290421468-22
+2.310495588-22
-6.54695118-23
+1.88423148-23
-5.5043418-24
+1.6309508-24
-4.898608-25
+1.490548-25
-4.59228-26
+1.43188-26
-4.5168-27
+1.4408-27
-4.648-28
+1.518-28
-5.08-29
+1.78-29
-6.08-30
+2.08-30
-1.08-30
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
1235
CHEBYSHEV EXPANSIONS
The expansion for large x has the form
erfOc)
= 1 - Ç- y(t),
where
yit) = £
aJrit),
t = (10.5 -x2)/(2.5
+x2),
and
tE (-1,+1)
ifxE(2,°°).
The coefficients ar correct to 30D are tabulated above.
The complementary error function, erfc(x) has no zeros. It takes the value one
at the origin. It asymptotes to zero for large positive x and to two for large nega-
tive x.
For x > 0, erfc(x) = e~x2y(x) and for x < 0, erfc(x) = 2 - e~x2y(-x).
Hence, the whole region may be covered by approximating y (x) for positive x. That
is by the expansion
yix) =Y.'°rTriO,
where t E (-1,+1)
t = (x- 3.75)/(x + 3.75),
if x E (0, °°).
The coefficients ar correct to 30D are tabulated below.
Table 3
y=exp(x*x)*erfc(x)
x=(0,inf)
«ax,0r0.=
43
«ax.acc.=
0
1
2
3
ï
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
3*
35
36
37
38
39
40
41
42
43
t=(x-k)/(x+k)
30
k=3.75
+6.10143 0819232004179264658157568-1
-4.3484127271257747182
81828208888-1
+1.76351193643605501125
8402981238-1
-6.071079 56092494148600512158258-2
+1.7712 068995694114 4861471411918-2
-I.321119385 567293 8185998649688-3
+8.54 216676887098 67 88198320556-4
-1.2715 5090609162 74 26288939408-4
+1.124 81672436711894688470726-5
+3.130638854218209726301528-7
-2.709880685377620220090866-7
+3.07376227014076884409598-8
+2.5156203848176229373146-9
-1.0289299213203191275908-9
+2.99440521199499393638-11
+2.60517896872669362908-11
-2.6348399241719693868-12
-¿.434045098906364436-13
+1.124574018016634476-13
+1.72815333899860988-14
-4.2641016949423756-15
-5.453719778801918-16
+1.586976077616718-16
+2.08998378443346-17
-5.9005268694096-18
-5.418933875548-19
+2.149773564708-19
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
+4.66609850086-20
-7.2430118628-21
-2.3879668248-21
+1.911775358-22
+1.204825688-22
-6.723778-25
-5.7479978-24
-4.284936-25
+2.448566-25
+4.37936-26
-8.1518-27
-3.0896-27
+9.36-29
+1.746-28
+1.68-29
-8.08-30
-2.08-30
1236
J. L. SCHONFELDER
Discussion. Taking the bilinear transformation used for erfc first, the entire
semi-infinite range x E (0, °°) may be uniquely mapped onto the required finite range
t E (-1, +1) for the Chebyshev expansion by the bilinear transformation
t = ix-k)/ix
+ k),
k>0.
The resulting Chebyshev expansions in terms of the variable / provide, by truncation,
approximations which preserve most of the properties of the Chebyshev polynomial
expansions [4]. In particular, they provide approximations which are near mini-max
and which allow precision changes to be made simply by changes in truncation point.
However, the resulting approximations are in fact rational approximations in terms of
the variable x. A polynomial approximation in the variable x over the entire range is
obviously impractical, if not impossible. However, the use of the rational variable t
allows us to produce, in essence, a polynomial approximation with all its advantages
but to gain at least some of the increased flexibility or rational approximations. In
this case the flexibility has been used to extend the range of approximation. We have
gained this flexibility to some extent by introducing a further parameter, k.
The value of k used in the above expansion was chosen essentially by trial and
error. For any given precision there is a value of k which gives optimum convergence.
This value is different for different precisions and so the value actually used is a compromise which gives near optimal convergence over the main precision range of interest,
viz. 8D to 18D. Fortunately, the convergence is comparatively insensitive to k so the
value that gives optimal convergence for about 12—14D is not far from optimal for 8D
or 18D. Certainly, for 30D one could have obtained a shorter expansion but only at
the expense of requiring more terms in the 8—10D truncations. As these expansions
were intended for use in transportable
software, a further constraint
on the values of
k was that it had to be a value that was exactly representable on any machine. This
means that k must be representable by less than six decimal digits and it must be the
sum of a limited number of adjacent powers of two. For instance, the value 3.75
actually used is equivalent to 21 + 2° + 2-1 + 2-2 and, hence, should be represented
exactly on any floating point system currently in use.
Figure 1 shows graphically the order of the polynomial approximation required
in the expansions for ex erfc(x) to provide truncation errors less than 0.5 x 10_<i
for d = 8, 10, 12, 14, 16, 18 for various values of k. This graph shows that for each
precision there is a fairly large region in which k may vary without the number of
terms in the expansion changing from the optimum. This optimum valley moves
slowly to the right as the precision increases. The value 3.75 was chosen as a reasonable compromise value, being clearly within the optimum valley for all precisions from
8-18D. In fact, 3.75 remains within the optimal valley for precisions up to 25D and
is only just outside it at 30D.
For the large x range of the error function itself, the function y(x) we are actually
approximating is dependent on x2 not x; and hence, a biquadratic is more appropriate.
In this case we have a mapping
t = ik-x2)/ik-8
+x2),
k>4,
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
1237
CHEBYSHEV EXPANSIONS
which uniquely maps the region x € (2, <*>)
into the required region tE(-\,
+1). It
should be noted in this case that this mapping is, in fact, a simple generalization of the
more usual mapping as employed by Clenshaw [1]. If k = 8, then the mapping collapses into the simple form
in which case the expansion is equivalent to an expansion in terms of the modified
range Chebyshev polynomials T*(r) with the expansion variable 4/x2 € (0, 1).
Figure 1
Parameter
k in x to / mapping
Figure 2
a.
o.
o
c
jj
0
a.
Parameter
k in x to t mapping
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
J. L. SCHONFELDER
1238
Figure 1 shows the order of polynomial required, to provide each of the precisions indicated, plotted against the mapping parameter k for the expansion of y(x) =
ex2erfcix), t = (x: - *)/(* + k) and x E (0, °°).
N. B. In both Figures 1 and 2 the Unes joining the measured points have no
real significance. They are included as a guide to the eye.
Figure 2 shows the order of polynomial required, to provide each of the precisions indicated, plotted against the mapping parameter k, for the expansion of y(x) =
[1 -erf(x)]xe*2,
t = (k - x2)/(k - 8 + x2) and x G (2, °°).
Figure 2 shows a plot of the order of the polynomial approximation required to
give a truncation error of less than 0.5 x 10~d for d = 8, 10, 12, 14, 16, 18 for various values of k. Note the behavior is similar to the previous case except that the
width of the optimal valley is now precision dependent ; by and large it is smaller for
higher precision. Also the degree of improvement possible over the normal expansions, k = 8 is greater for greater precisions, a desirable feature. The compromise
value of k chosen in this case was 10.5. Unlike the situation with erfc, this value of
k is not optimal for precisions like 25D or 30D. A value of k = 12 or more would
be needed to give optimal convergence at these precisions, and this would mean the
lower precisions would be well away from optimal. However, k = 10.5 still provides
a considerable improvement, eight terms, over the normal k = 8 expansions at 30D.
The convergence of the Chebyshev expansion, as with all such mathematical expansions is governed by the closeness of the singularities of the function being expanded to the expansion region. The major effect of mappings such as these is to allow us to move the singularities further away from the expansion region. The mapping
may also weaken the effect of the singularities by modifying the strength of the singularity as well as moving it. This fact explains the reason why a similar mapping is not
of any significant use for the small x range in approximating erf(xr). The generaliza-
tion of the mapping actually used is
t=-—,
2(x2 - k)
(2 - k)x2 + 2k
0<it<4.
If k = 2, this collapses to the normal mapping as used.
sion region is symmetrically located with respect to the
different value of k destroys this symmetry and, hence,
to the expansion region, hence making the convergence
Generation of Expansions.
In the case k = 2 the expansingularities. Therefore, any
brings the singularities closer
worse rather than better.
The three expansions tabulated in the previous sec-
tion were generated making use of the fact that the three functions involved satisfy
linear differential equations with polynomial coefficients.
(4 + 4r)y + (14 + 8r)y + 4y = 0,
y(-l) = 2/y/ñ
For small x, erf(x) we have
and y(-l) = - 4/3\/ff.
For large x, erf(x) we have
[ Ä+fH+tH ''+ jTj >>]>
♦to- »)+("- «xi*
= 2k/Vtt"+ (16- 2k)tlyfn and y(-l) = 1/sfñ.
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
CHEBYSHEV EXPANSIONS
1239
For erfc(x) we have
[l-3t+
3t2-t3]y
+ [-4k2-4k2t]y
= -4k/y/Ti+4kt/\/ñ
and y(+l) = 0.
These equations can be used to find the set of coefficients ar such that y = zZ^=0'arTrit)
satisfies the equations plus boundary conditions to within a required tolerance using
methods described in Fox and Parker [5].
The precise details of the programs involved
will be published elsewhere [6]. The general principle is as follows. The coefficients
ar can be shown to satisfy an infinite set of linear equations
Aa_= b,
where the first few rows of the matrix A and the right-hand side b are determined by
the boundary conditions. The subsequent rows are then determined by the differential equations, given that the coefficient ar tends to zero rapidly for large r. The infinite set may be handled approximately by assuming ar = 0 for all r> N. The finite set
can be conveniently solved by using the Crout LU decomposition and forward and
backward substitution [7]. In fact, as the decomposition is independent of order, the
process can be done iteratively. At any order N the next row and column of A can
be generated and the decomposition extended from order N - 1 to N, making use of
the A-
1 decomposition already done. The forward substitution can also be similarly
extended. The first step of the backward substitution, which is trivial, gives a reasonable estimate of the value of the coefficient aN added to the set. The process can then
be terminated if two successive coefficients are less than the required tolerance. Apart
from the first few rows, the matrix A, is mainly diagonally dominant and, hence, the
Crout reduction technique is highly stable. The programs performing this calculation
have all been written in Algol 68 using the multiple length arithmetic facility, mlaritha
[8]. This allows arithmetic to be done to any required precision. The above expansions were generated with a basic working precision of at least 36D. The Crout reduction process was terminated when two successive coefficients were less than 10-33.
The resulting coefficients were then rounded to 30D and stored in a card image file
and punched as an actual card deck,^ the correctness of the coefficients as verified by
summing the series at selected points, points for which the value of the series was
known exactly or could be calculated by some other means. The adequacy of the
working tolerances was also checked by running the same programs with the tolerances increased to a working precision of 48D and stopping criteria at 10-42, and no
effect was found on the 30D coefficients.
Conclusion. The main motivation for the production of these expansions was
their use as the basis for transportable function approximation routines in the NAG
library. However, the expansions themselves may well find application directly in other
aspects of numerical computing, and it is for that reason that they are presented here.
The Computer Centre
The University of Birmingham
Birmingham B15 2TT, England
'TSee footnote'.
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
1240
J. L. SCHONFELDER
1. C.W. CLENSHAW, "Chebyshev series for mathematical
functions"
in National Physical
Laboratory Mathematical
Tables, Vol. 5, Her Majesty's Stationery Office, London, 1962.
2. Y. L. LUKE, 77ie Special Functions and their Approximations,
Vols. 1, 2 (especially
Vol. 2, pp. 323-324), Academic Press, New York, 1969.
Y. L. LUKE, Mathematical Functions and their Approximations,
Academic Press, New
York, 1976, pp. 123-124.
Y. L. LUKE, Algorithms for the Computation
of Mathematical Functions, Academic
Press, New York, 1978.
3. G. F. MILLER, Private communication.
4. J. L. SCHONFELDER, "The NAG library and its special functions chapter," International
Computing Symposium
1974 (A. Günther
Elsevier, New York, 1974.
J. L. SCHONFELDER,
Mathematics
(D. J. Evans, Editor),
et al., Editors),
North-Holland,
Amsterdam;
American
"Special functions in the NAG library," Software for Numerical
(Proc. Conf.,
1973), Academic
Press, London
and New York,
1974, pp. 285-300.
library,"
J. L. SCHONFELDER,
"The production
of special function routines
Software-Practice
and Experience, vol. 6, 1976, pp. 71—82.
5. L. FOX & I. B. PARKER, Chebyshev Polynomials
Press, London and New York, 1968.
6. J. L. SCHONFELDER,
script in preparation.)
"Generation
for a multi-machine
in Numerical Analysis, Oxford Univ.
of high precision
Chebyshev
expansions."
(Manu-
7. J. H. WILKINSON & C. REINSCH, Linear Algebra, Handbook for Automatic Computation,
Vol. 2 (Grundlehren
der math. Wissenschaften,
Band 186, vol. 2), Springer-Verlag,
Berlin and
New York, 1971.
8. J. L. SCHONFELDER & J. T. THOMASON, "Applications support by direct language extension-An
arbitrary precision arithmetic facility in Algol 68," International
Computing Symposium 1975 (Proc. Sympos., Antibes, 1975), E. Gelenbe and D. Potier (Editors), North-Holland,
Amsterdam; American Elsevier, New York, 1975.
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use