diff --git a/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-graph-interval-jms.pg b/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-graph-interval-jms.pg index 063d79a7e5..59a6ff1743 100644 --- a/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-graph-interval-jms.pg +++ b/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-graph-interval-jms.pg @@ -48,7 +48,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (5,{$p*pow(5-$a,$b)/$c- $p*abs($a)}) node[above right, outer sep=2pt]{\(y=f(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML [@ image($graph_image, width => 600, tex_size => 1000) @]* diff --git a/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-interpret-graph1.pg b/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-interpret-graph1.pg index 02b3538e2d..4f6a086325 100644 --- a/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-interpret-graph1.pg +++ b/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-interpret-graph1.pg @@ -37,7 +37,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (1,9) node[outer sep=2pt]{\(y=f(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML [@ image($graph_image, width => 600, tex_size => 1000) @]* diff --git a/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-quad-linear-jms.pg b/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-quad-linear-jms.pg index 3754d9d7cc..f2ce22f67f 100644 --- a/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-quad-linear-jms.pg +++ b/Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-quad-linear-jms.pg @@ -2,7 +2,6 @@ ## ## ENDDESCRIPTION - ## DBsubject(Algebra) ## DBchapter(Quadratic equations and functions) ## DBsection(Graphs) @@ -13,65 +12,85 @@ DOCUMENT(); -loadMacros("PGstandard.pl", "PGML.pl", "PGtikz.pl", "PGcourse.pl","parserPopUp.pl",); -$a = non_zero_random(-1, 1, 1); #nonzero repeated root -$b = random(1,2,1); #linear or quadratic -if($b==2) -{$c = 10*$b;} -else -{$c = 2}; #dampening factor for graph -$p = non_zero_random(-1,1,1); #coefficient +/- 1 -# popup_type answers depend on $b -if($b==1) -{$type = 'linear function';} -else -{$type = 'quadtratic function';} -$popup_type = DropDown( - [ - 'linear function', - 'quadratic function', - ], - $type +loadMacros( + "PGstandard.pl", "PGML.pl", + "PGtikz.pl", 'plots.pl', + 'parserRadioMultiAnswer.pl', "parserPopUp.pl", + "PGcourse.pl" ); +$a = non_zero_random(-1, 1, 1); #nonzero repeated root +$b = random(1, 2, 1); #linear or quadratic +if ($b == 2) { $c = 10 * $b; } +else { $c = 2 } +; #dampening factor for graph +$p = random(-1, 1, 2); #coefficient +/- 1 +# popup_type answers depend on $b +if ($b == 1) { + $type = 'linear function'; + if ($p > 0) { + $graph_desc = + 'A graph of a straight line oriented from lower left to upper right'; + } else { + $graph_desc = + 'A graph of a straight line oriented from upper left to lower right'; + } +} else { + $type = 'quadratic function'; + if ($p > 0) { + $graph_desc = 'A graph of a parabola opening upward'; + } else { + $graph_desc = 'A graph of a parabola opening downward'; + } +} # popup_slope answers depend on $b and $p -if($p==1 and $b==1) -{$slope = 'positive';} -elsif($p==-1 and $b==1) -{$slope = 'negative';} -else -{$slope = 'neither';} -$popup_slope = DropDown( +if ($p == 1) { $slope = 'positive'; } +else { $slope = 'negative'; } + +$popup_slope = DropDown([ 'negative', 'positive' ], $slope); + +$rma = RadioMultiAnswer( [ - 'negative', - 'positive', - 'neither', + [ + '\(f\) is a linear function, and the slope of \(y=f(x)\) is %s.', + $popup_slope + ], + ['\(f\) is a quadratic function.'] ], - $slope + $b - 1 ); -$graph_image = createTikZImage(); -$graph_image->tikzLibraries("arrows.meta"); +$f = Formula("$p*(($b*(x-$a))^$b/$c-abs($a*$b))"); + +$plot = Plot( + xmin => -5, + xmax => 5, + ymin => -5, + ymax => 5, + xtick_delta => 1, + ytick_delta => 1, + xminor => 0, + yminor => 0, + xlabel => '\(x\)', + ylabel => '\(y\)', + aria_label => $graph_desc, + axes_on_top => 1, +); -$graph_image->BEGIN_TIKZ -\draw[->,thick] (-5.5,0) -- (5.5,0) node[above left,outer sep=2pt]{\(x\)}; -\draw[->,thick] (0,-5.5) -- (0,5.5) node[below right,outer sep=2pt]{\(y\)}; -\draw[very thin,color=gray] (-5.5,-5.5) grid (5.5,5.5); -\foreach \x in {-4,-2,2,4} \draw[thin] (\x,5pt) -- (\x,-5pt) node[below]{\(\x\)}; -\foreach \y in {-4,-2,2,4} \draw[thin] (5pt,\y) -- (-5pt,\y) node[left]{\(\y\)}; -\draw[<->,red, very thick] plot[domain={-5}:{5}] (\x,{$p*pow($b*(\x-$a),$b)/($c) - $p*abs($a*$b)}); -\draw[red] (5,{$p*pow($b*(5-$a),$b)/($c) - $p*abs($a*$b)}) node[above right, outer sep=2pt]{\(y=f(x)\)}; -END_TIKZ +$plot->add_function( + $f, 'x', -5, 5, + color => 'red', + start_mark => 'arrow', + end_mark => 'arrow', + width => 3 +); -\Context("Interval"); BEGIN_PGML -[@ image($graph_image, width => 600, tex_size => 1000) @]* +[! $graph_desc !]{$plot} Consider the graph of the of the function [`y=f(x)`] given above in red. -Based on the visible portion of the graph [`f`] is a [_]{$popup_type}. - -If [`f`] is a linear function, then the slope of [`y=f(x)`] is [_]{$popup_slope}. (If [`f`] is a quadratic function, choose "neither"). - +Based on the visible portion of the graph, choose the correct conclusion. +[_]{$rma} END_PGML ENDDOCUMENT(); diff --git a/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-1-jms.pg b/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-1-jms.pg index dbb775a501..35b946328c 100644 --- a/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-1-jms.pg +++ b/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-1-jms.pg @@ -33,7 +33,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (4,$u) node[below right, outer sep=2pt]{\(y=L(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML [@ image($graph_image, width => 600, tex_size => 1000) @]* diff --git a/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-2-jms.pg b/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-2-jms.pg index 31975df599..38ba770ebe 100644 --- a/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-2-jms.pg +++ b/Contrib/UCalgary/249-1-0-0-C/1-1-1-U-C/1-1-1-U-C-slope-int-2-jms.pg @@ -43,7 +43,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (4,$l) node[above right, outer sep=2pt]{\(y=L(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML [@ image($graph_image, width => 600, tex_size => 1000) @]* diff --git a/Contrib/UCalgary/249-8-0-0-C/8-1-2-U-C/8-1-2-U-C-pw-inc-dec-1-jms.pg b/Contrib/UCalgary/249-8-0-0-C/8-1-2-U-C/8-1-2-U-C-pw-inc-dec-1-jms.pg index 303e59b184..b4031d06e0 100644 --- a/Contrib/UCalgary/249-8-0-0-C/8-1-2-U-C/8-1-2-U-C-pw-inc-dec-1-jms.pg +++ b/Contrib/UCalgary/249-8-0-0-C/8-1-2-U-C/8-1-2-U-C-pw-inc-dec-1-jms.pg @@ -209,7 +209,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (10,$f10) node[above right, outer sep=2pt]{\(y=f(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML Recall the following definitions: diff --git a/Contrib/UCalgary/249-9-0-0-C/9-1-1-U-C/9-1-1-U-C-pw-loc-ext-1-jms.pg b/Contrib/UCalgary/249-9-0-0-C/9-1-1-U-C/9-1-1-U-C-pw-loc-ext-1-jms.pg index 8c5f3ffe44..13712c40b6 100644 --- a/Contrib/UCalgary/249-9-0-0-C/9-1-1-U-C/9-1-1-U-C-pw-loc-ext-1-jms.pg +++ b/Contrib/UCalgary/249-9-0-0-C/9-1-1-U-C/9-1-1-U-C-pw-loc-ext-1-jms.pg @@ -165,7 +165,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (10,$f10) node[above right, outer sep=2pt]{\(y=f(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML Consider the following graph of the piecewise defined function [`y=f(x)`] on the open interval [`(-10,10).`] diff --git a/Contrib/UCalgary/249-9-0-0-C/9-3-2-U-C/9-3-2-U-C-pw-loc-glob-ext-1-jms.pg b/Contrib/UCalgary/249-9-0-0-C/9-3-2-U-C/9-3-2-U-C-pw-loc-glob-ext-1-jms.pg index d9c22f18c0..30d3004632 100644 --- a/Contrib/UCalgary/249-9-0-0-C/9-3-2-U-C/9-3-2-U-C-pw-loc-glob-ext-1-jms.pg +++ b/Contrib/UCalgary/249-9-0-0-C/9-3-2-U-C/9-3-2-U-C-pw-loc-glob-ext-1-jms.pg @@ -243,7 +243,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (10,$f10) node[above right, outer sep=2pt]{\(y=f(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML Consider the following graph of the piecewise defined function [`y=f(x)`] on the closed interval [`[-10,10].`] diff --git a/Contrib/UCalgary/249-9-0-0-C/9-3-3-U-C/9-3-3-U-C-pw-glob-ext-1-jms.pg b/Contrib/UCalgary/249-9-0-0-C/9-3-3-U-C/9-3-3-U-C-pw-glob-ext-1-jms.pg index f2d6248187..5db1f3dff4 100644 --- a/Contrib/UCalgary/249-9-0-0-C/9-3-3-U-C/9-3-3-U-C-pw-glob-ext-1-jms.pg +++ b/Contrib/UCalgary/249-9-0-0-C/9-3-3-U-C/9-3-3-U-C-pw-glob-ext-1-jms.pg @@ -178,7 +178,7 @@ $graph_image->BEGIN_TIKZ \draw[red] (10,$f10) node[above right, outer sep=2pt]{\(y=f(x)\)}; END_TIKZ -\Context("Interval"); +Context("Interval"); BEGIN_PGML Consider the following graph of the piecewise defined function [`y=f(x)`] on the closed interval [`[-10,10].`]