Decompose a function into two functions
Download file: FunctionDecomposition.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'answerComposition.pl', 'PGcourse.pl');
Preamble
We need to include the macro file answerComposition.pl
, which provides an answer checker that determines if two functions compose to form a given function. This can be used in problems where you ask a student to break a given function into a composition of two simpler functions, neither of which is allowed to be the identity function.
Context()->variables->add(u => 'Real'); $a = random(2, 9); $f = Formula("sqrt(u)"); $g = Formula("x^2+$a");
Setup
We will ask the students for a function f(u)
and and function g(x)
such that f(g(x))
is a given function. Therefore, we need to make u
a variable and define $f
and $g
.
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) =`] [_]{ width => 15 } * [`g(x) =`] [_]{ width => 15 } END_PGML
Statement
This is the problem statement in PGML.COMPOSITION_ANS($f, $g, vars => [ 'u', 'x' ], showVariableHints => 1);
Answer
We use the COMPOSITION_ANS()
routine to evaluate both answer blanks. It is possible to use the same variable for both answer blanks. See answerComposition.pl for more options and details.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.