Difference between revisions of "EquationImplicitFunction1"

From WeBWorK_wiki
Jump to navigation Jump to search
(add historical tag and give links to newer problems.)
 
(6 intermediate revisions by 3 users 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/Algebra/EquationImplicitFunction.html a newer version of this problem]</p>
  +
  +
 
<h2>Answer is an Equation that Implicitly Defines a Function</h2>
 
<h2>Answer is an Equation that Implicitly Defines a Function</h2>
   
Line 5: Line 10:
 
This PG code shows how to have an answer that is an equation that implicitly defines a function.
 
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 16: Line 21:
   
 
<tr valign="top">
 
<tr valign="top">
<th> PG problem file </th>
+
<th style="width: 50%"> PG problem file </th>
 
<th> Explanation </th>
 
<th> Explanation </th>
 
</tr>
 
</tr>
Line 42: Line 47:
 
DOCUMENT();
 
DOCUMENT();
   
loadMacros(
 
  +
loadMacros('PGstandard.pl','MathObjects.pl',
"PGstandard.pl",
 
  +
'parserImplicitEquation.pl','PGML.pl','PGcourse.pl');
"MathObjects.pl",
 
"parserImplicitEquation.pl",
 
"AnswerFormatHelp.pl",
 
);
 
 
 
TEXT(beginproblem());
 
TEXT(beginproblem());
 
</pre>
 
</pre>
Line 65: Line 65:
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context("ImplicitEquation");
+
Context('ImplicitEquation');
 
Context()->{error}{msg}{
 
Context()->{error}{msg}{
"Can't find any solutions to your equation"} = " ";
+
"Can't find any solutions to your equation"} = ' ';
 
Context()->{error}{msg}{
 
Context()->{error}{msg}{
"Can't generate enough valid points for comparison"} = " ";
+
"Can't generate enough valid points for comparison"} = ' ';
   
 
Context()->variables->set(
 
Context()->variables->set(
Line 79: Line 79:
 
$b = random(1,5,1);
 
$b = random(1,5,1);
 
$r = random(2,5,1);
 
$r = random(2,5,1);
  +
$p = Compute("($a,$b)");
   
 
$answer = ImplicitEquation(
 
$answer = ImplicitEquation(
 
"(x-$a)^2 + (y-$b)^2 = $r^2",
 
"(x-$a)^2 + (y-$b)^2 = $r^2",
solutions=>[
+
solutions=>[
 
[$a,$b+$r],
 
[$a,$b+$r],
 
[$a,$b-$r],
 
[$a,$b-$r],
Line 95: Line 96:
 
<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.
+
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>
 
<p>
 
<p>
Line 108: Line 109:
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context()->texStrings;
 
  +
BEGIN_PGML
BEGIN_TEXT
 
  +
Enter an equation for a circle in the [`xy`]-plane
Enter an equation for a circle in the xy-plane
 
  +
of radius [` [$r] `] centered at [` [$p] `].
of radius \( $r \) centered at \( ($a,$b) \).
 
  +
$BR
 
  +
[________________________]{$answer}
$BR
 
  +
\{ ans_rule(40) \}
 
  +
[@ helpLink('equation') @]*
\{ AnswerFormatHelp("equation") \}
 
  +
END_PGML
END_TEXT
 
Context()->normalStrings;
 
 
</pre>
 
</pre>
 
<td style="background-color:#ffcccc;padding:7px;">
 
<td style="background-color:#ffcccc;padding:7px;">
 
<p>
 
<p>
 
<b>Main Text:</b>
 
<b>Main Text:</b>
</p>
 
</td>
 
</tr>
 
 
<!-- Answer evaluation section -->
 
 
<tr valign="top">
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<pre>
 
$showPartialCorrectAnswers = 1;
 
 
ANS( $answer->cmp() );
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<p>
 
<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_TRUNK/macros/parserImplicitEquation.pl.html parserImplicitEquation.pl.html]
 
 
</p>
 
</p>
 
</td>
 
</td>
Line 148: Line 130:
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<pre>
 
<pre>
Context()->texStrings;
 
  +
BEGIN_PGML_SOLUTION
BEGIN_SOLUTION
 
${PAR}SOLUTION:${PAR}
 
 
Solution explanation goes here.
 
Solution explanation goes here.
END_SOLUTION
 
  +
END_PGML_SOLUTION
Context()->normalStrings;
 
 
COMMENT("MathObject version.");
 
   
 
ENDDOCUMENT();
 
ENDDOCUMENT();
Line 173: Line 150:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Latest revision as of 04:43, 18 July 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 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','PGML.pl','PGcourse.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);
$p = Compute("($a,$b)");

$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.

BEGIN_PGML
Enter an equation for a circle in the [`xy`]-plane
of radius [` [$r] `] centered at [` [$p] `].

[________________________]{$answer}

[@ helpLink('equation') @]*
END_PGML

Main Text:

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution:

Templates by Subject Area