Skip to content

Commit c93645e

Browse files
authored
Merge pull request #1288 from kyleschlitt/main
Thompson Rivers University added 7 problems to Contrib
2 parents 6d6f248 + 64217d7 commit c93645e

File tree

8 files changed

+887
-0
lines changed

8 files changed

+887
-0
lines changed

Contrib/TRU/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Thompson Rivers University Problem Authors:
2+
3+
Kyle Schlitt; email [email protected]; GitHub: kyleschlitt
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
## DBsubject(Financial mathematics)
2+
## DBchapter(Interest)
3+
## DBsection(Compound interest)
4+
## Level(2)
5+
## KEYWORDS('simple interest rate', 'compound interest')
6+
## Author(Kyle Schlitt)
7+
## Institution(TRU)
8+
## Language(en)
9+
10+
DOCUMENT();
11+
12+
loadMacros(
13+
'PGstandard.pl',
14+
'PGML.pl',
15+
'contextCurrency.pl',
16+
'parserPopUp.pl'
17+
);
18+
19+
Context("Currency");
20+
21+
Context()->flags->set(
22+
tolerance => 0.01,
23+
tolType => "absolute",
24+
);
25+
26+
# what is the compounding frequency
27+
@frequencies = (1,2,4,6,12,24,52,365);
28+
29+
@compounding_type = (
30+
"annually",
31+
"semi-annually",
32+
"quarterly",
33+
"bi-monthly",
34+
"monthly",
35+
"semi-monthly",
36+
"weekly",
37+
"daily"
38+
);
39+
40+
do {
41+
$P = Currency(10000 + 1000 * random(0,10,1));
42+
$t = random(15,20,1);
43+
44+
$simple_r = 0.07 + 0.01 * random(0,3,1);
45+
$simple_r_percent = $simple_r * 100;
46+
$compound_r = $simple_r - 0.02;
47+
$compound_r_percent = $compound_r * 100;
48+
49+
$k = random(0,7,1);
50+
$m = $frequencies[$k];
51+
$m_word = @compounding_type[$k];
52+
53+
$n = $m*$t;
54+
$i = $compound_r/$m;
55+
56+
$simple_amount = $P * (1 + $simple_r*$t);
57+
$simple_interest = $simple_amount - $P;
58+
59+
$compound_amount = $P * (1 + $i)**($n);
60+
$compound_interest = $compound_amount - $P;
61+
62+
if ($compound_amount > $simple_amount) {
63+
$correct_choice = "Option #2";
64+
} else { # unlikely
65+
$correct_choice = "Option #1";
66+
}
67+
68+
$final_choice = DropDown(
69+
["Option #1", "Option #2"],
70+
$correct_choice,
71+
placeholder => "Select One"
72+
);
73+
74+
} while ($compound_amount == $simple_amount);
75+
76+
BEGIN_PGML
77+
78+
You plan to invest [$P] in a retirement fund for [$t] years, and you are offered two investment options:
79+
80+
**Option #1:** Simple interest at an annual rate of [$simple_r_percent]%.
81+
82+
**Option #2:** Compound interest at an annual rate of [$compound_r_percent]%, compounded [$m_word].
83+
84+
How much interest will each investment option yield? After comparing the two plans, which option should be chosen?
85+
86+
----
87+
88+
**Answer**:
89+
90+
Under simple interest, the investment will earn [_]{$simple_interest} in interest, growing to a total of [_]{$simple_amount}.
91+
92+
Under compound interest, the investment will earn [_]{$compound_interest} in interest, growing to a total of [_]{$compound_amount}.
93+
94+
[_]{$final_choice} should be chosen.
95+
96+
END_PGML
97+
98+
ENDDOCUMENT();
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## DBsubject(Algebra)
2+
## DBchapter(Linear equations and functions)
3+
## DBsection(Applications and models)
4+
## Level(2)
5+
## KEYWORDS('supply', 'demand', 'price')
6+
## Author(Kyle Schlitt)
7+
## Institution(TRU)
8+
## Language(en)
9+
10+
DOCUMENT();
11+
12+
loadMacros(
13+
"PGstandard.pl",
14+
"PGML.pl",
15+
"contextCurrency.pl",
16+
"parserImplicitEquation.pl"
17+
);
18+
19+
$slope_num = -(1 + random(5,20,1));
20+
$slope_den = 100;
21+
$m = $slope_num/$slope_den;
22+
23+
$data_q_1 = random(10,20,1);
24+
$data_p_1 = 4 + 0.01*random(0,50,1);
25+
26+
$b = $data_p_1 - $m*$data_q_1;
27+
$q_intercept = $data_q_1 - $data_p_1/$m;
28+
29+
$data_q_2 = $data_q_1 + random(4,10,1);
30+
$data_p_2 = $slope_num/$slope_den*($data_q_2 - $data_q_1) + $data_p_1;
31+
32+
$target_quantity = int($data_q_2 + int(($q_intercept - $data_q_2)/random(2,3,1)));
33+
34+
$target_price = $m*($target_quantity - $data_q_2) + $data_p_2;
35+
36+
$specified_price = -1;
37+
38+
while ($specified_price < 0 || $specified_price == $target_price) {
39+
$random_multiplier = random(5,15,1);
40+
$specified_quantity = $data_q_2 + $random_multiplier;
41+
$specified_price = $data_p_2 + $m * $random_multiplier;
42+
}
43+
44+
Context("Currency");
45+
46+
BEGIN_PGML
47+
48+
A store-owner is marketing a brand new energy drink at a local convenience store. He observes that [`[$data_q_1]`] cans per day are sold if the price per can is set to [`[@ Currency($data_p_1) @]`], but [`[$data_q_2]`] cans per day are sold if the price is set at [`[@ Currency($data_p_2) @]`] per can.
49+
50+
Assuming there is a linear relationship between
51+
52+
* [`p =`] the price per can, and
53+
* [`q =`] the number of cans sold per day,
54+
55+
find the demand equation, expressed as a relationship between the variables [`p`] and [`q`].
56+
57+
END_PGML
58+
59+
Context("ImplicitEquation");
60+
61+
Context()->variables->add(q => 'Real', p => 'Real');
62+
63+
Context()->variables->set(
64+
q => { limits => [-10,10]},
65+
p => { limits => [-10,10]}
66+
);
67+
68+
$demand_equation = ImplicitEquation("p=$m*q + $b");
69+
70+
BEGIN_PGML
71+
72+
**Answer:** [_]{$demand_equation}
73+
74+
----
75+
76+
END_PGML
77+
78+
Context("Currency");
79+
80+
BEGIN_PGML
81+
82+
What should the price be set to in order to sell [`[$target_quantity]`] cans per day -- be sure to include units!
83+
84+
**Answer:** The price should be set to [_]{Currency($target_price)} per can.
85+
86+
----
87+
88+
If the price per can is set to [`[@ Currency($specified_price) @]`], how many cans should the store-owner expect to sell per day?
89+
90+
**Answer:** The store will sell [_]{$specified_quantity} cans per day.
91+
92+
END_PGML
93+
94+
ENDDOCUMENT();
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
## DBsubject(Algebra)
2+
## DBchapter(Functions)
3+
## DBsection(Graphs)
4+
## Level(2)
5+
## KEYWORDS('domain', 'range', 'intercepts', 'rational function', 'rational functions')
6+
## Author(Kyle Schlitt)
7+
## Institution(TRU)
8+
## Language(en)
9+
10+
DOCUMENT();
11+
12+
loadMacros(
13+
"PGstandard.pl",
14+
"PGML.pl",
15+
"parserMultiAnswer.pl",
16+
"parserPopUp.pl",
17+
"contextFraction.pl"
18+
);
19+
20+
Context("Fraction");
21+
22+
# choose the x-intercepts of f
23+
$xintercept1num = random(1,4,1);
24+
$xintercept1den = 5;
25+
$xintercept1 = Fraction($xintercept1num, $xintercept1den)->reduce;
26+
27+
$xintercept2 = random(2,5);
28+
29+
# build the numerator of f so it has the desired xintercepts
30+
$f_num_a = $xintercept1den;
31+
$f_num_b = -($xintercept1den*$xintercept2 + $xintercept1num);
32+
$f_num_c = $xintercept1num*$xintercept2;
33+
$f_num = Compute("$f_num_a x^2 + $f_num_b x + $f_num_c")->reduce;
34+
35+
# choose the points at which f will not be defined
36+
$singularity1 = random(5,9,1);
37+
38+
do {
39+
$singularity2 = random(1,7,1);
40+
} while ($singularity2 == $singularity1);
41+
42+
# build the denominator of f so it has the desired singularities
43+
$f_den_a = 1;
44+
$f_den_b = -($singularity1 + $singularity2);
45+
$f_den_c = $singularity1*$singularity2;
46+
47+
$f_den = Compute("$f_den_a x^2 + $f_den_b x + $f_den_c")->reduce;
48+
49+
$f = $f_num/$f_den;
50+
51+
$popup = DropDown(['a polynomial', 'a rational function', 'an exponential function', 'a quadratic function'], 'a rational function', placeholder => 'Select One');
52+
53+
BEGIN_PGML
54+
55+
Consider the function [`f(x) = \displaystyle{[$f]}`].
56+
57+
What type of function is [`f`]?
58+
59+
**Answer:** [`f`] is [_]{$popup}.
60+
----
61+
62+
END_PGML
63+
64+
Context("Interval");
65+
66+
$a = 0;$b = 0;
67+
68+
if ($singularity1 < $singularity2) {
69+
$a = $singularity1; $b = $singularity2;
70+
} else {
71+
$a = $singularity2; $b = $singularity1;
72+
}
73+
74+
$domain = Union("(-infinity, $a) U ($a, $b) U ($b, infinity)");
75+
76+
BEGIN_PGML
77+
78+
What is the domain of [`f`]? Express your answer using interval notation.
79+
80+
**Answer:** [`\text{dom}(f)=`] [_]{$domain}
81+
82+
----
83+
84+
END_PGML
85+
86+
$intercepts = MultiAnswer($xintercept1, $xintercept2)->with(
87+
singleResult => 0,
88+
checker => sub {
89+
my ($correct, $student, $self) = @_;
90+
my ($x1stu, $x2stu) = @{$student};
91+
my ($x1, $x2) = @{$correct};
92+
93+
if (($x1 == $x1stu && $x2 == $x2stu) || ($x1 == $x2stu && $x2 == $x1stu)) {
94+
return [1,1];
95+
} elsif ($x1 == $x1stu || $x2 == $x1stu) {
96+
return [1,0];
97+
} elsif ($x1 == $x2stu || $x2 == $x2stu) {
98+
return [0,1];
99+
} else {
100+
return [0,0];
101+
}
102+
}
103+
);
104+
105+
BEGIN_PGML
106+
107+
What are the [`x`]-intercepts of the graph of [`f`]?
108+
109+
**Answer:** [`x =`] [_]{$intercepts} and [`x = `] [_]{$intercepts}
110+
111+
----
112+
END_PGML
113+
114+
Context("Fraction");
115+
116+
$yintercept = Fraction("$f_num_c/$f_den_c")->reduce;
117+
118+
BEGIN_PGML
119+
120+
What is the [`y`]-intercept of the graph of [`f`]?
121+
122+
**Answer:** [`y =`] [_]{$yintercept}
123+
124+
END_PGML
125+
126+
ENDDOCUMENT();

0 commit comments

Comments
 (0)