@rayyamhk/complex
Version:
A lightweight and easy-to-use library for you to manipulate complex numbers
29 lines (24 loc) • 674 B
JavaScript
;
/**
* Calculates the natural log of the Complex Number.<br><br>
*
* Note that complex log is a multivalued function,
* and this function only provides the principal value by
* restricting the imaginary part to the interval [0, 2π).
* @memberof Complex
* @static
* @param {Complex} num - Complex Number
* @returns {number} Natural log of the Complex Number
*/
function log(num) {
if (!(num instanceof this)) {
return this.NaN;
}
var r = num.getModulus();
var theta = num.getArgument();
if (r < this.EPSILON || theta === undefined) {
return this.NaN;
}
return new this(Math.log(r), theta);
}
module.exports = log;