Interval Evaluator

This shows how to use intervals in a problem.

Complete Code

Download file: IntervalEvaluators.pg

PG problem file

Explanation

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

Preamble

These standard macros need to be loaded.
Context('Interval');
# To allow open or closed intervals, uncomment the following line.
#Context()->flags->set(ignoreEndpointTypes => 1);

$int = Compute('(1, 3)');

Setup

Select the Interval context.

Once the Interval context is selected, intervals can be defined. The constant inf (with alias infinity) is defined in the context, and can be used for the end points of an interval. For example,

$int2 = Compute('(-inf, 1]');

This would give the interval from negative infinity to 1, including the point at one.

The context flag ignoreEndpointTypes can be set to 1 to ignore inclusion or exclusion of end points in intervals. However, this does not apply to infinite end points. The interval (-5, inf] is still invalid.

BEGIN_PGML
On what interval is the parabola [`y = (1 - x)(x - 3)`] above the [`x`]-axis?

For [`x`] in [_____]{$int}
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.