Shows how to check that the answer is the composition of two functions.
Download file: ComposingFunctions.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'answerComposition.pl', 'PGcourse.pl');
Preamble
Include the macro answerComposition.pl.
Context()->variables->are(x => 'Real', y => 'Real', u => 'Real');
$a = random(2, 9);
$f = Formula('sqrt(u)');
$g = Formula("x^2 + $a");
Setup
This perl code sets up the problem.BEGIN_PGML
Express the function [`y = \sqrt{x^2 + [$a]}`] as a composition [`y = f(g(x))`]
of two simpler functions [`y = f(u)`] and [`u = g(x)`].
[`f(u) =`] [___]
[`g(x) =`] [___]
END_PGML
Statement
This is the problem statement in PGML.COMPOSITION_ANS($f, $g);
Answer
Call the COMPOSITION_ANS method with the arguments
$f and $g to test that the composition of the
student answers for f and g is equal to the
composition of the correct answers. Note that the
COMPOSITION_ANS checker takes care to not allow certain
trivial answers like f(u) = u and
g(x) = sqrt(x^2 + $a).
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.