Problem3

From WeBWorK_wiki
Jump to navigation Jump to search

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

# DESCRIPTION
# Sample problem for WeBWorK PREP workshop
# Model problem:
# Determine if the function f(x) = sin(x^3)/x is positive,
# negative, or zero, and increasing, decreasing, or neither
# at x=2.
# WeBWorK problem written by Gavin LaRose, <glarose@umich.edu>
# ENDDESCRIPTION

DOCUMENT();

loadMacros(
"PGstandard.pl",
"parserPopUp.pl",
"MathObjects.pl",
);

############################################################
# problem set-up
Context("Numeric");
$showPartialCorrectAnswers = 1;

# randomize
$r = random(2,5,1);
$p = random(1,5,1);

# the function
$f = Compute("sin(x^$r)/x");

# the answers
$fd = $f->D();
$fp = $f->eval(x=>$p);
if ( $fp > 0 ) {
    $ans1 = 'positive';
} elsif ( $fp < 0 ) {
    $ans1 = 'negative';
} else {
    $ans1 = 'zero';
}
$sign = PopUp( [ '?', 'positive', 'negative', 'zero' ], $ans1 );

$fdp = $fd->eval(x=>$p);
if ( $fdp > 0 ) {
    $dsgn = 'is positive';
    $ans2 = 'increasing';
} elsif ( $fdp < 0 ) {
    $dsgn = 'is negative';
    $ans2 = 'decreasing';
} else {
    $dsgn = 'is zero';
    $ans2 = 'neither increasing nor decreasing';
}

$deriv = PopUp( [ '?', 'increasing', 'decreasing',
		   'neither increasing nor decreasing' ], $ans2 );

############################################################
# text

TEXT(beginproblem());
Context()->texStrings;
BEGIN_TEXT

Determine the sign and behavior of the function \(f(x) = $f\)
at the point \(x = $p\).
$BR
At \(x = $p\), the function is \{ $sign->menu() \} and
\{ $deriv->menu() \}.

END_TEXT
Context()->normalStrings;

############################################################
# answer and solution

ANS( $sign->cmp() );
ANS( $deriv->cmp() );

Context()->texStrings;
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR SOLUTION $PAR
At the point \(x = $p\), the function \(f(x) = $f\) has the
value \(f($p) = $fp\), which is \{ $sign->correct_ans() \}.
The derivative of \(f\) is \(f'(x) = $fd\), so that
\(f'($p) = $fdp\) $dsign, and \(f\) is \{ $deriv->correct_ans() \}.

END_SOLUTION
Context()->normalStrings;

ENDDOCUMENT();

# end of problem
############################################################