Can anyone reproduce the following problem?
The Problem
Union/setDervBasic/s2_2_17.pg
(from the OPL) is in a homework set
with seed 1728.
The problem is to compute f'(x), where
f(x) = sqrt(6x).
The correct answer 6 / (2 sqrt(6x)) is
marked incorrect, with the Message:
Can't generate enough valid points for comparison
The same is true with other (e.g., simplified)
forms of the correct answer.
We have recently upgraded to WeBWorK 2.7
and PG 2.7.
It looks as though the most obvious files
(lib/Value/AnswerChecker.pm and lib/Value/Formula.pm)
have not changed since 2.7.
Related information:
If I change the seed and edit the problem
to force the coefficient of x to be 6, the
correct answer is accepted.
It is of course easy to avoid this problem
by setting $fprime->{limits} (and I have
done so in a local copy), but I thought
that would not be necessary here.
-wb
comparing MathObjects Formulas (problem generating test points)
by William Boshuck - Number of replies: 10
In reply to William Boshuck
Re: comparing MathObjects Formulas (problem generating test points)
by Alex Jordan -
The default interval to pull random test points from is [-2,2]. I'm not sure how many random test points are pulled, but if say 10 are, then 1/1024 of the time every single one of them will be in [-2,0), and the square root will not evaluate anywhere. So you may have just hit on a bad seed. Setting the limits is a good fix.
When you fixed the coefficient to be 6, you changed the usage of randomness in your problem. Formerly, the random number generator had been used once to get your coefficient. Now with that gone, the random test points would be different, and possibly not all in [-2,0). This would explain why that change made it work.
When you fixed the coefficient to be 6, you changed the usage of randomness in your problem. Formerly, the random number generator had been used once to get your coefficient. Now with that gone, the random test points would be different, and possibly not all in [-2,0). This would explain why that change made it work.
In reply to Alex Jordan
Re: comparing MathObjects Formulas (problem generating test points)
by William Boshuck -
Ok, thank you.
I thought I remembered reading that the MathObjects
checkers are careful about the domain of a function,
and I guess I incorrectly thought that meant doing
more than checking whether or not a test point is
in the domain of the function.
Should I file a PR with buzilla?
-wb
I thought I remembered reading that the MathObjects
checkers are careful about the domain of a function,
and I guess I incorrectly thought that meant doing
more than checking whether or not a test point is
in the domain of the function.
Should I file a PR with buzilla?
-wb
In reply to William Boshuck
Re: comparing MathObjects Formulas (problem generating test points)
by Alex Jordan -
Hi William,
It doesn't sound like there is any bug to report here. MathObjects do not have the CAS level capacity to actually identify their own true domains. As a problem author, if your Formula answer does have a domain with large gaping holes missing from [-2,2], then you just have to take this into account and set some domains manually. (Also, if your function distinguishes itself outside of [-2,2], you should think about that. For example, "x" and "|x+3|-3" will be declared equal if WBWK only looks into [-2,2].)
Alex
It doesn't sound like there is any bug to report here. MathObjects do not have the CAS level capacity to actually identify their own true domains. As a problem author, if your Formula answer does have a domain with large gaping holes missing from [-2,2], then you just have to take this into account and set some domains manually. (Also, if your function distinguishes itself outside of [-2,2], you should think about that. For example, "x" and "|x+3|-3" will be declared equal if WBWK only looks into [-2,2].)
Alex
In reply to Alex Jordan
Re: comparing MathObjects Formulas (problem generating test points)
by Nandor Sieben -
Is it possible to set the manual domain to a union of several intervals?
In reply to Nandor Sieben
Re: comparing MathObjects Formulas (problem generating test points)
by Alex Jordan -
It does not appear that this could be done in a streamlined way. But I thought of two workarounds.
Firstly, check out here and in particular look at the limits, test_points, and test_at properties. The latter two could be used to get at what you are looking for. For example you could specify some randomly generated points within each interval and set those to be the test_points.
You could also make a custom checker that checks for equality multiple times, resetting the limits between each check to a different interval, and only returning OK if there was equality on each interval. Between each check, you may also need to delete $f->{test_values} for both the student and correct answers; their existence after the first check could influence the future checks.
Firstly, check out here and in particular look at the limits, test_points, and test_at properties. The latter two could be used to get at what you are looking for. For example you could specify some randomly generated points within each interval and set those to be the test_points.
You could also make a custom checker that checks for equality multiple times, resetting the limits between each check to a different interval, and only returning OK if there was equality on each interval. Between each check, you may also need to delete $f->{test_values} for both the student and correct answers; their existence after the first check could influence the future checks.
In reply to Nandor Sieben
Re: comparing MathObjects Formulas (problem generating test points)
by William Boshuck -
I was never able to do this directly,
although I have needed something like
it. In the example along the lines of
the one Alex mentioned, what I did
would amount to something like this:
$xs = [
( map { [random(-3, -2, .01)] } ( 0 .. 4) ),
( map { [random(-1, 0, .01)] } ( 0 .. 4) ),
( map { [random(1.5, 2, .01)] } ( 0 .. 4) ),
( map { [random(3, 4, .01)] } ( 0 .. 4) )
];
$g = Formula("|2x + 3| + |x - 1| + |3x - 7|")->with(
test_points => $xs
);
cheers,
-wb
although I have needed something like
it. In the example along the lines of
the one Alex mentioned, what I did
would amount to something like this:
$xs = [
( map { [random(-3, -2, .01)] } ( 0 .. 4) ),
( map { [random(-1, 0, .01)] } ( 0 .. 4) ),
( map { [random(1.5, 2, .01)] } ( 0 .. 4) ),
( map { [random(3, 4, .01)] } ( 0 .. 4) )
];
$g = Formula("|2x + 3| + |x - 1| + |3x - 7|")->with(
test_points => $xs
);
cheers,
-wb
In reply to Alex Jordan
Re: comparing MathObjects Formulas (problem generating test points)
by William Boshuck -
Hi,
sorry, I was not explicit.
I was wondering whetherI should submit a PR
regarding the problem itself (it is from the
OPL).
cheers,
-wb
sorry, I was not explicit.
I was wondering whetherI should submit a PR
regarding the problem itself (it is from the
OPL).
cheers,
-wb
In reply to William Boshuck
Re: comparing MathObjects Formulas (problem generating test points)
by Alex Jordan -
Oh! Good question, this may be helpful if you want to fix it yourself for the library. Otherwise it looks like using Bugzilla is what you do and someone else will get to it following these steps.
In reply to Alex Jordan
Re: comparing MathObjects Formulas (problem generating test points)
by Paul Pearson -
Hi all,
The bug is that the domain needs to be set manually, as below, so that none of the test points for function evaluation throw an error. Just below the
Context('Numeric');
Context()->variables->set(x=>{limits=>[1,5]});
to the file
https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/Union/setDervBasic/s2_2_17.pg
You can modify your local copy or update your copy of the OPL to the github version. In the future, filling out a bugzilla report for such things is a good idea.
Best regards,
Paul Pearson
The bug is that the domain needs to be set manually, as below, so that none of the test points for function evaluation throw an error. Just below the
TEXT(beginproblem());I added the lines
Context('Numeric');
Context()->variables->set(x=>{limits=>[1,5]});
to the file
https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/Union/setDervBasic/s2_2_17.pg
You can modify your local copy or update your copy of the OPL to the github version. In the future, filling out a bugzilla report for such things is a good idea.
Best regards,
Paul Pearson
In reply to Paul Pearson
Re: comparing MathObjects Formulas (problem generating test points)
by William Boshuck -
Thanks.
I have fixes for quite a few bugs in
problems in the Libarary, but until
recently the server I'm using hasn't
been using the OPL. I will look into
Alex's suggestion.
cheers,
-wb
I have fixes for quite a few bugs in
problems in the Libarary, but until
recently the server I'm using hasn't
been using the OPL. I will look into
Alex's suggestion.
cheers,
-wb