Difference between revisions of "EquationsDefiningFunctions"

From WeBWorK_wiki
Jump to navigation Jump to search
(New page: <h2>Equations Defining Functions (Not Implicit)</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px...)
 
(added historical tag and gave updated problem link)
 
(6 intermediate revisions by 2 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/problem-techniques/EquationsDefiningFunctions.html a newer version of this problem]</p>
 
<h2>Equations Defining Functions (Not Implicit)</h2>
 
<h2>Equations Defining Functions (Not Implicit)</h2>
   
Line 4: Line 7:
   
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
<em>This PG code shows how to check student answers that are equations that define functions.</em>
+
This PG code shows how to check student answers that are equations that define functions. If an equation defines a function, it is much more reliable to use the this method of answer evaluation (via <code>parserAssignment.pl</code>) than the implicit equation method (via <code>parserImplicitEquation.pl</code>).
 
</p>
 
</p>
   
Line 29: Line 32:
 
"parserAssignment.pl",
 
"parserAssignment.pl",
 
);
 
);
  +
TEXT(beginproblem());
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 55: Line 59:
 
<p>
 
<p>
 
<b>Setup:</b>
 
<b>Setup:</b>
We must allow assignment, and declare any function names we wish to use.
+
We must allow assignment, and declare any function names we wish to use. For more details and examples in other MathObjects contexts, see [http://webwork.maa.org/pod/pg/macros/parserAssignment.html parserAssignment.pl]
 
</p>
 
</p>
 
</td>
 
</td>
Line 86: Line 90:
 
ANS( $eqn->cmp() );
 
ANS( $eqn->cmp() );
 
ANS( $f->cmp() );
 
ANS( $f->cmp() );
  +
  +
ENDDOCUMENT();
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">
Line 101: Line 107:
   
 
[[Category:Problem Techniques]]
 
[[Category:Problem Techniques]]
 
 
 
<ul>
 
<li>POD documentation: [http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/parserAssignment.pl.html parserAssignment.pl.html]</li>
 
<li>PG macro [http://cvs.webwork.rochester.edu/viewcvs.cgi/pg/macros/parserAssignment.pl parserAssignment.pl]</li>
 
</ul>
 

Latest revision as of 09:31, 28 June 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

Equations Defining Functions (Not Implicit)


This PG code shows how to check student answers that are equations that define functions. If an equation defines a function, it is much more reliable to use the this method of answer evaluation (via parserAssignment.pl) than the implicit equation method (via parserImplicitEquation.pl).

Problem Techniques Index

PG problem file Explanation
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserAssignment.pl",
);
TEXT(beginproblem());

Initialization: We need to include the macro file parserAssignment.pl.

Context("Numeric")->variables->are(x=>"Real",y=>"Real");
parser::Assignment->Allow;
parser::Assignment->Function("f");

$eqn = Formula("y=5x+2");
$f = Formula("f(x)=5x+2");

Setup: We must allow assignment, and declare any function names we wish to use. For more details and examples in other MathObjects contexts, see parserAssignment.pl

BEGIN_TEXT
Enter \( y = 5x+2 \) \{ ans_rule(20) \}
$BR
Enter \( f(x) = 5x+2 \) \{ ans_rule(20) \}
END_TEXT

Main Text: The problem text section of the file is as we'd expect.

ANS( $eqn->cmp() );
ANS( $f->cmp() );

ENDDOCUMENT();

Answer Evaluation: As is the answer.

Problem Techniques Index