Difference between revisions of "EquationDefiningFunction1"
Jump to navigation
Jump to search
Line 41: | Line 41: | ||
<pre> |
<pre> |
||
DOCUMENT(); |
DOCUMENT(); |
||
+ | |||
loadMacros( |
loadMacros( |
||
"PGstandard.pl", |
"PGstandard.pl", |
||
Line 46: | Line 47: | ||
"parserAssignment.pl", |
"parserAssignment.pl", |
||
); |
); |
||
+ | |||
TEXT(beginproblem()); |
TEXT(beginproblem()); |
||
</pre> |
</pre> |
||
Line 67: | Line 69: | ||
$eqn = Formula("y=5x+2"); |
$eqn = Formula("y=5x+2"); |
||
− | $ |
+ | $fun = Formula("f(x)=3x^2+2x"); |
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 103: | Line 105: | ||
<pre> |
<pre> |
||
ANS( $eqn->cmp() ); |
ANS( $eqn->cmp() ); |
||
− | ANS( $ |
+ | ANS( $fun->cmp() ); |
ENDDOCUMENT(); |
ENDDOCUMENT(); |
Revision as of 23:01, 30 November 2010
Answer is an Equation Defining a Function
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
)
- Download file: File:EquationDefiningFunction1.txt (change the file extension from txt to pg)
- File location in NPL:
NationalProblemLibrary/FortLewis/Authoring/Templates/Algebra/EquationDefiningFunction1.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
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"); $fun = Formula("f(x)=3x^2+2x"); |
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.html |
BEGIN_TEXT Enter \( y = 5x+2 \) \{ ans_rule(20) \} $BR Enter \( f(x) = 3x^2+2x \) \{ ans_rule(20) \} END_TEXT |
Main Text: The problem text section of the file is as we'd expect. |
ANS( $eqn->cmp() ); ANS( $fun->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |