time-to-botec

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

README.md (4271B)


      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 # negaFibonacci
     22 
     23 > Compute the nth [negaFibonacci number][fibonacci-number].
     24 
     25 <section class="intro">
     26 
     27 The [negaFibonacci numbers][fibonacci-number] are the integer sequence
     28 
     29 <!-- <equation class="equation" label="eq:negafibonacci_sequence" align="center" raw="0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, \ldots" alt="NegaFibonacci sequence"> -->
     30 
     31 <div class="equation" align="center" data-raw-text="0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144, \ldots" data-equation="eq:negafibonacci_sequence">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negafibonacci/docs/img/equation_negafibonacci_sequence.svg" alt="NegaFibonacci 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:negafibonacci_recurrence_relation" align="center" raw="F_{n-2} = F_{n} - F_{n-1}" alt="NegaFibonacci sequence recurrence relation"> -->
     41 
     42 <div class="equation" align="center" data-raw-text="F_{n-2} = F_{n} - F_{n-1}" data-equation="eq:negafibonacci_recurrence_relation">
     43     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negafibonacci/docs/img/equation_negafibonacci_recurrence_relation.svg" alt="NegaFibonacci sequence recurrence relation">
     44     <br>
     45 </div>
     46 
     47 <!-- </equation> -->
     48 
     49 which yields
     50 
     51 <!-- <equation class="equation" label="eq:negafibonacci_fibonacci" align="center" raw="F_{-n} = (-1)^{n+1} F_n" alt="NegaFibonacci relationship to Fibonacci numbers"> -->
     52 
     53 <div class="equation" align="center" data-raw-text="F_{-n} = (-1)^{n+1} F_n" data-equation="eq:negafibonacci_fibonacci">
     54     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/negafibonacci/docs/img/equation_negafibonacci_fibonacci.svg" alt="NegaFibonacci relationship to Fibonacci numbers">
     55     <br>
     56 </div>
     57 
     58 <!-- </equation> -->
     59 
     60 with seed values `F_0 = 0` and `F_{-1} = 1`.
     61 
     62 </section>
     63 
     64 <!-- /.intro -->
     65 
     66 <section class="usage">
     67 
     68 ## Usage
     69 
     70 ```javascript
     71 var negafibonacci = require( '@stdlib/math/base/special/negafibonacci' );
     72 ```
     73 
     74 #### negafibonacci( n )
     75 
     76 Computes the nth [negaFibonacci number][fibonacci-number].
     77 
     78 ```javascript
     79 var v = negafibonacci( 0 );
     80 // returns 0
     81 
     82 v = negafibonacci( -1 );
     83 // returns 1
     84 
     85 v = negafibonacci( -2 );
     86 // returns -1
     87 
     88 v = negafibonacci( -3 );
     89 // returns 2
     90 
     91 v = negafibonacci( -78 );
     92 // returns -8944394323791464
     93 ```
     94 
     95 If `n < -78`, the function returns `NaN`, as larger [negaFibonacci numbers][fibonacci-number] cannot be safely represented in [double-precision floating-point format][ieee754].
     96 
     97 ```javascript
     98 var v = negafibonacci( -79 );
     99 // returns NaN
    100 ```
    101 
    102 If not provided a nonpositive integer value, the function returns `NaN`.
    103 
    104 ```javascript
    105 var v = negafibonacci( -3.14 );
    106 // returns NaN
    107 
    108 v = negafibonacci( 1 );
    109 // returns NaN
    110 ```
    111 
    112 If provided `NaN`, the function returns `NaN`.
    113 
    114 ```javascript
    115 var v = negafibonacci( 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 negafibonacci = require( '@stdlib/math/base/special/negafibonacci' );
    137 
    138 var v;
    139 var i;
    140 
    141 for ( i = 0; i > -79; i-- ) {
    142     v = negafibonacci( i );
    143     console.log( v );
    144 }
    145 ```
    146 
    147 </section>
    148 
    149 <!-- /.examples -->
    150 
    151 <section class="links">
    152 
    153 [fibonacci-number]: https://en.wikipedia.org/wiki/Fibonacci_number
    154 
    155 [ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
    156 
    157 </section>
    158 
    159 <!-- /.links -->