Difference between revisions of "ScalingTranslating1"

From WeBWorK_wiki
Jump to navigation Jump to search
(PGML example link)
Line 6: Line 6:
 
</p>
 
</p>
 
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/ScalingTranslating1.pg FortLewis/Authoring/Templates/Precalc/ScalingTranslating1.pg]
 
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/ScalingTranslating1.pg FortLewis/Authoring/Templates/Precalc/ScalingTranslating1.pg]
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/ScalingTranslating1_PGML.pg FortLewis/Authoring/Templates/Precalc/ScalingTranslating1_PGML.pg]
   
 
<br clear="all" />
 
<br clear="all" />

Revision as of 20:59, 13 June 2015

Scaling and Translating Functions

Click to enlarge

This PG code shows how to add a named function to the context and use it to asses whether students know their graph transformations.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"AnswerFormatHelp.pl",
"parserFunction.pl",
);

TEXT(beginproblem());

Initialization: We must load parserFunction.pl so that we can add a named function to the context.

Context("Numeric");
parserFunction(f => "sin(e*x)+5.5*pi");

$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.

Context()->texStrings;
BEGIN_TEXT
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) \).
$BR
$BR
Answer = \{ ans_rule(20) \}
\{ AnswerFormatHelp("formulas") \}
END_TEXT
Context()->normalStrings;

Main Text:

$showPartialCorrectAnswers = 1;

ANS( $answer->cmp() );

Answer Evaluation:

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area