#DESCRIPTION #KEYWORDS('limits', 'sequences') # Find limits (intuitively or by experimental calculations). #ENDDESCRIPTION ##KEYWORDS('Calculus') ##Tagged by ynw2d ##DBsubject('Calculus') ## DBchapter('Limits and Derivatives') ##DBsection('Continuity') DOCUMENT(); # This should be the first executable line in the problem. loadMacros("PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGauxiliaryFunctions.pl", "PGgraphmacros.pl"); $showPartialCorrectAnswers=1; # define a broken graph f and a broken graph g: do { # first define the parameters (value and first derivatives) foreach my$i (0..5) { $f1y[$i] = random(0, 3, 1); $f1yp[$i] = random(-1,1, 2); $f2y[$i] = random(0, 3, 1); $f2yp[$i] = random(-1,1, 2); $g1y[$i] = random(0, 3, 1); $g1yp[$i] = random(-1,1, 2); $g2y[$i] = random(0, 3, 1); $g2yp[$i] = random(-1,1, 2); } # define the break points where we switch from one hemite function to the other # and the value of the function at that point $xf = random(0,3);$yf = random(-1,4); $xg = random(0,3);$yg = random(-1,4); # Make sure the two functions break at different places (or we can get some # questions repeated), and make sure they don't both vanish at the same time, # regardless of which pieces are compared, to avoid L'hopital situations. } until ( $xg !=$xf and ($f1y[$xf+1]**2 + $g1y[$xf+1]**2>0) and ($f1y[$xf+1]**2 + $g2y[$xf+1]**2>0) and ($f2y[$xf+1]**2 + $g1y[$xf+1]**2>0) and ($f2y[$xf+1]**2 + $g2y[$xf+1]**2>0) and ($f1y[$xg+1]**2 + $g1y[$xg+1]**2>0) and ($f2y[$xg+1]**2 + $g1y[$xg+1]**2>0) and ($f1y[$xg+1]**2 + $g2y[$xg+1]**2>0) and ($f2y[$xg+1]**2 + $g2y[$xg+1]**2>0) ); # define the functions $hermite_f1 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ], [ @f1y ], [ @f1yp ]);$hermite_f2 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ], [ @f2y ], [ @f2yp ]); $hermite_g1 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ], [ @g1y ], [ @g1yp ]);$hermite_g2 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ], [ @g2y ], [ @g2yp ]); # define the broken functions themselves -- we'll need them to answer questions. sub f_rule { my $x = shift; my$out; if ($x <$xf ) { $out =$hermite_f1->rf_f->($x); } elsif ($x == $xf) {$out = $yf; } else {$out = $hermite_f2->rf_f->($x); } $out; }; sub g_rule { my$x = shift; my $out; if ($x < $xg ) {$out = $hermite_g1->rf_f->($x); } elsif ($x ==$xg) { $out =$yg; } else { $out =$hermite_g2->rf_f->($x); }$out; }; # plot the f graph $graphf = init_graph(-2,-2,5,5,grid =>[7,7], axes => [0,0]);$graphg = init_graph(-2,-2,5,5,,grid =>[7,7], axes => [0,0]); $f1 = new Fun($hermite_f1->rf_f,$graphf);$f2 = new Fun($hermite_f2->rf_f,$graphf); $graphf->stamps(open_circle($xf, $hermite_f1->rf_f->($xf), 'red') ); $graphf->stamps(open_circle($xf, $hermite_f2->rf_f->($xf), 'red') ); $graphf ->stamps( closed_circle($xf, $yf, 'red') ); # value at$xf; $f1->color('red');$f2->color('red'); # restrict the two partial graph domains so that only the 'active' one is drawn $f1->domain(-1,$xf); $f2->domain($xf, 4); #plot the g graph $g1 = new Fun($hermite_g1->rf_f,$graphg);$g2 = new Fun($hermite_g2->rf_f,$graphg); $graphg->stamps(open_circle($xg, $hermite_g1->rf_f->($xg), 'blue') ); $graphg->stamps(open_circle($xg, $hermite_g2->rf_f->($xg), 'blue') ); $graphg ->stamps(closed_circle($xg, $yg, 'blue') ); # value at$xg; $g2->color('blue');$g2->color('blue'); # restrict the two partial graph domains so that only the 'active' one is drawn $g1->domain(-1,$xg); $g2->domain($xg, 4); TEXT(beginproblem()); # draw the graphs BEGIN_TEXT \{ begintable(2) \} \{ row( image( insertGraph($graphf), tex_size =>400), image( insertGraph($graphg) , tex_size =>400 ) )\} \{ row( '$$f(x)$$', '$$g(x)$$') \} \{ endtable() \} END_TEXT sub rnd { my $x = shift; my$places = shift; $places = 0 unless defined($places); my $sign = ($x <0 ) ? -1 : 1; $x = abs($x); $x = int($x*10 **(-$places) +.5) *10 **($places); $sign*$x; } # now construct the questions @questions = (); @answers = (); qa( ~~@questions, ~~@answers, '$$\displaystyle \lim_{x\to xf^-} [f(x) + g(x) ]$$ ', num_cmp(rnd( f_rule($xf-.00001) +g_rule($xf-.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$\displaystyle \lim_{x\to xf^+} [f(x) + g(x) ]$$ ', num_cmp(rnd( f_rule($xf+.00001) +g_rule($xf+.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$f(xf) + g(xf)$$', num_cmp(f_rule($xf) + g_rule($xf), strings=>['DNE'] ), '$$\displaystyle \lim_{x\to xf^-} [f(x)g(x) ]$$ ', num_cmp(rnd( f_rule($xf-.00001)*g_rule($xf-.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$\displaystyle \lim_{x\to xf^+} [f(x)g(x) ]$$ ', num_cmp(rnd( f_rule($xf+.00001)*g_rule($xf+.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$f(xf)g(xf)$$', num_cmp(f_rule($xf)*g_rule($xf), strings=>['DNE'] ), '$$\displaystyle \lim_{x\to xf^-} [f( g(x) ) ]$$ ', num_cmp(rnd( f_rule(g_rule($xf-.00001) ) ), strings=>['DNE'] ), # we are expecting integer answers '$$\displaystyle \lim_{x\to xf^+} [f( g(x) ) ]$$ ', num_cmp(rnd( f_rule(g_rule($xf+.00001) ) ), strings=>['DNE'] ), # we are expecting integer answers '$$f( g(xf) )$$', num_cmp(f_rule( g_rule($xf) ), strings=>['DNE'] ), #check for zeros in answering the division limits '$$\displaystyle \lim_{x\to xf^-} [f(x)/g(x) ]$$ ', ( not rnd(g_rule($xf-.00001) ) and rnd(f_rule($xf-.00001) ) ) ? num_cmp('DNE', strings=>['DNE']) # if g is zero, but f is not : num_cmp(rnd( f_rule($xf-.00001)/g_rule($xf-.00001) , -3 ), tol =>.002, strings=>['DNE'] ), # the chances of g being identically zero are small since the derivatives at defined points are never zero. # we are expecting integer answers '$$\displaystyle \lim_{x\to xf^+} [f(x)/g(x) ]$$ ', ( not rnd(g_rule($xf+.00001) ) and rnd(f_rule($xf+.00001) ) ) ? num_cmp('DNE', strings=>['DNE']) : num_cmp(rnd( f_rule($xf+.00001)/g_rule($xf+.00001) , -3 ), tol =>.002, strings=>['DNE'] ) , # we are expecting integer answers '$$f(xf)/g(xf)$$', (rnd(g_rule($xf)) ) ? num_cmp( rnd(f_rule($xf)/g_rule($xf), -3), tol =>.002, strings=>['DNE'] ) : num_cmp('DNE', strings=>['DNE']), '$$\displaystyle \lim_{x\to xg^-} [f(x) + g(x) ]$$ ', num_cmp(rnd( f_rule($xg-.00001) +g_rule($xg-.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$\displaystyle \lim_{x\to xg^+} [f(x) + g(x) ]$$ ', num_cmp(rnd( f_rule($xg+.00001) +g_rule($xg+.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$f(xg) + g(xg)$$', num_cmp(f_rule($xg) + g_rule($xg), strings=>['DNE'] ), '$$\displaystyle \lim_{x\to xg^-} [f(x)g(x) ]$$ ', num_cmp(rnd( f_rule($xg-.00001)*g_rule($xg-.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$\displaystyle \lim_{x\to xg^+} [f(x)g(x) ]$$ ', num_cmp(rnd( f_rule($xg+.00001)*g_rule($xg+.00001) ), strings=>['DNE'] ), # we are expecting integer answers '$$f(xg)g(xg)$$', num_cmp(f_rule($xg)*g_rule($xg), strings=>['DNE'] ), '$$\displaystyle \lim_{x\to xg^-} [f( g(x) ) ]$$ ', num_cmp(rnd( f_rule( g_rule($xg-.00001) )), strings=>['DNE'] ) , # we are expecting integer answers '$$\displaystyle \lim_{x\to xg^+} [f( g(x) ) ]$$ ', num_cmp(rnd( f_rule( g_rule($xg + .00001 ) ) ), strings=>['DNE'] ), # we are expecting integer answers '$$f( g(xg) )$$', num_cmp(f_rule( g_rule($xg) ), strings=>['DNE'] ), #check for zeros in answering the division limits '$$\displaystyle \lim_{x\to xg^-} [f(x)/g(x) ]$$ ', ( not rnd(g_rule($xg-.00001) ) and rnd(f_rule($xg-.00001) ) ) ? num_cmp('DNE', strings=>['DNE']) # if g is zero, but f is not : num_cmp(rnd( f_rule($xg-.00001)/g_rule($xg-.00001) , -3 ), tol =>.002, strings=>['DNE'] ), # the chances of g being identically zero are small since the derivatives at defined points are never zero. # we are expecting integer answers '$$\displaystyle \lim_{x\to xg^+} [f(x)/g(x) ]$$ ', ( not rnd(g_rule($xg+.00001) ) and rnd(f_rule($xg+.00001) ) ) ? num_cmp('DNE', strings=>['DNE']) : num_cmp(rnd( f_rule($xg+.00001)/g_rule($xg+.00001) , -3 ), tol =>.002, strings=>['DNE'] ) , # we are expecting integer answers '$$f(xg)/g(xg)$$', (rnd(g_rule($xg)) ) ? num_cmp( rnd(f_rule($xg)/g_rule($xg), -3), tol =>.002, strings=>['DNE'] ) : num_cmp('DNE', strings=>['DNE']), ); @slice = NchooseK(scalar(@questions) ,4); BEGIN_TEXT $BR The graphs of $$f(x)$$ and $$g(x)$$ are given above. Use them to evaluate each quantity below. Write$BITALIC DNE$EITALIC if the limit or value does not exist (or if it's infinity).$BR \{ match_questions_list(@questions[@slice] ) \} END_TEXT ANS(@answers[@slice] ); ENDDOCUMENT(); # This should be the last executable line in the problem.