[rochester] / trunk / rochester_problib / setDerivatives1 / nsc2s10p3.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/rochester_problib/setDerivatives1/nsc2s10p3.pg

Mon Jun 25 19:20:51 2001 UTC (11 years, 11 months ago) by sam
File size: 2544 byte(s)
```added problem library as webwork/ww_prob_lib with revision tag prob-lib-2
```

```    1 #DESCRIPTION
2 # Identify the graphs of the function and the derivative
3 #ENDDESCRIPTION
4
5 #KEYWORDS('derivatives', 'graphs')
6
7 DOCUMENT();        # This should be the first executable line in the problem.
8
10 "PG.pl",
11 "PGbasicmacros.pl",
12 "PGchoicemacros.pl",
14 "PGauxiliaryFunctions.pl",
15 "PGgraphmacros.pl"
16 );
17
18 TEXT(&beginproblem);
20
21 \$a=random(0, 6.3, .1);
22 \$b=random(.7, .9, .1);
23
24 \$dom = 4;
25 @slice = NchooseK(3,3);
26
27 @colors = ("blue", "red", "green");
28 @sc = @colors[@slice];  #scrambled colors
29 @sa = ('A','B','C')[@slice];
30
31 # define the functions and their derivatives.
32 # FEQ (Format EQuations) cleans up the writing of the functions (see FEQ in PGbasicmacros)
33 # Otherwise we would need to worry about the signs of \$a, \$b and so forth.
34
35 \$f = FEQ("sin(\$a+\$b*cos(x)) for x in <-\$dom,\$dom> using color:\$sc[0] and weight:2");
36 \$fp = FEQ("cos(\$a+\$b*cos(x))*(-\$b)*sin(x)   for x in <-\$dom,\$dom> using color=\$sc[1] and weight:2");
37 \$fpp = FEQ("-sin(\$a+\$b*cos(x))*\$b*\$b*sin(x)*sin(x)+ cos(\$a+\$b*cos(x))*(-\$b)*cos(x) for x in <-\$dom,\$dom> using color=\$sc[2] and weight=2");
38
39 \$graph = init_graph(-4,-4,4,4,'axes'=>[0,0],'grid'=>[8,8]);
40
41 (\$fRef,\$fpRef,\$fppRef) = plot_functions( \$graph,
42                \$f,\$fp,\$fpp
43                            );
44
45         # create labels
46
47 \$label_point=-1;
48 \$label_f = new Label ( \$label_point,&{\$fRef->rule}(\$label_point),\$sa[0],"\$sc[0]",'left')        ;
49         # NOTE: \$fRef->rule is a reference to the subroutine which calculates the
50         # function.  It was defined in the output of plot_functions. It is used         here
51         # to calculate the y value of the label corresponding to the function,
52         # and below to find the y values for the labels corresponding to the
53         # first and second derivatives.
54
55 \$label_fp = new Label ( \$label_point+.5,&{\$fpRef->rule}(\$label_point+.5),\$sa[1],"\$sc[1]",'left')      ;
56 \$label_fpp = new Label ( \$label_point+1,&{\$fppRef->rule}(\$label_point+1),\$sa[2],"\$sc[2]",'left');
57
58         # insert the labels into the graph
59 \$graph->lb(\$label_f,\$label_fp,\$label_fpp);
60
61 TEXT(image(insertGraph(\$graph)));
62 TEXT(EV2(qq!
63 Identify the graphs A (blue), B( red) and C (green) as the graphs of a function and its
64 derivatives:\$PAR
65 \{ans_rule(4)\} is the graph of the function \$PAR
66 \{ans_rule(4)\} is the graph of the function's first derivative \$PAR
67 \{ans_rule(4)\} is the graph of the function's second derivative \$PAR
68 !));
69 &ANS(str_cmp( [ @sa ] ) );
70
71 ENDDOCUMENT();        # This should be the last executable line in the problem.
72
```