Features & Development

Strange answer checking behavior

Strange answer checking behavior

by Geoff Cox -
Number of replies: 2
I am experiencing an issue that has me very confused.

In a pg-file, I defined the following variable that stores the answer to a question:

$xAnti = FormulaUpToConstant("(-1/15)*e^(-5*x^3)");

I am using the default answer checker (via PGML syntax)

The problem is that the student's correct answer is not being registered as correct. This seems to only happen with this combination of constants. For example, if I change the -5 to a -4, it works as expected.

HOWEVER, if I also simply change the order of the multiplication to

$xAnti = FormulaUpToConstant("e^(-5*x^3)/-15");

the problem works fine.

Does anyone know why this would happen?

Thanks

Geoff





In reply to Geoff Cox

Re: Strange answer checking behavior

by Alex Jordan -
If a random text x-value is large and negative, you will have that formula producing a pretty large result that may lead to some overflow issues. So my first guess would be to constrain the test values to [-1,1].

I think the default is [-2,2], and with the "5" and a test value close to -2, you get e^40 in there, which has 17 or so digits, just more than perl is tracking. Since this is formula up to constant, I assume some addition is then happening, and we've lost precision to track the addition well.
In reply to Alex Jordan

Re: Strange answer checking behavior

by Geoff Cox -
Of course, that makes perfect sense. I always forget about the test values behind the scenes. Thanks Alex.