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 the test points need to be chosen so that they are not close to these vertical asymptotes because answer evaluators don’t work well when the function values are very large or very small. Thus, the test points that are to be used are explicitly listed.

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

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

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

Statement

It is possible to get diagnostic information about the answer checker by replacing {$ans1} with {$ans1->cmp(diagnostics => 1)}. When diagnostics are turned on and an answer is submitted, the correct answer and the student answer will be shown 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 test points. 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_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.