## WeBWorK Problems

### Error Message: Your formula isn't a linear one ### Error Message: Your formula isn't a linear one

by James Morski -
Number of replies: 5
In the following code, I am getting the attached error message.

I think this might have something to do with ImplicitPlane, although I am not certain. Interestingly, for the asymptotes, 6y=7x, 6y=-7x is accepted as correct. And, in other seeds, an answer like y=1/7x, y=-1/7x is also accepted as correct. Any help would be great, because I'm stumped.

## DESCRIPTION
## Algebra, Exponential functions
## ENDDESCRIPTION

## DBsubject(Algebra)
## DBchapter(Conic sections)
## DBsection(Hyperbolas)
## Date(11/09/2017)
## Institution(Community College of Denver, Colorado Community College System)
## Author(James Morski)
## Static(1)
## MO(1)
## KEYWORDS('algebra','hyperbola')

###########################
# Initialization

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"contextLimitedPoint.pl",
"parserImplicitPlane.pl",
"PGML.pl",
"PGcourse.pl",
);

TEXT(beginproblem());

$showPartialCorrectAnswers = 1; ########################## # Setup Context("Numeric");$a = random(1,8,1);
do { $b =random(1,8,1); } until ($b != $a );$c=Compute("($a^2+($b)^2)^(1/2)");

$chooser=random(1,2,1); #vertical orientation if ($chooser==1) {
Context("LimitedPoint");
$f = Formula("(y^2)/$b^2-(x^2)/$a^2")->reduce;$foci = List(Point("(0,$c)"), Point("(0,-$c)"));
$vertices= List( Point("(0,-$b)"),Point("(0,$b)")); Context("ImplicitPlane")->variables->are(x=>'Real',y=>'Real');$posasymptote = ImplicitPlane("$a*y=$b*x");
$negasymptote = ImplicitPlane("$a*y=-$b*x");$asymptote = List($posasymptote,$negasymptote)
}

#horizontal orientation
else {
Context("LimitedPoint");
$f = Formula("(x^2)/$a^2-(y^2)/$b^2")->reduce;$foci = List(Point("($c,0)"), Point("(-$c,0)"));
$vertices = List( Point("(-$a,0)"),Point("($a,0)")); Context("ImplicitPlane")->variables->are(x=>'Real',y=>'Real');$posasymptote = ImplicitPlane("y=($b/$a)x");
$negasymptote = ImplicitPlane("y=-($b/$a)x");$asymptote = List($posasymptote,$negasymptote)
}

#################################
# Main text

BEGIN_PGML
For the given equation of a hyperbola, identify the foci and the vertices, and write the equations of the asymptote lines. Enter each as a comma separated list.

>>[ [$f]=1 ]<< Foci:[___________________________]{$foci} [@ AnswerFormatHelp("points") @]*

Vertices: [_____________________]{$vertices} [@ AnswerFormatHelp("points") @]* Asymptotes: [____________________________________________]{$asymptote} [@ AnswerFormatHelp("equations")@]*

END_PGML

#################################
# Solution

#BEGIN_PGML_SOLUTION
#Solution explanation goes here.
#END_PGML_SOLUTION

COMMENT('Uses PGML.');

ENDDOCUMENT();  ### Re: Error Message: Your formula isn't a linear one

by Alex Jordan -
Hi James,

What seed is producing the issue?

Is anything different if you use:
$asymptote = Compute("$posasymptote, $negasymptote") ? Aside from troubleshooting what you describe, if it is reasonable to expect "x = number" or "y = number" for the answers here, then I might use consider using parserAssignment.pl instead (http://webwork.maa.org/pod/pg_TRUNK/macros/parserAssignment.pl.html). It would side step whatever issue is happening here. Although, perhaps it is not semantically correct for the case of vertical and horizontal lines. Alex In reply to Alex Jordan ### Re: Error Message: Your formula isn't a linear one by James Morski - This is seed 205. Changing to$asymptote = Compute("$posasymptote,$negasymptote")

yields the same result.

I don't think your suggestion for parserAssignment.pl will do here because the asymptotes aren't vertical or horizontal lines. ### Re: Error Message: Your formula isn't a linear one

by Davide Cervone -
It turns out that there is an issue with the ImplicitPlane implementation. When a plane is given by a list of coefficients and a constant, the plane is produced by creating a string that is then parsed into the ImplicitPlane object. The problem is, since the coordinates of the vector are MathObject Reals, when they are turned into strings, they are printed with only 6 digits of precision. So there is a numeric issue when comparing against a version of the place that has full precision.

Now the way that the student answer is processed is that the coefficients are determined by first creating a formula by subtracting the right-hand side of their equality from the left (to get a function equal to 0), then evaluating that function at (0,0) to get the constant c in ax + by + c = 0, and then evaluating at (1,0) and (0,1) and subtracting c to get a and b. These computation cam be performed no matter whether the student's function is linear or not. So we need to check that the ax + by + c = 0 that is produced actually matches the original function (i.e., the student's original actually is a linear one).

So the plane with those coefficients and constant is produced (via the process described above) and that plane's left-hand side minus its right-hand side is compared to the students original function. If they match, the student's answer IS this plane. Otherwise the error you received is produced.

Because the student's plane is being produced from coefficients that have been reduced to 6 digits of precision, it ends up not matching their original equation (at least for some seeds, when the numeric instability kicks in).

The offending line of code is line 120 of the parserImplicitPlane.pl file. If you change string to value there, it should clear up the problem. Make a copy of the file in your course's templates/macros folder and edit that line. See if that works for you.  