WeBWorK Problems

Other Bases of Logarithm

Other Bases of Logarithm

by Gregory Varner -
Number of replies: 1

My goal is to have a student convert an exponential equation into a logarithm. (The other way around is not as difficult.)

For instance, something like

(x-2)^3=z becomes log_(x-2)(z)=3.

I am avoiding needing to look for answer mirroring by requiring a particular order to the answer. I am not currently using multianswer, though I am not against doing so.

My main problem is in getting the students to be able to input log_(x-2) in and have Webwork recognize it. (I realize that there is probably something similar on the discussion board somewhere but I have not been able to find it).


Here is what my code currently is. It is not randomized (I am fitting it to some static questions at the moment).

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(

  "PGstandard.pl",

  "MathObjects.pl",

  "answerHints.pl",

  "PGML.pl",

  "PGcourse.pl",

);

TEXT(beginproblem());

######################################

#  Setup

Context("Numeric");

Context()->variables->add(z=>"Real");

$base = Formula("x-2");

$power = 3;

$equals = Formula("z");

######################################

#  Main text


BEGIN_PGML

Convert the equation into a logarithmic equation.

[`` ([$base])^[$power] = [$equals] ``]

The logarithmic equation is :  [__________] = [_________]. (You must write the logarithmic terms on the left.)

END_PGML

######################################

#  Answer

$ans1 =Formula("log_($base)($equals)");

$ans2 = Formula("$power");

ANS($ans1->cmp());

ANS($ans2->cmp());

$showPartialCorrectAnswers = 1;

#####################################

;

ENDDOCUMENT();

In reply to Gregory Varner

Re: Other Bases of Logarithm

by Danny Glin -

As far as I know logs with arbitrary bases are not implemented in WeBWorK.  I suspect that for someone who has a better understanding of MathObjects it wouldn't be hard to define a new function of two arguments, "log_", which evaluates log_(x)(y) to log(x)/log(y).

In the meantime you can always ask your question in the form (x-2)^3=z becomes log_(a)(b)=c.  What are a, b and c?