@rayyamhk/complex
Version:
A lightweight and easy-to-use library for you to manipulate complex numbers
20 lines (17 loc) • 441 B
JavaScript
;
/**
* Calculates the cosine of a Complex Number.
* @memberof Complex
* @static
* @param {Complex} num - Any Complex Number
* @returns {Complex} The result of cosine function
*/
function cos(num) {
if (!(num instanceof this)) {
return this.NaN;
}
var a = num.getReal();
var b = num.getImaginary();
return new this(Math.cos(a) * Math.cosh(b), Math.sin(a) * Math.sinh(b) * -1);
}
module.exports = cos;