FunctionDecomposition1

From WeBWorK
(Difference between revisions)
Jump to: navigation, search
(PGML example link)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<h2>Function Decomposition</h2>
 
<h2>Function Decomposition</h2>
  
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
+
[[File:FunctionDecomposition1.png|300px|thumb|right|Click to enlarge]]
 +
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
 
This PG code shows how to check student answers that are a composition of functions.
 
This PG code shows how to check student answers that are a composition of functions.
<ul>
 
<li>Download file: [[File:FunctionDecomposition1.txt]] (change the file extension from txt to pg when you save it)</li>
 
<li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1.pg</code></li>
 
</ul>
 
 
</p>
 
</p>
 +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1.pg FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1.pg]
 +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1_PGML.pg FortLewis/Authoring/Templates/Precalc/FunctionDecomposition1_PGML.pg]
  
 +
 +
<br clear="all" />
 
<p style="text-align:center;">
 
<p style="text-align:center;">
 
[[SubjectAreaTemplates|Templates by Subject Area]]
 
[[SubjectAreaTemplates|Templates by Subject Area]]
Line 155: Line 156:
  
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
 +
[[Category:Subject Area Templates]]

Latest revision as of 19:47, 13 June 2015

Function Decomposition

Click to enlarge

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



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: We need to include the macros 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("Numeric");
Context()->variables->add(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: 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.html for more options and details.

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

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area

follow us