Difference between revisions of "EquationImplicitFunction1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with '<h2>Answer is an Equation that Implicitly Defines a Function</h2> 300px|thumb|right|Click to enlarge <p style="background-color:#f9f9f9;bo…')
 
(7 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
[[File:EquationImplicitFunction1.png|300px|thumb|right|Click to enlarge]]
 
[[File:EquationImplicitFunction1.png|300px|thumb|right|Click to enlarge]]
 
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
 
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
This PG code shows how to have an answer that is an equation that implicitly defines a function. The answer evaluator used is very sensitive and finicky, so it is strongly recommended that you read about it at [http://webwork.maa.org/pod/pg_TRUNK/macros/parserImplicitEquation.pl.html parserImplicitEquation.pl.html]
+
This PG code shows how to have an answer that is an equation that implicitly defines a function.
 
</p>
 
</p>
* Download file: [[File:EquationImplicitFunction1.txt]] (change the file extension from txt to pg when you save it)
 
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1.pg FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1.pg</code>
 
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1_PGML.pg FortLewis/Authoring/Templates/Algebra/EquationImplicitFunction1_PGML.pg]
   
 
<br clear="all" />
 
<br clear="all" />
Line 95: Line 95:
 
<p>
 
<p>
 
<b>Setup:</b>
 
<b>Setup:</b>
  +
We quash some error messages by redefining them to be a blank string <code>" "</code> (notice the space). Since the circle will always be contained in a rectangle with two opposite corners at <code>(-4,-4)<code> and <code>(10,10)</code>, we set the limits for the variables x and y to be outside of this rectangle. The <code>ImplicitEquation</code> object allows us to specify as many solutions as we like, and doing so should improve the accuracy of the answer evaluator.
  +
</p>
  +
<p>
  +
If your equation is linear of the form <code>x=3</code>, <code>4x+3y=12</code>, or <code>4x+3y+5z=21</code>, or..., you should probably use the [ImplicitPlane1 implicit plane] context and answer evaluator.
 
</p>
 
</p>
 
</td>
 
</td>
Line 134: Line 138:
 
<p>
 
<p>
 
<b>Answer Evaluation:</b>
 
<b>Answer Evaluation:</b>
  +
The answer evaluator used is very sensitive and finicky. We strongly recommended that you read about it at [http://webwork.maa.org/pod/pg/macros/parserImplicitEquation.html parserImplicitEquation.pl]
 
</p>
 
</p>
 
</td>
 
</td>
Line 149: Line 154:
 
END_SOLUTION
 
END_SOLUTION
 
Context()->normalStrings;
 
Context()->normalStrings;
 
   
 
COMMENT("MathObject version.");
 
COMMENT("MathObject version.");
Line 169: Line 173:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Revision as of 18:03, 7 April 2021

Answer is an Equation that Implicitly Defines a Function

Click to enlarge

This PG code shows how to have an answer that is an equation that implicitly defines a function.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();   

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserImplicitEquation.pl",
"AnswerFormatHelp.pl",
);     

TEXT(beginproblem());

Initialization:

Context("ImplicitEquation");
Context()->{error}{msg}{
"Can't find any solutions to your equation"} = " ";
Context()->{error}{msg}{
"Can't generate enough valid points for comparison"} = " ";

Context()->variables->set(
  x=>{limits=>[-6,11]},
  y=>{limits=>[-6,11]},
);

$a = random(1,5,1);
$b = random(1,5,1);
$r = random(2,5,1);

$answer = ImplicitEquation(
  "(x-$a)^2 + (y-$b)^2 = $r^2",
  solutions=>[ 
     [$a,$b+$r],
     [$a,$b-$r],
     [$a+$r,$b],
     [$a-$r,$b],
     [$a+$r*sqrt(2)/2,$b+$r*sqrt(2)/2],
  ]
);

Setup: We quash some error messages by redefining them to be a blank string " " (notice the space). Since the circle will always be contained in a rectangle with two opposite corners at (-4,-4) and (10,10), we set the limits for the variables x and y to be outside of this rectangle. The ImplicitEquation object allows us to specify as many solutions as we like, and doing so should improve the accuracy of the answer evaluator.

If your equation is linear of the form x=3, 4x+3y=12, or 4x+3y+5z=21, or..., you should probably use the [ImplicitPlane1 implicit plane] context and answer evaluator.

Context()->texStrings;
BEGIN_TEXT
Enter an equation for a circle in the xy-plane 
of radius \( $r \) centered at \( ($a,$b) \).
$BR
$BR
\{ ans_rule(40) \}
\{ AnswerFormatHelp("equation") \}
END_TEXT
Context()->normalStrings;

Main Text:

$showPartialCorrectAnswers = 1;

ANS( $answer->cmp() );

Answer Evaluation: The answer evaluator used is very sensitive and finicky. We strongly recommended that you read about it at parserImplicitEquation.pl

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

COMMENT("MathObject version.");

ENDDOCUMENT();

Solution:

Templates by Subject Area