Skip to content

Commit 48e5bf6

Browse files
authored
Merge branch 'openwebwork:main' into master
2 parents 885eed2 + b28e69f commit 48e5bf6

File tree

2,287 files changed

+138473
-77973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,287 files changed

+138473
-77973
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ pm_to_blib
1616
*.swp
1717
.ai
1818
.svg
19+
.bak
1920
setDefs/
2021

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
##DESCRIPTION
2+
## Volume of revolution of parabolic region around x-axis
3+
## Student must setup the integral, entering limits and integrand,
4+
## then give the numerical value.
5+
## Limits weighted 20%, integrand and answer weighted 50/30.
6+
## These percentages can be adjusted if desired.
7+
##ENDDESCRIPTION
8+
9+
## DBsubject(Calculus - single variable)
10+
## DBchapter(Applications of integration)
11+
## DBsection(Volumes by disks)
12+
## Institution(Agnes Scott College)
13+
## Author(Larry Riddle)
14+
## Answer boxes for limits of integration Coding in PG - Nathan Wallach (CSS based formatting work and more)
15+
## Answer boxes for limits of integration Coding in PGML - Glenn Rice
16+
## https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4767#p14157
17+
## Level(2)
18+
## MO(1)
19+
## TitleText1('APEX Calculus')
20+
## AuthorText1('Hartman')
21+
## EditionText1('4.0')
22+
## Section1('7.2')
23+
## Problem1('4')
24+
25+
DOCUMENT();
26+
27+
loadMacros(
28+
"PGstandard.pl",
29+
"MathObjects.pl",
30+
"PGML.pl",
31+
"PGgraphmacros.pl",
32+
"weightedGrader.pl",
33+
"contextFraction.pl",
34+
"answerHints.pl",
35+
"PGcourse.pl"
36+
);
37+
38+
install_weighted_grader();
39+
40+
TEXT(beginproblem());
41+
42+
$showPartialCorrectAnswers = 1;
43+
$refreshCachedImages=1;
44+
45+
Context("Numeric")->flags->set(
46+
formatStudentAnswer => parsed,
47+
reduceConstantFunctions => 0,);
48+
49+
$a = random(4,16);
50+
$xlow = ($a==4 or $a==9 or $a==16) ? Real(-sqrt($a)) : Formula("-sqrt($a)");
51+
$xhigh = ($a==4 or $a==9 or $a==16) ? Real(sqrt($a)) : Formula("sqrt($a)");
52+
$s = sqrt($a);
53+
$f = Formula("$a-x^2");
54+
$integrand = Formula("pi*($a-x^2)^2");
55+
$ans = Compute("16/15*pi*$a^(5/2)");
56+
$rans = Real("16/15*pi*$a^(5/2)");
57+
58+
$xmin = floor(-sqrt($a))-1;
59+
$xmax = ceil(sqrt($a))+1;
60+
$ymin = -1;
61+
$ymax = $a+1;
62+
63+
64+
$gr = init_graph($xmin,$ymin,$xmax,$ymax,axes=>[0,0], ticks=>[$xmax-$xmin,$ymax-$ymin], size=>[400,400]);
65+
$gr->lb('reset');
66+
$gr->new_color("lightblue", 214,230,244); # RGB
67+
$gr->new_color("darkblue", 100,100,255);
68+
add_functions($gr, "$f for x in [-$s,$s] using color:darkblue and weight:2");
69+
$gr->moveTo($xmin,0);
70+
$gr->lineTo($xmax,0,"darkblue",1);
71+
$gr->fillRegion([0.5,0.5,"lightblue"]);
72+
73+
$i = 0; # Number the axes
74+
do {
75+
$xtick = $i;
76+
$labelx1 = new Label($xtick,-0.2, "$xtick",'black','center');
77+
$labelx2 = new Label(-$xtick,-0.2, "-$xtick",'black','center');
78+
if ($xtick!=0) {
79+
$gr->lb($labelx1);
80+
$gr->lb($labelx2);
81+
}
82+
$i =$i+1;
83+
} while ($i<($xmax-$xmin)-1);
84+
85+
$i = 0;
86+
do {
87+
$ytick = $i;
88+
$labely = new Label(-0.2,$ytick, "$ytick",'black', 'right','middle');
89+
if ($ytick!=0) {$gr->lb($labely);}
90+
$i =$i+1;
91+
} while ($i<($ymax-$ymin)-1);
92+
93+
# Code to format the answer boxes for integration limits
94+
TEXT( MODES(
95+
HTML=>"
96+
<style>
97+
.lowerIntegrationBoundOfPair input[type=text].codeshard {
98+
padding:1px;
99+
font-size:11pt;
100+
height:20px !important;
101+
}
102+
.upperIntegrationBoundOfPair input[type=text].codeshard {
103+
padding:1px;
104+
font-size:11pt;
105+
height:20px !important;
106+
}
107+
.divOnLineWithIntegrationLimits {
108+
display:inline-block;
109+
padding-top: 15px;
110+
position: relative;
111+
left: 0px;
112+
}
113+
.divIntegrand {
114+
display:inline-block;
115+
position: relative;
116+
left: -8px;
117+
}
118+
.gridForPairOfIntegrationBounds {
119+
display:inline-grid;
120+
position: relative;
121+
top: -17px;
122+
left: -6px;
123+
grid-gap: 6px;
124+
text-align: left;
125+
}
126+
.lowerIntegrationBoundOfPair {
127+
grid-column: 1; grid-row: 2;
128+
}
129+
.upperIntegrationBoundOfPair {
130+
grid-column: 1; grid-row: 1;
131+
padding-left: 10px;
132+
}
133+
</style>",
134+
TeX=>""
135+
));
136+
137+
# ===============================================================
138+
139+
# Display the answer blanks properly in different modes
140+
141+
Context()->texStrings;
142+
if ($displayMode eq 'TeX') {
143+
$integral1 = join("", (
144+
'\( \displaystyle \text{Volume = } \int_{ ',
145+
$xlow->ans_rule(5),
146+
' }^{ ',
147+
$xhigh->ans_rule(5),
148+
'}\)', $xhigh->ans_rule(30), '\(\, dx \)' ));
149+
} else {
150+
$integral1 = join("", (
151+
openDiv( { "class" => "divOnLineWithIntegrationLimits" } ),
152+
'\( \displaystyle \quad\quad \text{Volume = } \int \)',
153+
closeDiv(),
154+
155+
openDiv( { "class" => "gridForPairOfIntegrationBounds" } ),
156+
openDiv( { "class" => "lowerIntegrationBoundOfPair" } ),
157+
$xlow->ans_rule(8),
158+
closeDiv(),
159+
openDiv( { "class" => "upperIntegrationBoundOfPair" } ),
160+
$xhigh->ans_rule(8),
161+
closeDiv(),
162+
closeDiv(),
163+
164+
openDiv( { "class" => "divIntegrand" } ),
165+
$integrand->ans_rule(15),
166+
'\( \, dx \)',
167+
closeDiv(),
168+
) );
169+
}
170+
Context()->normalStrings;
171+
172+
173+
BEGIN_PGML
174+
175+
>>[@ image(insertGraph($gr),width=>300, height=>300, tex_size=>400) @]*<<
176+
>>[`\quad`]Graph of [`y = [$a] - x^2`]<<
177+
178+
a) A region of the Cartesian plane is shaded, as shown in the figure above. Use the Disk/Washer Method to set up an integral that gives the volume of the solid of revolution formed by revolving the region around the [`x`]-axis.
179+
[`\;`]
180+
[@ openDiv() . $integral1 . closeDiv() @]*
181+
182+
b) Compute the volume of the solid. [_______________]
183+
184+
END_PGML
185+
186+
187+
WEIGHTED_ANS( $xlow->cmp,10 );
188+
WEIGHTED_ANS( $xhigh->cmp ,10);
189+
WEIGHTED_ANS( $integrand->cmp->withPostFilter(AnswerHints(
190+
Formula("$f") => "This looks like you are finding the area of the region, not the volume of the solid of revolution.",
191+
[Formula("pi*$f"),Formula("($f)^2")] => "This is almost correct. What is the formula for the area of a circle?",
192+
)),50 );
193+
WEIGHTED_ANS( $rans->cmp,30 );
194+
195+
Context("Fraction")->flags->set(reduceConstantFunctions => 0,);
196+
$a2 = $a*$a;
197+
$a3 = Fraction(2*$a,3);
198+
$c1 = Fraction(1,5);
199+
$c2 = Fraction(8,15);
200+
$c3 = Fraction(16,15);
201+
if ($a==4 or $a==9 or $a==16) {
202+
$w1 = $c2*sqrt($a)**5;
203+
$w2 = $c3*sqrt($a)**5;
204+
$c2 = "";
205+
$c3 = "";
206+
} else {
207+
$w1 = "($a)^{5/2}";
208+
$w2 = "($a)^{5/2}";
209+
}
210+
211+
212+
213+
BEGIN_PGML_SOLUTION
214+
215+
The curve [`y = [$f]`] intersects the [`x`]-axis where [`[$f]=0`], so at [`x = [$xlow]`] and [`x = [$xhigh]`]. A slice of the region rotated around the [`x`]-axis forms a disk of radius [`R(x) = [$f]`]. The cross-sectional area of the slice is [`\pi R(x)^2 = \pi([$f])^2`]. The volume is therefore given by the integral
216+
217+
[``\int_{[$xlow]}^{[$xhigh]}\pi R(x)^2\;dx = \int_{[$xlow]}^{[$xhigh]}\pi([$f])^2\;dx \approx [$ans]``]
218+
219+
Here is the calculation with the antidifferentiation carried out.
220+
221+
[``\begin{aligned}
222+
\int_{[$xlow]}^{[$xhigh]}\pi([$f])^2\;dx &= \pi \int_{[$xlow]}^{[$xhigh]} \left([$a2]-[$a*2]x^2 + x^4\right)\;dx \\ \\
223+
&= \pi \left([$a2]x - [$a3]x^3 + [$c1]x^5\right)\bigg|_{[$xlow]}^{[$xhigh]} \\ \\
224+
&= \pi \left([$c2][$w1] - (-[$c2][$w1]\right) = [$c3][$w2]\pi
225+
\end{aligned}
226+
``]
227+
228+
END_PGML_SOLUTION
229+
230+
COMMENT('Randomization provides 13 different possible versions of this question.');
231+
232+
ENDDOCUMENT();

0 commit comments

Comments
 (0)