Simplify error
gunnarmein-ts opened this issue · 3 comments
gunnarmein-ts commented
nerdamer("simplify(0.5sqrt(4a+4y))").text() -> '2sqrt(a+y)' when it should be 'sqrt(a+y)'
That's pretty horrifying. Used last all.min.js from repo. Any thoughts?
gunnarmein-ts commented
Here is a slightly simpler case:
nerdamer("simplify(sqrt(2a+2b))").text() ===> '2*sqrt(a+b)'
gunnarmein-ts commented
Martin, here is a proposed fix in Algebra.js mfactor (quote starts line 3017)
`
var factors2 = new Factors(),
arg = __.Factor.common(symbol.args[0].clone(), factors2); // factors are put into factors2 here already
// GM proposed fix for sqrt simplify bug
// arg = __.Factor.coeffFactor(arg, factors2);
arg = __.Factor.coeffFactor(arg, null); // if you put factors2 here -> get square of the factors (wrong)
symbol = _.multiply(_.symfunction('sqrt', [arg]), _.parse(symbol.multiplier));
factors2.each(function (x) {
symbol = _.multiply(symbol, _.parse(core.Utils.format('sqrt({0})', x)));
`
gunnarmein-ts commented