This is great. I go teach my classe and someone else solves the problem for me. (see below)
We'll get this patch into PGanswermacros.pl, test it as fast
as we can, and put a new version in the updates directory on "Download Webwork".
I think I'll apply this test to both the student's answer and the instructors code as well, Bill.
Does that seem right to you?
Thanks very much, Bill.
Take care,
Mike
From Bill Wheeler at Indiana University:
Dear Zig,
Thanks for bringing this "weird bug" to our attention.
The cause is that, on some Unix implementations, including Solaris,
the C math library apparently does not throw a floating point exception
signal when it attempts to compute pow(-1, 0.5) ,
i.e., in WebWork notation (-1)^(0.5).
Instead, the library just returns the IEEE NaN.
Consequently, WebWork's attempt to catch an SIGFPE in order
to detect the error fails.
The patch I give below is based on the fact that NaN is a number
but that (BY DEFINITION) NaN != NaN . In other words,
in Perl, if you set $x = (-1)**(0.5), then the value of $x is NaN
but $x != $x .
The patch below seems to work. I've installed it on our
test system, but I have not yet installed it on our production system.
Sincerely,
Bill Wheeler
-----------------------------------------------------------------------------
The patch goes in PGanswermacros.pl in the calculate_difference_vector
subroutine. Insert the following lines between lines 2373 and 2374
(at least those are the line numbers in our current copy of PGanswermacros.pl):
use it to test that the student's function has evaluated to a real number.
########################## Patch for Wierd Bug (=NaN) phenomenon ########
if ($inVal ne "" && $inVal != $inVal) {
$err1 .= " For some values of the independent variable, your function does not produce real numbers. ";
$errors .= " $err1 ";
}
###########################
<| Post or View Comments |>
|