Factored Polynomial

Factored polynomial

Complete Code

Download file: FactoredPolynomial.pg

PG problem file

Explanation

DOCUMENT();

loadMacros(
    'PGstandard.pl',               'PGML.pl',
    'contextPolynomialFactors.pl', 'contextLimitedPowers.pl',
    'PGcourse.pl'
);

Preamble

Additional contexts provided by the contextPolynomialFactors.pl and contextLimitedPowers.pl macros are needed.

# Expanded form
Context('Numeric');
$poly = Compute('8x^2 + 28x + 12');

# Factored form
Context('PolynomialFactors-Strict');
Context()->flags->set(singleFactors => 0);
LimitedPowers::OnlyIntegers(
    minPower => 0,
    maxPower => 1,
    message  => 'either 0 or 1',
);
$factored = Compute('4(2x+1)(x+3)');

Setup

Before computing the answer which will be the factored form of the polynomial, change to the PolynomialFactors-Strict context, and restrict the allowed powers to only 0 and 1 using the LimitedPowers::OnlyIntegers method. Note that restricting all powers to 0 or 1 means that repeated factors will have to be entered in the form k(ax+b)(ax+b) instead of k(ax+b)^2. Also, restricting all exponents to 0 or 1 means that the polynomial must factor as a product of linear factors (no irreducible quadratic factors can appear). If the exponents of 0, 1, or 2 were allowed, then students would be allowed to enter reducible quadratic factors. There are no restrictions on the coefficients, so the quadratic could have any nonzero leading coefficient. Also set singleFactors => 0 so that repeated, non-simplified factors do not generate errors.

BEGIN_PGML
Write the quadratic expression [`[$poly]`] in factored form [`k(ax+b)(cx+d)`].

[_]{$factored}{20}
END_PGML

Statement

Explicitly inform students to enter answers in the form k(ax+b)(cx+d).

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.