-
-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathbeth2algfunb.pg
More file actions
128 lines (99 loc) · 3.44 KB
/
Copy pathbeth2algfunb.pg
File metadata and controls
128 lines (99 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
## DESCRIPTION
## Algebra and Number Theory: Algebra
## ENDDESCRIPTION
## Tagged by YJ
## DBsubject(Algebra)
## DBchapter(Functions)
## DBsection(Compositions and combinations of functions)
## Date(5/26/2005)
## Institution(UVA)
## Author(Jeff Holt)
## MLT(cc-graphs-evaluate)
## Level(2)
## TitleText1('Calculus: Early Transcendentals')
## AuthorText1('Stewart')
## EditionText1('5')
## Section1('3.1')
## Problem1('')
## TitleText2('Calculus: Early Transcendentals')
## AuthorText2('Stewart')
## EditionText2('6')
## Section2('3.1')
## Problem2('')
## KEYWORDS('algebra', 'number', 'theory')
DOCUMENT(); # This should be the first executable line in the problem.
loadMacros(
"PGstandard.pl",
"PGchoicemacros.pl",
"PGgraphmacros.pl",
"PGcourse.pl"
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$a = random(-1,1);
$b = random(-1,1);
$graph = init_graph(-4,-4,8,8, 'axes'=>[0,0],'grid'=>[12,12]);
$g1 = "-x+$a for x in <-4,-1> using color:blue and weight:2";
$g2 = "1+$a for x in <-1,1> using color:blue and weight:2";
$g3 = "4*x-3+$a for x in <1,2> using color:blue and weight:2";
$g4 = "-x+7+$a for x in <2,8> using color:blue and weight:2";
$f1 = "x/3+$b for x in <-4,0> using color:red and weight:2";
$f2 = "-x+$b for x in <0,2> using color:red and weight:2";
$f3 = "2*x-6+$b for x in <2,6> using color:red and weight:2";
$f4 = "6+$b for x in <6,8> using color:red and weight:2";
plot_functions($graph, $g1, $g2, $g3, $g4, $f1, $f2, $f3, $f4);
$l1 = new Label(3, -2+$b, "f(x)",'black','right');
$l2 = new Label(3, 5.4+$a, "g(x)",'black','right');
$graph->lb($l1,$l2);
BEGIN_TEXT
The functions \(f(x)\) and \(g(x)\) are given in the graph below (\(f(x)\) in red
and \(g(x)\) in blue).
$BR
$BCENTER
\{ image(insertGraph($graph),
alt=>"Graph showing two piecewise linear functions: f(x) in red and g(x) in blue, plotted on coordinate axes from approximately x = -4 to x = 8."
) \}
$BR
$BBOLD Note: $EBOLD Click on the graph to view a larger graph
$ECENTER
$BR$BR
Find the corresponding function values.
$BR
END_TEXT
@ans=(2+$a+$b, 1+$a+$b, $a+$b, 3+$a+$b, 4+$a+$b, 5+$a+$b, 6+$a+$b);
#This will produce the addition of functions question
$quest1 = '\( (f+g)(-3) \)';
$quest2 = '\( (f+g)(0) \)';
$quest3 = '\( (f+g)(1) \)';
$quest4 = '\( (f+g)(2) \)';
$quest5 = '\( (f+g)(3) \)';
$quest6 = '\( (f+g)(4) \)';
$quest7 = '\( (f+g)(5) \)';
@questions =( $quest1,$quest2,$quest3,$quest4,$quest5,$quest6,$quest7);
## Now choose randomly 1 questions out of the 6 questions strings above.
@slice = NchooseK(scalar(@questions),1);
## Next we output the chosen questions.
BEGIN_TEXT
$questions[$slice[0]] = \{ ans_rule(10)\}$BR
END_TEXT
#Answer to the first question
ANS(num_cmp($ans[$slice[0]]));
#This will produce the subtraction of functions question
@ans=(-4+$b-$a, -1+$b-$a, -2+$b-$a, -7+$b-$a, -4+$b-$a, -1+$b-$a, 2+$b-$a);
$quest11 = '\( (f-g)(-3) \)';
$quest12 = '\( (f-g)(0) \)';
$quest13 = '\( (f-g)(1) \)';
$quest14 = '\( (f-g)(2) \)';
$quest15 = '\( (f-g)(3) \)';
$quest16 = '\( (f-g)(4) \)';
$quest17 = '\( (f-g)(5) \)';
@questions1 =( $quest11,$quest12,$quest13,$quest14,$quest15,$quest16,$quest17);
## Now choose randomly 1 questions out of the 6 questions strings above.
@slice1 = NchooseK(scalar(@questions1),1);
## Next we output the chosen question.
BEGIN_TEXT
$questions1[$slice1[0]] = \{ ans_rule(10)\}
END_TEXT
#Answer to the first question
ANS(num_cmp($ans[$slice1[0]]));
ENDDOCUMENT(); # This should be the last executable line in the problem.