I'm trying to have students enter two ordered pairs, separated by commas. I want their answers to be rounded to two decimal places, and I tried the following:
$xi1 = Point(2+sqrt(5),0);
$xi2 = Point(2-sqrt(5),0);
$x_intercepts = List($xi1,$xi2);
The answer input of "(4.24,0), (-.24,0)" gets only half credit--the second point (-.24,0) is not correct, but the correct value is approximately (-.236068,0).
I expected (-.24,0) to be marked correct, because the error is less than 0.005. What am I missing?
The problem is that the tolerance and tolType being set on the List object isn't percolating down to the points (or rather to the coordinates of the points -- the percolation only goes one step, as I recall). In any case, try putting them in the cmp() call rather than on the object itself:
ANS($x_intercepts->cmp(tolType=>'absolute',tolerance=>.005));I like your version better from a conceptual viewpoint, but this one has the advantage of actually working with the existing code. The problem needs to be fixed, but this will work now.
Hope that helps.