README.md (2513B)
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 # Exponential Function 22 23 > [Exponential function][exponential-function]. 24 25 <section class="intro"> 26 27 The [exponential function][exponential-function] is defined as 28 29 <!-- <equation class="equation" label="eq:exponential_function" align="center" raw="y = b^x" alt="Exponential function"> --> 30 31 <div class="equation" align="center" data-raw-text="y = b^x" data-equation="eq:exponential_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/pow/docs/img/equation_exponential_function.svg" alt="Exponential function"> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 where `b` is the **base** and `x` is the **exponent**. 39 40 </section> 41 42 <!-- /.intro --> 43 44 <section class="usage"> 45 46 ## Usage 47 48 ```javascript 49 var pow = require( '@stdlib/math/base/special/pow' ); 50 ``` 51 52 #### pow( base, exponent ) 53 54 Evaluates the [exponential function][exponential-function]. 55 56 ```javascript 57 var v = pow( 2.0, 3.0 ); 58 // returns 8.0 59 60 v = pow( 4.0, 0.5 ); 61 // returns 2.0 62 63 v = pow( 100.0, 0.0 ); 64 // returns 1.0 65 66 v = pow( 3.141592653589793, 5.0 ); 67 // returns ~306.0197 68 69 v = pow( 3.141592653589793, -0.2 ); 70 // returns ~0.7954 71 72 v = pow( NaN, 3.0 ); 73 // returns NaN 74 75 v = pow( 5.0, NaN ); 76 // returns NaN 77 78 v = pow( NaN, NaN ); 79 // returns NaN 80 ``` 81 82 </section> 83 84 <!-- /.usage --> 85 86 <section class="examples"> 87 88 ## Examples 89 90 <!-- eslint no-undef: "error" --> 91 92 ```javascript 93 var randu = require( '@stdlib/random/base/randu' ); 94 var round = require( '@stdlib/math/base/special/round' ); 95 var pow = require( '@stdlib/math/base/special/pow' ); 96 97 var b; 98 var x; 99 var i; 100 101 for ( i = 0; i < 100; i++ ) { 102 b = round( randu()*10.0 ); 103 x = round( randu()*10.0 ) - 5.0; 104 console.log( '%d^%d = %d', b, x, pow( b, x ) ); 105 } 106 ``` 107 108 </section> 109 110 <!-- /.examples --> 111 112 <section class="links"> 113 114 [exponential-function]: https://en.wikipedia.org/wiki/Exponential_function 115 116 </section> 117 118 <!-- /.links -->