time-to-botec

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

README.md (1748B)


      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 # Logarithm
     22 
     23 > Compute the base `b` [logarithm][logarithm].
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var log = require( '@stdlib/math/base/special/log' );
     31 ```
     32 
     33 #### log( x, b )
     34 
     35 Computes the base `b` logarithm of `x`.
     36 
     37 ```javascript
     38 var v = log( 100.0, 10.0 );
     39 // returns 2.0
     40 
     41 v = log( 16.0, 2.0 );
     42 // returns 4.0
     43 
     44 v = log( 5.0, 1.0 );
     45 // returns Infinity
     46 ```
     47 
     48 For negative `x` or `b`, the [logarithm][logarithm] is **not** defined.
     49 
     50 ```javascript
     51 var v = log( -4.0, 1.0 );
     52 // returns NaN
     53 
     54 v = log( 2.0, -4.0 );
     55 // returns NaN
     56 ```
     57 
     58 </section>
     59 
     60 <!-- /.usage -->
     61 
     62 <section class="examples">
     63 
     64 ## Examples
     65 
     66 <!-- eslint no-undef: "error" -->
     67 
     68 ```javascript
     69 var randu = require( '@stdlib/random/base/randu' );
     70 var round = require( '@stdlib/math/base/special/round' );
     71 var log = require( '@stdlib/math/base/special/log' );
     72 
     73 var b;
     74 var x;
     75 var i;
     76 
     77 for ( i = 0; i < 100; i++ ) {
     78     x = round( randu() * 100.0 );
     79     b = round( randu() * 5.0 );
     80     console.log( 'log( %d, %d ) = %d', x, b, log( x, b ) );
     81 }
     82 ```
     83 
     84 </section>
     85 
     86 <!-- /.examples -->
     87 
     88 <section class="links">
     89 
     90 [logarithm]: https://en.wikipedia.org/wiki/Logarithm
     91 
     92 </section>
     93 
     94 <!-- /.links -->