nerdamer-ts
Version:
javascript light-weight symbolic math expression evaluator
29 lines • 920 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.arg = void 0;
const Symbol_1 = require("../../../Types/Symbol");
const Parser_1 = require("../../../Parser/Parser");
/**
* Returns the arugment of a complex number
* @param {Symbol} symbol
* @returns {Symbol}
*/
function arg(symbol) {
var re = symbol.realpart();
var im = symbol.imagpart();
if (re.isConstant() && im.isConstant()) {
if (im.equals(0) && re.equals(-1)) {
return (0, Parser_1.parse)('pi');
}
else if (im.equals(1) && re.equals(0)) {
return (0, Parser_1.parse)('pi/2');
}
else if (im.equals(1) && re.equals(1)) {
return (0, Parser_1.parse)('pi/4');
}
return new Symbol_1.Symbol(Math.atan2(im, re));
}
return (0, Symbol_1.symfunction)('atan2', [im, re]);
}
exports.arg = arg;
//# sourceMappingURL=arg.js.map