#Description
# Tests the ability to recognize the graphs created by
# translation and stretching transformations.
#EndDescription
DOCUMENT(); # This should be the first executable line in the problem.
loadMacros("PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGgraphmacros.pl",
"numericalmethods.pl"
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 0;
# allow the student to change the seed for this problem.
$newProblemSeed = ( defined( ${$inputs_ref}{'newProblemSeed'} ) )? ${$inputs_ref}{'newProblemSeed'} : $problemSeed;
$PG_random_generator->srand($newProblemSeed);
@questStr = (
"\( F(x+3)\) ",
"\(F(x-3) \)" ,
"\( -F(-x)\) ",
"\( F(-x) \)",
"\( 5F(x) \)",
"\( F(3x) \)" ,
"\( F(x/3) \)",
"\( F(x^2) \)",
);
# create a graph to hold a function
### A tutorial on creating graphs in WeBWorK problems
$graph = init_graph(-5,-5,5,5,'axes'=>[0,0],'grid'=>[8,8]);
# create a function to graph: cos(x)exp(x^2) -- using an anonymous subroutine
$fun_rule = sub { my $x = shift; # take the first input and put in an a local variable x
my $sqx = $x*$x;
cos($x)+.1*exp((.5*$sqx)); # calculate the output value and return it.
};
# Create a string which describes the function
$a = random(1,5,1);
# the subroutine FEQ (Format EQuation) cleans up the expression after substitution of constants occurs.
# If $a were -1 for example, then
# cos(x) + -1*exp(x) would be replaced by cos(x) -1*exp(x)
$string1 = FEQ( qq! cos($a*x) + .1*exp(x) for x in [-1,4) using color:red and weight:3!);
# Create the function from this string and store it in the graph.
my($f1 )= plot_functions($graph,
$string1);
# make sure that the browser will fetch the new picture when it is created by changing the name of the
# graph each time the problem seed is changed.
$graph->gifName($graph->gifName()."-$newProblemSeed");
# Insert the graph and the text.
BEGIN_TEXT
To see a different version of the problem change
the problem seed and press the 'Submit Answer' button below.$PAR Problem Seed:
\{ M3(
qq! Change the problem seed to change the problem:$problemSeed!,
qq! Change the problem seed to change the problem:
\begin{rawhtml}
\end{rawhtml}!,
qq! !
)
\}
$PAR
This graph was created 'on the fly'. This function was created from the expression
$PAR
$string1
$PAR
Click on the graph to see an enlarged image.
$PAR
\{ image(insertGraph($graph) ) \}
$PAR
You can view the \{ htmlLink(alias("prob3.html"),"source", q!TARGET="source"!)\} for this problem.
or consult the \{ htmlLink("/webwork_system_html/docs/techdescription/pglanguage/index.html","documentation") \} for more details on the PG language.
END_TEXT
ANS(str_cmp( @ALPHABET[ &invert(@shuffle) ] ) ) ;
ENDDOCUMENT(); # This should be the last executable line in the problem.