PREP 2013 Question Authoring - Archived

complex math object

Re: complex math object

by Davide Cervone -
Number of replies: 0
Joan:

Two things to think about. I noticed you comment about the formula using x. The reason that doesn't work is that the Complex context doesn't have a variable x in it (just z). If you want to use x, you need to add it to the context. (I see Gavin has already answered this -- I had to step away for a bit, and he beat me to it.)

Your real question, however, is how to make the list of complex numbers that you want in the end. It is easiest to use

    $answer = Compute("$a,-$a,i,-i");
and later use
    ANS($answer->cmp);
Frequently, it is best to use Compute() with whatever answer you want the students to type, rather than the individual class constructors like List(). This makes sure the students actually can type what you want them to, and makes it easier on you, since you don't have to be concerned with the details of the classes involved.

Finally, note that inside a string used to create a MathObject, you don't have to do -1*i, as -i is sufficient. It is only in perl expressions that there is a problem with -i.

Hope that clears things up.

Davide