From d05f86be0dabf77c1efe4594945f8a075259f5d7 Mon Sep 17 00:00:00 2001 From: Danny Glin Date: Wed, 15 Oct 2025 16:36:23 -0600 Subject: [PATCH 1/2] Convert problem to PGML and add solution --- .../AlfredUniv/anton8e/chapter2/2.2/prob18.pg | 56 +++++++------------ 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/OpenProblemLibrary/AlfredUniv/anton8e/chapter2/2.2/prob18.pg b/OpenProblemLibrary/AlfredUniv/anton8e/chapter2/2.2/prob18.pg index 21e929d8b9..e786a8e996 100644 --- a/OpenProblemLibrary/AlfredUniv/anton8e/chapter2/2.2/prob18.pg +++ b/OpenProblemLibrary/AlfredUniv/anton8e/chapter2/2.2/prob18.pg @@ -27,49 +27,33 @@ DOCUMENT(); # Load whatever macros you need for the problem -loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "PGgraphmacros.pl", - "MathObjects.pl", - "PGcourse.pl" -); - -## Show partial correct answers -$showPartialCorrectAnswers = 1; -## Display the problem information -TEXT(beginproblem()); - -## Declare Variables -Context()->variables->are(x=>'Real',y=>'Real'); +loadMacros("PGstandard.pl", "PGML.pl", "PGcourse.pl"); ## Function Definition -$a = random(1,9); +$a = random(1, 9); $f = Formula("(sqrt(x+$a**2)-$a)/x")->reduce; -$ans1 = Formula("1/(2*$a)")->reduce; - +$twoa = 2 * $a; +$a2 = $a**2; +$ans1 = Compute("1/($twoa)"); +$conj = Formula("sqrt(x+$a**2)+$a"); +BEGIN_PGML +Let [`` f(x)= [$f]``]. -Context()->texStrings; -BEGIN_TEXT -Let \(\> f(x)= $f\). -$BR -$BR -Find \(\> \lim_{x \rightarrow 0} f(x) \>\) by first rationalizing the numerator. -$BR -$BR -Enter $BBOLD I $EBOLD for \(\infty\), $BBOLD -I $EBOLD for \(-\infty\), -and $BBOLD DNE $EBOLD if the limit does not exist. -$BR -$BR -Answer: \{ans_rule(20)\} - -END_TEXT -Context()->normalStrings; -ANS(num_cmp($ans1, strings=>["I", "-I", "DNE"])); +Find [`` \lim_{x \rightarrow 0} f(x) ``] by first rationalizing the numerator (multiplying and dividing by the conjugate). +[`` \lim_{x \rightarrow 0} f(x) =``][_]{$ans1}{5}[@helpLink('limits')@]* +END_PGML +BEGIN_PGML_SOLUTION +[``\begin{array}{rl}\displaystyle \lim_{x \rightarrow 0} [$f] & = \displaystyle\lim_{x \rightarrow 0} [$f]\cdot\frac{[$conj]}{[$conj]}\\ +& =\displaystyle\lim_{x \rightarrow 0}\frac{(x+[$a2])-[$a2]}{x\left([$conj]\right)}\\ +& =\displaystyle\lim_{x \rightarrow 0}\frac{x}{x\left([$conj]\right)}\\ +& =\displaystyle\lim_{x \rightarrow 0}\frac{1}{[$conj]}\\ +& =\displaystyle\frac{1}{\sqrt{0+[$a2]}+[$a]}\\ +& =\displaystyle\frac{1}{[$twoa]} +\end{array}``] +END_PGML_SOLUTION ENDDOCUMENT(); - From 18bb4f2966e977b562ee70fab0addf345507ced3 Mon Sep 17 00:00:00 2001 From: Danny Glin Date: Wed, 15 Oct 2025 16:44:38 -0600 Subject: [PATCH 2/2] Convert dynamic graph problems to use plots and PGML --- .../ASU-topics/setLimitConcepts/3-2-36.pg | 184 +++++++------- OpenProblemLibrary/Michigan/Chap12Sec4/Q15.pg | 181 ++++++-------- .../UMN/calculusStewartCCC/s_2_4_prob01.pg | 230 ++++++++++++------ 3 files changed, 309 insertions(+), 286 deletions(-) diff --git a/OpenProblemLibrary/ASU-topics/setLimitConcepts/3-2-36.pg b/OpenProblemLibrary/ASU-topics/setLimitConcepts/3-2-36.pg index 271956325c..b91844f455 100644 --- a/OpenProblemLibrary/ASU-topics/setLimitConcepts/3-2-36.pg +++ b/OpenProblemLibrary/ASU-topics/setLimitConcepts/3-2-36.pg @@ -4,7 +4,6 @@ ## Tagged by LD - ## DBsubject(Calculus - single variable) ## DBchapter(Limits and continuity) ## DBsection(Finding limits using graphs) @@ -36,107 +35,88 @@ ## Problem4('45') ## KEYWORDS('calculus','limits', 'derivatives','limit') -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "PGgraphmacros.pl", - "PGcourse.pl" +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros('PGstandard.pl', 'PGML.pl', 'plots.pl', 'PGcourse.pl'); + +$a = random(-3, 3, 1); +$b = random(-2, 3, 1); +$c = random(-3, 2, 1); +$ap1 = 1 + $a; +$bp1 = 1 + $b; +$m1 = random(-1, 1, 0.5); +$m2 = ($b - $a) / 2; +$m3 = ($c - $b - 1) / 2; +$m4 = random(-1, 1, 0.5); +$ystart = $a - $m1; +$yend = $c + $m4; + +$color = list_random("blue", "red", "green"); + +$plot = Plot( + xmin => -3, + xmax => 5, + ymin => -6, + ymax => 6, + xtick_delta => 1, + xminor => 0, + ytick_delta => 1, + yminor => 0, + xlabel => '\(x\)', + ylabel => '\(y\)', + aria_label => 'The graph of the function y=F(x)', + axes_on_top => 1, ); -TEXT(beginproblem()); -$showPartialCorrectAnswers = 1; - -$a=random(-3,3,1); -$b=random(-2,3,1); -$c=random(-3,2,1); -$m1=random(-1,1,0.5); -$m2=($b - $a)/2; -$m3=($c - $b - 1)/2; -$m4=random(-1,1,0.5); -@slice = NchooseK(3,3); - -@colors = ("blue", "red", "green"); -@sc = @colors[@slice]; #scrambled colors -@sa = ('A','B','C')[@slice]; - -$f1 = FEQ("${m1}*(x+1)+$a for x in [-2,-1) using color:$sc[0] and weight:2"); -$f2 = FEQ("${m2}*(x-1)+$b for x in (-1,1) using color=$sc[0] and weight:2"); -$f3 = FEQ("${m3}*(x-3)+$c for x in [1,3) using color=$sc[0] and weight=2"); -$f4 = FEQ("1+$a for x in [-1,-1] using color=$sc[0] and weight=2"); -$f5 = FEQ("${m4}*(x-3)+$c for x in (3,4] using color=$sc[0] and weight=2"); - -$graph = init_graph(-3,-6,5,6,'axes'=>[0,0],'grid'=>[8,12]); - -($f1Ref,$f2Ref,$f3Ref,$f4Ref,$f5Ref) = plot_functions($graph,$f1,$f2,$f3,$f4,$f5); - -TEXT(EV2(< -$SPACE - - \( \displaystyle \lim_{x \to -1^+} F(x) \) = \ -$SPACE - - \( \displaystyle \lim_{x \to -1} F(x) \) = \ -$SPACE - - \( F(-1) \) = \ -$PAR - -b) \( \displaystyle \lim_{x \to 1^-} F(x) \) = \ -$SPACE - - \( \displaystyle \lim_{x \to 1^+} F(x) \) = \ -$SPACE - - \( \displaystyle \lim_{x \to 1} F(x) \) = \ -$SPACE - - \( F(1) \) = \ -$PAR - -c) \( \displaystyle \lim_{x \to 3^-} F(x) \) = \ -$SPACE - - \( \displaystyle \lim_{x \to 3^+} F(x) \) = \ -$SPACE - -\( \displaystyle \lim_{x \to 3} F(x) \) = \ -$SPACE - - \( F(3) \) = \ -$PAR - -EOT - -$ap1 = 1 + $a; -$bp1 = 1 + $b; - -ANS(num_cmp($a, strings=>['DNE'])) ; -ANS(num_cmp($a, strings=>['DNE'])) ; -ANS(num_cmp($a, strings=>['DNE'])) ; -ANS(num_cmp($ap1, strings=>['DNE'])); -ANS(num_cmp($b, strings=>['DNE'])) ; -ANS(num_cmp($bp1, strings=>['DNE'])); -ANS(num_cmp('DNE', strings=>['DNE'])) ; -ANS(num_cmp($bp1, strings=>['DNE'])); -ANS(num_cmp($c, strings=>['DNE'])) ; -ANS(num_cmp($c, strings=>['DNE'])) ; -ANS(num_cmp($c, strings=>['DNE'])) ; -ANS(num_cmp('DNE', strings=>['DNE'])) ; - -ENDDOCUMENT(); # This should be the last executable line in the problem. +$plot->add_function( + ["${m1}*(x+1)+$a", 'x', -2, -1, start_mark=>'circle', end_mark=>'open_circle', color=>$color, weight=>2], + ["${m2}*(x-1)+$b", 'x', -1, 1, start_mark=>'open_circle', end_mark=>'open_circle', color=>$color, weight=>2], + ["${m3}*(x-3)+$c", 'x', 1, 3, start_mark=>'circle', end_mark=>'open_circle', color=>$color, weight=>2], + ["${m4}*(x-3)+$c", 'x', 3, 4, start_mark=>'open_circle', end_mark=>'circle', color=>$color, weight=>2] +); +$plot->add_dataset([ -1, $ap1 ], color => $color, marks => 'circle'); + +$alttext = + "A graph showing a line segment starting with a solid circle at the point (-2,$ystart) and ending with an open circle at the point (-1,$a). There is a solid circle at the point (-1,$ap1). There is a line segment starting with an open circle at the point (-1,$a) and ending with an open circle at the point (1,$b). There is a line segment starting with a solid circle at the point (1,$bp1) and ending with an open circle at the point (3,$c). There is a line segment starting with an open circle at the point (3,$c) and ending with a solid circle at the point (4,$yend)."; + +$ans1 = Compute($a); +$ans2 = Compute($a); +$ans3 = Compute($a); +$ans4 = Compute($ap1); +$ans5 = Compute($b); +$ans6 = Compute($bp1); +$ans7 = Compute('DNE'); +$ans8 = Compute($bp1); +$ans9 = Compute($c); +$ans10 = Compute($c); +$ans11 = Compute($c); +$ans12 = Compute('DNE'); + +BEGIN_PGML +The graph of [`y=F(x)`] is given below. + +If you are having a hard time seeing the picture clearly, click on the picture. It will expand to a larger picture on its own page so that you can inspect it more clearly. + +[! $alttext !]{$plot} + +Evaluate each of the following expressions. + +Note: Enter 'DNE' if the limit does not exist or is not defined. +[# + [. a) .] [. [`` \lim_{x \to -1^-} F(x) ``] = [_]{$ans1}{5} .] + [. [`` \lim_{x \to -1^+} F(x) ``] = [_]{$ans2}{5} .] + [. [`` \lim_{x \to -1} F(x) ``] = [_]{$ans3}{5} .] + [. [` F(-1) `] = [_]{$ans4}{5} .]* + [. b) .] [. [`` \lim_{x \to 1^-} F(x) ``] = [_]{$ans5}{5} .] + [. [`` \lim_{x \to 1^+} F(x) ``] = [_]{$ans6}{5} .] + [. [`` \lim_{x \to 1} F(x) ``] = [_]{$ans7}{5} .] + [. [` F(1) `] = [_]{$ans8}{5} .]* + [. c) .] [. [`` \lim_{x \to 3^-} F(x) ``] = [_]{$ans9}{5} .] + [. [`` \lim_{x \to 3^+} F(x) ``] = [_]{$ans10}{5} .] + [. [`` \lim_{x \to 3} F(x) ``] = [_]{$ans11}{5} .] + [. [` F(3) `] = [_]{$ans12}{5} .]* +#]* +END_PGML + +ENDDOCUMENT(); diff --git a/OpenProblemLibrary/Michigan/Chap12Sec4/Q15.pg b/OpenProblemLibrary/Michigan/Chap12Sec4/Q15.pg index 79e8742df1..ca5760d67a 100644 --- a/OpenProblemLibrary/Michigan/Chap12Sec4/Q15.pg +++ b/OpenProblemLibrary/Michigan/Chap12Sec4/Q15.pg @@ -2,20 +2,8 @@ # Problem from Calculus, multi-variable, Hughes-Hallett et al., # originally from 5ed (with updates) # WeBWorK problem written by Gavin LaRose, - -DOCUMENT(); - -loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "MathObjects.pl", - "PGgraphmacros.pl", - "PGcourse.pl" -); - ## Tagged by glr 05/12/09 - ## DBsubject(Calculus - multivariable) ## DBchapter(Concepts for multivariable functions) ## DBsection(Traces, contours, and level sets) @@ -43,120 +31,105 @@ loadMacros( ## Textbook tags ## HHChapter1('Functions of Several Variables') -$refreshCachedImages = 1; +DOCUMENT(); -Context("Numeric"); -$showPartialCorrectAnswers = 1; +loadMacros('PGstandard.pl', 'PGML.pl', 'plots.pl', 'PGcourse.pl'); ## the cost of a cd -$p = random(6,10,2); +$p = random(6, 10, 2); ## the cost of a dvd -$q = $p + random(2,6,2); - -$p = 10; -$q = 14; +$q = $p + random(2, 6, 2); ## then the revenue is given by ## r = p c + q d, ## so the contour lines are the lines -## d = r/q - (p/q) c -$gr = init_graph(0,0,400,400, axes=>[0,0], grid=>[8,8], size=>[300,300]); -$gr->lb('reset'); -foreach my $v ( 100, 200, 300, 400 ) { - $gr->lb( new Label( $v, 0, "$v", 'black', 'right', 'bottom' ) ); - $gr->lb( new Label( 0, $v, "$v", 'black', 'left', 'top' ) ); +## d = r/q - (p/q) c + +$plot = Plot( + xmin => 0, + xmax => 400, + ymin => 0, + ymax => 400, + xtick_delta => 100, + xminor => 1, + ytick_delta => 100, + yminor => 1, + xlabel => '\(c\)', + ylabel => '\(d\)', + aria_label => 'The revenue based on number of CDs and DVDs sold', + axes_on_top => 1, +); + +for ($i = 1; $i < 9; $i++) { + $r = 1000 * $i; + $plot->add_function( + "($r - $p*x)/($q)", 'x', 0, $r / $p, + color => 'blue', + weight => 2 + ); + $y1 = $r / ($p + $q); + $plot->add_label($y1 + 20, $y1 + 10, label => "$r", color => 'blue'); } -$gr->lb( new Label( 350, 0, "c", 'black', 'right', 'bottom' ) ); -$gr->lb( new Label( 0, 350, " d", 'black', 'left', 'top' ) ); -for ( my $i=1; $i<9; $i++ ) { - my $r = 1000*$i; - add_functions( $gr, "($r - $p*x)/$q for x in <0,400> using color:" . - "blue and weight:2" ); +## nice intersection points are given by +%rpoints = ( + 6 => { + 8 => [ [ 200, 100, 2000 ], [ 100, 300, 3000 ] ], + 10 => [ [ 250, 50, 2000 ], [ 250, 150, 3000 ] ], + 12 => [ [ 100, 200, 3000 ], [ 200, 150, 3000 ] ] + }, + 8 => { + 10 => [ [ 250, 100, 3000 ], [ 250, 200, 4000 ] ], + 12 => [ [ 100, 100, 2000 ], [ 100, 350, 5000 ] ], + 14 => [ [ 200, 100, 3000 ], [ 100, 300, 5000 ] ] + }, + 10 => { + 12 => [ [ 100, 250, 4000 ], [ 200, 250, 5000 ] ], + 14 => [ [ 150, 250, 5000 ], [ 250, 250, 6000 ] ], + 16 => [ [ 100, 250, 5000 ], [ 200, 250, 6000 ] ] + } +); - ## put the contour label on the line y=x - my $y1 = $r/($p+$q); - $gr->lb( new Label( $y1, $y1, "$r", 'black', 'right', 'bottom' ) ); -} +($c0, $d0, $r0) = @{ $rpoints{$p}->{$q}->[0] }; +($c1, $d1, $r1) = @{ $rpoints{$p}->{$q}->[1] }; -Context()->texStrings; -TEXT(beginproblem()); -BEGIN_TEXT +$alt_text = + "A graph where the horizontal axis is labelled as c, and the vertical axis is labelled as d. On the graph are eight parallel horizontal lines starting at the vertical axis and travelling down and right until they meet the horizontal axis. The lowest such line is labelled with 1000, and each higher line has a label that is 1000 greater than the one below. The line that is labelled $r0 passes through the point ($c0,$d0). The line that is labelled $r1 passes through the point ($c1,$d1)."; +BEGIN_PGML A store sells CDs at one price and DVDs at another price. The figure below shows the revenue (in dollars) -of the music store as a function of the number, \( c \), -of CDs and the number, \( d \), of DVDs that it sells. The +of the music store as a function of the number, [` c `], +of CDs and the number, [` d `], of DVDs that it sells. The values of the revenue are shown on each line. -$PAR -$BCENTER -\{ image( insertGraph( $gr ), tex_size=>350, height=>300, width=>300, - extra_html_tags=>'alt="graph of contours"' ) \} -$ECENTER -$PAR -${BITALIC}(Hint: for this problem there are many possible ways to -estimate the requisite values; you should be able to find information -from the figure that allows you to give an answer that is essentially -exact.)$EITALIC -$PAR -${BBOLD}(a)$EBOLD -What is the price of a CD? \{ ans_rule(25) \} dollars -$BR -${BBOLD}(b)$EBOLD -What is the price of a DVD? \{ ans_rule(25) \} dollars +>> [! $alt_text !]{$plot}{300} << -END_TEXT -Context()->normalStrings; +_(Hint: for this problem there are many possible ways to +estimate the requisite values; you should be able to find information +from the figure that allows you to give an answer that is essentially +exact.)_ -ANS(Compute("$p")->cmp() ); -ANS(Compute("$q")->cmp() ); +a) What is the price of a CD? [_]{$p}{5} dollars +b) What is the price of a DVD? [_]{$q}{5} dollars +END_PGML -## nice intersection points are given by -%rpoints = ( 6 => { 8 => [ [ 200, 100, 2000 ], - [ 100, 300, 3000 ] ], - 10 => [ [ 250, 50, 2000 ], - [ 250, 150, 3000 ] ], - 12 => [ [ 100, 200, 3000 ], - [ 200, 150, 3000 ] ] }, - 8 => { 10 => [ [ 250, 100, 3000 ], - [ 250, 200, 4000 ] ], - 12 => [ [ 100, 100, 2000 ], - [ 100, 350, 5000 ] ], - 14 => [ [ 200, 100, 3000 ], - [ 100, 300, 5000 ] ] }, - 10 => { 12 => [ [ 100, 250, 4000 ], - [ 200, 250, 5000 ] ], - 14 => [ [ 150, 250, 5000 ], - [ 250, 250, 6000 ] ] } ); -($c0, $d0, $r0) = @{$rpoints{$p}->{$q}->[0]}; -($c1, $d1, $r1) = @{$rpoints{$p}->{$q}->[1]}; - -Context()->texStrings; -SOLUTION(EV3(<<'END_SOLUTION')); -$PAR SOLUTION $PAR - - -The revenue -function, \(R\), is linear and so we may write it as: -\[ +BEGIN_PGML_SOLUTION +The revenue function, [`R`], is linear and so we may write it as: +[``` R = (p_1)c + (p_2)d -\] -where \(p_1\) is the price of CDs and \(p_2\) is the price of DVDs, in +```] +where [`p_1`] is the price of CDs and [`p_2`] is the price of DVDs, in dollars. -From the diagram, we can pick two points, such as \(c = $c0\), \(d=$d0\) -on the contour \(R=$r0\), and \(c = $c1\), \(d = $d1\) on the contour -\(R = $r1\). These +From the diagram, we can pick two points, such as [`c = [$c0]`], [`d=[$d0]`] +on the contour [`R=[$r0]`], and [`c = [$c1]`], [`d = [$d1]`] on the contour +[`R = [$r1]`]. These points give the following system of linear equations: -\[ -$r0 = $c0 p_1 + $d0 p_2, \mbox{ and } -$r1 = $c1 p_1 + $d1 p_2. -\] -Solving gives \(p_1 = $p\) dollars and \(p_2 = $q\) dollars. - -END_SOLUTION -Context()->normalStrings; - +[``` +[$r0] = [$c0] p_1 + [$d0] p_2, \mbox{ and } +[$r1] = [$c1] p_1 + [$d1] p_2. +```] +Solving gives [`p_1 = [$p]`] dollars and [`p_2 = [$q]`] dollars. +END_PGML_SOLUTION -; ENDDOCUMENT(); diff --git a/OpenProblemLibrary/UMN/calculusStewartCCC/s_2_4_prob01.pg b/OpenProblemLibrary/UMN/calculusStewartCCC/s_2_4_prob01.pg index 5fc954227b..cb89e3592e 100644 --- a/OpenProblemLibrary/UMN/calculusStewartCCC/s_2_4_prob01.pg +++ b/OpenProblemLibrary/UMN/calculusStewartCCC/s_2_4_prob01.pg @@ -2,7 +2,6 @@ ## Calculus: Points of discontinuity ##ENDDESCRIPTION - ## DBsubject(Calculus - single variable) ## DBchapter(Limits and continuity) ## DBsection(Continuity - classifying discontinuities) @@ -18,105 +17,176 @@ ## Problem1('') ## KEYWORDS('calculus', 'function', 'continuous', 'type of discontinuity') -##################################################################### DOCUMENT(); loadMacros( - "PGstandard.pl", - "parserPopUp.pl", - "MathObjects.pl", - "PGgraphmacros.pl", - "PGcourse.pl" + 'PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'plots.pl', + 'PGcourse.pl' ); -COMMENT('It is best to give no more than two scored attempts for this problem.'); +COMMENT('It is best to give no more than two scored attempts for this problem.' +); -##################################################################### +$showPartialCorrectAnswers = 0; -TEXT(beginproblem()); +Context("Numeric"); -$showPartialCorrectAnswers = 0; +$plot = Plot( + xmin => -10, + xmax => 10, + ymin => -10, + ymax => 10, + xtick_delta => 1, + ytick_delta => 1, + xminor => 0, + yminor => 0, + xlabel => '\(x\)', + ylabel => '\(y\)', + aria_label => 'The graph of y=f(x)', + axes_on_top => 1, +); -##################################################################### +$a = random( 1, 2, 1); +$x1 = random(-6, -4, 1); +$x2 = $x1 + random(2, 3, 1); +$x3 = $x2 + random(2, 3, 1); +$x4 = $x3 + random(2, 3, 1); + +if ($a == 1) { + $popup1 = + PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'infinite'); + $popup2 = + PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'removable'); + $popup3 = + PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'removable'); + $popup4 = PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'jump'); + + $y1 = random(2, 7, 1); + $y2 = random(1, 5, 1); + $k = $y2 * ($x2 - $x1); + $y3open = random(-5, -2, 1); + $y3closed = random( 1, 7, 1); + $m1 = ($y3open - $y2) / ($x3 - $x2); + $y4left = random( 2, 5, 1); + $y4right = random(-5, -2, 1); + $m2 = ($y4left - $y3open) / ($x4 - $x3); + + $plot->add_function( + [ "1/(x-$x1)", 'x', -10, $x1 - 0.01, color => 'blue', weight => 2 ], + [ + "$k/(x-$x1)", 'x', $x1 + 0.01, $x2, + end_mark => 'open_circle', + color => 'blue', + weight => 2 + ], + [ + "$m1*(x-$x2)+$y2", 'x', $x2, $x3, + start_mark => 'open_circle', + end_mark => 'open_circle', + color => 'blue', + weight => 2 + ], + [ + "$m2*(x-$x4)+$y4left", 'x', $x3, $x4, + start_mark => 'open_circle', + end_mark => 'circle', + color => 'blue', + weight => 2 + ], + [ + "(x-$x4)^2+$y4right", 'x', $x4, 10, + start_mark => 'open_circle', + color => 'blue', + weight => 2 + ], + ); + + $plot->add_dataset( + [ [ $x1, $y1 ], color => 'blue', marks => 'circle' ], + [ [ $x3, $y3closed ], color => 'blue', marks => 'circle' ], + ); +} -Context("Numeric"); +if ($a == 2) { + $popup1 = PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'jump'); + $popup2 = + PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'removable'); + $popup3 = + PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'removable'); + $popup4 = + PopUp([ 'choose one', 'removable', 'jump', 'infinite' ], 'infinite'); + + $y1left = random(1, 3, 1); + $y1right = $y1left + random(2, 3, 1); + $y2open = random(-4, -2, 1); + $y2closed = $y2open - random(1, 3, 1); + $y3 = random( 2, 4, 1); + $y4 = random(-2, 2, 1); + $k = ($y2open - $y1right) / ($x2 - $x1)**2; + $m = ($y3 - $y2open) / ($x3 - $x2); + $p = $y3 * ($x3 - $x4); + + $plot->add_function( + [ + "(x-$x1)^2+$y1left", 'x', -10, $x1, + end_mark => 'open_circle', + color => 'blue', + weight => 2 + ], + [ + "$k*(x-$x1)^2+$y1right", 'x', $x1, $x2, + start_mark => 'circle', + end_mark => 'open_circle', + color => 'blue', + weight => 2 + ], + [ + "$m*(x-$x2)+$y2open", 'x', $x2, $x3, + start_mark => 'open_circle', + end_mark => 'open_circle', + color => 'blue', + weight => 2 + ], + [ + "$p/(x-$x4)", 'x', $x3, $x4 - 0.01, + start_mark => 'open_circle', + color => 'blue', + weight => 2 + ], + [ + "-1/(x-$x4)^2", 'x', $x4 + 0.01, 10, + color => 'blue', + weight => 2 + ], + ); + + $plot->add_dataset( + [ [ $x2, $y2closed ], color => 'blue', marks => 'circle' ], + [ [ $x4, $y4 ], color => 'blue', marks => 'circle' ], + ); +} -$a = random(1,2,1); +BEGIN_PGML +Use the given graph of the function [`f`] to determine the type of discontinuity at each [`x`]-value. -if ($a==1){ -$popup1 = PopUp(['choose one','removable', 'jump', 'infinite'],'infinite'); -$popup2 = PopUp(['choose one','removable', 'jump', 'infinite'],'removable'); -$popup3 = PopUp(['choose one','removable', 'jump', 'infinite'],'removable'); -$popup4 = PopUp(['choose one','removable', 'jump', 'infinite'],'jump'); +>> [! Alty Texty !]{$plot} << -$w = 400; # graph size -$tw = 500; # graph size in TeX +--- -$graph1 = init_graph(-8,-8,8,8,'axes'=>[0,0],'ticks'=>[16,16],'grid'=>[16,16],'size'=>[500,500]); + [_]{$popup1} *1.* What type of discontinuity does [`f`] have at [`x=[$x1]`]? -$p1 = FEQ("1/(x+4) for x in [-8,-4.01> using color:blue weight:2"); -$p2 = FEQ("$a for x in [-4,-4] using color:blue weight:2"); -$p3 = FEQ("4/(x+4) for x in <-3.99,-2) using color:blue weight:2"); -$p4 = FEQ("-x for x in (-2,2) using color:blue weight:2"); -$p5 = FEQ("5 for x in [2,2] using color:blue weight:2"); -$p6 = FEQ("2x-6 for x in (2,4] using color:blue weight:2"); -$p7 = FEQ("(x-4)^2-2 for x in (4,8] using color:blue weight:2"); -} + [_]{$popup2} *2.* What type of discontinuity does [`f`] have at [`x=[$x2]`]? -############################################################### + [_]{$popup3} *3.* What type of discontinuity does [`f`] have at [`x=[$x3]`]? -if ($a==2){ -$popup1 = PopUp(['choose one','removable', 'jump', 'infinite'],'jump'); -$popup2 = PopUp(['choose one','removable', 'jump', 'infinite'],'removable'); -$popup3 = PopUp(['choose one','removable', 'jump', 'infinite'],'removable'); -$popup4 = PopUp(['choose one','removable', 'jump', 'infinite'],'infinite'); + [_]{$popup4} *4.* What type of discontinuity does [`f`] have at [`x=[$x4]`]? -$w = 400; # graph size -$tw = 500; # graph size in TeX +--- -$graph1 = init_graph(-8,-8,8,8,'axes'=>[0,0],'ticks'=>[16,16],'grid'=>[16,16],'size'=>[500,500]); +*Note:* _You can click on the graph to enlarge the image._ -$p1 = FEQ("(x+4)^2+2 for x in [-8,-4) using color:blue weight:2"); -$p2 = FEQ("-(3/2)*(x+4)^2+4 for x in [-4,-2) using color:blue weight:2"); -$p3 = FEQ("-5 for x in [-2,-2] using color:blue weight:2"); -$p4 = FEQ("x for x in (-2,2) using color:blue weight:2"); -$p5 = FEQ("-4/(x-4) for x in (2,3.99> using color:blue weight:2"); -$p6 = FEQ("0 for x in [4,4] using color:blue weight:2"); -$p7 = FEQ("-1/(x-4)^2 for x in <4.01,8] using color:blue weight:2"); -} +--- -plot_functions($graph1,$p1,$p2,$p3,$p4,$p5,$p6,$p7); - -############################################################### -Context()->texStrings; - -BEGIN_TEXT -Use the given graph of the function \(f\) to determine the type of discontinuity at each \(x\)-value. -$PAR -$BCENTER -\{image(insertGraph($graph1),width=>$w,height=>$w,tex_size=>$tw)\} -$ECENTER -$HR -\{$popup1->menu\} $BBOLD 1. $EBOLD What type of discontinuity does \(f\) have at \(x=-4\)? -$PAR -\{$popup2->menu\} $BBOLD 2. $EBOLD What type of discontinuity does \(f\) have at \(x=-2\)? -$PAR -\{$popup3->menu\} $BBOLD 3. $EBOLD What type of discontinuity does \(f\) have at \(x=2\)? -$PAR -\{$popup4->menu\} $BBOLD 4. $EBOLD What type of discontinuity does \(f\) have at \(x=4\)? - -$HR -$BBOLD Note: $EBOLD $BITALIC You can click on the graph to enlarge the image.$EITALIC -$HR -END_TEXT - -Context()->normalStrings; - -##################################################################### - -ANS($popup1->cmp); -ANS($popup2->cmp); -ANS($popup3->cmp); -ANS($popup4->cmp); +END_PGML ENDDOCUMENT();