# contextLimitedComplex.pl - Allow complex numbers but not complex operations.

### From WeBWorK

# NAME

contextLimitedComplex.pl - Allow complex numbers but not complex operations.

# DESCRIPTION

Implements a context in which complex numbers can be entered, but no complex operations are permitted. So students will be able to perform operations within the real and imaginary parts of the complex numbers, but not between complex numbers.

Context("LimitedComplex")

Complex Numbers can still be entered in a+bi or a*e^(bt) form. The e and i are allowed to be entered only once, so we have to keep track of that, and allow SOME complex operations, but only when one term is one of these constants (or an expression involving it that we've already OKed).

You control which format to use by setting the complex_format context flag to 'cartesian', 'polar' or 'either'. E.g.,

Context()->flags->set(complex_format => 'polar');

The default is 'either'. There are predefined contexts that already have these values set:

Context("LimitedComplex-cartesian"); Context("LimitedComplex-polar");

You can require that the a and b used in these forms be strictly numbers (not expressions) by setting the strict_numeric flag and disabling all the functions:

Context()->flags->set(strict_numeric=>1); Context()->functions->disable('All');

There are predefined contexts that already have these values set:

Context("LimitedComplex-cartesian-strict"); Context("LimitedComplex-polar-strict"); Context("LimitedComplex-strict");