Difference between revisions of "AnswerIsSolutionToEquation"

From WeBWorK_wiki
Jump to navigation Jump to search
(Update links to http://webwork.maa.org/viewvc/system/trunk/pg/macros/parserSolutionFor.pl?view=log, etc)
 
(One intermediate revision by one other user 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/AnswerIsSolutionToEquation.html a newer version of this problem]</p>
 
<h2>Answer is any Solution to an Equation</h2>
 
<h2>Answer is any Solution to an Equation</h2>
   
Line 109: Line 112:
   
 
<ul>
 
<ul>
<li>POD documentation: [http://webwork.maa.org/pod/pg_TRUNK/macros/parserSolutionFor.pl.html parserSolutionFor.pl.html]</li>
+
<li>POD documentation: [http://webwork.maa.org/pod/pg/macros/parserSolutionFor.html parserSolutionFor.pl]</li>
 
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/parserSolutionFor.pl?view=log parserSolutionFor.pl]</li>
 
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/parserSolutionFor.pl?view=log parserSolutionFor.pl]</li>
 
</ul>
 
</ul>

Latest revision as of 16:53, 20 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

Answer is any Solution to an Equation


This PG code shows how to check student answers that can be any point satisfying an equation.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserSolutionFor.pl",
);

TEXT(beginproblem());

Initialization: We need to include the macros file parserDifferenceQuotient.pl.

Context("Vector")->variables->are(x=>'Real',y=>'Real');
$f = SolutionFor("x^2 = cos(y)","(1,0)");

#$f = SolutionFor("x^2 - y = 0",[2,4]);
#$f = SolutionFor("x^2 - y = 0",Point(4,2),vars=>['y','x']);

Setup: The routine SolutionFor("equation",point,options) takes an equation, a point that satisfies that equation, and options such as vars=>['y','x'] in case you want to change the order in which the variables appear in order pairs (the default is lexicographic ordering of the variables).

Context()->texStrings;
BEGIN_TEXT
A solution to \($f->{f}\) is \((x,y)\) = \{ans_rule(30)\}.
END_TEXT
Context()->normalStrings;

Main Text: We can use $f->{f} to get the Formula object of the equation, and $f->(point) to determine if the given point is solution to the equation or not.

$showPartialCorrectAnswers = 1;

ANS( $f->cmp() );

ENDDOCUMENT();

Answer Evaluation: As is the answer.

Problem Techniques Index