Difference between revisions of "EquationDefiningFunction1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with '<h2>Answer is a Linear Equation</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to check an answer that is a linear equation…')
 
Line 1: Line 1:
<h2>Answer is a Linear Equation</h2>
+
<h2>Answer is an Equation Defining a Function</h2>
   
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
This PG code shows how to check an answer that is a linear equation.
 
  +
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>)
 
<ul>
 
<ul>
 
<li>Download file: [[File:LinearEquationAnswer1.txt]] (change the file extension from txt to pg)</li>
 
<li>Download file: [[File:LinearEquationAnswer1.txt]] (change the file extension from txt to pg)</li>

Revision as of 23:58, 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:LinearEquationAnswer1.txt (change the file extension from txt to pg)
  • File location in NPL: NationalProblemLibrary/FortLewis/Authoring/Templates/Algebra/LinearEquationAnswer1.pg

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

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.


Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:


Templates by Subject Area