numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
198 stars 118 forks source link

Simplification doesn't pull unary minus out of brackets with more subtraction terms #996

Open christianp opened 1 year ago

christianp commented 1 year ago

Here's a small example: -a + b - 2c + 0. I'd expect this to simplify to b - a - 2c, with all the rules turned on.

I think the problem is that the rule for pulling out unary minus, ?;x + (-?;y), matches with strictInverse turned on, so while extra addition terms are matched under rest, extra subtraction terms are not. Could getTerms be changed to capture inverse terms only under rest, and not consider them for the match?