[rochester] / trunk / rochester_problib / setSampleGraphs / prob8.html Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/rochester_problib/setSampleGraphs/prob8.html

Mon May 16 02:27:31 2005 UTC (8 years ago) by gage
File size: 3031 byte(s)
```Cleaned up &beginproblem  and &ANS old style function reference.
```

```    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
4   <TITLE>Source for problem 6</TITLE>
5   <META NAME="generator" CONTENT="BBEdit 5.0">
7 <BODY BGCOLOR="#FFFFFF">
8 <PRE>
9
10 #Description
11 #KEYWORDS('derivatives', 'graphs')
12 # Identify the graphs of the function and the derivative
13 #EndDescription
14
15 &DOCUMENT;
16
17
19            "PGbasicmacros.pl",
20            "PGchoicemacros.pl",
22            "PGgraphmacros.pl");
23
24 \$a=random(0, 6.3, .1);
25 \$b=random(1.1, 1.5, .1);
26
27 \$dom = 4;
28 @slice = NchooseK(3,3);
29
30 @colors = ("blue", "red", "green");
31 @sc = @colors[@slice];  #scrambled colors
32 @sa = ('A','B','C')[@slice];
33
34 # define the functions and their derivatives.
35 # FEQ (Format EQuations) cleans up the writing of the functions (see FEQ in PGbasicmacros)
36 # Otherwise we would need to worry about the signs of \$a, \$b and so forth.
37
38 \$f = FEQ("sin(\$a+\$b*cos(x)) for x in <-\$dom,\$dom> using color:\$sc[0] and weight:2");
39 \$fp = FEQ("cos(\$a+\$b*cos(x))*(-\$b)*sin(x)   for x in <-\$dom,\$dom> using color=\$sc[1] and weight:2");
40 \$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");
41
42 \$graph = init_graph(-4,-4,4,4,'axes'=>[0,0],'grid'=>[8,8]);
43
44 (\$fRef,\$fpRef,\$fppRef) = plot_functions( \$graph,
45                \$f,\$fp,\$fpp
46                            );
47
48         # create labels
49
50 \$label_point=-0.75;
51 \$label_f = new Label ( \$label_point,&{\$fRef->rule}(\$label_point),\$sa[0],"\$sc[0]",'left')        ;
52         # NOTE: \$fRef->rule is a reference to the subroutine which calculates the
53         # function.  It was defined in the output of plot_functions. It is used         here
54         # to calculate the y value of the label corresponding to the function,
55         # and below to find the y values for the labels corresponding to the
56         # first and second derivatives.
57
58 \$label_fp = new Label ( \$label_point,&{\$fpRef->rule}(\$label_point),\$sa[1],"\$sc[1]",'left')      ;
59 \$label_fpp = new Label ( \$label_point,&{\$fppRef->rule}(\$label_point),\$sa[2],"\$sc[2]",'left');
60
61         # insert the labels into the graph
62 \$graph->lb(\$label_f,\$label_fp,\$label_fpp);
63
65 TEXT(beginproblem());
66 TEXT(image(insertGraph(\$graph)));
67 TEXT(EV2(qq!
68 Identify the graphs A (blue), B( red) and C (green) as the graphs of a function and its
69 derivatives (click on the graph to see an enlarged image):\$PAR
70 \{ans_rule(4)\} is the graph of the function \$PAR
71 \{ans_rule(4)\} is the graph of the function's first derivative \$PAR
72 \{ans_rule(4)\} is the graph of the function's second derivative \$PAR
73 !));
74 ANS(str_cmp( [@sa] ) );
75
76 BEGIN_TEXT
77 \$PAR
78 You can view the \{ htmlLink(alias("prob8.html"),"source", q!TARGET="source"!)\} for this problem.
79 or consult the \{ htmlLink("/webwork_system_html/docs/techdescription/pglanguage/index.html","documentation") \}  for  more details on the PG language.
80 END_TEXT
81
82 &ENDDOCUMENT;
83
84
85
86 </PRE>
87 </BODY>
88 </HTML>
```