## WeBWorK Main Forum

### unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected

by Christian Seberino -
Number of replies: 8
Factoring for quadractics of 1 or 2 variables seems to be correctly enforced
by PolynomialFactors-Strict context.

However, polynomials with 4 variables seems to not have factoring enforced.
See below.

If you submit your answer as a*c + a*d + b*c + b*d
it is accepted.

DOCUMENT();
"PGstandard.pl",
"PGML.pl",
"MathObjects.pl",
"PGcourse.pl",
"parserNumberWithUnits.pl",
"contextArbitraryString.pl",
"contextPolynomialFactors.pl",
"contextLimitedPowers.pl",
"parserPopUp.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1; ###################################################################### Context("PolynomialFactors-Strict"); Context()->flags->set(singleFactors=>0); LimitedPowers::OnlyIntegers(minPower => 0, maxPower => 1); Context()->variables->add(a => "Real"); Context()->variables->add(b => "Real"); Context()->variables->add(c => "Real"); Context()->variables->add(d => "Real"); BEGIN_PGML Write [ac + ad + bc + bd] in completely factored form. [________________________]{"(a + b)*(c + d)"} END_PGML ###################################################################### ENDDOCUMENT(); In reply to Christian Seberino ### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected by Danny Glin - The reason for this is that it is only checking that the power of each variable is at most 1, which is also true of the original expression. You would run into the same problem in the two-variable case with something like xy+2x+3y+6. This type of answer checker is only effective if the solution is linear in each variable, and the original expression is not, so there are also many other cases which it won't handle. Unfortunately, I don't know a good way of checking such factoring in general. I still use questions with two answer blanks in brackets, and then use a multi-answer checker so students can enter the factors in either order. Danny In reply to Danny Glin ### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected by Christian Seberino - > I still use questions with two answer blanks in brackets, and then use a multi-> answer checker so students can enter the factors in either order. That's a *great* idea! cs In reply to Christian Seberino ### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected by Paul Pearson - Hi, Even easier: use unorderedAnswer.pl instead of parserMultiAnswer.pl. For example, see http://webwork.maa.org/wiki/UnorderedAnswers1 Have a good weekend! Paul Pearson In reply to Paul Pearson ### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected by Alex Jordan - The problem I'd have with unorderedAnswers arises with say, factoring 2x^2-3x+1. Probably the expected factors would be (2x-1) and (x-1). But should a student's answer be incorrect if they give (1-2x) and (1-x)? What about (x-1/2) and (2x-2)? multiAnswer could at lease deal with these by multiplying student factors and comparing to the known correct answer. But these approaches are unsatisfying. First, they give away the number of factors to the student. Worse, they just don't feel true to what the pen-and-paper experience would be. Even the method using PolynomialFactors that limits exponents feels artificial, because why should a student a priori know that the given polynomial factors at all? Or doesn't have quadratic factors? How does one ask a student to factor x^4-1? We can't limit the degrees to 2 and below, or (x^2-1)(x^2+1) is legal. But more importantly, why should a student a be told a priori that cubic factors are not allowed in such a problem? It's a tough nut to crack! At least with my degree of pickiness :) In reply to Danny Glin ### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected by Christian Seberino - Even with a ONE variable case the problem persists.... e.g. 2y + 6 :) In reply to Danny Glin ### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected by Alex Jordan - We're working on something that may be relevant. There are a lot of WeBWorK projects happening here and when we have the time, the plan is: • Use PolynomialFactors for pre-filter checking of the student answer. • Have the checker compare the correct answer and student answer as functions, and of course if they are not equal, the answer is incorrect. • Process the student answer as a Math Object Formula, and break down its parse tree by its top-level operators. The idea is to create an array of the student's primitive factors, so say 3(x+1)(x+2)^2 gives (3,x+1,x+2). • Because we may want factoring over Z, checking the gcd of coefficients within each factor. • Pass each of these things to SAGE and ask if the nonconstant factors are reducible over Z or Q. Also ask if they are monic. These things at least we learned how to do at the Vancouver code camp. The end goal is to count the following forms as correct, possibly controlled by flags: n \prod (factor)^power, where each factor is irreducible in Z[X], n in Z r \prod (factor)^power, where each factor is irreducible and monic in Q[X], r in Q I suppose on the last one the monic requirement could be dropped with a flag. I have no plans to check that the form is fully condensed, e.g. forcing (x+1)^2 and rejecting (x+1)(1+x), but that could be done in SAGE too somehow looking at the gcd of the student's factors. In reply to Alex Jordan ### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected by Hedley Pinsent - Seems like we have too much "division of labour" in the system. The Problem (Author) is best qualified to determine the characteristics of an answer. However it seems we are expecting the "Answer Checkers" to go away and, in isolation, sort it all out. Maybe these "answer checkers" (very clever algorithms) should simply make recommendations back to the Problem, the Problem would then make the last call. ---------------------------------------------------------- Factor: a*c + a*d + b*c + b*d$Recommendation1 = Is_NumericallyEqualTo_($StudentAnswer, a*c + a*d + b*c + b*d) //check points$Recommendation2 = AreThere_OccurancesOf_In_(2,"+",$StudentAnswer) // check for 2 "+"s$FinalRecommendation = $Recommendation1 AND$Recommendation2
Submit($FinalRecommendation,$StudentResponse,$CorrectResponse)//only$FinalRecommendation counts

------------------------------------------------------------

Factor: 2x^2 + 10x +12 ................. 2(x+2)(x+3)

$Recommendation1 = Is_NumericallyEqualTo_($StudentAnswer, 2x^2 + 10x +12) //check points
@List = (2,2,3)
$Recommendation2 = Are_In_(@List,$StudentAnswer)
$FinalRecommendation =$Recommendation1 AND $Recommendation2 Submit($FinalRecommendation,$StudentResponse,$CorrectResponse)//only $FinalRecommendation counts ------------------------------------------------------------- Add 12.3 +45.7$Recommendation1 = Is_Equal_($StudentAnswer,58) //check numerical equality$Recommendation2 = AreThere_DigitsIn_(3,$StudentAnswer) //checking for trailing zero$FinalRecommendation = $Recommendation1 AND$Recommendation2

Submit($FinalRecommendation,$StudentResponse,$CorrectResponse)//only$FinalRecommendation counts
In reply to Hedley Pinsent

### Re: unfactored low degree polynomial can slip through PolynomialFactors-Strict context undetected

by Danny Glin -
Alex beat me to most of my comments on "what is considered factored".

In our department alone, there is disagreement on what the factored form of something like 2x^2+3x+1 should be.  One camp expects (2x+1)(x+1), while another expects 2(x+1/2)(x+1).

Regarding not giving away the number of factors in the correct answer, the solution I had in mind for that is something I'd like to see more generally:

For list-type answers, start the student with a single answer blank, but beside it have a (probably javascript) button that adds another blank.  Behind the scenes, compile these blanks into a list object, and pass it to the answer checker.

I have several uses for this:
1. I think it would be a nicer interface for any question where the answer is an unordered list of objects.
2. It could be used for factoring questions (where the button reads "add another factor").
3. The more advanced use I'd have for this is to handle unordered, paired answers.  For example, give the students a matrix and ask for the eigenvalues and corresponding eigenvectors.  Start the student with one pair of blanks: one for an eigenvalue and the next for the corresponding eigenvector(s).  The students can then add another set of eigenvector/eigenvalue blanks if there are additional eigenvectors.
Of course this is a solution to the student input challenges, which doesn't address the (much harder) problem of what to accept as an answer in our factoring discussion.