## DESCRIPTION ## Multivariable integral calculus: setting up double integrals ## ENDDESCRIPTION ## DBsubject(WeBWorK) ## DBchapter(WeBWorK tutorial) ## DBsection(PGML tutorial 2015) ## Date(06/01/2015) ## Institution(Hope College) ## Author(Paul Pearson) ## MO(1) ## KEYWORDS('Integrals', 'setting up double integrals') ################################## # Initialization DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserMultiAnswer.pl", "PGML.pl", "PGcourse.pl" ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; ################################### # Setup Context("Numeric"); Context()->variables->are( x=>"Real",dx=>"Real", y=>"Real",dy=>"Real"); Context()->flags->set(reduceConstants=>0); # # limits of integration #$a = random(1,5,1); $b =$a + random(1,4,1); do { $c = random(1,5,1); } until ($c != $a); do {$d = $c + random(1,4,1); } until ($d != $b); # # integrand and volume #$f = Formula("x*y"); $V = Formula("($b^2-$a^2) * ($d^2-$c^2) / 4"); # # differentials and limits of integration # # Case 0, element 0 of each array below, is # if the order of integration is dx dy # # Case 1, element 1 of each array below, is # if the order of integration is dy dx # # "id" and "od" stand for inner and outer differential # @id = (Formula("dx"),Formula("dy")); # (case 0, case 1) @od = (Formula("dy"),Formula("dx")); # (case 0, case 1) # # A = outer integral, lower limit # B = outer integral, upper limit # C = inner integral, lower limit # D = inner integral, upper limit # @A = (Formula("$c"),Formula("$a")); # (case 0, case 1) @B = (Formula("$d"),Formula("$b")); # (case 0, case 1) @C = (Formula("$a"),Formula("$c")); # (case 0, case 1) @D = (Formula("$b"),Formula("$d")); # (case 0, case 1)$multians = MultiAnswer( $f,$id[0], $od[0],$A[0], $B[0],$C[0], $D[0] )->with( singleResult => 1, checker => sub { my ($correct, $student,$self ) = @_; my ( $fstu,$idstu, $odstu,$Astu, $Bstu,$Cstu, $Dstu ) = @{$student}; if ( ( $f ==$fstu && $id[0] ==$idstu && $od[0] ==$odstu && $A[0] ==$Astu && $B[0] ==$Bstu && $C[0] ==$Cstu && $D[0] ==$Dstu ) || ( $f ==$fstu && $id[1] ==$idstu && $od[1] ==$odstu && $A[1] ==$Astu && $B[1] ==$Bstu && $C[1] ==$Cstu && $D[1] ==$Dstu ) ) { return 1; } elsif ( ( $f ==$fstu && $id[0] ==$idstu && $od[0] ==$odstu && ($A[0] !=$Astu || $B[0] !=$Bstu) && $C[0] ==$Cstu && $D[0] ==$Dstu ) || ( $f ==$fstu && $id[1] ==$idstu && $od[1] ==$odstu && ($A[1] !=$Astu || $B[1] !=$Bstu) && $C[1] ==$Cstu && $D[1] ==$Dstu ) || ( $f ==$fstu && $id[0] ==$idstu && $od[0] ==$odstu && $A[0] ==$Astu && $B[0] ==$Bstu && ($C[0] !=$Cstu || $D[0] !=$Dstu) ) || ( $f ==$fstu && $id[1] ==$idstu && $od[1] ==$odstu && $A[1] ==$Astu && $B[1] ==$Bstu && ($C[1] !=$Cstu || $D[1] !=$Dstu) ) ) { $self->setMessage(1,"Check your limits of integration."); return 0.94; } elsif ( ($f == $fstu &&$id[0] == $idstu &&$od[0] == $odstu && ($A[0] != $Astu ||$B[0] != $Bstu) && ($C[0] != $Cstu ||$D[0] != $Dstu) ) || ($f == $fstu &&$id[1] == $idstu &&$od[1] == $odstu && ($A[1] != $Astu ||$B[1] != $Bstu) && ($C[1] != $Cstu ||$D[1] != $Dstu) ) ) {$self->setMessage(1, "Check your limits of integration and order of integration."); return 0.47; } else { return 0; } } ); ##################################### # Main text BEGIN_PGML Set up a double integral in rectangular coordinates for calculating the volume of the solid under the graph of the function [ f(x,y) = [$f] ] over the region [ [$a] \leq x \leq [$b] ] and [ [$c] \leq y \leq [$d] ]. _Instructions:_ Please enter the integrand in the first answer box. Depending on the order of integration you choose, enter _dx_ and _dy_ in either order into the second and third answer boxes with only one _dx_ or _dy_ in each box. Then, enter the limits of integration and evaluate the integral to find the volume. [ \int_A^B \int_C^D ] [___________]{$multians} [_____]{$multians} [_____]{$multians} A = [_____________]{$multians} B = [_____________]{$multians} C = [_____________]{$multians} D = [_____________]{$multians} Volume = [___________________________]{\$V} END_PGML #################################### # Solution BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION COMMENT('Allows integration in either order. Uses PGML.'); ENDDOCUMENT();