Domain and Range of a Function

Domain and range of a function using inequalities

Complete Code

Download file: DomainRange.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

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

Preamble

The contextInequalities.pl macro is used for inequality answers.

#; context by calling `Context('Interval')`. Note that `inf` is built-in for
$a = random(1, 6);

Context('Inequalities-Only')->variables->are(x => 'Real');
Context()->flags->set(formatStudentAnswer => 'parsed');

$domain = Compute("x >= $a");

Context('Inequalities-Only')->variables->are(y => 'Real');
Context()->flags->set(formatStudentAnswer => 'parsed');

$range = Compute('y >= 0');

# Interval version of the same domain and range.
Context('Interval');
$domain_interval = Compute("[$a, inf)");
$range_interval  = Compute('[0, inf)');

Setup

Different contexts can be used for different answers in a problem. Calling Context(‘Inequalities-Only’) creates a new instance of the context. The two contexts in this problem have different variables defined. The first only has the variable “x”, and the second only has the variable “y”. Note that calling ->variables->are(x => 'Real') for the first instance is actually unnecessary since “x” is the only variable in the context by default. It is only shown here for emphasis. For the first part, the “Inequalities-Only” context is used. That context requires students to enter their answer using inequalities. If the “Inequalities” context had been used instead, then students would also be able to enter answers using interval notation. For more details, please see contextInequalities.pl.

Calling Context(‘Inequalities-Only’) creates a new instance of the context. The first two contexts in this problem have different variables defined. The first only has the variable “x”, and the second only has the variable “y”. Note that calling ->variables->are(x => 'Real') for the first instance is actually unnecessary since “x” is the only variable in the context by default. It is only shown here for emphasis.

Setting the context flag formatStudentAnswer => 'parsed' insists that the parsed student answers be displayed and no further reduction or evaluation is done. Generally this means the student answer is displayed much as it is entered. In particular in this instance it prevents the student’s answer from being reduced to a decimal.

For the second part, the “Interval” context is used instead. Change to this infinte intervals.

BEGIN_PGML
Suppose [`f(x) = \sqrt(x - [$a])`].

Enter inequalities for the domain and range of [`f`].

Domain: [_]{$domain}{15}

Range: [_]{$range}{15}

Use interval notation to give the domain and range of [`f`].

Domain: [____]{$domain_interval}

Range: [____]{$range_interval}
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.