WeBWorK Problems

Implicit Equation

Implicit Equation

by Brittni Lorton -
Number of replies: 5

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();


In reply to Brittni Lorton

Re: Implicit Equation

by Alex Jordan -

The default domain for any variable is [-2,2]. In your problem, x and y are presumed to come from [-2,2].

x^2 - y^2 = 4

has no solutions in [-2,2] x [-2,2], except for the two at (-2,0) and (2,0). I suspect this is the issue. So I would try changing the text point domain of each variable to something such that you encompass more of the hyperbola curve.

Here is a page with ways to do that:

https://webwork.maa.org/wiki/FormulaTestPoints

In reply to Alex Jordan

Re: Implicit Equation

by Brittni Lorton -

Hm. so when I include the solution points to be just those two solutions, WW is still testing others? I was under the impression that the line

$ans3 = ImplicitEquation("x^2-y^2=$c3",

                solutions => [[$sc3,0], [-$sc3,0]],

                tolerance => .000001

        );

is making it so that WW is only checking the points [[$sc3,0], [-$sc3,0]] and not others. Maybe I am just misunderstanding what the line is doing when I am defining the solutions?


In reply to Brittni Lorton

Re: Implicit Equation

by Alex Jordan -

If it worked that way, then a student could enter y = 0 and it would be counted correct, since the two solutions you provided do agree with that equation.

I am skimming the code for parserImplicitEquation.pl, and I think it works like this. Two equations are being compared: your correct answer, and the student's submission. When you specify "solutions" you are declaring some solutions for your correct answer. However it still goes hunting for solutions to the student's answer. Then it tests your "solutions" in the student answer and it also tests the solutions that it found for the student's answer into the correct answer. It all needs to match up to be counted correct.

But I think in this case, with the default window being [-2,2]x[-2,2], it cannot find solutions at all to the student's submitted answer. There needs to be places within the domain window where F(x,y) takes on both positive and negative values.

So what is the purpose of specifying "solutions" as you are doing? Consider if a student entered x=sqrt(y^2+$c3). This is the right branch of that hyperbola curve. Presuming you want this to be counted incorrect, there is a concern. If you do not specify some "solutions" from both branches, then it's possible through the random point testing that only solutions on the right half of the plane will be tested. And it will miss how the student answer does not agree with the correct answer on the left side. So you are specifying "solutions" to make sure these two places are both tested.

If you expand the x-domain to something like [-4,4], it should cover this exercise.

In reply to Alex Jordan

Re: Implicit Equation

by Brittni Lorton -

That makes sense, definitely helps me understand what the defined solutions is doing.

Unfortunately, expanding the limits still has the same issue, I've tried multiple ways and still no go. I wonder if there is something else I should consider to make this one work out?

In reply to Brittni Lorton

Re: Implicit Equation

by Brittni Lorton -
I spoke too soon! I had expanded the limits only locally and for the wrong equation I meant to be testing. Expanding the limits definitely worked, thanks!