## WeBWorK Problems

### algebra question

by Paul Pearson -
Number of replies: 2
Hi everyone,

I would like to be able to ask a question such as

Expand and simplify (x^{-3} + x^2 + 1) (x - 1/x)

and require student answers to be a sum of terms of the form k x^p, k x^{-p} or k / x^p that is fully simplified in the sense that there is only one term for each power. These kind of restrictions are currently available for products of polynomials (via contextLimitedPolynomial.pl). There are also ways to restrict the allowable exponents on student answers (via contextLimitedPowers.pl).

Is there a (hopefully easy) way to require student answers to be fully expanded and simplified for questions such as this one? (Note: I have thought of removing parentheses from the context; however, this may cause difficulties for students who enter x^(-3) who don't think to enter x^-3 instead.)

Paul Pearson

### Re: algebra question

by John Travis -
You could just create the answer entry to be in the form you want with small entry blanks for only coefficients and exponents.

That is, roughly
\{ ans_rule(2) \} $$x^$$ \{ ans_rule(2) \} + blah

JT
I think the solution would be to write a modified version of contextLimitedPolynomial.pl that allows negative powers, and that handles k/x^p (and knows that this is the same as k x^(-p) for the purposes of checking that each power is only used once). The contextLimitedPolynomial.pl file would be a good starting point, and I don't think it would be too hard to add the required functionality. But then I haven't looked at it in a while, so perhaps there would be complications that I'm not remembering. I'll see if I can give it a shot, but I'm not sure when I will have time. you see how long it has taken for me to reply!