Difference between revisions of "FunctionDecomposition1"

From WeBWorK_wiki
Jump to navigation Jump to search
(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…')
 
(add historical tag and give links to newer problems.)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/FunctionDecomposition.html a newer version of this problem]</p>
  +
  +
 
<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)</li>
 
<li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Precalc</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 16: Line 22:
   
 
<tr valign="top">
 
<tr valign="top">
<th> PG problem file </th>
+
<th style="width: 50%"> PG problem file </th>
 
<th> Explanation </th>
 
<th> Explanation </th>
 
</tr>
 
</tr>
Line 43: Line 49:
   
 
loadMacros(
 
loadMacros(
"PGstandard.pl",
+
'PGstandard.pl',
"MathObjects.pl",
+
'MathObjects.pl',
"answerComposition.pl",
+
'answerComposition.pl',
"AnswerFormatHelp.pl",
+
'PGML.pl',
  +
'PGcourse.pl'
 
);
 
);
 
 
TEXT(beginproblem());
 
TEXT(beginproblem());
 
</pre>
 
</pre>
Line 55: Line 60:
 
<p>
 
<p>
 
<b>Initialization:</b>
 
<b>Initialization:</b>
  +
We need to include the macros file <code>answerComposition.pl</code>, 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.
 
</p>
 
</p>
 
</td>
 
</td>
Line 66: Line 72:
 
<pre>
 
<pre>
 
Context("Numeric");
 
Context("Numeric");
Context()->variables->are(x=>"Real",y=>"Real",u=>"Real");
+
Context()->variables->add(u=>"Real");
   
 
$a = random(2,9,1);
 
$a = random(2,9,1);
Line 86: Line 92:
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context()->texStrings;
 
  +
BEGIN_PGML
BEGIN_TEXT
 
  +
Express the function [` y = \sqrt{ x^2 + [$a] } `]
Express the function \( y = \sqrt{ x^2 + $a } \)
 
  +
as a composition [` y = f(g(x)) `] of two simpler
as a composition \( y = f(g(x)) \) of two simpler
 
  +
functions [` y = f(u) `] and [` u = g(x) `].
functions \( y = f(u) \) and \( u = g(x) \).
 
  +
$BR
 
  +
+ [` f(u) = `] [_______________]
$BR
 
  +
\( f(u) \) = \{ ans_rule(20) \}
 
  +
+ [` g(x) = `] [_______________]
\{ AnswerFormatHelp("formulas") \}
 
  +
$BR
 
  +
[@ helpLink('formula') @]*
\( g(x) \) = \{ ans_rule(20) \}
 
  +
END_PGML
\{ AnswerFormatHelp("formulas") \}
 
END_TEXT
 
Context()->normalStrings;
 
 
</pre>
 
</pre>
 
<td style="background-color:#ffcccc;padding:7px;">
 
<td style="background-color:#ffcccc;padding:7px;">
Line 120: Line 123:
 
<p>
 
<p>
 
<b>Answer Evaluation:</b>
 
<b>Answer Evaluation:</b>
  +
We use the <code>COMPOSITION_ANS()</code> routine to evaluate both answer blanks. It is possible to use the same variable for both answer blanks. See [http://webwork.maa.org/pod/pg/macros/answerComposition.html answerComposition.pl] for more options and details.
 
</p>
 
</p>
 
</td>
 
</td>
Line 129: Line 133:
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<pre>
 
<pre>
Context()->texStrings;
 
  +
BEGIN_PGML_SOLUTION
BEGIN_SOLUTION
 
${PAR}SOLUTION:${PAR}
 
 
Solution explanation goes here.
 
Solution explanation goes here.
END_SOLUTION
 
  +
END_PGML_SOLUTION
Context()->normalStrings;
 
 
COMMENT('MathObject version.');
 
   
 
ENDDOCUMENT();
 
ENDDOCUMENT();
Line 153: Line 152:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Latest revision as of 05:04, 18 July 2023

This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem


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',
  'PGML.pl',
  'PGcourse.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:

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) = `] [_______________]

+ [` g(x) = `]  [_______________]

[@ helpLink('formula') @]*
END_PGML

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 for more options and details.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution:

Templates by Subject Area