i) Below is a problem students had a hard time with last semester on the College Algebra final exam. I'm stumped at "adding units" to the answer (A pedagogical question: is it worth requiring units in webwork problems?) I commanded out the attempts I made, which were:
a) Loading "parserNumberWithUnits.pl";
b) Attempted to define my $t1 and $t2 as number with units
c) Attempt to put help for students:
help(units) [@ AnswerFormatHelp("units") @]*
ii) I noticed the file "PGML.pl" in the "sample problem". What is it doing? Do we need it?
iii) What should be in "PGcourse.pl"? My fear is that once I put the problems I wrote in my regular courses, they will behave differently than how they behave now.
------------------------------------------------------------------------------------
# DESCRIPTION
# From half-life to formula for an exponential; solve an exp equation
# ENDDESCRIPTION
# Homework/Workshop3/Souza/problem1.pg
#---------------------------------------------------------------------------------------------------------------------
# initialization section
#---------------------------------------------------------------------------------------------------------------------
DOCUMENT();
loadMacros("PGstandard.pl",
"MathObjects.pl",
# "parserNumberWithUnits.pl";
"PGML.pl",
"PGcourse.pl");
Context("Numeric");
Context()->variables->add(t => "Real");
#---------------------------------------------------------------------------------------------------------------------
# problem set-up section
#---------------------------------------------------------------------------------------------------------------------
$A = random(120,240,10);
$T = random(8,12,1);
$t1 = 2*$T;
#$g1 = NumberWithUnits("$A/2 g");
$g1 = $A/4;
# $n is an integer amount of substance left after about 3.4 half-lives
$n = ceil($A*0.5**(3.4*$T));
$g2 = random($n,$n+6,1);
#$t2 = NumberWithUnits($T*log($g2/$A)/log(0.5) hr");
$t2 = $T*log($g2/$A)/log(0.5);
$f = Formula("$A*0.5^(t/$T)");
$k = ln(0.5)/ $T;
#---------------------------------------------------------------------------------------------------------------------
# text section
#---------------------------------------------------------------------------------------------------------------------
TEXT(beginproblem());
BEGIN_PGML
The half-life of a radioactive substance is [` [$T] `] hours. The amount of [` [$A] `] grams of the substance is present at [` t=0 `].
a. How much of the substance remains after [` [$t1] `] hours? [______]{$g1}.
[% Include units. Need to figure out how to use "units". It looked like the help to students looked like help(units) [@ AnswerFormatHelp("units") @]* %]
b. Write a formula for [` f(t) `] which gives the amount of substance remaining after [` t `] hours. [` f(t) = `] [_________]{$f}.
c. When will there be [` [$g2] `] grams of the substance left? Include units. [_________]{$t2} . [% Include units. Need to figure out how to use "units" %]
END_PGML
#---------------------------------------------------------------------------------------------------------------------
# (answer and) solution section
#---------------------------------------------------------------------------------------------------------------------
BEGIN_PGML_SOLUTION
*SOLUTION*
a. Since we start with [` [$A] `] grams of the substance, and every [` [$T] `] days half of the substance is gone, after [` [$t1] `] days, [` 0.25([$A]) `] grams of the substance will be left.
b. If we use base [`` \frac{1}{2} ``] and the fact the half-life is [$T] we easily get the formula [` f(t) = [$f] `].
We can also get a formula with base [` e `]. By solving the equation [`` 0.5([$A]) = [$A]e^{k[$T]} ``] we obtain
[`` f(t) = [$A]e^{kt} ``] where [` k=\frac{\ln(0.5)}{ [$T] } = [$k] `].
c. By solving the equation [`` [$g2] = [$A]\Big(0.5^{t/[$T]} \Big) ``] we obtain
[` t =[$T]*\Big( \frac{\log([$g2])}{[$A]} \Big) /\log(0.5) = [$t2] `].
END_PGML_SOLUTION
ENDDOCUMENT();