davidedc / Algebrite

Computer Algebra System in Javascript (Typescript)
http://algebrite.org
MIT License
966 stars 59 forks source link

factor could/should automatically simplify its argument #88

Open Frivolimous opened 5 years ago

Frivolimous commented 5 years ago

factor(x*(x+1)/(x+1)) returns x/(x+1) + x^2/(x+1). It should return x.

It seems that in cases involving fractions, the system tries to distribute first before resolving the fractions.

ASSUMED STEPS IN ALGEBRITE: x*(x+1)/(x+1) => (x^2 + x) / (x+1) => (x^2)/(x+1) + x/(x+1)

Instead, when factoring, the system should recognise that sums within products can be cancelled out within fractions.

davidedc commented 5 years ago

factor(simplify(x*(x+1)/(x+1))) does what you want. Thing is that simplify() is an expensive function so is not called implicitly. I'll try looking into that.

Frivolimous commented 5 years ago

for this specific case simplify first will work, but if you have another term then simplify can't handle it.

simplify(x(x+1)/(x+1)+1) gives (x^2+2x+1)/(x+1), instead of x+1. This is actually closer to the case where I first encountered the issue.

davidedc commented 5 years ago

OK I created a separate issue linked above.