DOCUMENT(); loadMacros( "PGstandard.pl", "PGML.pl", "MathObjects.pl", "contextArbitraryString.pl", "parserPopUp.pl", "parserImplicitEquation.pl", "parserMultiAnswer.pl", "parserFunction.pl" ); $x_intercept1 = random(2,7); $x_intercept2_num = 1; $x_intercept2_den = random(2,7); $x_intercept2 = $x_intercept2_num/$x_intercept2_den; $a = $x_intercept2_den; $b = -($x_intercept2_den*$x_intercept1 + $x_intercept2_num); $c = $x_intercept1*$x_intercept2_num; if (random(0,1,1) == 0) { $a = -$a;$b = -$b;$c = -$c; $direction = "a downwards"; $minmax = "maximum"; } else { $direction = "an upwards"; $minmax = "minimum"; } $popup1 = DropDown( ['an upwards', 'a downwards'], $direction, placeholder => 'Select One' ); $popup2 = DropDown( ['line', 'curve', 'sinusoidal wave', 'circle', 'hyperbola', 'parabola', 'ellipse'], 'parabola', placeholder => 'Select One' ); $popup3 = DropDown( ['minimum', 'maximum'], $minmax, placeholder => 'Select One' ); Context()->noreduce('(-x)+y','y-x'); $f = Formula("$a x^2 + $b x + $c")->reduce; BEGIN_PGML Define the function [`f`] by [`f(x) = [$f]`]. ---- Describe the graph of [`f`]. **Answer:** The graph of [`f`] is [_]{$popup1} facing [_]{$popup2}. ---- END_PGML Context("ImplicitEquation"); Context()->variables->set( x => { limits => [-100,100] } ); $symmetry = -$b/(2*$a); $axis = ImplicitEquation("x = $symmetry"); BEGIN_PGML Find the axis of symmetry and express it as an equation. **Answer:** [_]{$axis} ---- END_PGML Context("Point"); Context()->variables->are( x => 'Real'); parserFunction('f(x)' => $f); $vertex_x = $symmetry; $vertex_y = $f->substitute(x => "$symmetry")->eval(); $vertex = Compute("($vertex_x,f($vertex_x))"); BEGIN_PGML Find the vertex of [`f`], and express it as a point. **Answer:** [_]{$vertex} ---- END_PGML Context("Interval"); Context()->variables->are( x => 'Real'); parserFunction('f(x)' => $f); if ($a > 0) {$range = Interval("[$vertex_y,infinity)");} else {$range = Interval("(-infinity, $vertex_y]");} BEGIN_PGML What is the range of [`f(x)`]? **Answer:** [_]{$range} ---- END_PGML Context("Numeric"); $intercepts = MultiAnswer($x_intercept1, $x_intercept2)->with( singleResult => 0, checker => sub { my ($correct, $student, $self) = @_; my ($x1stu, $x2stu) = @{$student}; my ($x1, $x2) = @{$correct}; if (($x1 == $x1stu && $x2 == $x2stu) || ($x1 == $x2stu && $x2 == $x1stu)) { return [1,1]; } elsif ($x1 == $x1stu || $x2 == $x1stu) { return [1,0]; } elsif ($x1 == $x2stu || $x2 == $x2stu) { return [0,1]; } else { return [0,0]; } } ); BEGIN_PGML What are the [`x`]-intercepts of the graph of [`f`]? **Answer:** [`x = `] [_]{$intercepts} and [`x = `] [_]{$intercepts} END_PGML ENDDOCUMENT();