Answer in an Exponent

Provides an answer blank in an exponent.

Complete Code

Download file: AnswerInExponent.pg

PG problem file

Explanation

DOCUMENT();

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

Preamble

These standard macros need to be loaded.
Context()->variables->are(a => 'Real', b => 'Real');

$n = random(3, 9);

$ans_rule1 = ans_rule(4);
$ans_rule2 = ans_rule(4);

Setup

The Context()->variables->are sets the variables for the context.

BEGIN_PGML
Rewrite the following using a single exponent.

[@ MODES(
    TeX => "\\( \\displaystyle a^{$n}b^{$n} = ( $ans_rule1)^{$ans_rule2} \\)",
    HTML =>"<div><span>\\( \\displaystyle a^{$n}b^{$n} = (\\)$ans_rule1\\()\\)</span>" .
        "<span style='vertical-align: 1.4em'> $ans_rule2 </span></div>"
)@]*

END_PGML

Statement

To create an exponential, there is different code for both the TeX (hardcopy) and HTML version. The TeX is as expected using the standard power ^. The HTML version creates a exponent using the vertical-align attribute.

ANS(Compute('a b')->cmp);
ANS(Real($n)->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.