diff options
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Ferfc.html')
| -rw-r--r-- | devdocs/c/numeric%2Fmath%2Ferfc.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Ferfc.html b/devdocs/c/numeric%2Fmath%2Ferfc.html new file mode 100644 index 00000000..cbbc7e72 --- /dev/null +++ b/devdocs/c/numeric%2Fmath%2Ferfc.html @@ -0,0 +1,75 @@ + <h1 id="firstHeading" class="firstHeading">erfc, erfcf, erfcl</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><math.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float erfcf( float arg );</pre> +</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double erfc( double arg );</pre> +</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double erfcl( long double arg );</pre> +</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code><tgmath.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define erfc( arg )</pre> +</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <div class="t-li1"> +<span class="t-li">1-3)</span> Computes the <a href="https://en.wikipedia.org/wiki/Complementary_error_function" class="extiw" title="enwiki:Complementary error function">complementary error function</a> of <code>arg</code>, that is <code><span class="nu16">1.0</span> <span class="sy2">-</span> <a href="http://en.cppreference.com/w/c/numeric/math/erf"><span class="kw682">erf</span></a><span class="br0">(</span>arg<span class="br0">)</span></code>, but without loss of precision for large <code>arg</code>.</div> <div class="t-li1"> +<span class="t-li">4)</span> Type-generic macro: If <code>arg</code> has type <code>long double</code>, <code>erfcl</code> is called. Otherwise, if <code>arg</code> has integer type or the type <code>double</code>, <code>erfc</code> is called. Otherwise, <code>erfcf</code> is called.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> arg </td> <td> - </td> <td> floating point value </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> If no errors occur, value of the complementary error function of <code>arg</code>, that is \(\frac{2}{\sqrt{\pi} }\int_{arg}^{\infty}{e^{-{t^2} }\mathsf{d}t}\)<span><span>2</span><span>/</span><span>√π</span></span>∫<sub class="t-su t-su-b">∞arg</sub><i>e</i><sup>-t<sup class="t-su">2</sup></sup>d<i>t</i> or \({\small 1-\operatorname{erf}(arg)}\)1-erf(arg), is returned. <p>If a range error occurs due to underflow, the correct result (after rounding) is returned.</p> +<h3 id="Error_handling"> Error handling</h3> <p>Errors are reported as specified in <a href="math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>.</p> +<p>If the implementation supports IEEE floating-point arithmetic (IEC 60559),</p> +<ul> +<li> If the argument is +∞, +0 is returned. </li> +<li> If the argument is -∞, 2 is returned. </li> +<li> If the argument is NaN, NaN is returned. </li> +</ul> <h3 id="Notes"> Notes</h3> <p>For the IEEE-compatible type <code>double</code>, underflow is guaranteed if <code>arg</code> > <code>26.55</code>.</p> +<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> +#include <math.h> + +double normalCDF(double x) // Phi(-∞, x) aka N(x) +{ + return erfc(-x / sqrt(2)) / 2; +} + +int main(void) +{ + puts("normal cumulative distribution function:"); + for(double n = 0; n < 1; n += 0.1) + printf("normalCDF(%.2f) %5.2f%%\n", n, 100 * normalCDF(n)); + + printf("special values:\n" + "erfc(-Inf) = %f\n" + "erfc(Inf) = %f\n", + erfc(-INFINITY), + erfc(INFINITY)); +}</pre></div> <p>Output:</p> +<div class="text source-text"><pre data-language="c">normal cumulative distribution function: +normalCDF(0.00) 50.00% +normalCDF(0.10) 53.98% +normalCDF(0.20) 57.93% +normalCDF(0.30) 61.79% +normalCDF(0.40) 65.54% +normalCDF(0.50) 69.15% +normalCDF(0.60) 72.57% +normalCDF(0.70) 75.80% +normalCDF(0.80) 78.81% +normalCDF(0.90) 81.59% +normalCDF(1.00) 84.13% +special values: +erfc(-Inf) = 2.000000 +erfc(Inf) = 0.000000</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul> +<li> 7.12.8.2 The erfc functions (p: 249-250) </li> +<li> 7.25 Type-generic math <tgmath.h> (p: 373-375) </li> +<li> F.10.5.2 The erfc functions (p: 525) </li> +</ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul> +<li> 7.12.8.2 The erfc functions (p: 230) </li> +<li> 7.22 Type-generic math <tgmath.h> (p: 335-337) </li> +<li> F.9.5.2 The erfc functions (p: 462) </li> +</ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="erf" title="c/numeric/math/erf"> <span class="t-lines"><span>erf</span><span>erff</span><span>erfl</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes error function <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/math/erfc" title="cpp/numeric/math/erfc">C++ documentation</a></span> for <code>erfc</code> </td> +</tr> </table> <h3 id="External_links"> External links</h3> <table> <tr> <td> +<a rel="nofollow" class="external text" href="https://mathworld.wolfram.com/Erfc.html">Weisstein, Eric W. "Erfc."</a> From MathWorld — A Wolfram Web Resource. </td> +</tr> +</table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/numeric/math/erfc" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/erfc</a> + </p> +</div> |
