README.md (2591B)
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 # Common Logarithm 22 23 > Evaluate the [common logarithm][common-logarithm]. 24 25 <section class="intro"> 26 27 The [common logarithm][common-logarithm] (logarithm with base 10) is defined for any positive real number as 28 29 <!-- <equation class="equation" label="eq:common_logarithm" align="center" raw="\quad \log_{10} \left( x \right) = y \quad \text{such that} \quad 10^y = x" alt="Equation for the common logarithm."> --> 30 31 <div class="equation" align="center" data-raw-text="\quad \log_{10} \left( x \right) = y \quad \text{such that} \quad 10^y = x" data-equation="eq:common_logarithm"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@8cb4d022f6163be6523964802725ed2a74f2497b/lib/node_modules/@stdlib/math/base/special/log10/docs/img/equation_common_logarithm.svg" alt="Equation for the common logarithm."> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 </section> 39 40 <!-- /.intro --> 41 42 <section class="usage"> 43 44 ## Usage 45 46 ```javascript 47 var log10 = require( '@stdlib/math/base/special/log10' ); 48 ``` 49 50 #### log10( x ) 51 52 Evaluates the [common logarithm][common-logarithm]. 53 54 ```javascript 55 var v = log10( 100.0 ); 56 // returns 2.0 57 58 v = log10( 8.0 ); 59 // returns ~0.903 60 61 v = log10( 0.0 ); 62 // returns -Infinity 63 64 v = log10( Infinity ); 65 // returns Infinity 66 67 v = log10( NaN ); 68 // returns NaN 69 ``` 70 71 For negative numbers, the [common logarithm][common-logarithm] is **not** defined. 72 73 ```javascript 74 var v = log10( -4.0 ); 75 // returns NaN 76 ``` 77 78 </section> 79 80 <!-- /.usage --> 81 82 <section class="examples"> 83 84 ## Examples 85 86 <!-- eslint no-undef: "error" --> 87 88 ```javascript 89 var randu = require( '@stdlib/random/base/randu' ); 90 var round = require( '@stdlib/math/base/special/round' ); 91 var log10 = require( '@stdlib/math/base/special/log10' ); 92 93 var x; 94 var i; 95 96 for ( i = 0; i < 100; i++ ) { 97 x = round( randu() * 100.0 ); 98 console.log( 'log10(%d) = %d', x, log10( x ) ); 99 } 100 ``` 101 102 </section> 103 104 <!-- /.examples --> 105 106 <section class="links"> 107 108 [common-logarithm]: https://en.wikipedia.org/wiki/Common_logarithm 109 110 </section> 111 112 <!-- /.links -->