Skip to content

Commit

Permalink
fix for factor problem
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmein-ts committed Dec 11, 2023
1 parent c99e178 commit c11bc04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Algebra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 8 additions & 3 deletions spec/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c11bc04

Please sign in to comment.