Problem12

From WeBWorK_wiki
Revision as of 13:19, 16 June 2021 by Berndsing (talk | contribs) (added tag)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Prep Main Page > Web Conference 2 > Sample Problems > Problem 12

This is Library/Michigan/Chap2Sec1/Q11.pg

DOCUMENT();
loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl",
"PGgraphmacros.pl",
"MathObjects.pl",
"hhAdditionalMacros.pl",
);

Context("Numeric");

TEXT(beginproblem());
$showPartialCorrectAnswers = 0;

## make this have a known seed, so that it's consistent with
##    problem 13
SRAND($psvn);

@gr = ();
for (my $i=0; $i<8; $i++) { 
    $gr[$i] = init_graph(0,0,1,1.2,axes=>[0,0],size=>[100,100]);
    $gr[$i]->lb('reset');
}
add_functions($gr[0], "x for x in <0,1> using color:black and weight:2");
add_functions($gr[1], "0.75 for x in <0,1> using color:black and weight:2");
add_functions($gr[2], "1-x for x in <0,1> using color:black and weight:2");
add_functions($gr[3], "x^2 for x in <0,1> using color:black and weight:2");
add_functions($gr[4], "1-x^2 for x in <0,1> using color:black and weight:2");
add_functions($gr[5], "1-(x-1)^2 for x in <0,1> " .
                      "using color:black and weight:2");
add_functions($gr[6], "(x-1)^2 for x in <0,1> using color:black and weight:2");
add_functions($gr[7], "1-4*(x-.5)^2 for x in <0,1> " .
                      "using color:black and weight:2");

@grdesc = ( "a graph of a line with positive slope through the origin",
	    "a graph of a horizontal line with positive y-intercept",
	    "a graph of a line with negative slope and positive y-intercept",
	    "a graph of a curve with a positive increasing slope starting " .
	        "at the origin",
	    "a graph of a curve with negative, decreasing slope starting " .
	        "on the positive y-axis",
	    "a graph of a curve with positive, decreasing slope starting " .
	        "at the origin",
	    "a graph of a curve with negative, increasing(ly less negative) " .
	        "slope",
	    "a graph of a concave down curve that starts at the origin, " .
	        "increases and then decreases" );

# get a permutation of these images to put into the problem
($mapref, $zeroindex) = shufflemap(8);
# and build a table of them all
@figs = ();
for ( my $i=0; $i<8; $i++ ) {
    push( @figs, ($i+1) . '.' );
    push( @figs, image(insertGraph($gr[$mapref->{$i}]),tex_size=>150,
		       height=>100,width=>100,extra_html_tags=>'alt="' .
		       $grdesc[$mapref->{$i}] . '"') );
}
$figtable = begintable(8) . row( @figs[0..7] ) . row( @figs[8..15] ) .
    endtable();

$whichprob = random(0,2,1);
if ( $whichprob == 0 ) {
    $ptext = "at a constant speed";
    $ans = $zeroindex + 1;
    $stext =<<eos;
Because the car is driven at a constant speed, the change in the 
distance traveled is the same for different time intervals of the 
same length.  Thus the graph of the distance traveled must have 
a constant positive slope, and must be graph $ans.
eos
} elsif ( $whichprob == 1 ) {
    $ptext = "at an increasing speed";
    foreach $j ( keys %$mapref ) {
        if ( $mapref->{$j} == 3 ) {
            $ans = $j+1;
            last;
        }
    }
    $stext =<<eos;
Because the car is driven at an increasing speed, the distance 
traveled for different time intervals of the same length must 
increase as time goes on.  Therefore the slope of the graph 
of distance traveled must increase with increasing time, and 
must be $ans.
eos
} else {
    $ptext = "at a speed that is initially high and then decreases";
    foreach $j ( keys %$mapref ) {
        if ( $mapref->{$j} == 5 ) {
            $ans = $j+1;
            last;
        }
    }
    $stext =<<eos;
Because the car is driven at a decreasing speed, the distance 
traveled for different time intervals of the same length must 
decrease as time goes on.  Therefore the slope of the graph 
of distance traveled must decrease with increasing time, and 
must be $ans.
eos
}

Context()->texStrings;
BEGIN_TEXT

A car is driven $ptext, starting at noon.  Which of the following
could be a graph of the distance the car has traveled as a function
of time past noon?
$PAR
$BCENTER
$figtable
$ECENTER

$PAR
figure \{ ans_rule(5) \}.

END_TEXT
Context()->normalStrings;

ANS(Compute($ans)->cmp() );

Context()->texStrings;
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR SOLUTION $PAR
$stext
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version');
ENDDOCUMENT();