libcerf

package
v0.0.0-...-e794f60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2019 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package libcerf implements functions from libcerf by Steven G. Johnson

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Erfcx

func Erfcx(x float64) float64

Erfcx computes the scaled complementary error function erfcx(x) = exp(x*x) * erfc(x).

The implementation based on Steven G. Johnson and Joachim Wuttke algorithm.

This function combines a few different ideas. First, for x > 50, it uses a continued-fraction expansion (same as for the Faddeeva function, but with algebraic simplifications for z=i*x).

Second, for 0 <= x <= 50, it uses Chebyshev polynomial approximations, but with two twists:

a) It maps x to y = 4 / (4+x) in [0,1]. This simple transformation, inspired by a similar transformation in the octave-forge/specfun erfcx by Soren Hauberg, results in much faster Chebyshev convergence than other simple transformations I have examined.

b) Instead of using a single Chebyshev polynomial for the entire [0,1] y interval, we break the interval up into 100 equal subintervals, with a switch/lookup table, and use much lower degree Chebyshev polynomials in each subinterval. This greatly improves performance in my tests.

For x < 0, we use the relationship erfcx(-x) = 2 exp(x^2) - erfc(x), with the usual checks for overflow etcetera.

Performance-wise, it seems to be substantially faster than either the SLATEC DERFC function [or an erfcx function derived therefrom] or Cody's CALERF function (from netlib.org/specfun), while retaining near machine precision in accuracy.

func ErfcxY100

func ErfcxY100(y100 float64) float64

ErfcxY100 uses y100=100*y, where y = 4/(4+x) for x >= 0 to compute erfc(x).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL