Dec 072017
This collection of C routines contains a series of fast and highly accurate double precision mathematical routines for scientific and engineering applications. Full source included.
File CEPHES.ZIP from The Programmer’s Corner in
Category C Source Code
This collection of C routines contains a series of fast and highly accurate double precision mathematical routines for scientific and engineering applications. Full source included.
File Name File Size Zip Size Zip Type
ASIN.C 4608 1809 deflated
ATAN.C 4736 1741 deflated
CEPHES.DOC 9600 2833 deflated
CHDTR.C 3712 990 deflated
EXP.C 5120 1856 deflated
FDTR.C 3840 1191 deflated
FFTR.C 3968 1662 deflated
LOG.C 7168 2694 deflated
LOG10.C 4864 2177 deflated
MTHUTL.C 3968 1658 deflated
NDTR.C 10240 3462 deflated
NDTRI.C 10240 3678 deflated
POW.C 12288 4351 deflated
POWERI.C 1920 870 deflated
SIMQ.C 3200 1313 deflated
SIN.C 8064 2774 deflated
SQRT.C 2688 1108 deflated
STDTR.C 3200 1289 deflated
TAN.C 5504 2036 deflated

Download File CEPHES.ZIP Here

Contents of the CEPHES.DOC file


This computer software library is a collection of fast and
highly accurate double precision mathematical routines for
scientific and engineering applications. All are written
entirely in C language.

The library contains more than 100 tested functions. In
addition to the elementary transcendental functions, it includes
a substantial collection of probability integrals, Bessel
functions, and higher transcendental functions.

There are complex variable routines covering complex
arithmetic, complex logarithm and exponential, and complex
trigonometric functions.

Each subroutine has been tested by comparing at a large
number of points against high precision check routines. The test
programs use floating point arithmetic having 144 bit (43
decimal) precision. Test results are given with the desription
of each routine.

The routines have been characterized and tested in IEEE Std
754 double precision arithmetic, used on IBM PC and a growing
number of other computers, and also in the popular DEC/IBM double
precision format.

For DEC and IEEE arithmetic, numerical constants and
approximation coefficients are supplied as integer arrays in
order to eliminate conversion errors that might be introduced by
the language compiler. All coefficients are also supplied in the
normal decimal scientific notation so that the routines can be
compiled and used on other machines that do not support either of
the above numeric formats.

A single, common error handling routine is supplied. Error
conditions produce a display of the function name and error type.
The user may easily insert modifications to implement any desired
action on specified types of error.

The following table summarizes the current contents of the
library. Note that since the quoted accuracies are
experimentally measured, they are not guaranteed maximum errors.
Nevertheless the same tests applied to several published math
routine libraries have revealed significant differences, in favor
of the Cephes routines.

Following the summary table are Unix-style manual pages that
describe the functions and their invocation.


Function Name Accuracy
-------- ---- DEC IEEE
---- ----
Square root sqrt 2e-17 2e-16
Long integer square root lsqrt 1 1
Cube root cbrt 2e-17 2e-16
Evaluate polynomial polevl
Evaluate Chebyshev series chbevl
Round to nearest integer value round
Truncate upward to integer ceil
Truncate downward to integer floor
Extract exponent frexp
Add integer to exponent ldexp
Absolute value fabs
Roots of a polynomial polrt

Exponential and Trigonometric
Arc cosine acos 3e-17 2e-16
Arc hyperbolic cosine acosh 4e-17 4e-16
Arc hyperbolic sine asinh 5e-17 4e-16
Arc hyperbolic tangent atanh 3e-17 2e-16
Arcsine asin 6e-17 5e-16
Arctangent atan 3e-17 3e-16
Quadrant correct arctangent atan2 3e-17 3e-16
Cosine cos 3e-17 2e-16
Cosine of arg in degrees cosdg 4e-17 2e-16
Exponential, base e exp 3e-17 2e-16
Exponential, base 2 exp2 2e-17 2e-16
Exponential, base 10 exp10 3e-17 3e-16
Hyperbolic cosine cosh 3e-17 2e-16
Hyperbolic sine sinh 4e-17 3e-16
Hyperbolic tangent tanh 3e-17 2e-16
Logarithm, base e log 2e-17 2e-16
Logarithm, base 10 log10 3e-17 2e-16
Power pow 1e-15 1e-14
Sine sin 3e-17 2e-16
Sine of arg in degrees sindg 4e-17 2e-16
Tangent tan 4e-17 3e-16
Tangent of arg in degrees tandg 3e-17 2e-16

Exponential integral
Exponential integral expn 2e-16 1e-15
Hyperbolic cosine integral shichi 9e-17 7e-16
Hyperbolic sine integral shichi 9e-17 6e-16
Cosine integral sici 8e-17A 6e-16
Sine integral sici 4e-17A 5e-16

Beta beta 8e-15 2e-14
Factorial fac 2e-17 1e-15
Gamma gamma 1e-16 1e-15
Logarithm of gamma function lgam 5e-17 5e-16


Incomplete beta integral incbet 4e-14 4e-13
Inverse beta integral incbi 3e-13 2e-12
Incomplete gamma integral igam 5e-15 3e-14
Complemented gamma integral igamc 3e-15 2e-14
Inverse gamma integral igami 9e-16 6e-15
Psi (digamma) function psi 2e-16 4e-15
Reciprocal Gamma rgamma 1e-16 1e-15

Error function
Error function erf 5e-17 3e-16
Complemented error function erfc 5e-16 6e-14
Dawson's integral dawsn 2e-16 1e-15
Fresnel integral (C, S) fresnl 2e-16 2e-15

Airy (Ai, Ai', Bi, Bi') airy 8e-13A 2e-9A
Bessel, order 0 j0 4e-17A 4e-16A
Bessel, order 1 j1 3e-17A 2e-16A
Bessel, order n jn 7e-17A 5e-16A
Bessel, noninteger order jv 1e-13A 9e-13A
Bessel, second kind, order 0 y0 8e-17A 1e-15A
Bessel, second kind, order 1 y1 9e-17A 7e-16A
Bessel, second kind, order n yn 3e-16A 2e-15A
Modified Bessel, order 0 i0 8e-17 8e-16
Exponentially scaled i0 i0e 8e-17 8e-16
Modified Bessel, order 1 i1 1e-16 2e-15
Exponentially scaled i1 i1e 1e-16 2e-15
Modified Bessel, nonint. order iv 3e-15 2e-15
Mod. Bessel, 3rd kind, order 0 k0 1e-16 1e-15
Exponentially scaled k0 k0e 1e-16 1e-15
Mod. Bessel, 3rd kind, order 1 k1 9e-17 8e-16
Exponentially scaled k1 k1e 9e-17 8e-16
Mod. Bessel, 3rd kind, order n kn 1e-9 7e-9

Confluent hypergeometric hyperg 1e-15 1e-14
Gauss hypergeometric function hyp2f1 4e-11 3e-9

Complete elliptic integral (E) ellpe 3e-17 2e-16
Incomplete elliptic integral (E) ellie 2e-16 2e-15
Complete elliptic integral (K) ellpk 4e-17 3e-16
Incomplete elliptic integral (K) ellik 9e-17 5e-16
Jacobian elliptic functions ellpj 5e-16A 9e-13

Binomial distribution bdtr 4e-14 4e-13
Complemented binomial bdtrc 4e-14 4e-13
Inverse binomial bdtri 3e-13 2e-12
Chi square distribution chdtr 5e-15 3e-14
Complemented Chi square chdtrc 3E-15 2E-14
Inverse Chi square chdtri 9e-16 6e-15
F distribution fdtr 4e-14 4e-13


Complemented F fdtrc 4e-14 4e-13
Inverse F distribution fdtri 3e-13 2e-12
Gamma distribution gdtr 5e-15 3e-14
Complemented gamma gdtrc 3e-15 2e-14
Negative binomial distribution nbdtr 4e-14 4e-13
Complemented negative binomial nbdtrc 4e-14 4e-13
Normal distribution ndtr 2e-15 3e-14
Inverse normal distribution ndtri 8e-17 7e-16
Poisson distribution pdtr 3e-15 2e-14
Complemented Poisson pdtrc 5e-15 3e-14
Inverse Poisson distribution pdtri 3e-15 5e-14
Student's t distribution stdtr 2e-15 1e-14

Dilogarithm spence 2e-16 1e-15
Riemann Zeta function zetac 1e-16
Two argument zeta function zeta

Fast Fourier transform fftr
Simultaneous linear equations simq

Complex Arithmetic
Complex addition cadd 1e-17 1e-16
Subtraction csub 1e-17 1e-16
Multiplication cmul 2e-17 2e-16
Division cdiv 5e-17 4e-16
Absolute value cabs 3e-17 2e-16
Square root sqrt 3e-17 2e-16

Complex Exponential and Trigonometric
Exponential cexp 4e-17 3e-16
Logarithm clog 9e-17 7e-16
Cosine ccos 5e-17 4e-16
Arc cosine cacos 2e-15 1e-14
Sine csin 5e-17 4e-16
Arc sine casin 2e-15 2e-14
Tangent ctan 7e-17 6e-16
Arc tangent catan 1e-16 4e-16
Cotangent ccot 7e-17 5e-16

A: absolute error; others are relative error (i.e., % of reading)

Copyright 1987 by Stephen L. Moshier

Release 1.0: July, 1984
Release 1.1: March, 1985
Release 1.2: May, 1986
Release 2.0: April, 1987

 December 7, 2017  Add comments

Leave a Reply