Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar problem and needed to find the exact definition of <code>erf</code> so let me expand on this. As said by Chris Dodd the function is declared in <code>bits/mathcalls.h</code> which is included by <code>maths.h</code>.</p> <p><code>bits/mathcalls.h</code>:</p> <pre><code>... #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99 __BEGIN_NAMESPACE_C99 /* Error and gamma functions. */ __MATHCALL (erf,, (_Mdouble_)); __MATHCALL (erfc,, (_Mdouble_)); __MATHCALL (lgamma,, (_Mdouble_)); __END_NAMESPACE_C99 #endif ... </code></pre> <p>Macro magic expands <code>__MATHCALL (erf,, (_Mdouble_));</code> to</p> <pre><code>extern double erf (double) throw (); extern double __erf (double) throw (); </code></pre> <p>The actual code is in <code>libm.a</code> or <code>libm.so</code> (<code>gcc -lm</code>):</p> <pre><code>$ nm /usr/lib/libm.a ... s_erf.o: 00000400 T __erf 00000000 T __erfc U __ieee754_exp 00000400 W erf 00000000 W erfc ... </code></pre> <p>The source can be obtained from the <a href="http://www.gnu.org/s/libc/#Availability" rel="noreferrer" title="gnu libc">gnu libc</a> webpage. For a rough idea on the actual implementation here a few lines of the source:</p> <p><code>sysdeps/ieee754/dbl-64/s_erf.c</code>:</p> <pre><code>/* double erf(double x) * double erfc(double x) * x * 2 |\ * erf(x) = --------- | exp(-t*t)dt * sqrt(pi) \| * 0 * * erfc(x) = 1-erf(x) * Note that * erf(-x) = -erf(x) * erfc(-x) = 2 - erfc(x) * * Method: * 1. For |x| in [0, 0.84375] * erf(x) = x + x*R(x^2) * erfc(x) = 1 - erf(x) if x in [-.84375,0.25] * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375] * where R = P/Q where P is an odd poly of degree 8 and * Q is an odd poly of degree 10. * -57.90 * | R - (erf(x)-x)/x | &lt;= 2 * * * Remark. The formula is derived by noting * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) * and that * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 * is close to one. The interval is chosen because the fix * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is * near 0.6174), and by some experiment, 0.84375 is chosen to * guarantee the error is less than one ulp for erf. * * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and ... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload