@rayyamhk/complex
Version:
A lightweight and easy-to-use library for you to manipulate complex numbers
21 lines (18 loc) • 452 B
JavaScript
;
/**
* Calculates the exponential function with base E.
* @memberof Complex
* @static
* @param {Complex} num - Exponent
* @returns {Complex} The value of E to the power of num
*/
function exp(num) {
if (!(num instanceof this)) {
return this.NaN;
}
var re = num.getReal();
var theta = num.getImaginary();
var r = Math.exp(re);
return new this(r * Math.cos(theta), r * Math.sin(theta));
}
module.exports = exp;