WeBWorK Problems

Displaying answers in scientific notation with exponent -13

Displaying answers in scientific notation with exponent -13

by Bruce Yoshiwara -
Number of replies: 2

I have an exercise with several answers. Most of the answers are of the order 10^(-13) or smaller, one is of the order 10^14. For the small answers, WeBWorK shows 0 for the answer and gives credit for 0, but not for a value of the proper order but not within the relative tolerance specified.

That is, when the specified answer is 6.5346*10^(-13), WeBWorK marks 0 as correct but marks 5.5346*10^(-13) as wrong. WeBWorK also marks the student input of 6.5346*10^(-13) as correct, but shows 0 as the entered value (with nicely formatted scientific notation for the Answer preview).

I have been unable to use Context("ScientificNotation"), even after loading "contextScientificNotation.pl"--I get various error messages such as “'pi' is not defined in this context”, but the exercise includes computation of the volume of a small sphere, so I need pi.

I’d certainly like WeBWorK not to show 0 for a value that is intentionally small but positive. But I’m really perturbed that WeBWorK gives credit for an answer of 0 but rejects an answer that is actually closer to the correct value.

The code includes

$f = Formula("k (A)^(1/3)");
#Context("ScientificNotation");
$k = 1.3 *10**(-13);
$r_iodine = $f->eval(k=>$k, A=>127);
$V_iodine = (4*pi*($r_iodine)**3)/3;
$m_iodine = 2.1*10**(-22);
$d_iodine = ($m_iodine)/($V_iodine);

####other stuff including BEGIN_PGML#######

a.
Estimate the radius of the nucleus of an atom of iodine-127, which has mass number 127. If the nucleus is roughly spherical, what is its volume?
Radius [` \approx `][_____________]{$r_iodine->with(tolType => 'relative', tolerance => .05, );} cm, volume [` \approx `][_____________]{$V_iodine->with(tolType => 'relative', tolerance => .05, );} [`\text{cm}^3`].
b.
The nuclear mass of iodine-127 is [`2.1 \times 10^{-22} `] gram. What is the density of the nucleus? (Density is mass per unit volume.)
Density [` \approx `][_____________]{$d_iodine->with(tolType => 'relative', tolerance => .05, );} [`\text{gm/cm}^3`].
In reply to Bruce Yoshiwara

Re: Displaying answers in scientific notation with exponent -13

by John Travis -
Look at resetting zeroLevelTol.

http://webwork.maa.org/wiki/Strict_num_cmp

and

http://webwork.maa.org/wiki/Context_flags

for examples. Not certain about the big numbers.

Another option is to have the student enter three answer blanks of the form

___ x ____ 10^(____)

using "multianswer" so that they are checked as a unit. See http://webwork.maa.org/wiki/MultiAnswerProblems
In reply to John Travis

Re: Displaying answers in scientific notation with exponent -13

by Bruce Yoshiwara -
Hey John!

Great! Inserting zeroLevelTol=>1E-15 in my pgml answer checker did succeed both in preventing a response of 0 to be marked correct and also in displaying the correct nonzero answer.

It did not change the fact that the student's correct input is still shown as 0 (and the student's answer preview still shows the full input). I can live with that.

In a part of my exercise which I did not post here, I had students fill in a table with a few more values (radii of other elements) of order 10^-(13). The table was not in the pgml section (I have yet succeeded in getting tables in pgml), and I was not successful in getting the zeroLevelTol=>1E-15 to affect the display of the correct answer for those, only to display 0.

But I'm not planning to solve that puzzle, instead I've decided to ask for the table values to be input in units of 10^(-13), and everything seems to be working fine.

Many thanks!