[npl] / trunk / NationalProblemLibrary / LoyolaChicago / Precalc / Chap2Sec3 / Connally3-2-3-19-Piecewise-functions.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/NationalProblemLibrary/LoyolaChicago/Precalc/Chap2Sec3/Connally3-2-3-19-Piecewise-functions.pg

Fri Sep 16 17:43:41 2011 UTC (20 months, 1 week ago) by glarose
File size: 5799 byte(s)
LoyolaChicago/2.3: 4e tagging, cleanup.

    1 ## DESCRIPTION
2 ## Functions: Piecewise defined functions
3 ## ENDDESCRIPTION
4
5 ## KEYWORDS('functions','piecwise')
6
7 ## DBsubject('Precalculus')
8 ## DBchapter('Functions')
9 ## DBsection('Piecewise Defined Functions')
10 ## Date('01/01/10')
11 ## Author('Paul Pearson')
12 ## Institution('Fort Lewis College')
13 ## TitleText1('Functions Modeling Change')
14 ## EditionText1('3')
15 ## AuthorText1('Connally')
16 ## Section1('2.3')
17 ## Problem1('19')
18 ## EditionText2('4')
19 ## AuthorText2('Connally')
20 ## Section2('2.Review')
21 ## Problem2('70')
22
23 DOCUMENT();
24
26 "PGstandard.pl",
27 "MathObjects.pl",
28 "PGunion.pl",
29 "PGcourse.pl",
30 "PGgraphmacros.pl",
31 );
32
33 TEXT(beginproblem());
34
35 ##############################################
36 #  Setup
37
38 Context("Numeric")->variables->are(p=>"Real");
39
40 $pagespersig = random(8,16,4); 41$costpersig = sprintf("%0.2f", random(0.1,0.2,0.01) );
42 $numsigs = random(7,12,1); 43$pages = $pagespersig *$numsigs;
44 $pages1 =$pages + 1;
45
46 $costpages = Real("$numsigs * $costpersig"); 47$costpages1 = Real("($numsigs + 1) *$costpersig");
48
49 $costfunction = Formula("$costpersig * p / $pagespersig"); 50 51 52 ############################################## 53 # Main text 54 55 Context()->texStrings; 56 BEGIN_TEXT 57 58 Many printing presses are designed with large plates 59 that print a fixed number of pages as a unit. Each 60 unit is called a signature. A particular press 61 prints signatures of$pagespersig pages each.  Suppose
62 $$C(p)$$ is the cost of printing a book of $$p$$
63 pages, assuming each signature printed costs
64 ${DOLLAR}${costpersig}.
65 $PAR 66 (a) What is the cost of printing a book of$pages pages?
67 ${DOLLAR} \{ ans_rule(10) \} 68$BR
69 What if there are $pages1 pages? 70${DOLLAR} \{ ans_rule(10) \}
71 $BR 72 What if there are $$p$$ pages? 73 $$C(p) =$$ 74${DOLLAR} \{ ans_rule(10) \}
75 where the cost is rounded (up/down)
76 \{ pop_up_list(["?","up","down"]) \}
77 for the next signature.
78 $PAR 79 (b) What are the domain and range of $$C(p)$$? 80$BR
81 Domain: all nonnegative integer multiples of (1 through 16)
82 \{ pop_up_list(["?","1","2","3","4","5","6","7","8",
83 "9","10","11","12","13","14","15","16"]) \}
84 $BR 85 Range:$SPACE all nonnegative integer multiples of
86 (0.01 through 0.20)
87 \{ pop_up_list(["?","0.01","0.02","0.03","0.04","0.05",
88 "0.06","0.07","0.08","0.09","0.10","0.11","0.12","0.13",
89 "0.14","0.15","0.16","0.17","0.18","0.19","0.20"]) \}
90 $PAR 91 (c) On a piece of paper, sketch a graph of $$C(p)$$. 92 93 END_TEXT 94 Context()->normalStrings; 95 96 ################################################## 97 # Answers 98 99$showPartialCorrectAnswers = 1;
100
101 ANS($costpages->cmp()); 102 ANS($costpages1->cmp());
103 ANS($costfunction->cmp()); 104 ANS(str_cmp("up")); 105 ANS(str_cmp("1")); 106 ANS(str_cmp("$costpersig"));
107
108 $numsigp1 =$numsigs + 1;
109 $pagespersigp1 =$pagespersig + 1;
110 $twopagespersig = 2*$pagespersig;
111 $twocostpersig = 2*$costpersig;
112
113 $solgr = init_graph( -$pagespersig, -$costpersig,$pages, $costpages+$costpersig, axes=>[0,0],
114          size=>[250,250], grid=>[$numsigs+1,$numsigs+2] );
115
116 $datarows = ''; 117 for (my$i=0; $i<$numsigs; $i++ ) { 118 my$j = $i*$pagespersig + 1;
119     my $k = ($i+1)*$pagespersig; 120$datarows .= row( "$j-$k", $costpersig*($i+1) );
121     plot_functions( $solgr, 122$costpersig*($i+1) . " for x in [$j,$k) using color:blue" . 123 " and weight:2" ); 124 } 125 126 127 128 SOLUTION(EV3(<<'END_SOLUTION')); 129$PAR
130 $BBOLD SOLUTION$EBOLD
131 $PAR 132 133 (a) 134 Each signature printed costs${DOLLAR}$costpersig, and in a book 135 of $$p$$ pages, there are at least $$p/pagespersig$$ signatures. 136 In a book of$pages pages, there are
137 $\frac{pages}{pagespersig}=numsigs \hbox{ signatures},$
138 $\hbox{Cost for pages pages }=costpersig(numsigs)=costpages.$
139 A book of pages1 pages requires $numsigp1 signatures, although the 140${numsig1}th signature is used to print only 1 page. Therefore,
141 $\hbox{Cost for pages2 pages }=costpersig(numsigp1)=costpages1.$
142 $PAR 143 To find the cost of $$p$$ pages, we first find the number of 144 signatures. If $$p$$ is divisible by$pagespersig, then the number of signatures
145 is $$p/pagespersig$$ and the cost is
146 $C(p)=costpersig\left(\frac{p}{pagespersig}\right).$
147 If $$p$$ is not divisible by $pagespersig, the number of signatures is $$p/pagespersig$$ 148 rounded up to the next highest integer and the cost is$costpersig times
149 that number.  In this case, it is hard to write a formula for $$C(p)$$
150 without a symbol for rounding up.''
151
152 $PAR 153 (b) 154 The number of pages, $$p$$, 155 is greater than zero. Although it is possible to have a page which is 156 only half filled, we do not say that a book has 124 1/2 pages, so $$p$$ 157 must be an integer. Therefore, the 158 domain of $$C(p)$$ is $$p>0$$, $$p$$ an integer. Because the cost of a book 159 increases by multiples of${DOLLAR}$costpersig (the cost of one signature), the range 160 of $$C(p)$$ is $$C>0$$, $$C$$ an integer multiple of${DOLLAR}$costpersig. 161 162$PAR
163 (c)
164 For 1 to $pagespersig pages, the cost is${DOLLAR}$costpersig, because only 1 165 signature is required. For$pagespersigp1 to $twopagespersig pages, 166 the cost is${DOLLAR}$twocostpersig, because 2 signatures are required. These data are continued in the table below, and plotted in the following figure, 167 for $$0\leq p\leq pages$$. 168 A closed circle 169 represents a point included on the graph, and an open 170 circle indicates a point excluded from the graph. The unbroken lines 171 in the figure suggest, erroneously, that${BITALIC}fractions$EITALIC of 172 pages can be printed. It would be more accurate to draw each step as 173$pagespersig separate dots instead of as an unbroken line.
174
175 $PAR 176 \{ begintable(2) \} 177 \{ row( "$$p$$ (pages)", "$$C$$ (dollars)" ) \} 178$datarows
179 \{ endtable() \}
180
181 $PAR 182$BCENTER
183 \{ image(insertGraph($solgr), height=>250, width=>250, tex_size=>250, 184 extra_html_tags=>'alt="graph of a piecewise constant function ' . 185 'as described above."') \} 186$ECENTER
187
188 END_SOLUTION
189
190 COMMENT('Uses MathObjects');
191 ENDDOCUMENT();