Skip to content

Commit 928f891

Browse files
authored
Merge pull request #1227 from d-torrance/function-arithmetic
Convert function arithmetic problem to MathObjects
2 parents c56c8a5 + 99cab77 commit 928f891

File tree

1 file changed

+38
-51
lines changed
  • OpenProblemLibrary/ASU-topics/setAlgebraFunctions

1 file changed

+38
-51
lines changed

OpenProblemLibrary/ASU-topics/setAlgebraFunctions/srw2_8_1.pg

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,60 +16,47 @@ DOCUMENT(); # This should be the first executable line in the problem.
1616

1717
loadMacros(
1818
"PGstandard.pl",
19-
"PGchoicemacros.pl",
20-
"PGcourse.pl"
19+
"MathObjects.pl",
20+
"PGcourse.pl",
2121
);
2222

23-
TEXT(beginproblem());
24-
$showPartialCorrectAnswers = 1;
25-
2623
$a = random(2,15,1);
2724
$b = random(1,15,1);
2825

29-
TEXT(EV2(<<EOT));
30-
$BBOLD Note: $EBOLD For this question, input $BITALIC infinity $EITALIC
31-
for \( \infty \)
32-
and input $BITALIC -infinity $EITALIC for \( -\infty \).
33-
$BR
34-
$BR
35-
Given that \(f(x)=x^2-$a x\) and \(g(x)=x + $b\), find
36-
$BR
37-
(a) \(f+g\)= \{ans_rule(25)\} and its domain is
38-
(\{ans_rule(10)\}, \{ans_rule(10)\})
39-
$BR
40-
(b) \(f-g\)= \{ans_rule(25)\} and its domain is
41-
(\{ans_rule(10)\}, \{ans_rule(10)\})
42-
$BR
43-
(c) \(fg\)= \{ans_rule(25)\} and its domain is
44-
(\{ans_rule(10)\}, \{ans_rule(10)\})
45-
$BR
46-
(d) \(f/g\)= \{ans_rule(25)\} and its domain is
47-
\(x\not=\)\{ans_rule(10)\}
48-
$BR
49-
EOT
50-
51-
$ans1 = "x**2-($a-1)*x+$b";
52-
$ans2 = "-infinity";
53-
$ans3 = "infinity";
54-
$ans4 = "x**2-($a+1)*x-$b";
55-
$ans5 = "-infinity";
56-
$ans6 = "infinity";
57-
$ans7 = "(x**2-$a*x)*(x+$b)";
58-
$ans8 = "-infinity";
59-
$ans9 = "infinity";
60-
$ans10 = "(x**2-$a*x)/(x+$b)";
61-
$ans11 = -$b;
62-
ANS(fun_cmp($ans1));
63-
ANS(str_cmp($ans2));
64-
ANS(str_cmp($ans3));
65-
ANS(fun_cmp($ans4));
66-
ANS(str_cmp($ans5));
67-
ANS(str_cmp($ans6));
68-
ANS(fun_cmp($ans7));
69-
ANS(str_cmp($ans8));
70-
ANS(str_cmp($ans9));
71-
ANS(fun_cmp($ans10));
72-
ANS(num_cmp($ans11));
73-
74-
ENDDOCUMENT(); # This should be the last executable line in the problem.
26+
$f = Formula("x^2 - $a x");
27+
$g = Formula("x + $b");
28+
29+
Context("Interval");
30+
31+
$R = Interval("R");
32+
33+
BEGIN_TEXT
34+
35+
$BBOLD Note: $EBOLD See \{helpLink("intervals")\} for help on entering intervals.
36+
$PAR
37+
38+
Given that \(f(x)=\{$f->TeX\}\) and \(g(x)=\{$g->TeX\}\), find
39+
$PAR
40+
41+
(a) \((f+g)(x)\)= \{ans_rule(25)\} and its domain is \{ans_rule(10)\}
42+
$PAR
43+
44+
(b) \((f-g)(x)\)= \{ans_rule(25)\} and its domain is \{ans_rule(10)\}
45+
$PAR
46+
47+
(c) \((fg)(x)\)= \{ans_rule(25)\} and its domain is \{ans_rule(10)\}
48+
$PAR
49+
(d) \((f/g)(x)\)= \{ans_rule(25)\} and its domain is \{ans_rule(10)\}
50+
51+
END_TEXT
52+
53+
ANS(($f + $g)->cmp);
54+
ANS($R->cmp);
55+
ANS(($f - $g)->cmp);
56+
ANS($R->cmp);
57+
ANS(($f * $g)->cmp);
58+
ANS($R->cmp);
59+
ANS(($f / $g)->cmp);
60+
ANS(Interval("R - {-$b}")->cmp);
7561

62+
ENDDOCUMENT();

0 commit comments

Comments
 (0)