FormulasQuestion / moodle-qtype_formulas

Formulas question type for Moodle
17 stars 29 forks source link

Limitation in the Algebraic formula answer type #130

Closed dbauer-ets closed 7 months ago

dbauer-ets commented 7 months ago

Hi Philipp,

Hope you're doing well.

I've noticed a little issue recently. It's not exactly a bug, more of a limitation, shall we say.

With the Algebraic formula answer type, if the answer "sqrt(a^2+ b^2)" given by the student is correct, then "sqrt(a^2+ b^2) + 2 - 2" should be correct too.

I was told it might be due to using PHP functions in the plugin's code.

Anyway, if "sqrt(a^2+ b^2)" is marked as being correct, then "sqrt(a^2+ b^2) + 2 - 2" should be too.

What do you think? Could we possibly fix this anomaly at some point? No rush, take your time whenever you can.

PhilippImhof commented 7 months ago

Hello Dominique

This is due to the way how floating point numbers work and will depend heavily on the values that the algebraic variables a and b may take and on the tolerance chosen in the grading criterion.

I just tried it with a={0:1:.1} and a={100:200:10} (same values for b) and it worked fine with an absolute error less than 0.0001.

Unfortunately, there is nothing one can do about this, because it is inherent to floating point arithmetic. In some cases, it may even happen that a+b-c and a-c+b will not be considered equivalent, because (to put it simply) calculating a-c might lead to a small inaccuracy whereas (a+b)-c will not, because the numbers do "match" better in a numerical sense.

PhilippImhof commented 7 months ago

Closing this, as it is not within our sphere of influence.