README.md (3176B)
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 # Kernel Cosine 22 23 > Compute the [cosine][cosine] of a number on `[-π/4, π/4]`. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var kernelCos = require( '@stdlib/math/base/special/kernel-cos' ); 31 ``` 32 33 #### kernelCos( x, y ) 34 35 Computes the [cosine][cosine] of a `number` on `[-π/4, π/4]`. For increased accuracy, the number for which the [cosine][cosine] should be evaluated can be supplied as a [double-double number][double-double-arithmetic] (i.e., a non-evaluated sum of two [double-precision floating-point numbers][ieee754] `x` and `y`). 36 37 ```javascript 38 var v = kernelCos( 0.0, 0.0 ); 39 // returns ~1.0 40 41 v = kernelCos( 3.141592653589793/6.0, 0.0 ); 42 // returns ~0.866 43 44 v = kernelCos( 0.785, -1.144e-17 ); 45 // returns ~0.707 46 47 v = kernelCos( NaN, 0.0 ); 48 // returns NaN 49 ``` 50 51 </section> 52 53 <!-- /.usage --> 54 55 <section class="notes"> 56 57 ## Notes 58 59 - As components of a [double-double number][double-double-arithmetic], the two [double-precision floating-point numbers][ieee754] `x` and `y` must satisfy 60 61 <!-- <equation class="equation" label="eq:double_double_inequality" align="center" raw="|y| \leq \frac{1}{2} \operatorname{ulp}(x)" alt="Inequality for the two components of a double-double number."> --> 62 63 <div class="equation" align="center" data-raw-text="|y| \leq \frac{1}{2} \operatorname{ulp}(x)" data-equation="eq:double_double_inequality"> 64 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/kernel-cos/docs/img/equation_double_double_inequality.svg" alt="Inequality for the two components of a double-double number."> 65 <br> 66 </div> 67 68 <!-- </equation> --> 69 70 where `ulp` stands for [units in the last place][ulp]. 71 72 </section> 73 74 <!-- /.notes --> 75 76 <section class="examples"> 77 78 ## Examples 79 80 <!-- eslint no-undef: "error" --> 81 82 ```javascript 83 var linspace = require( '@stdlib/array/linspace' ); 84 var PI = require( '@stdlib/constants/float64/pi' ); 85 var kernelCos = require( '@stdlib/math/base/special/kernel-cos' ); 86 87 var x = linspace( -PI/4.0, PI/4.0, 100 ); 88 var i; 89 90 for ( i = 0; i < x.length; i++ ) { 91 console.log( 'kernelCos(%d) = %d', x[ i ], kernelCos( x[ i ], 0.0 ) ); 92 } 93 ``` 94 95 </section> 96 97 <!-- /.examples --> 98 99 <section class="links"> 100 101 [cosine]: https://en.wikipedia.org/wiki/Cosine 102 103 [double-double-arithmetic]: https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#Double-double_arithmetic 104 105 [ieee754]: https://en.wikipedia.org/wiki/IEEE_floating_point 106 107 [ulp]: https://en.wikipedia.org/wiki/Unit_in_the_last_place 108 109 </section> 110 111 <!-- /.links -->