Answer Rules in Limits of Integration

Answer rules in limits of integration

Complete Code

Download file: LimitsOfIntegration.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

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

Preamble

The niceTables.pl macro is used to construct a table containing the answer rules in the limits of integration. The answerHints.pl macro is used to help guide students toward the correct answer.

Context()->variables->are(
    x  => 'Real',
    dx => 'Real',
    t  => 'Real',
    dt => 'Real'
);

$integral = LayoutTable(
    [
        [ ' ', ans_rule(4) ],
        [
            '\(f(x)= \) ' . ans_rule(10) . ' \(+\)',
            '\(\displaystyle \int \;\;\)' . ans_rule(10)
        ],
        [ ' ', ans_rule(4) ],
    ],
    align      => 'rl',
    allcellcss => { padding => '3pt' }
);

$fx = Formula("sin(x)");
$ft = Formula("sin(t)");

Setup

The variables x, t, dx, and dt are added to the context. Note that dx would be incorrect for a student to use in the answer and dt is the correct differential.

The LayoutTable of niceTables.pl is used to display the definite integral. Note that the option align => 'rl' is used to make the formatting look right.

BEGIN_PGML
Find a formula for the function [`f(x)`] such that [`f'(x) = [$fx]`] and
[`f(2) = 5`].  Use [`t`] for the variable of integration.

[$integral]*
END_PGML

Statement

The integral is placed in the problem with the [$integral]* which displays the table.

ANS(Compute('x')->cmp());
ANS(Compute('5')->cmp());
ANS(
    Compute("$ft * dt")->cmp()->withPostFilter(AnswerHints(
        Formula("$fx")    => "Are you using the correct variable?",
        Formula("$fx*dx") => "Are you using the correct variable?",
        Formula("$ft")    => "Don't forget the differential \(dt\).",
    ))
);
ANS(Compute('2')->cmp());

Answer

The answer rules are inserted using ans_rule, so ANS must be called to associate the answer evaluators to those answer rules. The AnswerHints method is used to provide hints that guide the students to the correct answer. Note that hints for the incorrect answers that use x for the variable instead of t are cases that a hint is provided for.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.