Problem10

From WeBWorK_wiki
Jump to navigation Jump to search

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

This is Library/Rochester/setDerivatives10_5Optim/S04.07.Optimization.PTP09b.pg

DOCUMENT();

loadMacros(
#"PGbasicmacros.pl",
#"PGchoicemacros.pl",
#"PGanswermacros.pl",
#"PGauxiliaryFunctions.pl",
#"extraAnswerEvaluators.pl",
"PGstandard.pl",
"MathObjects.pl",
"parserNumberWithUnits.pl",
"parserFormulaWithUnits.pl",
);

TEXT(beginproblem());

Context("Numeric");

$a = random(2,5,1);
$b = random(6,12,1);
$row = random(2,4,1);
$walk = $row + 1;

$cp = ($row*$a)/(($walk**2 - $row**2)**(0.5));

$function = FormulaWithUnits("(sqrt($a**2 + x**2))/$row + ($b - x)/$walk","hr");
$critical = NumberWithUnits("($row*$a)/(($walk^2 - $row^2)^(0.5))","mi");
$leasttravel = NumberWithUnits("(($a^2 + $cp^2)**(0.5))/$row + ($b - $cp)/$walk","hr");

Context()->texStrings;
BEGIN_TEXT
A small island is $a miles from the nearest point P on the straight
shoreline of a large lake.  If a woman on the island can row a boat
$row miles per hour and can walk $walk miles per hour, where should
the boat be landed in order to arrive at a town $b miles down the
shore from P in the least time?  Let \( x \) be the distance (in miles) between
point P and where the boat lands on the lakeshore.
$BR
$BR
(a) Enter a function \( T(x) \) that describes the total amount of
time the trip takes as a function of the distance \( x \).
$BR
\( T(x) = \) \{ans_rule(30)\}
(include \{ helpLink('units') \})
$BR
$BR
(b) What is the distance \( x = c \) that minimizes the travel time?
$BR 
\( c = \) \{ans_rule(25)\} 
(include \{ helpLink('units') \})
$BR
$BR 
(c) What is the least travel time?  
$BR
The least travel time is \{ans_rule(25)\}
(include \{ helpLink('units') \})
END_TEXT
Context()->normalStrings;
HINT(EV2(<<END_HINT));
When velocity is constant, time is distance divided by velocity.
END_HINT

$showPartialCorrectAnswers = 1;

ANS( $function->cmp(limits=>[0,$b]) );
ANS( $critical->cmp() );
ANS( $leasttravel->cmp() );

#ANS(fun_cmp($function,var=>'x',limits=>[0,$b]));
#ANS(num_cmp("$critical", units => 'mi'));
#ANS(num_cmp("$leasttravel", units => 'hr'));

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