Function table of values
Download file: TableOfValues.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'PGcourse.pl');
Preamble
These standard macros need to be loaded.$f = Formula('3^(-x)'); @answer = (); for $i (0 .. 2) { $answer[$i] = $f->eval(x => $i); } $table = DataTable( [ [ '\(x\)', '\(f(x)\)' ], [ '\(0\)', ans_rule(4) ], [ '\(1\)', ans_rule(4) ], [ '\(2\)', ans_rule(4) ], ], horizontalrules => 1, texalignment => '|c|c|' );
Setup
We create an empty array @answer
and use a for loop to simplify filling it with values.
The DataTable
is from niceTables.pl. This builds a simple table. The options horizontalrules
and texalignment
gives the borders around each of the cells.
BEGIN_PGML If [`f(x) = [$f]`], fill in the table of values with numbers. [@ $table @]* END_PGML
Statement
This is the problem statement in PGML.for $i (0 .. 2) { ANS($answer[$i]->cmp); }
Answer
Because the answer blanks are built with ans_rule
inside the table, we need to use the traditional ANS
call here.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.