EquationDefiningFunction1

From WeBWorK_wiki
(Redirected from LinearEquationAnswer1)
Jump to navigation Jump to search
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


Answer is an Equation Defining a Function

Click to enlarge

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)


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

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");
$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

Context()->texStrings;
BEGIN_TEXT
Enter \( y = 5x+2 \) \{ ans_rule(20) \}
$BR
$BR
Enter \( f(x) = 3x^2+2x \) \{ ans_rule(20) \}
END_TEXT
Context()->normalStrings;

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

$showPartialCorrectAnswers = 1;

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

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:


Templates by Subject Area