[npl] / trunk / NationalProblemLibrary / Rochester / setLimitsRates2Limits / ur_lr_2_10.pg Repository:
ViewVC logotype

Annotation of /trunk/NationalProblemLibrary/Rochester/setLimitsRates2Limits/ur_lr_2_10.pg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 314 - (view) (download)

1 : jj 143 #DESCRIPTION
2 :     #KEYWORDS('limits', 'sequences')
3 :     # Find limits (intuitively or by experimental calculations).
4 :     #ENDDESCRIPTION
5 :    
6 : jjholt 314 ##KEYWORDS('Calculus')
7 :     ##Tagged by ynw2d
8 :    
9 :     ##DBsubject('Calculus')
10 :     ##DBchapter('Limits and Derivatives')
11 :     ##DBsection('The Limit of a Function')
12 :    
13 :    
14 : jj 143 DOCUMENT(); # This should be the first executable line in the problem.
15 :    
16 :     loadMacros("PG.pl",
17 :     "PGbasicmacros.pl",
18 :     "PGchoicemacros.pl",
19 :     "PGanswermacros.pl",
20 :     "PGauxiliaryFunctions.pl",
21 :     "PGgraphmacros.pl");
22 :    
23 :     $showPartialCorrectAnswers=1;
24 :     # define a broken graph f and a broken graph g:
25 :    
26 :     # first define the parameters (value and first derivatives)
27 :     foreach my $i (0..5) {
28 :     $f1y[$i] = random(0, 3, 1);
29 :     $f1yp[$i] = random(-1,1, 2);
30 :     $f2y[$i] = random(0, 3, 1);
31 :     $f2yp[$i] = random(-1,1, 2);
32 :     $g1y[$i] = random(0, 3, 1);
33 :     $g1yp[$i] = random(-1,1, 2);
34 :     $g2y[$i] = random(0, 3, 1);
35 :     $g2yp[$i] = random(-1,1, 2);
36 :     }
37 :    
38 :     # define the functions
39 :     $hermite_f1 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ],
40 :     [ @f1y ],
41 :     [ @f1yp ]);
42 :     $hermite_f2 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ],
43 :     [ @f2y ],
44 :     [ @f2yp ]);
45 :     $hermite_g1 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ],
46 :     [ @g1y ],
47 :     [ @g1yp ]);
48 :     $hermite_g2 = new Hermite( [ -1 , 0, 1, 2 , 3, 4 ],
49 :     [ @g2y ],
50 :     [ @g2yp ]);
51 :    
52 :     # define the break points where we switch from one hemite function to the other
53 :     # and the value of the function at that point
54 :    
55 :     $xf = random(0,3,1);
56 :     $yf = random(-1,4,1);
57 :     $xg = random(0,3,1);
58 :     $yg = random(-1,4,1);
59 :    
60 :    
61 :     # define the broken functions themselves -- we'll need them to answer questions.
62 :     sub f_rule {
63 :     my $x = shift;
64 :     my $out;
65 :     if ($x < $xf ) {
66 :     $out = $hermite_f1->rf_f->($x);
67 :     } elsif ($x == $xf) {
68 :     $out = $yf;
69 :     } else {
70 :     $out = $hermite_f2->rf_f->($x);
71 :     }
72 :     $out;
73 :     };
74 :     sub g_rule {
75 :     my $x = shift;
76 :     my $out;
77 :     if ($x < $xg ) {
78 :     $out = $hermite_g1->rf_f->($x);
79 :     } elsif ($x == $xg) {
80 :     $out = $yg;
81 :     } else {
82 :     $out = $hermite_g2->rf_f->($x);
83 :     }
84 :     $out;
85 :     };
86 :    
87 :    
88 :     # plot the f graph
89 :    
90 :     $graphf = init_graph(-2,-2,5,5,grid =>[7,7], axes => [0,0], size =>[500,500]);
91 :     $graphg = init_graph(-2,-2,5,5,,grid =>[7,7], axes => [0,0], size =>[500,500]);
92 :     $f1 = new Fun($hermite_f1->rf_f,$graphf);
93 :     $f2 = new Fun($hermite_f2->rf_f,$graphf);
94 :     $graphf->stamps(open_circle($xf, $hermite_f1->rf_f->($xf), 'red') );
95 :     $graphf->stamps(open_circle($xf, $hermite_f2->rf_f->($xf), 'red') );
96 :     $graphf ->stamps( closed_circle($xf, $yf, 'red') ); # value at $xf;
97 :     $f1->color('red');
98 :     $f2->color('red');
99 :     # restrict the two partial graph domains so that only the 'active' one is drawn
100 :     $f1->domain(-1, $xf);
101 :     $f2->domain($xf, 4);
102 :    
103 :     #plot the g graph
104 :     $g1 = new Fun($hermite_g1->rf_f,$graphg);
105 :     $g2 = new Fun($hermite_g2->rf_f,$graphg);
106 :     $graphg->stamps(open_circle($xg, $hermite_g1->rf_f->($xg), 'blue') );
107 :     $graphg->stamps(open_circle($xg, $hermite_g2->rf_f->($xg), 'blue') );
108 :     $graphg ->stamps(closed_circle($xg, $yg, 'blue') ); # value at $xg;
109 :     $g2->color('blue');
110 :     $g2->color('blue');
111 :     # restrict the two partial graph domains so that only the 'active' one is drawn
112 :     $g1->domain(-1, $xg);
113 :     $g2->domain($xg, 4);
114 :    
115 :     TEXT(beginproblem());
116 :    
117 :    
118 :     # draw the graphs
119 :     TEXT(
120 :     begintable(2),
121 :     row( image( insertGraph($graphf), tex_size =>400), image( insertGraph($graphg) , tex_size =>400 ) ),
122 :     row( 'f(x)', 'g(x)'),
123 :     endtable(),
124 :     );
125 :     sub rnd {
126 :     my $x = shift;
127 :     my $places = shift;
128 :     $places = 0 unless defined($places);
129 :     my $sign = ($x <0 ) ? -1 : 1;
130 :     $x = abs($x);
131 :    
132 :     $x = int( $x*10 **(-$places) +.5) *10 **($places);
133 :     $sign*$x;
134 :     }
135 :     # now construct the questions
136 :     @questions = ();
137 :     @answers = ();
138 :    
139 :     qa( ~~@questions, ~~@answers,
140 :     '\( \lim_{x\to $xf^-} [f(x) + g(x) ] \) ',
141 :     num_cmp(rnd( f_rule($xf-.00001) +g_rule($xf-.00001) ), strings => ['DNE'] ), # we are expecting integer answers
142 :     '\( \lim_{x\to $xf^+} [f(x) + g(x) ] \) ',
143 :     num_cmp(rnd( f_rule($xf+.00001) +g_rule($xf+.00001) ), strings => ['DNE'] ), # we are expecting integer answers
144 :     '\( f($xf) + g($xf) \)',
145 :     num_cmp(f_rule($xf) + g_rule($xf), strings => ['DNE'] ),
146 :    
147 :     '\( \lim_{x\to $xf^-} [f(x)g(x) ] \) ',
148 :     num_cmp(rnd( f_rule($xf-.00001)*g_rule($xf-.00001) ), strings => ['DNE'] ), # we are expecting integer answers
149 :     '\( \lim_{x\to $xf^+} [f(x)g(x) ] \) ',
150 :     num_cmp(rnd( f_rule($xf+.00001)*g_rule($xf+.00001) ), strings => ['DNE'] ), # we are expecting integer answers
151 :     '\( f($xf)g($xf) \)',
152 :     num_cmp(f_rule($xf)*g_rule($xf), strings => ['DNE'] ),
153 :    
154 :     '\( \lim_{x\to $xf^-} [f( g(x) ) ] \) ',
155 :     num_cmp(rnd( f_rule(g_rule($xf-.00001) ) ), strings => ['DNE'] ), # we are expecting integer answers
156 :     '\( \lim_{x\to $xf^+} [f( g(x) ) ] \) ',
157 :     num_cmp(rnd( f_rule(g_rule($xf+.00001) ) ), strings => ['DNE'] ), # we are expecting integer answers
158 :     '\( f( g($xf) ) \)',
159 :     num_cmp(f_rule( g_rule($xf) ), strings => ['DNE'] ),
160 :    
161 :     #check for zeros in answering the division limits
162 :     '\( \lim_{x\to $xf^-} [f(x)/g(x) ] \) ',
163 :     ( 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
164 :     : 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.
165 :     # we are expecting integer answers
166 :     '\( \lim_{x\to $xf^+} [f(x)/g(x) ] \) ',
167 :     ( not rnd(g_rule($xf+.00001) ) and rnd(f_rule($xf+.00001) ) ) ? num_cmp('DNE', strings => ['DNE'] )
168 :     : num_cmp(rnd( f_rule($xf+.00001)/g_rule($xf+.00001) , -3 ), tol =>.002, strings => ['DNE'] ) ,
169 :     # we are expecting integer answers
170 :     '\( f($xf)/g($xf) \)',
171 :     (rnd(g_rule($xf)) ) ? num_cmp( rnd(f_rule($xf)/g_rule($xf), -3), tol =>.002, strings => ['DNE'] ) : num_cmp('DNE', strings => ['DNE'] ),
172 :    
173 :     '\( \lim_{x\to $xg^-} [f(x) + g(x) ] \) ',
174 :     num_cmp(rnd( f_rule($xg-.00001) +g_rule($xg-.00001) ), strings => ['DNE'] ), # we are expecting integer answers
175 :     '\( \lim_{x\to $xg^+} [f(x) + g(x) ] \) ',
176 :     num_cmp(rnd( f_rule($xg+.00001) +g_rule($xg+.00001) ), strings => ['DNE'] ), # we are expecting integer answers
177 :     '\( f($xg) + g($xg) \)',
178 :     num_cmp(f_rule($xg) + g_rule($xg), strings => ['DNE'] ),
179 :    
180 :     '\( \lim_{x\to $xg^-} [f(x)g(x) ] \) ',
181 :     num_cmp(rnd( f_rule($xg-.00001)*g_rule($xg-.00001) +.4 ), strings => ['DNE'] ), # we are expecting integer answers
182 :     '\( \lim_{x\to $xg^+} [f(x)g(x) ] \) ',
183 :     num_cmp(int( f_rule($xg+.00001)*g_rule($xg+.00001) +.4 ), strings => ['DNE'] ), # we are expecting integer answers
184 :     '\( f($xg)g($xg) \)',
185 :     num_cmp(f_rule($xg)*g_rule($xg), strings => ['DNE'] ),
186 :    
187 :     '\( \lim_{x\to $xg^-} [f( g(x) ) ] \) ',
188 :     num_cmp(int( f_rule( g_rule($xg-.00001) )), strings => ['DNE'] ) , # we are expecting integer answers
189 :     '\( \lim_{x\to $xg^+} [f( g(x) ) ] \) ',
190 :     num_cmp(rnd( f_rule( g_rule( $xg + .00001 ) ) ), strings => ['DNE'] ), # we are expecting integer answers
191 :     '\( f( g($xg) ) \)',
192 :     num_cmp(f_rule( g_rule($xg) ), strings => ['DNE'] ),
193 :    
194 :     #check for zeros in answering the division limits
195 :     '\( \lim_{x\to $xg^-} [f(x)/g(x) ] \) ',
196 :     ( 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
197 :     : 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.
198 :     # we are expecting integer answers
199 :     '\( \lim_{x\to $xg^+} [f(x)/g(x) ] \) ',
200 :     ( not rnd(g_rule($xg+.00001) ) and rnd(f_rule($xg+.00001) ) ) ? num_cmp('DNE', strings => ['DNE'] )
201 :     : num_cmp(rnd( f_rule($xg+.00001)/g_rule($xg+.00001) , -3 ), tol =>.002, strings => ['DNE'] ) ,
202 :     # we are expecting integer answers
203 :     '\( f($xg)/g($xg) \)',
204 :     (rnd(g_rule($xg)) ) ? num_cmp( rnd(f_rule($xg)/g_rule($xg), -3), tol =>.002, strings => ['DNE'] ) : num_cmp('DNE', strings => ['DNE'] ),
205 :    
206 :     );
207 :    
208 :     @slice = NchooseK(scalar(@questions) ,4);
209 :    
210 :     BEGIN_TEXT
211 :     $BR
212 :     The graphs of \( f \) and \( g \) are given above. Use them to evaluate each quantity below.
213 :     Write 'DNE' if the limit or value does not exist (or if it's infinity).
214 :     $BR
215 :     \{ match_questions_list(@questions[@slice] ) \}
216 :    
217 :     $BR
218 :    
219 :     END_TEXT
220 :    
221 :     ANS(@answers[@slice] );
222 :     ENDDOCUMENT(); # This should be the last executable line in the problem.

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9