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
We need to include the macros file 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
This must be called with the method COMPOSITION_ANS
with the arguments that will test for f(g(x))
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.