maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
138 stars 147 forks source link

Bug in factorlist(ex) #1202

Closed Mat-Ge closed 3 weeks ago

Mat-Ge commented 4 weeks ago

If a factor of the argument ex is a difference, then the line «ex:ev(factor(ex), simp)» in the function definition can be problematic due to the symbols used. For example, according to factorlist(), the expression a-b contains the factor b-a, but not the factor a-b. Thus, the factors of a^2-b^2 are not (a+b) and (a-b) but (a+b) and (b-a), etc.

sangwinc commented 3 weeks ago

Oh dear, well the unary minus really is a pain to deal with. I'll take a look.

sangwinc commented 3 weeks ago

I've looked into this. I don't think this is a "bug" in factorlist really. If you want to decide if f1 is a factor of ex then it's best to compare remainder(ex,f1) with zero than to look for f1 within factorlist(ex). That wasn't obvious to me this morning, but I think that's a better approach overall.