I've read quite a bit about this so I understand that the general consensus is that parserImplicitEquation.pl is 'finicky'. However, I am really struggling to think of another solution to this type of problem. I'd like to be able to have students enter equations of level curves of the form x^2-y^2=c.
The code seems to work just fine for other values I've tried, but when it is the constant $c3 is 4, I keep getting the 'Can't find any solutions to your equation" message. Here is my code. Any advice?
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"parserImplicitEquation.pl"
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
###########################
# Setup
#Context()->variables->add(y => 'Real');
Context()->noreduce('(-x)-y','(-x)+y');
$k1 = random(1,4,1);
$c1 = random(1,2,1);
$c2 = $c1+1;
$c3 = $c1+2;
$sc1 = sqrt($c1);
$sc2 = sqrt($c2);
$sc3 = sqrt($c3);
$a = Formula("x**2-y**2")->reduce;
Context("ImplicitEquation");
$ans1 = ImplicitEquation("x^2-y^2=$c1",
solutions => [[$sc1,0],[-$sc1,0]],
tolerance => .000001
);
$ans2 = ImplicitEquation("x^2-y^2=$c2",
solutions => [[$sc2,0],[-$sc2,0]],
tolerance => .000001
);
$ans3 = ImplicitEquation("x^2-y^2=$c3",
solutions => [[$sc3,0], [-$sc3,0]],
tolerance => .000001
);
BEGIN_PGML
Find the equation of the level curve of [`z(x,y) = [$a]`] at [`c=[$c1]`].[_]{$ans1}
Find the equation of the level curve of [`z(x,y) = [$a]`] at [`c=[$c2]`].[_]{$ans2}
Find the equation of the level curve of [`z(x,y) = [$a]`] at [`c=[$c3]`].[_]{$ans3}
END_PGML
############################
# Solution
#BEGIN_PGML_SOLUTION
#END_PGML_SOLUTION
COMMENT('MathObject version. Uses PGML.');
ENDDOCUMENT();