Provides an answer blank in an exponent.
Download file: AnswerInExponent.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'unionTables.pl', 'niceTables.pl', 'PGcourse.pl');
Preamble
We need to include the macros file unionTables.pl
Context()->variables->are(a => 'Real', b => 'Real'); $n = random(3, 9); # TeX $expression = "a^{$n} b^{$n}"; # MathObjects $base = Formula('a * b'); $exponent = Formula($n); # Display exponents nicely $w1 = 10; # width of 1st answer blank $w2 = 10; # width of 2nd answer blank if ($displayMode eq 'TeX') { $showpower = "\( \displaystyle $expression = (" . ans_rule($w1) . ")^{" . ans_rule($w2) . "}\)"; } else { $showpower = ColumnTable( "\( \displaystyle $expression = \Big( \) " . ans_rule($w1) . " \( \Big) \)", ans_rule($w2) . $BR . $BR, indent => 0, separation => 0, valign => 'BOTTOM' ); }
Setup
This perl code sets up the problem.BEGIN_PGML Rewrite the following using a single exponent. [$showpower]* [@ LayoutTable([$showpower] . \(=\)) @]* END_PGML
Statement
The problem text section of the file is as we’d expect. We insert the nicely formatted answer blanks using $showpower
.
ANS($base->cmp); ANS($exponent->cmp);
Answer
Because ans_rule
is used above, this form of answer checking must be used.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.