-
-
Notifications
You must be signed in to change notification settings - Fork 437
Expand file tree
/
Copy pathBoxMaxVolumeFixedCostScaffold.pg
More file actions
329 lines (246 loc) · 19.9 KB
/
Copy pathBoxMaxVolumeFixedCostScaffold.pg
File metadata and controls
329 lines (246 loc) · 19.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
##DESCRIPTION
## Optimization - maximize volume of a box with closed top and fixed
## cost. Uses GeoGebra HTML5 applet to display graph of volume
## function and an animation of the box as the base length is changed.
## Embedding of Geogebra applet uses https://github.com/Edfinity/ww_ggb_applet.
## Uses scaffolding to first set up the problem in terms of length and height,
## then to give a function for volume in terms of the base length, and find its derivative,
## then finally to use the derivative to find the optimal dimensions.
##ENDDESCRIPTION
## DBsubject(Calculus - single variable)
## DBchapter(Applications of differentiation)
## DBsection(Optimization - general)
## Date(12/2020)
## Institution(Agnes Scott College)
## Author(Larry Riddle)
## MO(1)
## KEYWORDS('optimization', 'applications', 'derivative', 'Geogebra')
##############################################################
# Initialization
##############################################################
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"scaffold.pl",
"PGML.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$showHint = 0;
##############################################################
# Problem Setup
##############################################################
Context("Numeric");
Context()->variables->add(h=>"Real");
Context()->flags->set(
tolerance => 0.0005, tolType => "absolute",
Context()->{format}{number} = "%.6f#",
# formatStudentAnswer => "parsed"
);
#C1 cost of top
#C2 cost of bottom
#C3 cost of sides
#C total cost in cents
$C1 = random(1.25,4,0.25);
do {$C2 = random(1.25,4,0.25);} until ($C2 != $C1);
do {$C3 = random(1,4,0.25);} until ($C3 != $C1+$C2);
$C = random(800,2000,50);
$Cdollars = sprintf("%0.2f",$C/100);
$domain = sprintf("%0.2f",sqrt($C/($C1+$C2)));
$costForm = Formula("$C1*x**2 +$C2*x**2+ 4*$C3*x*h");
$volForm = Formula("x^2*h");
$volFunc = Formula("($C*x-($C1+$C2)*x**3)/(4*$C3)");
$volDeriv = Formula("($C - 3*($C1+$C2)*x**2)/(4*$C3)");
$optimalLength = Real("sqrt($C/(3*($C1+$C2)))");
$optimalHeight = Real("sqrt(3*$C*($C1+$C2))/(6*$C3)");
$maxVolume = Real("$C**2*sqrt(3)/(18*$C3*sqrt($C*($C1+$C2)))");
# Possible errors in setting up the cost formula
# area, not cost
$AreaForm = Formula("2x**2 + 4*x*h");
# open top
$openTop = Formula("$C2*x**2 + 4*$C3*x*h");
# doesn't take into account 4 sides
$sideCostError1 = Formula("$C1*x**2+$C2*x**2 + $C3*x*h");
# uses only 2 sides rather than 4
$sideCostError2 = Formula("$C1*x**2+$C2*x**2 + 2*$C3**x*h");
# doesn't include the cost with the 4 sides
$sideCostError3 = Formula("$C1*x**2+$C2*x**2 + 4*x*h");
# doesn't take into account side costs
$noSideCost = Formula("$C1*x**2+$C2*x**2");
# doesn't include top and bottom
$noTopBottom = Formula("4*$C3*x*h");
# doesn't include the cost with the top and bottom
$noTopBottomCost = Formula("2x**2+4*$C3*x*h");
# mixed units in volume function
$mixed = Formula("($C/100*x-($C1+$C2)*x**3)/(4*$C3)");
$CostChecker = sub {
my ($correct,$student,$ansHash) = @_;
if ($student == $AreaForm) {
Value->Error("This appears to be the surface area of the box, not the cost. See the Hint.");
} elsif ($student == $mixed) {
Value->Error("Your answer is close, but it appears that you may have mixed units with the budget cost in dollars and the box costs in cents.");
} elsif ($student == $correct/100) {
Value->Error("Your answer is close, but it appears that you may have expressed the cost of the box in dollars, not cents.");
} elsif ($student == $openTop) {
Value->Error("It appears that you may not have included the top of the box. See the Hint.");
} elsif ($student == $sideCostError1) {
Value->Error("It appears that you may not have used the correct number of sides of the box. See the Hint.");
} elsif ($student == $sideCostError2) {
Value->Error("It appears that you may not have used the correct number of sides of the box. See the Hint.");
} elsif ($student == $sideCostError3) {
Value->Error("It appears that you may not have included the cost of the sides of the box. See the Hint.");
} elsif ($student == $noTopBottomCost) {
Value->Error("It appears that you may not have included the cost of the top and bottom. See the Hint.");
} elsif ($student == $noTopBottom) {
Value->Error("It appears that you may not have included the top and bottom of the box. See the Hint.");
} elsif ($student == $noSideCost) {
Value->Error("It appears that you may not have included the sides of the box. See the Hint.");
} elsif ($student != $correct) {
Value->Error("See the Hint.");
}
return 1;
};
$VolumeChecker = sub {
my ($correct,$student,$ansHash) = @_;
if ($student != $correct) {
Value->Error("See the Hint.");
}
return 1;
};
$maxVolumeChecker = sub {
my ($correct,$student,$ansHash) = @_;
if ((abs($student - $maxVolume) > 0.0005) && (abs($student-$maxVolume) < 0.05)) {
Value->Error("You may need to use 5 or more decimal places in x and h to get V accurate to 3 decimal places. See the Hint.");
} elsif ($student != $correct) {
Value->Error("See the Hint");
}
return 1;
};
HEADER_TEXT('<script type="text/javascript" src="https://cdn.geogebra.org/apps/deployggb.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ww_ggb_applet/lib/ww_ggb_applet.js"></script>');
TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) );
<div id="applet2" class="ww-ggb"></div>
<script>
var onUpdate = function(obj) {
}
var onLoad = function(applet) {
applet.evalCommand("C1 = $C1");
applet.evalCommand("C2= $C2");
applet.evalCommand("C3 = $C3");
applet.evalCommand("A = $C");
}
encodedApp = "UEsDBBQACAgIADR7mFEAAAAAAAAAAAAAAAAWAAAAZ2VvZ2VicmFfamF2YXNjcmlwdC5qc0srzUsuyczPU0hPT/LP88zLLNHQVKiu5QIAUEsHCEXM3l0aAAAAGAAAAFBLAwQUAAgICAA0e5hRAAAAAAAAAAAAAAAAFwAAAGdlb2dlYnJhX2RlZmF1bHRzMmQueG1s7Zpbc9soFICft7+C0dPuQ2whS7aTidNJO7OznUnTnU2ms69YwjIbDFpAsZxfXwS6xpfGdlI7bfIQcTAg+M7hAAedv89mFNxjIQlnIwd2XAdgFvKIsHjkpGpyMnTeX7w7jzGP8VggMOFihtTICfKSVT0tdXyvn+ehJBk5IUVSktABCUUqrzJyIgeATJIzxq/RDMsEhfgmnOIZuuIhUqaVqVLJWbc7n8875fs6XMTdOFadTOoGdF+ZHDlF4kw316o075ninuvC7r+fr2zzJ4RJhViIHaDHEeEJSqmSOokpnmGmgFokeORMUhbmvbj+ioQDKBpjOnJYSqkDijojpx84F+9+O5dTPgd8/B8OdZ4SKa7KG6Gbl9E/f+SUCyBGjuf6DtA0NZyx+Y9oMkU61RkEtjRFCyzAPaL5zyYHpYqHpgGTO0FU4rKsftVnHmH7i1+UZ2RmKAKpsFYAdIBMMI5Myo7QNdpYGMVW7Z13CwxLQCiRqhrYlREqELDnLpOwbW5G4RoQ0H2M4iQ3vAOj0O0Rhm/UgmKgpiS8Y1hqYwsalfLEXySKcD5VbJ2EE6ZuyEPRh6CZa5oy2SdwM+yE00XMWUXv71KukA8s8S27CLieZ0Qtd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343DunSjsB64MVgP3Yj3ZycTnZStBEXdJzv5oHyESWHsH91gwwF8lzfKOKB+4Mu7+MN+7zV5tUiWy3u67b3rR+bW+v3t9QeRWT4WQ1vc14Fb2xnv+iLmfiSDUERhgLKbULqrHxxXRF0uOQ1DHlMupAS3vtp/vvDvhs/548PnMcHz7KOB549A5+vHh84+5/p94DHnwRZAduP4HY+EO1B+oBB8n1PhboD4EaCbARJHgG4GyD8CtB8gTEj/2JtSjPLd8LBDnYLee5pr4dGk5R+0dd2g8YMd7O6Tp/9ep+MNPPkuPA/jQP+PcIojnIeE0z/CeUg47wDm3e4IPCyY4lGCyY9gHjBuHsE8YNQ8gnkfMI8PhY8PhR/zk5Xjw66PTCXH5/SPTyfH5/R/iE62Xom7LLLVe6PVrV6KwyE4c+utuO0X+Ox2+6BvxW0LU+tF3bx2/Zdf50X91+/JgNga+Zx0Xqg3+ocfYf0/4VfQbL/9vUtu5Oats77ZZt13+3ab7D4xD/FOqxpWRTav9etRqXXe/JEGNF7G7MMbIbee+vbaX6cwXxp0f8fhy/8BUEsHCL3fb77ZCgAAk0IAAFBLAQIUABQACAgIADR7mFFFzN5dGgAAABgAAAAWAAAAAAAAAAAAAAAAAAAAAABnZW9nZWJyYV9qYXZhc2NyaXB0LmpzUEsBAhQAFAAICAgANHuYUXLYhAf6BAAAdCYAABcAAAAAAAAAAAAAAAAAXgAAAGdlb2dlYnJhX2RlZmF1bHRzMmQueG1sUEsBAhQAFAAICAgANHuYUUc5j6PjAgAABg0AABcAAAAAAAAAAAAAAAAAnQUAAGdlb2dlYnJhX2RlZmF1bHRzM2QueG1sUEsBAhQAFAAICAgANHuYUb3fb77ZCgAAk0IAAAwAAAAAAAAAAAAAAAAAxQgAAGdlb2dlYnJhLnhtbFBLBQYAAAAABAAEAAgBAADYEwAAAAA="
new WwGgbApplet('applet2', {
width: 716,
height: 362,
ggbBase64: encodedApp,
appletOnLoad: onLoad,
appletOnUpdate: onUpdate,
hideAnswers: false,
enableShiftDragZoom: false,
showResetIcon: true
});
</script>
END_SCRIPT
##############################################################
# Text
##############################################################
BEGIN_TEXT
$PAR
$BBOLD Note: $EBOLD This problem uses an interactive GeoGebra applet. It may take a few seconds for the figures to appear.
\{ knowlLink(" Instructions ", value=>'Click and hold the mouse on the point to move it, or use your finger on a touchscreen. You can also click the point and use the left/right arrow keys on a keyboard to move the point. Click or touch the small icon in the upper right corner to reset the app.') \}
$PAR
END_TEXT
BEGIN_PGML
## ##
You have a budget of $[$Cdollars] to construct a box with a square bottom and with a closed top.
The cost of the top of the box is [$C1] cents per square inch.
The cost of the bottom of the box is [$C2] cents per square inch.
The cost of the sides of the box is [$C3] cents per square inch.
In this problem you will find the size of the box that will maximize its volume when you use all of the budget of $[$Cdollars]. The graph above shows a plot of the volume as a function of the base length. Move the indicated point along the graph to visualize how the volume changes for different lengths of the square base, and use this to estimate the optimal size of the bottom square.
Click on Part 1 to open the section. Enter your answers for the two questions in Part 1, then click on Submit Answers. Once your answers are both correct, you will be able to open Part 2. When your answers to Part 2 are both correct, continue to Part 3 to find the optimal width and height for the box with maximum volume.
END_PGML
# The scaffold
Scaffold::Begin(open_first_section => 0);
Section::Begin("Part 1: The Setup",
is_open => correct_or_first_incorrect);
BEGIN_PGML
Let [`x`] be the width of the square base in inches and let [`h`] be the height of the box in inches.
What is the cost of the box *in cents* in terms of [`x`] and [`h`]?
[`C`] = [_________________________]{$costForm->cmp(checker=>$CostChecker)} cents
What is the volume of the box in terms of [`x`] and [`h`]?
[`V`] = [_________________________]{$volForm->cmp(checker=>$VolumeChecker)} cubic inches
END_PGML
BEGIN_PGML_HINT
The cost of a closed box is the sum of the cost of the square top, the cost of the square bottom, and the cost of the four sides of the box. The costs should be given in cents. The volume of the box is the area of the base times the height.
END_PGML_HINT
BEGIN_PGML_SOLUTION
The cost of a closed box is the sum of the cost of the square top, the cost of the square bottom, and the cost of the four sides of the box. The top and bottom each has area [`x^2`]. Each side of the box has area [`xh`]. The cost of a closed box in cents is therefore [`C = [$C1]*x^2 + [$C2]*x^2 + ([$C3])(4xh) = [$C1*$C2]*x^2 + [$C3*4]xh`]. The volume of the box is [`V = x^2 h`].
END_PGML_SOLUTION
Section::End();
Section::Begin("Part 2: The Calculus Part: Function and Derivative",
can_open => when_previous_correct,
is_open => correct_or_first_incorrect);
BEGIN_PGML
Use the fact that the total cost is $[$Cdollars] to determine a function [`V(x)`] that gives the volume of the box in terms of the width [`x`] of the base (this is the function plotted above).
[`V(x)`] = [________________________]{$volFunc->cmp(checker=>$CostChecker)}
What is the derivative of [`V(x)`]?
[`V'(x)`] = [________________________]{$volDeriv}
END_PGML
BEGIN_PGML_HINT
Be careful of units! The cost expression in Part 1 is the cost in cents, but the budget amount is given in dollars.
Solve the cost equation for [`h`] and substitute into the volume formula to get a function for the surface area only in terms of [`x`], then simplify as much as possible before taking the derivative.
END_PGML_HINT
BEGIN_PGML_SOLUTION
The cost of the box in cents is [``[$C1]*x^2 + [$C2]*x^2 + 4([$C3])xh = [$C1*$C2]*x^2 + [$C3*4]xh = [$C]``] where the budget $[$Cdollars] has been converted from dollars to cents.
Solving this equation for [`h`] gives
>>[``
\begin{aligned}
[$C1*$C2]*x^2 + [$C3*4]xh = [$C] \\ \\
[$C3*4]xh = [$C] - [$C1*$C2]*x^2 \\ \\
h = \frac{[$C] - [$C1*$C2]*x^2}{[$C3*4]x}
\end{aligned}
``]<<
Now substitute into [`V = x^2h`] to get a function just in terms of [`x`].
>>[``V(x) = x^2 \left( \frac{[$C] - [$C1+$C2]x^2}{[$C3*4]x} \right) = \frac{1}{[$C3*4]}\left( [$C]x - [$C1+$C2]x^3 \right)``]<<
The domain of this function is [`0 \le x \le \sqrt{\frac{[$C]}{[$C1+$C2]}} \approx [$domain]`] since the you want [`V(x) \ge 0`] with [`x \ge 0.`]
>>[``V'(x) = \frac{1}{[$C3*4]}\left( [$C] - [$C1*3+$C2*3]x^2\right)``]<<
END_PGML_SOLUTION
Section::End();
Section::Begin("Part 3: The Calculus Part: Maximizing the Volume",
can_open => when_previous_correct,
is_open => correct_or_first_incorrect);
BEGIN_PGML
Give your answers rounded to 3 decimal places.
Use the derivative to find the width [`x`] that maximizes the volume.
[`x`] = [_________]{$optimalLength}
What is the height of the box of maximum volume?
[`h`] = [_________]{$optimalHeight}
What is the volume of the box?
[`V`] = [_________]{$maxVolume->cmp(checker=>$maxVolumeChecker)}
END_PGML
BEGIN_PGML_HINT
While you may enter your answer to [`x`] rounded to 3 decimal places, you might need to use *more* than 3 decimal places in [`x`] when computing the value of [`h`] to have it correctly rounded to 3 decimal places. And you may need to use even more decimal places in [`x`] and [`h`] when computing the value of [`V`] correctly rounded to 3 decimal places.
END_PGML_HINT
BEGIN_PGML_SOLUTION
To maximize [`V`], take the derivative and set it equal to 0.
>>[``
\begin{aligned}
V'(x) = \frac{1}{[$C3*4]}\left( [$C] - [$C1*3+$C2*3]x^2\right) = 0 \\ \\
[$C] - [$C1*3+$C2*3]x^2 = 0 \\ \\
x^2 = \frac{[$C]}{[$C1*3+$C2*3]} \\ \\
x = \sqrt{ \frac{[$C]}{[$C1*3+$C2*3]}} \approx [$optimalLength]
\end{aligned}
``]<<
To three decimal places rounded, [`x \approx [@sprintf("%.3f", $optimalLength)@]`].
The graph shows that this is the global maximum on the domain [`0 \le x \le [$domain]`] of [`V`]. Calculus can verify this. Note that [``V'' = -\frac{[$C1*6+$C2*6]}{[$C3*4]}x \lt 0``]
and therefore the critical point is a local maximum by the second derivative test. But since [`V`] is a continuous function and there is only one critical point in the interval [`0 \le x \le [$domain]`], this must actually be the global maximum on this interval.
The optimal height is [``\ h =\frac{[$C] - [$C1+$C2]x^2}{[$C3*4]x} \approx [$optimalHeight]``] with the value of [`x`] found above. To three decimal places rounded, [`h \approx [@sprintf("%.3f", $optimalHeight)@]`].
The volume can be found using [`V = x^2h \approx [$maxVolume]`] with the optimal values of [`x`] and [`h`]. To three decimal places rounded, [`V \approx [@sprintf("%.3f", $maxVolume)@]`].
Note that to get [`h`] and [`V`] accurate to 3 decimal places, it may be necessary to use more decimal places for the intermediate calculations.
END_PGML_SOLUTION
Section::End();
Scaffold::End();
COMMENT(' Note: Uses GeoGebra which might not be executed in the Library Browser. Uses scaffolding.');
ENDDOCUMENT();