README.md (2637B)
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 # erf 22 23 > [Error function][error-function]. 24 25 <section class="intro"> 26 27 The [error function][error-function] is defined as 28 29 <!-- <equation class="equation" label="eq:error_function" align="center" raw="\operatorname{erf}(x) = \frac{2}{\sqrt\pi}\int_0^x e^{-t^2}\,\mathrm dt" alt="Error function."> --> 30 31 <div class="equation" align="center" data-raw-text="\operatorname{erf}(x) = \frac{2}{\sqrt\pi}\int_0^x e^{-t^2}\,\mathrm dt" data-equation="eq:error_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/erf/docs/img/equation_error_function.svg" alt="Error function."> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 </section> 39 40 <!-- /.intro --> 41 42 <section class="usage"> 43 44 ## Usage 45 46 ```javascript 47 var erf = require( '@stdlib/math/base/special/erf' ); 48 ``` 49 50 #### erf( x ) 51 52 Evaluates the [error function][error-function]. 53 54 ```javascript 55 var y = erf( 2.0 ); 56 // returns ~0.9953 57 58 y = erf( -1.0 ); 59 // returns ~-0.8427 60 ``` 61 62 If provided `NaN`, the function returns `NaN`. 63 64 ```javascript 65 var y = erf( NaN ); 66 // returns NaN 67 ``` 68 69 The [error function][error-function] is an [odd function][odd-function]; i.e., `erf(-x) = -erf(x)`. Thus, in accordance with the [IEEE 754][ieee754] standard, if provided `-0`, the function returns `-0`. 70 71 ```javascript 72 var y = erf( -0.0 ); 73 // returns -0.0 74 ``` 75 76 </section> 77 78 <!-- /.usage --> 79 80 <section class="examples"> 81 82 ## Examples 83 84 <!-- eslint no-undef: "error" --> 85 86 ```javascript 87 var linspace = require( '@stdlib/array/linspace' ); 88 var erf = require( '@stdlib/math/base/special/erf' ); 89 90 var x = linspace( -10.0, 10.0, 100 ); 91 var y; 92 var i; 93 94 for ( i = 0; i < x.length; i++ ) { 95 y = erf( x[ i ] ); 96 console.log( 'x: %d, erf(x): %d', x[ i ], y ); 97 } 98 ``` 99 100 </section> 101 102 <!-- /.examples --> 103 104 <section class="links"> 105 106 [error-function]: https://en.wikipedia.org/wiki/Error_function 107 108 [odd-function]: https://en.wikipedia.org/wiki/Even_and_odd_functions 109 110 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985 111 112 </section> 113 114 <!-- /.links -->