Hi Alex,

Here's an alternate idea. Use the Complex context, add a function to the context ( http://webwork.maa.org/wiki/AddingFunctions ) defined by

parserFunction("P(r,t)" => "r*e^(i*t)");

and set a Context flag so that the student answer gets displayed in the feedback in the form P(r,t) instead of as a complex number. There's a minimal working example below my signature.

Best regards,

Paul Pearson

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

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGML.pl",

"parserFunction.pl",

);

TEXT(beginproblem());

Context("Complex")->variables->are(r=>'Real', t=>'Real');

Context()->flags->set(formatStudentAnswer => "reduced");

parserFunction("P(r,t)" => "r*e^(i*t)");

$a = Compute("P(2,pi/4)");

BEGIN_PGML

[` P(2,\pi/4) =`] [__________]{$a}

END_PGML

ENDDOCUMENT();