From WeBWorK_wiki
Jump to navigation Jump to search

Formula Answer Evaluation: Troubleshooting

This code snippet offers advice for troubleshooting when the correct answer isn't being marked correct, or when incorrect answers are being marked correct. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.

Problem Techniques Index

PG problem file Explanation

Initialization: We use MathObjects answer checkers.


$f = Formula("ln(x)");
$f->{limits} = [1,3]; # default is [-1,1]

Setup: Set the domain to 1 < x < 3 to avoid places where the function is undefined or has a vertical asymptote. For more ways to set the domain and to set test points that will avoid bad spots in the domain, see FormulaTestPoints

Try to keep outputs of formulas in the range between 10^(-4) and 10^4 for accurate function evaluation, especially near vertical asymptotes. Moderate values are better. Outside of this range, you may want to set the tolerance manually (which has default 0.01 percent). For more on how to set the tolerance, see NumericalTolerance

The domain and the tolerance should be set to work together. For example, if you ask students for an increasing exponential function f(x) and also for f(300) as a follow up question, but you set the domain to -1 < x < 1 with tolerance 0.0000001, it is likely that because the domain is so far from x=300 that no matter how small you set the tolerance, the answer checker won't work as you would like for f(300). Instead, in this situation, it would be better to set the domain to 290 < x < 310 with a moderate tolerance such as 0.0001.

Enter \( ln(x) \): \{ ans_rule(10) \}

Main Text: This is standard.

ANS( $f->cmp(diagnostics=>1) );

Answer Evaluation: We can use diagnostics=>1 as an argument to the cmp() call to get graphs of the correct answer and the student answer, as well as information about how far off the student's answer is from the correct answer. This will create a pink screen and generate a warning, so you should only use it while troubleshooting, and not while a problem is in normal service. You may also want to try debug=>1.

Problem Techniques Index