Factored polynomial
Download file: SimpleFactoring.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Preamble
These standard macros need to be loaded.($x0, $x1) = (non_zero_random(-6, 6), non_zero_random(-6, 6));
$factor1 = Compute("x-$x0")->reduce;
$factor2 = Compute("x-$x1")->reduce;
$f = Compute("x^2-($x0+$x1)x+$x0*$x1")->reduce;
$factors = List($factor1, $factor2);
$roots = List($x0, $x1);
# If there were only one solution
# $roots = List(4);
# If there were no solutions
# $roots = List("NONE");
Setup
First, create two random roots and then create the factors. Note that
calling ->reduce will simplify x-(-3) to
x+3. In addition, create the expanded form of the
quadratic.
Note that the argument of the List call are the objects
in the list, which can be any MathObjects. Here we create a list of
Formulas and a list of Reals (the numbers that we use in the second list
will be promoted to Real MathObjects when the List is created).
If, for example, there were no real roots, then set
$roots = List("NONE") so that students who enter a list of
roots will not receive an error message about entering the wrong type of
answer. If $roots = String("NONE") were used instead,
students who enter anything other than a string (e.g., a list of
numbers) would receive an error message.
Similarly, if there were only one root at x = 4, use
$roots = List(4) instead of $roots = Real(4)
to avoid sending error messages to students who enter multiple answers
or NONE.
BEGIN_PGML
a) What are the factors of [`[$f]`]?
Factors = [__]{$factors}
b) What are the roots of this equation?
Roots = [__]{$roots}
_(Enter both answers as a comma-separated list.)_
END_PGML
Statement
This is the problem statement in PGML.BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.