Skip to content

Add error functions (erf, erfc) to the f32/f64 API. #352

Closed as duplicate of#89
@avhz

Description

@avhz

Proposal

Problem statement

The f32/f64 APIs are missing some useful functions, namely erf and erfc, such as in libm (where the current gamma function is from I believe) or the C++ Faddeeva library.

Motivating examples or use cases

The error function is used in numerous areas of scientific computing, such as statistics where the CDF of the Normal Distribution can be written in terms of it:

$$ \mathbb{P}(X \leq x) = F_X(x) = \Phi\left(\frac{x-\mu}{\sigma}\right) = \frac{1}{2} \left[ 1 + \text{erf}\left( \frac{x-\mu}{\sigma\sqrt{2}} \right) \right] $$

Solution sketch

As far as I can tell, the float functions are already from the libm crate, and erf, erfc have just been skipped for some reason.

Alternatives

There are obviously multiple ways to implement integrals numerically, but if the gamma function from libm was good enough, I don't see why the error function wouldn't be.

Another alternative is to port the Faddeeva library from C++ (released under an MIT licence).

Links and related work

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions