Parent Directory
|
Revision Log
Revision 144 - (view) (download)
| 1 : | jj | 144 | #DESCRIPTION |
| 2 : | # Find the area of the enclosed region | ||
| 3 : | #Endescription | ||
| 4 : | |||
| 5 : | #KEYWORDS('Graph', 'Integration', 'Area' ) | ||
| 6 : | |||
| 7 : | DOCUMENT(); # This should be the first executable line in the problem. | ||
| 8 : | |||
| 9 : | loadMacros( | ||
| 10 : | "PG.pl", | ||
| 11 : | "PGbasicmacros.pl", | ||
| 12 : | "PGchoicemacros.pl", | ||
| 13 : | "PGanswermacros.pl", | ||
| 14 : | "PGauxiliaryFunctions.pl", | ||
| 15 : | "PGgraphmacros.pl" | ||
| 16 : | ); | ||
| 17 : | |||
| 18 : | TEXT(beginproblem()); | ||
| 19 : | $showPartialCorrectAnswers = 1; | ||
| 20 : | |||
| 21 : | #here are the parameters that will be varied. | ||
| 22 : | $a = random(3,10,1); | ||
| 23 : | $b = random(2,8,1); | ||
| 24 : | $c = random(-8,-2,1); | ||
| 25 : | $d = random(.1,.95,.1); | ||
| 26 : | |||
| 27 : | #with $bound* we ensure that the graph of the function will always be in view. | ||
| 28 : | $boundx1 = $c-3; | ||
| 29 : | $boundy1 = $c-8; | ||
| 30 : | $boundx2 = $b +2; | ||
| 31 : | $boundy2 = $d*8.2**2 +$a; | ||
| 32 : | |||
| 33 : | #here we create start and stop points for the x=lines which will be drawn later. | ||
| 34 : | $line1_finish_y = $d*$c**2 +$a ; | ||
| 35 : | $line2_finish_y = $d*$b**2 +$a ; | ||
| 36 : | |||
| 37 : | @line1_start = ($c, $c); | ||
| 38 : | @line1_finish = ($c,$line1_finish_y,'black'); | ||
| 39 : | @line2_start = ($b,$b); | ||
| 40 : | @line2_finish = ($b,$line2_finish_y,'black'); | ||
| 41 : | |||
| 42 : | $boundx1a = $boundx1 -1; | ||
| 43 : | $boundx2a = $boundx2 +1; | ||
| 44 : | |||
| 45 : | #We put the functions here to keep plot_functions' entries simple | ||
| 46 : | $fun1 = FEQ("$d*x^2 ? {$a} for x in [$boundx1a,$boundx2a] using color:red and weight:2"); | ||
| 47 : | $fun2 = FEQ("x for x in [$boundx1a,$boundx2a] using color:blue and weight:2"); | ||
| 48 : | |||
| 49 : | $graph = init_graph($boundx1,$boundy1,$boundx2,$boundy2,'axes' => [0,0]); | ||
| 50 : | |||
| 51 : | ($fun1_ref,$fun2_ref) = plot_functions ($graph, | ||
| 52 : | $fun1, $fun2 | ||
| 53 : | ); | ||
| 54 : | #Here Professor Gage uses a new routine for drawing non-functions (parametrically). | ||
| 55 : | #And replaces the first line. However, this doesnt work in the system version, | ||
| 56 : | #since the PGgraphmacros.pl (?) hasn't been updated there yet). | ||
| 57 : | |||
| 58 : | $temp = new Fun (sub {$c;}, | ||
| 59 : | sub {my $x = shift; | ||
| 60 : | $c+($x)*($line1_finish_y - $c);}, | ||
| 61 : | $graph); | ||
| 62 : | $temp ->color('black'); | ||
| 63 : | $temp -> domain(0,1); | ||
| 64 : | $temp -> weight(2); | ||
| 65 : | # here I make the two vertical lines at x=$c and x=$b | ||
| 66 : | #line1 (x<0) | ||
| 67 : | #$graph->moveTo(@line1_start); | ||
| 68 : | #$graph->lineTo(@line1_finish); | ||
| 69 : | #line2 (x>0) | ||
| 70 : | $graph->moveTo(@line2_start); | ||
| 71 : | $graph->lineTo(@line2_finish); | ||
| 72 : | |||
| 73 : | #where to put the labels | ||
| 74 : | #$label_lineN = new Label ($x,$y,$string,$color,@justification) | ||
| 75 : | #$string is the the text of the label, @justification can be: right, left or center. | ||
| 76 : | |||
| 77 : | $labelx = -4 ; | ||
| 78 : | $y1 = $d*$c**2 ; | ||
| 79 : | $y2 = $d*$b**2 ; | ||
| 80 : | $label_fun1 = new Label ($labelx,&{$fun1_ref->rule}($labelx),"f(x)",'red','left','bottom'); | ||
| 81 : | $label_fun2 = new Label ($labelx,&{$fun2_ref->rule}($labelx),"g(x)",'blue','left'); | ||
| 82 : | # NOTE: $fRef->rule is a reference to the subroutine which calculates the function. It was | ||
| 83 : | # defined in the output of plot_functions. It is used here to calculate the y value of the | ||
| 84 : | # label corresponding to the function, and below to find the y values for the labels | ||
| 85 : | # corresponding to the first and second derivatives. | ||
| 86 : | |||
| 87 : | $label_line1 = new Label ($c-.1,(&{$fun1_ref->rule}($c) + &{$fun2_ref->rule}($c))/2,"x=$c",'black','right','middle'); | ||
| 88 : | $label_line2 = new Label ($b+.1,(&{$fun1_ref->rule}($b) + &{$fun2_ref->rule}($b))/2,"x=$b",'black','left','middle'); | ||
| 89 : | |||
| 90 : | #prints the labels | ||
| 91 : | $graph->lb($label_fun1,$label_fun2 ,$label_line1 ,$label_line2 ); | ||
| 92 : | |||
| 93 : | TEXT(image( insertGraph($graph), 'width' => 200, 'height' => 200) ); | ||
| 94 : | |||
| 95 : | TEXT(EV2(<<EOT)); | ||
| 96 : | $PAR | ||
| 97 : | Find the area enclosed between \( f(x) = $d x^2 ? {$a} \) and \( g(x) = x \) from \(x= $c \) to \(x= $b\). $BR | ||
| 98 : | \{ans_rule(40)\} | ||
| 99 : | |||
| 100 : | EOT | ||
| 101 : | |||
| 102 : | $answer = ($d /3)*($b**3 -$c**3) + .5*($c**2 -$b**2) + $a*($b -$c); | ||
| 103 : | ANS(num_cmp($answer)); | ||
| 104 : | |||
| 105 : | ENDDOCUMENT(); # This should be the last executable line in the problem. |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |