Setting the Domain for Answer Checking

Formula answer with domain issues template

Complete Code

Download file: FormulaDomain.pg

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');

Preamble

These standard macros need to be loaded.
$a = random(2, 5);

$ans1 = Compute("sqrt(x - $a)");
$ans1->{limits} = [ $a + 1, $a + 4 ];

$ans2 = Compute("ln(abs(x / (x - $a)))");
$ans2->{test_points} = [ [-5], [-4], [1], [ $a - 1 ], [7], [8] ];

Setup

Restrict the domain of function evaluation using $ans1->{limits} = [ $a + 1, $a + 4 ];, which will choose test points at random in the interval [$a + 1, $a + 4]. This will ensure that the test points are in the domain of the function.

The domain for $ans2 is all real numbers except for 0 and $a, and we would like to stay away from these vertical asymptotes because answer evaluators don’t work well when the function values are very large or very small. Thus, we explicitly list those test points in the domain that will be used when the function is evaluated.

It is possible to set the domain once for all of the functions within a particular context. For more details, see Formula Test Points.

It is possible to get diagnostic information about the answer checker if one replaces the {$ans} with {$ans1->cmp(diagnostics => 1)}. When diagnostics are turned on and a student answer is submitted, you will get a graph of the correct answer and the student answer on the same graph, as well as a table that specifies which test points were used by the answer checker, and how much of a difference there was between the student answer and the correct answer at these checkpoints. To test the reliability of your answer checker, it is good to click the reload button on your browser several times after a student answer has been submitted, since reloading changes the test points used.

BEGIN_PGML
a. Enter the answer [``[$ans1] =``] [_]{$ans1}

b. Enter the answer [``[$ans2] =``] [_]{$ans2}
END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.