From WeBWorK

Jump to: navigation


NAME

contextPolynomialFactors.pl - Allow only entry of polynomials, and their products and powers

DESCRIPTION

Implements a context in which students can only enter products and powers of polynomials

Select the context using:

        Context("PolynomialFactors");

If you set the "singlePowers" flag, then only one monomial of each degree can be included in each factor polynomial:

        Context("PolynomialFactors")->flags->set(singlePowers=>1);

If you set the "singleFactors" flag, then factors can not be repeated. For example,

        Context("PolynomialFactors")->flags->set(singleFactors=>1);
        Formula("(x+1)^2*(x+1)");

will generate an error indicating that factors can appear only once. Note, however, that this only catches factors that appear exactly the same in both cases, so (x+1)*(1+x) would be allowed, as would -(x-1)*(1-x). Note also that there is no check for whether the factors are irreducible, so (x^2-1)*(x+1)*(x-1) would be allowed. Also, there is no check for whether constants have been factored out, so 3*(x+1)*(3x+3) would be allowed. This still needs more work to make it very useful.

There are two additional flags that control whether division by a constant or raising to a power are allowed to be performed on a product or factors or only on a single factor at at time. These are strictDivision and strictPowers. By default, strictDivisions is 0, so (x*(x+1))/3 is allowed, while strictPowers is 1, so (x*(x+1))^3 is not (it must be written x^3*(x+1)^3).

Finally, there is also a strict context that does not allow operations even within the coefficients. Select it using:

        Context("PolynomialFactors-Strict");

In addition to disallowing operations within the coefficients, this context does not reduce constant operations (since they are not allowed), and sets the singlePowers, singleFactors, strictDivision, and stricPowers flags automatically. In addition, it disables all the functions, though they can be re-enabled, if needed.