WeBWorK Problems

error tolerance on pair of points

by Bruce Yoshiwara -
Number of replies: 2
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:

Context("Point");
$xi1 = Point(2+sqrt(5),0);$xi2 = Point(2-sqrt(5),0);
$x_intercepts = List($xi1,$xi2); ... \{ans_rule(20)\} ... ANS($x_intercepts->with(tolType=>'absolute',tolerance=>.005)->cmp);

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?

Re: error tolerance on pair of points

by Davide Cervone -
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.

Davide

Re: error tolerance on pair of points

by Bruce Yoshiwara -
Davide,

That does it, thanks!

Bruce