ExpandedPolynomial1
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
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "contextLimitedPolynomial.pl", "contextPolynomialFactors.pl", "contextLimitedPowers.pl", ); TEXT(beginproblem()); |
Initialization: We need all of these macros. |
# # Vertex form # Context("Numeric"); $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 # Context("LimitedPolynomial-Strict"); $p[0] = $h**2 - $k; $p[1] = 2*$h; $expandedform = Formula("x^2 - $p[1] x + $p[0]")->reduce; # # Factored form # Context("PolynomialFactors-Strict"); Context()->flags->set(singleFactors=>0); LimitedPowers::OnlyIntegers( 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
For the expanded form we use the
For the factored form we need to change to the |
Context()->texStrings; BEGIN_TEXT The quadratic expression \( $vertexform \) is written in vertex form. $BR $BR (a) Write the expression in expanded form \( ax^2 + bx + c \). $BR \{ ans_rule(30) \} $BR $BR (b) Write the expression in factored form \( k(ax+b)(cx+d) \). $BR \{ ans_rule(30)\} END_TEXT Context()->normalStrings; |
Main Text:
Everything here is as usual. To help students understand how to format their answers, we give examples |
$showPartialCorrectAnswers = 1; ANS( $expandedform->cmp() ); ANS( $factoredform->cmp() ); |
Answer Evaluation: Everything is as expected. |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |