## WeBWorK Main Forum

### Any caveats regarding the range of x and y when using the ImplicitEquation context?

by Christian Seberino -
Number of replies: 3
I've noticed strange errors when the ranges of x and y below are changed to
[-1,1].  In that case I get this...

Error parsing answer: 'plicitEquation' is not defined in this context; see position 3 of formula

I thought the ranges of x and y were not so important but apparently there
are certain caveats to be aware of?

cs

DOCUMENT();
"MathObjects.pl",
"PGstandard.pl",
"PGML.pl",
"PGcourse.pl",
"parserNumberWithUnits.pl",
"contextArbitraryString.pl",
"parserPopUp.pl",
"contextInequalities.pl",
"parserImplicitEquation.pl",
"PGgraphmacros.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1; ###################################################################### Context("ImplicitEquation"); Context()->variables->set( x=>{limits=>[-8,8]}, y=>{limits=>[-8,8]} ); BEGIN_PGML What is the equation for a circle with its center at (4, 2) throught the point (3, 2)? [________________________]{ImplicitEquation("(x-4)^2 + (y-2)^2=1", tolerance=>0.0001)} END_PGML ###################################################################### ENDDOCUMENT(); In reply to Christian Seberino ### Re: Any caveats regarding the range of x and y when using the ImplicitEquation context? by Davide Cervone - The ImplicitEquation object requires the variable limits to include points that are solutions to the equation. This is from the documentation for parserImplicitEquation.pl: The method used to locate the solutions of A=B is by finding zeros of A-B, and it requires this function to take on both positive and negative values (that is, it can only find transverse intersections of the surface A-B=0 and the plane at height 0). ... In order to locate the zeros, you may need to change the limits so that they include regions where the function is both positive and negative Your equation is a circle of radius 1 centered at (4,2), so when the limits are [-8,8], this does include the circle, whereas the limits [-1,1] do not, so these limits are not appropriate for use with this equation. You should get a message about not being able to find solutions within the given limits, but I think the use of PGML has obscured that. My recommendation would be to create the MathObject outside of PGML, as in the following:  Context("ImplicitEquation");$circle = ImplicitEquation("(x-4)^2 + (y-2)^2=1",
tolerance=>0.0001, limits=>[0,8]);

BEGIN_PGML
What is the equation for a circle with its center at (4, 2)
throught the point (3, 2)?

[________________________]{\$circle}
END_PGML


This will make sure you get any error messages from the creation of the implicit equation.

### Re: Any caveats regarding the range of x and y when using the ImplicitEquation context?

by Christian Seberino -
Ah thanks that makes sense.  Would this "lazy" solution be a good idea?.....

You said the interval needs to include certain things.  What if I defaulted to a huge interval that was sure to work in 99% of the cases?

e.g.

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

cs