Function Decomposition

Decompose a function into two functions

Complete Code

Download file: FunctionDecomposition.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

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

Preamble

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 a student is asked 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

This problem asks the students for functions y = f(u) and u = g(x) such that f(g(x)) is a given function. Therefore, the variable u needs to be added to the context, and the functions $f and $g defined.

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

Use the COMPOSITION_ANS routine to evaluate the answers. It is possible to use the same variable for both answer rules. 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.