WeBWorK Main Forum

relative tolerance cmp vs num_cmp

relative tolerance cmp vs num_cmp

by Joel Trussell -
Number of replies: 1
is it intentional that using relative tolerance in cmp and num_cmp are different. If I use
ANS($aFv->cmp( tolerance => 0.01,
tolType => "relative",
));
the tolerated error is abs(student_answer - correct_answer) < 0.01*correct_answer
http://webwork.maa.org/wiki/NumericalTolerance#.WNVpk2e1thE

if I use
ANS(num_cmp( correct_answer, tolerance => 0.01,
tolType => "relative",
));
the tolerated error is abs(student_answer - correct_answer) < 0.01*0.01*correct_answer
http://webwork.maa.org/wiki/Num_cmp#.WNVoBme1thE

This seems inconsistent. It fouled us up recently. Is there a reason for it?
In reply to Joel Trussell

Re: relative tolerance cmp vs num_cmp

by Davide Cervone -
Yes, this is intentional. The legacy answer checkers like num_cmp used relative tolerance as a percentage value, while absolute tolerance was not. This was confusing, so MathObjects used non-percentage values for both. That way, a tolerance of .01 means roughly 2 significant figures, whereas .01 in num_cmp would mean roughly 4 significant figures. Because this seems non-intuitive, MathObjects went with non-percentage values. This does lead to an inconsistency with the older routines, but for backward compatibility, that could not be helped. (The num_cmp tolerances used to be set via tol and relTol, not tolerance, so when MathObjects were original developed, the inconsistency was less obvious).

In any case, the is the way it is, and there is little to do about it now without breaking existing problems.

Note that num_cmp is deprecated in favor of the MathObject checkers.