Difference between revisions of "FactoringAndExpanding"
(added historical tag and gave updated problem link) |
|||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/FactoringAndExpanding.html a newer version of this problem]</p> |
||
<h2>Factoring and Expanding Polynomials</h2> |
<h2>Factoring and Expanding Polynomials</h2> |
||
Line 15: | Line 18: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <b>Example 1:</b> (Recommended) Using the PolynomialFactors context and the LimitedPowers context for factoring and the LimitedPolynomial context for |
+ | <b>Example 1:</b> (Recommended) Using the PolynomialFactors context and the LimitedPowers context for factoring and the LimitedPolynomial context for factoring. |
</p> |
</p> |
||
Line 93: | Line 96: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
− | To construct this quadratic, we choose a nice factored form <code>(x+$a)(x-$b)</code> and from it we construct its vertex form (a(x-h)^2+k) and |
+ | To construct this quadratic, we choose a nice factored form <code>(x+$a)(x-$b)</code> and from it we construct its vertex form (a(x-h)^2+k) and expanded form (ax^2+bx+c). |
</p> |
</p> |
||
<p> |
<p> |
||
− | For the expanded form we use the <code>LimitedPolynomial-Strict</code> context, construct the coefficients <code>$p[0]</code> and <code>$p[1]</code> as Perl reals, and then construct <code>$ |
+ | For the expanded form we use the <code>LimitedPolynomial-Strict</code> context, construct the coefficients <code>$p[0]</code> and <code>$p[1]</code> as Perl reals, and then construct <code>$expandedform</code> using these pre-computed coefficients. This is because the LimitedPolynomial-Strict context balks at answers that are not already simplified completely. |
</p> |
</p> |
||
<p> |
<p> |
||
Line 115: | Line 118: | ||
$BR |
$BR |
||
$BR |
$BR |
||
− | (a) Write the expression in |
+ | (a) Write the expression in expanded form |
\( ax^2 + bx + c \). |
\( ax^2 + bx + c \). |
||
$BR |
$BR |
||
Line 327: | Line 330: | ||
[[Category:Problem Techniques]] |
[[Category:Problem Techniques]] |
||
+ | |||
+ | |||
+ | |||
+ | <ul> |
||
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/contextLimitedPolynomial.html contextLimitedPolynomial.pl]</li> |
||
+ | <li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/contextLimitedPolynomial.pl?view=log contextLimitedPolynomial.pl]</li> |
||
+ | </ul> |
||
+ | |||
+ | |||
+ | <ul> |
||
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/contextPolynomialFactors.html contextPolynomialFactors.pl]</li> |
||
+ | <li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/contextPolynomialFactors.pl?view=log contextPolynomialFactors.pl]</li> |
||
+ | </ul> |
||
+ | |||
+ | |||
+ | <ul> |
||
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/contextLimitedPowers.html contextLimitedPowers.pl]</li> |
||
+ | <li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/contextLimitedPowers.pl?view=log contextLimitedPowers.pl]</li> |
||
+ | </ul> |
||
<ul> |
<ul> |
||
− | <li>POD documentation: [http://webwork.maa.org/ |
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg/macros/parserMultiAnswer.html parserMultiAnswer.pl]</li> |
− | <li>PG macro: [http:// |
+ | <li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/parserMultiAnswer.pl?view=log parserMultiAnswer.pl]</li> |
</ul> |
</ul> |
Latest revision as of 08:43, 28 June 2023
This problem has been replaced with a newer version of this problem
Factoring and Expanding Polynomials
This is the PG code to check answers that require students to factor or expand a polynomial expression.
- Example 1: (Recommended) Using the PolynomialFactors context and the LimitedPowers context for factoring, and the LimitedPolynomial context for expanding.
- Example 2: Using adaptive parameters and a MultiAnswer for factoring and the LimitedPolynomial context for expanding.
Example 1: (Recommended) Using the PolynomialFactors context and the LimitedPowers context for factoring and the LimitedPolynomial context for factoring.
PG problem file | Explanation |
---|---|
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() ); ENDDOCUMENT(); |
Answer Evaluation: Everything is as expected. |
Example 2: Using adaptive parameters and a MultiAnswer for factoring and the LimitedPolynomial context for expanding.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserMultiAnswer.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the |
Context("Numeric"); $fac1 = Compute("(2 x + 3)"); $fac2 = Compute("(8 x + 12)"); $multians = MultiAnswer($fac1,$fac2)->with( singleResult => 0, allowBlankAnswers => 0, # singleResult => 1, # separator => " * ", # tex_separator => " \cdot ", checker => sub { my $correct = shift; my $student = shift; my $ansHash = shift; my ($F,$G) = @{$correct}; my ($f,$g) = @{$student}; $ansHash->setMessage(1,"Neither factor can be constant") unless $f->isFormula; $ansHash->setMessage(2,"Neither factor can be constant") unless $g->isFormula; # use an adaptive parameter 'a' my $context = Context()->copy; $context->flags->set(no_parameters=>0); $context->variables->add('a'=>'Parameter'); my $a = Formula($context,'a'); $f = Formula($context,$f); $g = Formula($context,$g); $F = Formula($context,$F); $G = Formula($context,$G); if ( (($a*$F == $f) && ($F*$G == $f*$g)) || (($a*$G == $f) && ($F*$G == $f*$g)) ) { return [1,1]; } elsif (($a*$F == $f) || ($a*$G == $f)) { return [1,0]; } elsif (($a*$F == $g) || ($a*$G == $g)) { return [0,1]; } else { return [0,0]; } } ); |
Setup:
This is a standard factoring problem for a non-monic polynomial (where the leading coefficient is not 1 or -1). Since it is possible to factor
The For more details on adaptive parameters and MultiAnswer, please see AdaptiveParameters and MultiAnswerProblems. |
Context()->texStrings; BEGIN_TEXT Factor the following expression. $BR $BR \( 16 t^2 + 48 t + 36 = \big( \) \{$multians->ans_rule(10)\} \( \big) \big( \) \{$multians->ans_rule(10)\} \( \big) \) END_TEXT Context()->normalStrings; |
Main Text:
Each answer blank must be a method of the |
$showPartialCorrectAnswers = 1; install_problem_grader(~~&std_problem_grader); ANS( $multians->cmp() ); ENDDOCUMENT(); |
Answer Evaluation:
Everything is as expected. We give students feedback on whether their answers are correct by using |
- POD documentation: contextLimitedPolynomial.pl
- PG macro: contextLimitedPolynomial.pl
- POD documentation: contextPolynomialFactors.pl
- PG macro: contextPolynomialFactors.pl
- POD documentation: contextLimitedPowers.pl
- PG macro: contextLimitedPowers.pl
- POD documentation: parserMultiAnswer.pl
- PG macro: parserMultiAnswer.pl