Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Contrib/TRU/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Thompson Rivers University Problem Authors:

Kyle Schlitt; email kschlitt@tru.ca; GitHub: kyleschlitt
98 changes: 98 additions & 0 deletions Contrib/TRU/math1070/comparingSimpleCompound.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
## DBsubject(Financial mathematics)
## DBchapter(Interest)
## DBsection(Compound interest)
## Level(2)
## KEYWORDS('simple interest rate', 'compound interest')
## Author(Kyle Schlitt)
## Institution(TRU)
## Language(en)

DOCUMENT();

loadMacros(
'PGstandard.pl',
'PGML.pl',
'contextCurrency.pl',
'parserPopUp.pl'
);

Context("Currency");

Context()->flags->set(
tolerance => 0.01,
tolType => "absolute",
);

# what is the compounding frequency
@frequencies = (1,2,4,6,12,24,52,365);

@compounding_type = (
"annually",
"semi-annually",
"quarterly",
"bi-monthly",
"monthly",
"semi-monthly",
"weekly",
"daily"
);

do {
$P = Currency(10000 + 1000 * random(0,10,1));
$t = random(15,20,1);

$simple_r = 0.07 + 0.01 * random(0,3,1);
$simple_r_percent = $simple_r * 100;
$compound_r = $simple_r - 0.02;
$compound_r_percent = $compound_r * 100;

$k = random(0,7,1);
$m = $frequencies[$k];
$m_word = @compounding_type[$k];

$n = $m*$t;
$i = $compound_r/$m;

$simple_amount = $P * (1 + $simple_r*$t);
$simple_interest = $simple_amount - $P;

$compound_amount = $P * (1 + $i)**($n);
$compound_interest = $compound_amount - $P;

if ($compound_amount > $simple_amount) {
$correct_choice = "Option #2";
} else { # unlikely
$correct_choice = "Option #1";
}

$final_choice = DropDown(
["Option #1", "Option #2"],
$correct_choice,
placeholder => "Select One"
);

} while ($compound_amount == $simple_amount);

BEGIN_PGML

You plan to invest [$P] in a retirement fund for [$t] years, and you are offered two investment options:

**Option #1:** Simple interest at an annual rate of [$simple_r_percent]%.

**Option #2:** Compound interest at an annual rate of [$compound_r_percent]%, compounded [$m_word].

How much interest will each investment option yield? After comparing the two plans, which option should be chosen?

----

**Answer**:

Under simple interest, the investment will earn [_]{$simple_interest} in interest, growing to a total of [_]{$simple_amount}.

Under compound interest, the investment will earn [_]{$compound_interest} in interest, growing to a total of [_]{$compound_amount}.

[_]{$final_choice} should be chosen.

END_PGML

ENDDOCUMENT();
94 changes: 94 additions & 0 deletions Contrib/TRU/math1070/convenienceStore.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
## DBsubject(Algebra)
## DBchapter(Linear equations and functions)
## DBsection(Applications and models)
## Level(2)
## KEYWORDS('supply', 'demand', 'price')
## Author(Kyle Schlitt)
## Institution(TRU)
## Language(en)

DOCUMENT();

loadMacros(
"PGstandard.pl",
"PGML.pl",
"contextCurrency.pl",
"parserImplicitEquation.pl"
);

$slope_num = -(1 + random(5,20,1));
$slope_den = 100;
$m = $slope_num/$slope_den;

$data_q_1 = random(10,20,1);
$data_p_1 = 4 + 0.01*random(0,50,1);

$b = $data_p_1 - $m*$data_q_1;
$q_intercept = $data_q_1 - $data_p_1/$m;

$data_q_2 = $data_q_1 + random(4,10,1);
$data_p_2 = $slope_num/$slope_den*($data_q_2 - $data_q_1) + $data_p_1;

$target_quantity = int($data_q_2 + int(($q_intercept - $data_q_2)/random(2,3,1)));

$target_price = $m*($target_quantity - $data_q_2) + $data_p_2;

$specified_price = -1;

while ($specified_price < 0 || $specified_price == $target_price) {
$random_multiplier = random(5,15,1);
$specified_quantity = $data_q_2 + $random_multiplier;
$specified_price = $data_p_2 + $m * $random_multiplier;
}

Context("Currency");

BEGIN_PGML

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.

Assuming there is a linear relationship between

* [`p =`] the price per can, and
* [`q =`] the number of cans sold per day,

find the demand equation, expressed as a relationship between the variables [`p`] and [`q`].

END_PGML

Context("ImplicitEquation");

Context()->variables->add(q => 'Real', p => 'Real');

Context()->variables->set(
q => { limits => [-10,10]},
p => { limits => [-10,10]}
);

$demand_equation = ImplicitEquation("p=$m*q + $b");

BEGIN_PGML

**Answer:** [_]{$demand_equation}

----

END_PGML

Context("Currency");

BEGIN_PGML

What should the price be set to in order to sell [`[$target_quantity]`] cans per day -- be sure to include units!

**Answer:** The price should be set to [_]{Currency($target_price)} per can.

----

If the price per can is set to [`[@ Currency($specified_price) @]`], how many cans should the store-owner expect to sell per day?

**Answer:** The store will sell [_]{$specified_quantity} cans per day.

END_PGML

ENDDOCUMENT();
126 changes: 126 additions & 0 deletions Contrib/TRU/math1070/domainInterceptsRationalFunction.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
## DBsubject(Algebra)
## DBchapter(Functions)
## DBsection(Graphs)
## Level(2)
## KEYWORDS('domain', 'range', 'intercepts', 'rational function', 'rational functions')
## Author(Kyle Schlitt)
## Institution(TRU)
## Language(en)

DOCUMENT();

loadMacros(
"PGstandard.pl",
"PGML.pl",
"parserMultiAnswer.pl",
"parserPopUp.pl",
"contextFraction.pl"
);

Context("Fraction");

# choose the x-intercepts of f
$xintercept1num = random(1,4,1);
$xintercept1den = 5;
$xintercept1 = Fraction($xintercept1num, $xintercept1den)->reduce;

$xintercept2 = random(2,5);

# build the numerator of f so it has the desired xintercepts
$f_num_a = $xintercept1den;
$f_num_b = -($xintercept1den*$xintercept2 + $xintercept1num);
$f_num_c = $xintercept1num*$xintercept2;
$f_num = Compute("$f_num_a x^2 + $f_num_b x + $f_num_c")->reduce;

# choose the points at which f will not be defined
$singularity1 = random(5,9,1);

do {
$singularity2 = random(1,7,1);
} while ($singularity2 == $singularity1);

# build the denominator of f so it has the desired singularities
$f_den_a = 1;
$f_den_b = -($singularity1 + $singularity2);
$f_den_c = $singularity1*$singularity2;

$f_den = Compute("$f_den_a x^2 + $f_den_b x + $f_den_c")->reduce;

$f = $f_num/$f_den;

$popup = DropDown(['a polynomial', 'a rational function', 'an exponential function', 'a quadratic function'], 'a rational function', placeholder => 'Select One');

BEGIN_PGML

Consider the function [`f(x) = \displaystyle{[$f]}`].

What type of function is [`f`]?

**Answer:** [`f`] is [_]{$popup}.
----

END_PGML

Context("Interval");

$a = 0;$b = 0;

if ($singularity1 < $singularity2) {
$a = $singularity1; $b = $singularity2;
} else {
$a = $singularity2; $b = $singularity1;
}

$domain = Union("(-infinity, $a) U ($a, $b) U ($b, infinity)");

BEGIN_PGML

What is the domain of [`f`]? Express your answer using interval notation.

**Answer:** [`\text{dom}(f)=`] [_]{$domain}

----

END_PGML

$intercepts = MultiAnswer($xintercept1, $xintercept2)->with(
singleResult => 0,
checker => sub {
my ($correct, $student, $self) = @_;
my ($x1stu, $x2stu) = @{$student};
my ($x1, $x2) = @{$correct};

if (($x1 == $x1stu && $x2 == $x2stu) || ($x1 == $x2stu && $x2 == $x1stu)) {
return [1,1];
} elsif ($x1 == $x1stu || $x2 == $x1stu) {
return [1,0];
} elsif ($x1 == $x2stu || $x2 == $x2stu) {
return [0,1];
} else {
return [0,0];
}
}
);

BEGIN_PGML

What are the [`x`]-intercepts of the graph of [`f`]?

**Answer:** [`x =`] [_]{$intercepts} and [`x = `] [_]{$intercepts}

----
END_PGML

Context("Fraction");

$yintercept = Fraction("$f_num_c/$f_den_c")->reduce;

BEGIN_PGML

What is the [`y`]-intercept of the graph of [`f`]?

**Answer:** [`y =`] [_]{$yintercept}

END_PGML

ENDDOCUMENT();
Loading