From WeBWorK_wiki
Revision as of 13:21, 1 December 2010 by Pearson (talk | contribs) (Created page with '<h2>Polynomial Multiplication (Expanding)</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to require students to expand poly…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Polynomial Multiplication (Expanding)

This PG code shows how to require students to expand polynomial multiplication.

  • Download file: File:ExpandedPolynomial1.txt (change the file extension from txt to pg when you save it)
  • File location in NPL: NationalProblemLibrary/FortLewis/Authoring/Templates/Algebra/ExpandedPolynomial1.pg

Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:



Initialization: We need all of these macros.

#  Vertex form
$n = list_random(4,6);
$a = random(2,4,1);
$b = ($a+$n);
$h = ($b-$a)/2;
$k = $h**2+$a*$b;
$vertexform = Compute("(x-$h)^2-$k");

#  Expanded form
$p[0] = $h**2 - $k;
$p[1] = 2*$h;
$expandedform = Formula("x^2 - $p[1] x + $p[0]")->reduce;

#  Factored form
minPower => 0, maxPower => 1,
message => "either 0 or 1",
$factoredform = Compute("(x+$a)(x-$b)");

Setup: To construct this quadratic, we choose a nice factored form (x+$a)(x-$b) and from it we construct its vertex form (a(x-h)^2+k) and expanded form (ax^2+bx+c).

For the expanded form we use the LimitedPolynomial-Strict context, construct the coefficients $p[0] and $p[1] as Perl reals, and then construct $expandedform using these pre-computed coefficients. This is because the LimitedPolynomial-Strict context balks at answers that are not already simplified completely.

For the factored form we need to change to the PolynomialFactors-Strict context and restrict the allowed powers to either 0 or 1 using the LimitedPowers::OnlyIntegers block of code. Note: restricting all exponents 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). Of course, we could allow exponents to be 0, 1, or 2, but then students would be allowed to enter reducible quadratic factors. There are no restrictions on the coefficients, i.e., the quadratic could have any nonzero leading coefficient. We set singleFactors=>0 so that repeated, non-simplified factors do not generate errors.

The quadratic expression \( $vertexform \)
is written in vertex form.
(a) Write the expression in expanded form 
\( ax^2 + bx + c \).
\{ ans_rule(30) \}
(b) Write the expression in factored form
\( k(ax+b)(cx+d) \).
\{ ans_rule(30)\}

Main Text: Everything here is as usual. To help students understand how to format their answers, we give examples ax^2+bx+c and k(ax+b)(cx+d) of what the answers should look like.

$showPartialCorrectAnswers = 1;

ANS( $expandedform->cmp() );
ANS( $factoredform->cmp() );

Answer Evaluation: Everything is as expected.

Solution explanation goes here.

COMMENT('MathObject version.');



Templates by Subject Area