Scaling and translating functions
Download file: ScalingTranslating.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'parserFunction.pl', 'PGcourse.pl');
Preamble
We must load parserFunction.pl
so that we can add a named function to the context.
parserFunction(f => 'sin(e * x) + 5.5 * pi * x^2'); $answer = Formula('f(x - 2) + 1');
Setup
The parserFunction
method allows us to add a named function to the context. We can define this function however we want, so we chose a function whose formula the students will not guess, whose domain is all real numbers, and which will have no issues during answer evaluation. Once a named function is added to the context, you can use it like you would any other named function.
BEGIN_PGML A function [`f(x)`] is shifted to the right [`2`] units and up [`1`] unit. Find a formula for this shifted function in terms of the function [`f(x)`]. [_]{$answer}{15} END_PGML
Statement
This is the problem statement in PGML.BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.