FunctionDecomposition1

From WeBWorK_wiki
Revision as of 00:38, 1 December 2010 by Pearson (talk | contribs) (Created page with '<h2>Function Decomposition</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to check student answers that are a composition o…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function Decomposition

This PG code shows how to check student answers that are a composition of functions.

  • Download file: File:FunctionDecomposition1.txt (change the file extension from txt to pg)
  • File location in NPL: NationalProblemLibrary/FortLewis/Authoring/Templates/Precalc

Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

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

TEXT(beginproblem());

Initialization:

Context("Numeric");
Context()->variables->are(x=>"Real",y=>"Real",u=>"Real");

$a = random(2,9,1);

$f = Formula("sqrt(u)");
$g = Formula("x^2+$a");

Setup:

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

Main Text:

$showPartialCorrectAnswers = 1;

COMPOSITION_ANS( $f, $g, vars=>['u','x'], showVariableHints=>1);

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