diff --git a/Algebra.js b/Algebra.js index cec0b8d..8913d49 100644 --- a/Algebra.js +++ b/Algebra.js @@ -714,8 +714,9 @@ if((typeof module) !== 'undefined') { //then add the minus one to that factor and return. if(s.equals(-1) && this.length > 0) { var fo = core.Utils.firstObject(this.factors, null, true); - this.add(_.symfunction(core.Settings.PARENTHESIS, [fo.obj]).negate()); + let newObj = _.symfunction(core.Settings.PARENTHESIS, [fo.obj]).negate(); delete this.factors[fo.key]; + this.add(newObj); this.length--; return this; } diff --git a/spec/test.js b/spec/test.js index ff18def..4887102 100644 --- a/spec/test.js +++ b/spec/test.js @@ -20,9 +20,14 @@ console.global = {tsDebugChannels: {notimeout: true}}; // const sol = nerdamer.solveEquations(testEq, [...testUnkwowns]); // console.log(sol.toString()); -nerdamer.setVar("x","-sqrt(-1+z)"); -nerdamer.setVar("y","-2*sqrt(-1+z)+5"); -console.log(nerdamer("(-1/2)*abs(-5+y)*sqrt(-1+z)^(-1)-1").simplify().text()); +// const x = nerdamer("-0.5*sqrt(5)+0.5").simplify().text() +const x = nerdamer("-2*sqrt(5)+2").simplify().text() +console.log(x); + +// nerdamer.setVar("x","-sqrt(-1+z)"); +// nerdamer.setVar("y","-2*sqrt(-1+z)+5"); +// console.log(nerdamer("(-1/2)*abs(-5+y)*sqrt(-1+z)^(-1)-1").simplify().text()); + // let text = nerdamer("2-2*(x/3)").text() // console.log(text); // const text = nerdamer("2-2*(x/3)").simplify().text()