Ideally I would love to be able to require students to enter the whole set-builder notation, but for now I would be happy if I could check only the condition involving an inequality in two variables.
Is there any way to do this?
WeBWorK doesn't currently have a way to do this. It's inequality notation is basically an alternative for describing intervals, so they must have a variable on one side and a number on the other. They are not general inequalities of multiple variables.
It would be possible to extend the current inequalities context to make them work with a variable on one side and a formula (in other variables) on the other, so you could get things like
x-1 <= y <= x+1
, or
y < x^2+ 1
but not
y - 1 < x^2
or
x^2 + y^2 < 10
.
I do not know a reasonable (numerical) way to check a student answer for something like
x^2 + y^2 < 10
in general. The crucial values are where
x^2 + y^2 = 10
, and this is a level set, which is notoriously hard to work with numerically, especially when the level set has singularities.
One possibility would be to use Newton's method to find a bunch of solutions to the equality and make sure the student answer also has those as solutions, and then check a bunch of random points to see that the signs match for student and professor's answers. But the numerics for this are pretty delicate.
The
parserImplicitEquation.pl
does something like this for equalities like
x^2 + y^2 = 10
, so that could be a starting point, but it is not a particularly reliable macro package, so I would be hesitant about that. But people are using it, so perhaps it would work for you.
Do you have any suggestions about how such an answer could be checked numerically in a reliable way?
Perhaps if I were to write my own checker? Or would I need to create a whole new Context?
An answer checker is not going to be enough, since you also need to extend the context to allow the inequalities, so that means writing your own context. And that is not as easy as I would like it to be.
To handle set-builder notation would also require a new context. But without a reliable way to test multi-variable inequalities, I don't think it is work the effort.
About using string comparisons for this, you are aware, of course, that this means the student must enter the answer in exactly the format you did, and that means correct answers will be marked incorrect. E.g., if you have
{ (x,y) : y < 2x + 1 }
and the student writes
{ (x,y) : y < 2*x + 1 }
or
{ (x,y) : y < 1 + 2x }
then they will be marked incorrect.
Personally, I think that is worse that rewriting the question to use the mathematical tools that you have available. For example, give them "
{ (x,y) : y < [_________] }
" where they have to fill in the blank with a formula. I know it doesn't force them to write the set themselves, but I would rather they be marked correct when they write the correct formula in an unexpected way than be forced to write set notation with the formula in a particular order.
I don't like string checking for such answers for this reason, and would not recommend that approach.