Skip to content

Commit

Permalink
simplify fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmein-ts committed Jul 12, 2024
1 parent a1f484e commit 3fc9815
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Algebra.js
Original file line number Diff line number Diff line change
Expand Up @@ -4826,13 +4826,13 @@ if((typeof module) !== 'undefined') {
r = _.add(r, s);
});
simplified = r;
//place back original multiplier and return
simplified = __.Simplify.unstrip(sym_array, simplified);
//mult on back the multiplier we saved here
simplified = _.multiply(simplified, new Symbol(m));
if (simplified.multiplier.equals(-1)) {
simplified.distributeMultiplier();
}
//place back original multiplier and return
simplified = __.Simplify.unstrip(sym_array, simplified);
return simplified;
}

Expand Down
25 changes: 7 additions & 18 deletions spec/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,16 @@ console.global = {tsDebugChannels: {notimeout: true}};
// x = nerdamer("3.535401^3.5").evaluate().text();
// console.log(x);

let text;
let x;

const solveConversion = (
currentUnit,
currentUnitValue,
targetUnit,
conversionString,
) => {
const conversion = nerdamer(conversionString)
let convertedExpression = conversion
.evaluate({ [currentUnit]: currentUnitValue })
.solveFor(targetUnit)
const convertedValue = convertedExpression[0].text()
return Number(convertedValue)
}



try {
x = solveConversion('x', 10, 'y', 'x = 2 * y');
console.log(x);
// x = nerdamer("(-sqrt(y^2)+4)^2");
x= nerdamer("(1-y)^2");
const y=x.simplify();
console.log(y.text());
text = x.divide(y).simplify().text();
console.log(text);
} catch (error) {
console.log("error "+error)
}
Expand Down

0 comments on commit 3fc9815

Please sign in to comment.