Answer Blank in the Exponent

Answer blank in the exponent

Complete Code

Download file: AnswerBlankInExponent.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

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

Preamble

The macro niceTables.pl provides a way to format the problem.

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
# Context()->texStrings;

$tab = LayoutTable([[
    ["\(\displaystyle $expression= \Big(\)" . ans_rule(4) . "\(\Big)\)", cellcss => { padding => '20pt 0pt 0pt 4pt'}],
    [ ans_rule(4), cellcss => {padding => '0pt 0pt 20pt 0pt'}]
]]);

# if ($displayMode eq 'TeX') {
#     $showpower =
#         "\( \displaystyle $expression = ("
#         . ans_rule(4) . ")^{"
#         . ans_rule(4) . "}\)";
# } else {
#     $showpower = ColumnTable(
#         "\( \displaystyle $expression = \Big( \)"
#             . ans_rule(4)
#             . "\( \Big) \)",
#         ans_rule(4) . $BR . $BR,
#         indent     => 0,
#         separation => 0,
#         valign     => 'BOTTOM'
#     );
# }
# Context()->normalStrings;

Setup

We want the only variables to be a and b and choose a random power.

The exponential layout is made with a table with padding on the top of the left cell and on the bottom of the right cell.

BEGIN_PGML
Rewrite the following using a single exponent.

[$tab]***
END_PGML

Statement

We insert the nicely formatted answer blanks using $showpower.

ANS($base->cmp());
ANS($exponent->cmp());

Answer

Because the answer blanks are traditional ans_rule, then we need to use this style of answer checking.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.