WeBWorK Problems

Disallow division, but only for complex numbers?

Disallow division, but only for complex numbers?

by Danny Glin -
Number of replies: 2

I'm writing a problem which involves students dividing complex numbers, and I'd like to force them to simplify their answers.

e.g. if the question asks for (1+i)/(2+i), I don't want the students to be able to type exactly that and get credit.  If I disallow division (Context()->operators->undefine('/');), then students can't enter 3/5+1/5*I, which I do want to accept as being correct.  Ideally I'd also like to accept (3+i)/5.

Is there a way to disallow division, but only when dividing by a complex number?  Alternatively, it there a flag for the Complex answer checker to only accept answers in a+bi form?

In reply to Danny Glin

Re: Disallow division, but only for complex numbers?

by Alex Jordan -
It looks like you can use LimitedComplex:
https://webwork.maa.org/pod/pg/macros/contextLimitedComplex.html