[npl] / trunk / NationalProblemLibrary / Rochester / setIntegrals0Theory / S05.01.AreaDistance.PTP02.pg Repository:
ViewVC logotype

Annotation of /trunk/NationalProblemLibrary/Rochester/setIntegrals0Theory/S05.01.AreaDistance.PTP02.pg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 704 - (view) (download)

1 : gage 704 #DESCRIPTION
2 :     #KEYWORDS('Integrals', 'Area and Distance')
3 :     # Interpreting Riemann sums in terms of area
4 :     #ENDDESCRIPTION
5 :    
6 :     ## DBsubject('Calculus')
7 :     ## DBchapter('Integrals')
8 :     ## DBsection('Area and Distance')
9 :     ## Date('5/10/2008')
10 :     ## Author('Paul Pearson')
11 :     ## Institution('University of Rochester')
12 :     ## TitleText1('Calculus: Early Transcendentals')
13 :     ## EditionText1('6')
14 :     ## AuthorText1('Stewart')
15 :     ## Section1('5.1')
16 :     ## Problem1('2,3,4')
17 :    
18 :     DOCUMENT();
19 :     loadMacros("PGbasicmacros.pl",
20 :     "PGchoicemacros.pl",
21 :     "PGanswermacros.pl",
22 :     "PGgraphmacros.pl",
23 :     "PGnumericalmacros.pl",
24 :     "extraAnswerEvaluators.pl"
25 :     );
26 :    
27 :     TEXT(beginproblem());
28 :    
29 :    
30 :     # Construct a graph for the left endpoint Riemann sum,
31 :     # define the function to be graphed, and add it to the graph
32 :     $graphL = init_graph(-1,-1,9,9,ticks=>[10,10],axes=>[0,0],pixels=>[400,400]);
33 :     $c = random(12,17,1); # a constant for scaling the function
34 :     $f = FEQ("$c / x for x in <-1,9> using color:blue and weight:2");
35 :     $ftex = "\frac{$c}{x}";
36 :     # the parentheses around $fRefL are necessary
37 :     ($fRefL) = plot_functions( $graphL, $f );
38 :    
39 :    
40 :     # Generate arrays of x and y values for the Riemann sum.
41 :     # There are n+1 entries in each array so that we can use
42 :     # only one pair of arrays for both the left and the right
43 :     # endpoint Riemann sums.
44 :     $a = random(2,4,1); # left endpoint of interval
45 :     $b = $a+4; # right endpoint of interval
46 :     $n = 8; # number of rectangles
47 :     $deltax = ($b - $a)/$n;
48 :     foreach $k (0..$n) { @x[$k] = $a + $k * $deltax; }
49 :     foreach $k (0..$n) { @y[$k] = &{$fRefL->rule}(@x[$k]); }
50 :    
51 :    
52 :     # Graph the left endpoint Riemann sum
53 :     $lightblue = $graphL->im->colorAllocate(148,201,255);
54 :     $darkblue = $graphL->im->colorAllocate(100,100,255);
55 :     # Create arrays of pixel references for x and y values
56 :     foreach $k (0..8) {
57 :     @xpixL[$k] = $graphL->ii(@x[$k]);
58 :     @ypixL[$k] = $graphL->jj(@y[$k]);
59 :     }
60 :     $xaxisL = $graphL->jj(0);
61 :     # Plot the rectangles in the Riemann sum
62 :     foreach $k (0..$n-1) {
63 :     $graphL->im->filledRectangle(@xpixL[$k],@ypixL[$k],@xpixL[$k+1],$xaxisL,$lightblue);
64 :     $graphL->im->rectangle(@xpixL[$k],@ypixL[$k],@xpixL[$k+1],$xaxisL,$darkblue);
65 :     }
66 :     $graphL->lb(new Label ( 8.5,0,'x','black','right','top'));
67 :     $graphL->lb(new Label ( -0.25,8.5,'y','black','right','top'));
68 :    
69 :    
70 :     # Construct a graph for the right endpoint Riemann sum
71 :     $graphR = init_graph(-1,-1,9,9,ticks=>[10,10],axes=>[0,0],pixels=>[400,400]);
72 :     # the parentheses around $fRefR are necessary
73 :     ($fRefR) = plot_functions( $graphR, $f );
74 :    
75 :    
76 :     # Graph the right endpoint Riemann sum
77 :     $lightblue = $graphR->im->colorAllocate(148,201,255);
78 :     $darkblue = $graphR->im->colorAllocate(100,100,255);
79 :     # Create arrays of pixel references for x and y values
80 :     foreach $k (0..8) {
81 :     @xpixR[$k] = $graphR->ii(@x[$k]);
82 :     @ypixR[$k] = $graphR->jj(@y[$k]);
83 :     }
84 :     $xaxisR = $graphR->jj(0);
85 :     # Plot the rectangles in the Riemann sum
86 :     foreach $k (1..$n) {
87 :     $graphR->im->filledRectangle(@xpixR[$k-1],@ypixR[$k],@xpixR[$k],$xaxisR,$lightblue);
88 :     $graphR->im->rectangle(@xpixR[$k-1],@ypixR[$k],@xpixR[$k],$xaxisR,$darkblue);
89 :     }
90 :     $graphR->lb(new Label ( 8.5,0,'x','black','right','top'));
91 :     $graphR->lb(new Label ( -0.25,8.5,'y','black','right','top'));
92 :    
93 :    
94 :    
95 :     BEGIN_TEXT
96 :    
97 :     The rectangles in the graph below illustrate a left endpoint Riemann sum for \( \displaystyle f(x) = $ftex \) on the interval \( \lbrack $a, $b \rbrack \).
98 :     $BR
99 :     The value of this left endpoint Riemann sum is \{ans_rule(30)\}
100 :     $BR
101 :     $BR
102 :    
103 :     $BCENTER
104 :     \{ begintable(1) \}
105 :     \{ row( image( insertGraph($graphL), height=>400, width=>400, tex_size=>800 ) ) \}
106 :     \{ row("Left endpoint Riemann sum for \( y = $ftex \) on \( \lbrack $a, $b \rbrack \)") \}
107 :     \{ endtable() \}
108 :     $ECENTER
109 :    
110 :     $BR
111 :     $HR
112 :     $BR
113 :    
114 :     The rectangles in the graph below illustrate a right endpoint Riemann sum for \( \displaystyle f(x) = $ftex \) on the interval \( \lbrack $a, $b \rbrack \).
115 :     $BR
116 :     The value of this right endpoint Riemann sum is \{ans_rule(30)\}
117 :     $BR
118 :     $BR
119 :    
120 :     $BCENTER
121 :     \{ begintable(1) \}
122 :     \{ row( image( insertGraph($graphR), height=>400, width=>400, tex_size=>800 ) ) \}
123 :     \{ row("Right endpoint Riemann sum for \( y = $ftex \) on \( \lbrack $a, $b \rbrack \)") \}
124 :     \{ endtable() \}
125 :     $ECENTER
126 :    
127 :     END_TEXT
128 :    
129 :     $LeftRiemannSum = 0;
130 :     foreach $k (0..$n-1) { $LeftRiemannSum = $LeftRiemannSum + @y[$k]; }
131 :     $LeftRiemannSum = $deltax * $LeftRiemannSum;
132 :     ANS(num_cmp($LeftRiemannSum));
133 :    
134 :     $RightRiemannSum = 0;
135 :     foreach $k (1..$n) { $RightRiemannSum = $RightRiemannSum + @y[$k]; }
136 :     $RightRiemannSum = $deltax * $RightRiemannSum;
137 :     ANS(num_cmp($RightRiemannSum));
138 :    
139 :    
140 :     SOLUTION(EV3(<<'END_SOLUTION'));
141 :     $BR
142 :     $HR
143 :     ${BBOLD}Solution:${EBOLD}
144 :     $BR
145 :     $BR
146 :    
147 :     (A) The left endpoint Riemann sum is
148 :     \( f(@x[0]) \cdot 0.5 + f(@x[1]) \cdot 0.5 + \cdots + f(@x[$n-1]) \cdot 0.5
149 :     = ( @y[0] + @y[1] + \cdots + @y[7] ) \cdot 0.5 = $LeftRiemannSum.\)
150 :     $BR
151 :     $BR
152 :    
153 :     (B) The right endpoint Riemann sum is
154 :     \( f(@x[1]) \cdot 0.5 + f(@x[2]) \cdot 0.5 + \cdots + f(@x[$n]) \cdot 0.5
155 :     = ( @y[1] + @y[2] + \cdots + @y[$n] ) \cdot 0.5 = $RightRiemannSum.\)
156 :    
157 :     END_SOLUTION
158 :    
159 :    
160 :     ENDDOCUMENT();

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9