Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) @]*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) @]*

Expand Down
115 changes: 67 additions & 48 deletions Contrib/UCalgary/249-1-0-0-C/1-1-0-An-C/1-1-0-An-C-quad-linear-jms.pg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
##
## ENDDESCRIPTION


## DBsubject(Algebra)
## DBchapter(Quadratic equations and functions)
## DBsection(Graphs)
Expand All @@ -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();
Original file line number Diff line number Diff line change
Expand Up @@ -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) @]*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) @]*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).`]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].`]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].`]
Expand Down