FormulaTroubleshooting
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.
PG problem file | Explanation |
---|---|
loadMacros( "PGstandard.pl", "MathObjects.pl", ); |
Initialization: We use MathObjects answer checkers. |
Context("Numeric"); Context()->flags->set(tolerance=>0.0001,tolType=>"relative"); $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. |
BEGIN_TEXT Enter \( ln(x) \): \{ ans_rule(10) \} END_TEXT |
Main Text: This is standard. |
ANS( $f->cmp(diagnostics=>1) ); |
Answer Evaluation:
We can use |