Difference between revisions of "EquationsDefiningFunctions"
Jump to navigation
Jump to search
Line 56: | Line 56: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
− | 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/ |
+ | 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> |
Revision as of 16:58, 7 April 2021
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
).
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserAssignment.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macro file |
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. |