README.md (3429B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # erfc 22 23 > [Complementary error function][complementary-error-function]. 24 25 <section class="intro"> 26 27 The [complementary error function][complementary-error-function] is defined as 28 29 <!-- <equation class="equation" label="eq:complementary_error_function" align="center" raw="\operatorname{erfc}(x) = 1 - \operatorname{erf}(x) = \frac{2}{\sqrt\pi} \int_x^{\infty} e^{-t^2}\, dt" alt="Complementary error function."> --> 30 31 <div class="equation" align="center" data-raw-text="\operatorname{erfc}(x) = 1 - \operatorname{erf}(x) = \frac{2}{\sqrt\pi} \int_x^{\infty} e^{-t^2}\, dt" data-equation="eq:complementary_error_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/erfc/docs/img/equation_complementary_error_function.svg" alt="Complementary error function."> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 The [complementary error function][complementary-error-function] can also be expressed using Craig's formula 39 40 <!-- <equation class="equation" label="eq:craigs_formula" align="center" raw="\operatorname{erfc}(x) = \frac{2}{\pi} \int_0^{\frac{\pi}{2}} \exp \left( - \frac{x^2}{\sin^2 \theta} \right) d\theta" alt="Craig's formula of the complementary error function."> --> 41 42 <div class="equation" align="center" data-raw-text="\operatorname{erfc}(x) = \frac{2}{\pi} \int_0^{\frac{\pi}{2}} \exp \left( - \frac{x^2}{\sin^2 \theta} \right) d\theta" data-equation="eq:craigs_formula"> 43 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/math/base/special/erfc/docs/img/equation_craigs_formula.svg" alt="Craig's formula of the complementary error function."> 44 <br> 45 </div> 46 47 <!-- </equation> --> 48 49 </section> 50 51 <!-- /.intro --> 52 53 <section class="usage"> 54 55 ## Usage 56 57 ```javascript 58 var erfc = require( '@stdlib/math/base/special/erfc' ); 59 ``` 60 61 #### erfc( x ) 62 63 Evaluates the [complementary error function][complementary-error-function]. 64 65 ```javascript 66 var y = erfc( 2.0 ); 67 // returns ~0.0047 68 69 y = erfc( -1.0 ); 70 // returns ~1.8427 71 72 y = erfc( Infinity ); 73 // returns 0.0 74 75 y = erfc( -Infinity ); 76 // returns 2.0 77 ``` 78 79 If provided `NaN`, the function returns `NaN`. 80 81 ```javascript 82 var y = erfc( NaN ); 83 // returns NaN 84 ``` 85 86 </section> 87 88 <!-- /.usage --> 89 90 <section class="examples"> 91 92 ## Examples 93 94 <!-- eslint no-undef: "error" --> 95 96 ```javascript 97 var linspace = require( '@stdlib/array/linspace' ); 98 var erfc = require( '@stdlib/math/base/special/erfc' ); 99 100 var x = linspace( -10.0, 10.0, 100 ); 101 var y; 102 var i; 103 104 for ( i = 0; i < x.length; i++ ) { 105 y = erfc( x[ i ] ); 106 console.log( 'x: %d, erfc(x): %d', x[ i ], y ); 107 } 108 ``` 109 110 </section> 111 112 <!-- /.examples --> 113 114 <section class="links"> 115 116 [complementary-error-function]: https://en.wikipedia.org/wiki/Error_function 117 118 </section> 119 120 <!-- /.links -->