README.md (3217B)
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 # exp 22 23 > Compute the [exponential][exponential-function] function of a complex number. 24 25 <section class="intro"> 26 27 The [exponential][exponential-function] function of a complex number is defined as 28 29 <!-- <equation class="equation" label="eq:cexp_function" align="center" raw="\operatorname{exp}(z) = e^{x + i y} = (\exp{x}) (\cos(y) + i \sin(y))" alt="Complex exponential function"> --> 30 31 <div class="equation" align="center" data-raw-text="\operatorname{exp}(z) = e^{x + i y} = (\exp{x}) (\cos(y) + i \sin(y))" data-equation="eq:cexp_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@d4edb68b52a6c646be5683023c5a24890300727f/lib/node_modules/@stdlib/math/base/special/cexp/docs/img/equation_cexp_function.svg" alt="Complex exponential function"> 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 cexp = require( '@stdlib/math/base/special/cexp' ); 48 ``` 49 50 #### cexp( \[out,] re, im ) 51 52 Evaluates the [exponential][exponential-function] function with a `complex` argument comprised of a **real** component `re` and an **imaginary** component `im`. 53 54 ```javascript 55 var v = cexp( 0.0, 0.0 ); 56 // returns [ 1.0, 0.0 ] 57 58 v = cexp( 0.0, 1.0 ); 59 // returns [ ~0.540, ~0.841 ] 60 ``` 61 62 By default, the function returns real and imaginary components as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. 63 64 ```javascript 65 var Float64Array = require( '@stdlib/array/float64' ); 66 67 var out = new Float64Array( 2 ); 68 69 var v = cexp( out, 0.0, 1.0 ); 70 // returns <Float64Array>[ ~0.540, ~0.841 ] 71 72 var bool = ( v === out ); 73 // returns true 74 ``` 75 76 </section> 77 78 <!-- /.usage --> 79 80 <section class="examples"> 81 82 ## Examples 83 84 <!-- eslint no-undef: "error" --> 85 86 ```javascript 87 var Complex128 = require( '@stdlib/complex/float64' ); 88 var randu = require( '@stdlib/random/base/randu' ); 89 var round = require( '@stdlib/math/base/special/round' ); 90 var real = require( '@stdlib/complex/real' ); 91 var imag = require( '@stdlib/complex/imag' ); 92 var cexp = require( '@stdlib/math/base/special/cexp' ); 93 94 var re; 95 var im; 96 var z1; 97 var z2; 98 var o; 99 var i; 100 101 for ( i = 0; i < 100; i++ ) { 102 re = round( randu()*100.0 ) - 50.0; 103 im = round( randu()*100.0 ) - 50.0; 104 z1 = new Complex128( re, im ); 105 106 o = cexp( real(z1), imag(z1) ); 107 z2 = new Complex128( o[ 0 ], o[ 1 ] ); 108 109 console.log( 'cexp(%s) = %s', z1.toString(), z2.toString() ); 110 } 111 ``` 112 113 </section> 114 115 <!-- /.examples --> 116 117 <section class="links"> 118 119 [exponential-function]: https://en.wikipedia.org/wiki/Exponential_function 120 121 </section> 122 123 <!-- /.links -->