nerdamer-ts
Version:
javascript light-weight symbolic math expression evaluator
39 lines • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.rectform = void 0;
const Symbol_1 = require("../../../Types/Symbol");
const index_1 = require("../index");
const Trig_1 = require("../../Trig");
const Utils_1 = require("../../../Core/Utils");
const Parser_1 = require("../../../Parser/Parser");
/**
* Returns the rectangular form of a complex number. Does not work for symbolic coefficients
* @param {Symbol} symbol
* @returns {Symbol}
*/
function rectform(symbol) {
//TODO: e^((i*pi)/4)
var original = symbol.clone();
try {
var f, p, q, s, h, d, n;
f = (0, Utils_1.decompose_fn)(symbol, 'e', true);
p = (0, index_1.divide)(f.x.power, Symbol_1.Symbol.imaginary());
q = (0, Parser_1.evaluate)(Trig_1.Trig.tan(p));
s = (0, index_1.pow)(f.a, new Symbol_1.Symbol(2));
d = q.getDenom(true);
n = q.getNum();
h = Symbol_1.Symbol.hyp(n, d);
//check
if (h.equals(f.a)) {
return (0, index_1.add)(d, (0, index_1.multiply)(Symbol_1.Symbol.imaginary(), n));
}
else {
return original;
}
}
catch (e) {
return original;
}
}
exports.rectform = rectform;
//# sourceMappingURL=rectform.js.map