## WeBWorK Problems

### Lists of Implicit Equations

by Peter Staab -
Number of replies: 4
I have been trying to get an answer submitted as a list of implicit equations, (i.e. a linear system of equations).

Here's a snippet of the problem:

DOCUMENT(); # This should be the first executable line in the problem.
"MathObjects.pl",
"parserImplicitEquation.pl"
);

Context("ImplicitEquation");

# Do not show which answers are incorrect.
$showPartialCorrectAnswers = 0;$f1=ImplicitEquation("x+y=1");
$f2=ImplicitEquation("2x+3y=3");$ans = List($f1,$f2);

.
.
\{ans_rule(60)\}
.

ANS($ans->cmp); However, the correct answer is not accepted. I would like either: x+y=1,2x+3y=3 OR 2x+3y=3,x+y=1 to be accepted. The only acceptable answers seem to be x+y-1,2x+3y-3 or 2x+3y-3,2x+3y-3 Or is there an alternative way to check for such an answer. In reply to Peter Staab ### Re: Lists of Implicit Equations by Davide Cervone - The ImplicitEquation object is not the best choice for this problem. It isn't as reliable as I'd like it to be, and the tolerances have to be set just right for it to work properly. See  http://webwork.maa.org/doc/cvs/pg_HEAD/macros/parserImplicitEquation.pl.html  for more details. It also appears that it doesn't interact well with the List object. I'll need to look into that. You would be better off using parserImplicitPlane.pl and ImplicitPlane objects. These work in any dimension, and so in 2D they will be the implicit lines that you use in your example. Simply replace ImplictEquation by ImplicitPlane throughout and you should be in business. I did check that they work with List objects. You may also want to do  Context("ImplicitPlane")->variables->are(x=>'Real',y=>'Real');  to force the context into 2D (it defaults to 3D) so that error messages will talk about implicit lines rather than implicit planes. Davide In reply to Davide Cervone ### Re: Lists of Implicit Equations by Peter Staab - Thanks for pointing out this. I'm having an error running the code listed on the documentation page, http://webwork.maa.org/doc/cvs/pg_HEAD/macros/parserImplicitPlane.pl.html The top of the code is now: DOCUMENT(); # This should be the first executable line in the problem. loadMacros("PGstandard.pl", "MathObjects.pl", "parserImplicitPlane.pl" ); Context("Numeric"); # Do not show which answers are incorrect.$showPartialCorrectAnswers = 0;

Context()->variables->are(x=>'Real',y=>'Real',z=>'Real',w=>'Real');
$P = ImplicitPlane([1,0,2,-1],10); # w+2y-z = 10 (alphabetical order) and the results are: Unexpected character '='; see position 20 of formula at line 2 of (eval 5468) Died within ImplicitPlane::new called at line 2 of (eval 5468) from within main::ImplicitPlane called at line 33 of [TMPL]/tmpEdit/FSCproblems/ch02/test.pg.pstaab.tmp  (line 33 is the$P= line)

### Re: Lists of Implicit Equations

by Davide Cervone -
You need to set the context to "ImplicitPlane", not "Numeric". It is the context that defines what operators are allowed, and the equal sign is not in the Numeric context.

Also, you can don't have to use the coefficients-value approach to defining the plane (though that might be easier if your coefficients are being computed randomly), and could just use

    $P = ImplicitPlane("w + 2y - z = 10");  if that is clearer to you. Or  ($a,$b,$c,$d) = (0,2,-1,1);$P = ImplicitPlane("$a x +$b y + $c z +$d w = 10");

would also work.

Davide

### Re: Lists of Implicit Equations

by Peter Staab -
Thanks Davide,

This worked great.

Peter