README.md (2313B)
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 # rempio2 22 23 > Compute `x - nπ/2 = r`. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var rempio2 = require( '@stdlib/math/base/special/rempio2' ); 31 ``` 32 33 #### rempio2( x, y ) 34 35 Computes `x - nπ/2 = r`. The function returns `n` and stores the remainder `r` as two numbers in `y`, such that `y[0]+y[1] = r`. 36 37 ```javascript 38 var y = [ 0.0, 0.0 ]; 39 var n = rempio2( 128.0, y ); 40 // returns 81 41 42 var y1 = y[ 0 ]; 43 // returns ~0.765 44 45 var y2 = y[ 1 ]; 46 // returns ~3.618e-17 47 ``` 48 49 When `x` is `NaN` or infinite, the function returns zero and sets the elements of `y` to `NaN`. 50 51 ```javascript 52 var y = [ 0.0, 0.0 ]; 53 var n = rempio2( NaN, y ); 54 // returns 0 55 56 var y1 = y[ 0 ]; 57 // returns NaN 58 59 var y2 = y[ 1 ]; 60 // returns NaN 61 62 y = [ 0.0, 0.0 ]; 63 n = rempio2( Infinity, y ); 64 // returns 0 65 66 y1 = y[ 0 ]; 67 // returns NaN 68 69 y2 = y[ 1 ]; 70 // returns NaN 71 ``` 72 73 </section> 74 75 <!-- /.usage --> 76 77 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 78 79 <section class="notes"> 80 81 ## Notes 82 83 - For input values larger than `2^20*π/2` in magnitude, the function **only** returns the last three binary digits of `n` and not the full result. 84 85 </section> 86 87 <!-- /.notes --> 88 89 <section class="examples"> 90 91 ## Examples 92 93 <!-- eslint no-undef: "error" --> 94 95 ```javascript 96 var linspace = require( '@stdlib/array/linspace' ); 97 var rempio2 = require( '@stdlib/math/base/special/rempio2' ); 98 99 var x = linspace( 0.0, 100.0, 100 ); 100 var y = [ 0.0, 0.0 ]; 101 var n; 102 var i; 103 104 for ( i = 0; i < x.length; i++ ) { 105 n = rempio2( x[ i ], y ); 106 console.log( '%d - %dπ/2 = %d + %d', x[ i ], n, y[ 0 ], y[ 1 ] ); 107 } 108 ``` 109 110 </section> 111 112 <!-- /.examples --> 113 114 <section class="links"> 115 116 </section> 117 118 <!-- /.links -->