time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (4080B)


      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 # negaLucas
     22 
     23 > Compute the nth [negaLucas number][lucas-number].
     24 
     25 <section class="intro">
     26 
     27 The [negaLucas numbers][lucas-number] are the integer sequence
     28 
     29 <!-- <equation class="equation" label="eq:negalucas_sequence" align="center" raw="2, -1, 3, -4, 7, -11, 18, -29, 47, -76, 123, -199, 322, \ldots" alt="NegaLucas sequence"> -->
     30 
     31 <div class="equation" align="center" data-raw-text="2, -1, 3, -4, 7, -11, 18, -29, 47, -76, 123, -199, 322, \ldots" data-equation="eq:negalucas_sequence">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negalucas/docs/img/equation_negalucas_sequence.svg" alt="NegaLucas sequence">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 The sequence is defined by the recurrence relation
     39 
     40 <!-- <equation class="equation" label="eq:negalucas_recurrence_relation" align="center" raw="L_{n-2} = L_{n} - L_{n-1}" alt="NegaLucas sequence recurrence relation"> -->
     41 
     42 <div class="equation" align="center" data-raw-text="L_{n-2} = L_{n} - L_{n-1}" data-equation="eq:negalucas_recurrence_relation">
     43     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negalucas/docs/img/equation_negalucas_recurrence_relation.svg" alt="NegaLucas sequence recurrence relation">
     44     <br>
     45 </div>
     46 
     47 <!-- </equation> -->
     48 
     49 which yields
     50 
     51 <!-- <equation class="equation" label="eq:negalucas_lucas" align="center" raw="L_{-n} = (-1)^{n} L_n" alt="NegaLucas relationship to Lucas numbers"> -->
     52 
     53 <div class="equation" align="center" data-raw-text="L_{-n} = (-1)^{n} L_n" data-equation="eq:negalucas_lucas">
     54     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negalucas/docs/img/equation_negalucas_lucas.svg" alt="NegaLucas relationship to Lucas numbers">
     55     <br>
     56 </div>
     57 
     58 <!-- </equation> -->
     59 
     60 with seed values `L_0 = 2` and `L_{-1} = -1`.
     61 
     62 </section>
     63 
     64 <!-- /.intro -->
     65 
     66 <section class="usage">
     67 
     68 ## Usage
     69 
     70 ```javascript
     71 var negalucas = require( '@stdlib/math/base/special/negalucas' );
     72 ```
     73 
     74 #### negalucas( n )
     75 
     76 Computes the nth [negaLucas number][lucas-number].
     77 
     78 ```javascript
     79 var v = negalucas( 0 );
     80 // returns 2
     81 
     82 v = negalucas( -1 );
     83 // returns -1
     84 
     85 v = negalucas( -2 );
     86 // returns 3
     87 
     88 v = negalucas( -3 );
     89 // returns -4
     90 
     91 v = negalucas( -76 );
     92 // returns 7639424778862807
     93 ```
     94 
     95 If `n < -76`, the function returns `NaN`, as larger [negaLucas numbers][lucas-number] cannot be safely represented in [double-precision floating-point format][ieee754].
     96 
     97 ```javascript
     98 var v = negalucas( -77 );
     99 // returns NaN
    100 ```
    101 
    102 If not provided a nonpositive integer value, the function returns `NaN`.
    103 
    104 ```javascript
    105 var v = negalucas( -3.14 );
    106 // returns NaN
    107 
    108 v = negalucas( 1 );
    109 // returns NaN
    110 ```
    111 
    112 If provided `NaN`, the function returns `NaN`.
    113 
    114 ```javascript
    115 var v = negalucas( NaN );
    116 // returns NaN
    117 ```
    118 
    119 </section>
    120 
    121 <!-- /.usage -->
    122 
    123 <section class="notes">
    124 
    125 </section>
    126 
    127 <!-- /.notes -->
    128 
    129 <section class="examples">
    130 
    131 ## Examples
    132 
    133 <!-- eslint no-undef: "error" -->
    134 
    135 ```javascript
    136 var negalucas = require( '@stdlib/math/base/special/negalucas' );
    137 
    138 var v;
    139 var i;
    140 
    141 for ( i = 0; i > -77; i-- ) {
    142     v = negalucas( i );
    143     console.log( v );
    144 }
    145 ```
    146 
    147 </section>
    148 
    149 <!-- /.examples -->
    150 
    151 <section class="links">
    152 
    153 [lucas-number]: https://en.wikipedia.org/wiki/Lucas_number
    154 
    155 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
    156 
    157 </section>
    158 
    159 <!-- /.links -->