I am writing exponential equation problems. While an approximate answer is fine in many cases, I am also wanting to force a correct answer at time. For instance, I may want the students to give the answer in the form: ln(5)/7 or (3ln(3)-4ln(2))/(2ln(2)-5ln(3)) instead of as the decimal.

I have a solution that is easily adaptable to a wide array of such problems, but am struggling to get the solutions to output the way I want (it is giving the decimal wonderfully). I could force the students to not use a decimal, but I want the solution output to match the answer they put in.

Here is what I have:

DOCUMENT();

loadMacros(

"PGstandard.pl", # Standard macros for PG language

"MathObjects.pl",

"PGML.pl",

"answerHints.pl",

"PGML.pl",

"PGcourse.pl",

);

# Print problem number and point value (weight) for the problem

TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect

$showPartialCorrectAnswers = 1;

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

#

# Setup

#

#

$base1 = e;

$base2 = 5;

$a = 7;

$b = 0;

$power1 = Formula("$a x+$b")->reduce;

$c = 0;

$d = 1;

$power2 = Formula("$c x+$d")->reduce;

Context("Numeric");

##y is base1, z is base2

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

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

$num = Formula("$d ln(z)-$b ln(y)")->reduce;

$den = Formula("$a ln(y)-$c ln(z)")->reduce;

$ans = Formula("$num/$den");

$ans=$ans->substitute(y=>$base1)->substitute(z=>$base2);

ANS($ans->cmp());

Any help would be appreciated.

Thank you!