# fn

fn, a Python code which approximates elementary and special functions using Chebyshev polynomials; functions include Airy, Bessel I, Bessel J, Bessel K, Bessel Y, beta, confluent hypergeometric, cosine integral, Dawson's integral, digamma (psi), error, exponential integral, gamma, hyperbolic cosine integral, hyperbolic sine integral, incomplete gamma, log gamma, logarithmic integral, Pochhammer, psi, sine integral, Spence; by Wayne Fullerton.

The original version of the code provided routines for single precision complex, single precision real, and double precision real arguments and used the prefixes "C" and "D" to indicate the complex and double precision versions.

This scheme has been modified for consistency, and also to avoid conflict with the names of functions commonly provided by various compilers. The prefixes "C4_", "R4_" and "R8_" are used to indicate functions for single precision complex, single precision real, and double precision real arguments. For example, the sine function can be calculated by the functions C4_SIN, R4_SIN or R8_SIN.

The original, true, correct version of FN is available through NETLIB: https://www.netlib.org/fn/index.html.

### Languages:

fn is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

### Related Data and codes:

c8lib, a Python code which implements certain elementary functions for double precision complex variables;

clausen, a Python code which evaluates a Chebyshev interpolant to the Clausen function Cl2(x).

legendre_polynomial, a Python code which evaluates the Legendre polynomial and associated functions.

machine, a Python code which stores the appropriate values of machine constants for a given machine.

r4lib, a Python code which contains many utility routines, using "R4" or "single precision real" arithmetic.

r8lib, a Python code which contains many utility routines, using "R8" or "double precision real" arithmetic.

test_values, a Python code which supplies test values of various mathematical functions.

### Reference:

1. Wayne Fullerton,
Portable Special Function Routines,
in Portability of Numerical Software,
edited by Wayne Cowell,
Lecture Notes in Computer Science, Volume 57, pages 452-483,
Springer 1977,
ISBN: 978-3-540-08446-4,
LC: QA297.W65.

### Source Code:

• fn.py, calls all the tests.
• fn.sh, runs all the tests.
• fn.txt, the output file.

• machine.py, returns machine dependent constants.
• r8_acos.py, evaluates the arc-cosine of an R8 argument.
• r8_acosh.py, evaluates the arc-hyperbolic cosine of an R8 argument.
• r8_admp.py, modulus and phase of the derivative of the Airy function.
• r8_ai.py, evaluates the Airy function Ai of an R8 argument.
• r8_aid.py, evaluates the derivative of the Airy function Ai of an R8 argument.
• r8_aide.py, exponentially scaled derivative, Airy function Ai of an R8 argument.
• r8_aie.py, evaluates the exponentially scaled Airy function Ai of an R8 argument.
• r8_aimp.py, evaluates the modulus and phase of the Airy function.
• r8_aint.py, truncates an R8 argument to an integer.
• r8_asin.py, evaluates the arc-sine of an R8 argument.
• r8_asinh.py, evaluates the arc-sine of an R8 argument.
• r8_atan.py, evaluates the arc-tangent of an R8 argument.
• r8_atan2.py, evaluates the arc-tangent of two R8 arguments.
• r8_atanh.py, evaluates the arc-hyperbolic tangent of an R8 argument.
• r8_b0mp.py, evaluates the modulus and phase for the Bessel J0 and Y0 functions.
• r8_b1mp.py, evaluates the modulus and phase for the Bessel J1 and Y1 functions.
• r8_besi0.py, evaluates the Bessel function I of order 0 of an R8 argument.
• r8_besi1.py, evaluates the Bessel function I of order 1 of an R8 argument.
• r8_besj0.py, evaluates the Bessel function J of order 0 of an R8 argument.
• r8_besj1.py, evaluates the Bessel function J of order 1 of an R8 argument.
• r8_besk0.py, evaluates the Bessel function K of order 0 of an R8 argument.
• r8_besk0e.py, evaluates the exponentially scaled Bessel function K0(X).
• r8_besk1.py, evaluates the Bessel function K of order 1 of an R8 argument.
• r8_besk1e.py, evaluates the exponentially scaled Bessel function K1(X).
• r8_beskes.py, evaluates a sequence of exponentially scaled K Bessel functions at X.
• r8_besks.py, evaluates a sequence of K Bessel functions at X.
• r8_besy0.py, evaluates the Bessel function Y of order 0 of an R8 argument.
• r8_besy1.py, evaluates the Bessel function Y of order 1 of an R8 argument.
• r8_beta.py, evaluates the beta function of R8 arguments.
• r8_betai.py, evaluates the incomplete beta ratio of R8 arguments.
• r8_bi.py, evaluates the Airy function Bi of an R8 argument.
• r8_bid.py, evaluates the derivative of the Airy function Bi of an R8 argument.
• r8_bide.py, exponentially scaled derivative, Airy function Bi of an R8 argument.
• r8_bie.py, evaluates the exponentially scaled Airy function Bi of an R8 argument.
• r8_binom.py, evaluates the binomial coefficient using R8 arithmetic.
• r8_cbrt.py, computes the cube root of an R8.
• r8_chi.py, evaluates the hyperbolic cosine integral of an R8 argument.
• r8_chu.py, evaluates the confluent hypergeometric function of R8 arguments.
• r8_chu_scaled.py, scaled confluent hypergeometric function of R8 arguments.
• r8_ci.py, evaluates the cosine integral Ci of an R8 argument.
• r8_cin.py, evaluates the alternate cosine integral Cin of an R8 argument.
• r8_cinh.py, evaluates the alternate hyperbolic cosine integral Cinh of an R8 argument.
• r8_cos.py, evaluates the cosine of an R8 argument.
• r8_cos_deg.py, evaluates the cosine of an R8 argument in degrees.
• r8_cosh.py, evaluates the hyperbolic cosine of an R8 argument.
• r8_cot.py, evaluates the cotangent of an R8 argument.
• r8_csevl.py, evaluates a Chebyshev series.
• r8_dawson.py, evaluates Dawson's integral of an R8 argument.
• r8_e1.py, evaluates the exponential integral E1 for an R8 argument.
• r8_ei.py, evaluates the exponential integral Ei for an R8 argument.
• r8_erf.py, evaluates the error function of an R8 argument.
• r8_exp.py, evaluates the exponential of an R8 argument.
• r8_exprel.py, evaluates the exponential relative error term of an R8 argument.
• r8_fac.py, evaluates the factorial of an I4 argument.
• r8_gami.py, evaluates the incomplete gamma function for an R8 argument.
• r8_gamic.py, evaluates the complementary incomplete gamma function.
• r8_gamit.py, evaluates Tricomi's incomplete gamma function for an R8 argument.
• r8_gaml.py, evaluates bounds for an R8 argument of the gamma function.
• r8_gamma.py, evaluates the gamma function of an R8 argument.
• r8_gamr.py, evaluates the reciprocal gamma function of an R8 argument.
• r8_gmic.py, complementary incomplete gamma, small X, A near negative integer.
• r8_gmit.py, Tricomi's incomplete gamma function for small X.
• r8_inits.py, initializes a Chebyshev series.
• r8_int.py, returns the integer part of an R8 argument.
• r8_knus.py, computes a sequence of K Bessel functions.
• r8_lbeta.py, evaluates the logarithm of the beta function of R8 arguments.
• r8_lgams.py, evaluates the log of |gamma(x)| and sign, for an R8 argument.
• r8_lgic.py, evaluates the log complementary incomplete gamma function for large X.
• r8_lgit.py, evaluates the log of Tricomi's incomplete gamma function.
• r8_lgmc.py, evaluates the log gamma correction factor for an R8 argument.
• r8_li.py, evaluates the logarithmic integral for an R8 argument.
• r8_lngam.py, evaluates the log of the absolute value of gamma of an R8 argument.
• r8_lnrel.py, evaluates log ( 1 + X ) for an R8 argument.
• r8_log.py, evaluates the logarithm of an R8.
• r8_log10.py, evaluates the logarithm, base 10, of an R8.
• r8_machar.py, determines double precision machine constants.
• r8_pak.py, packs a base 2 exponent into an R8.
• r8_poch.py, evaluates Pochhammer's function of R8 arguments.
• r8_poch1.py, evaluates a quantity related to Pochhammer's symbol.
• r8_psi.py, evaluates the psi function of an R8 argument.
• r8_rand.py, generates a uniformly distributed random number.
• r8_randgs.py, generates a normally distributed random number.
• r8_random.py, generates a uniformly distributed random number.
• r8_ren.py, is a simple random number generator.
• r8_shi.py, evaluates the hyperbolic sine integral Shi of an R8 argument.
• r8_si.py, evaluates the sine integral Si of an R8 argument.
• r8_sifg.py, is a utility routine.
• r8_sin.py, evaluates the sine of an R8 argument.
• r8_sin_deg.py, evaluates the sine of an R8 argument in degrees.
• r8_sinh.py, evaluates the hyperbolic sine of an R8 argument.
• r8_spence.py, evaluates a form of Spence's function for an R8 argument.
• r8_sqrt.py, computes the square root of an R8.
• r8_tab.py, evaluates the tangent of an R8 argument.
• r8_tanh.py, evaluates the hyperbolic tangent of an R8 argument.
• timestamp.py, prints out the current YMDHMS date as a timestamp.

Last revised on 23 January 2020.