Inequality Evaluator

This shows how to use inqualities in a problem.

Complete Code

Download file: InequalityEvaluators.pg

POD for Macro Files

PG problem file

Explanation

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

Preamble

Load the contextInequalities.pl macro.

Context('Inequalities-Only');
Context()->variables->add(y => 'Real');
# Context()->constants->add(EmptySet => Set());
# Context()->flags->set(noneWord => 'EmptySet');
# Context()->flags->set(ignoreEndpointTypes => 1);

# f(x) = x^2 - 16 on -1 <= x <= 5
$f = Formula('x^2 - 16');

$range = Compute('-16 <= y <= 9');

Context()->variables->remove('x');

Setup

Select the Inequalities-Only context. In this context, an inequality such as -16 <= y <= 9 will be accepted, but the equivalent interval [-16, 9] would not be. If the Inequalities context were used instead, both the inequality and the interval would be accepted.

Uncommenting the lines containing EmptySet creates an empty set in the context. Students could then enter EmptySet for an answer.

Uncommenting Context()->flags->set(ignoreEndpointTypes => 1) would also mark the student answers -16 < y < 9 or -16 <= y < 9 or -16 < y <= 9 correct.

BEGIN_PGML
What is the range of [`y = f(x) = [$f]`] on the domain [`-1 \leq x \leq 5`]?

Range: [___]{$range}

Enter your answer using inequalities (not intervals).
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.