NAME
Macros for complex numbers for the PG language
SYNPOSIS
DESCRIPTION
cplx_cmp
# This subroutine compares complex numbers.
# Available prefilters include:
# each of these are called by cplx_cmp( answer, mode => '(prefilter name)' )
# 'std' The standard comparison method for complex numbers. This option it the default
# and works with any combination of cartesian numbers, polar numbers, and
# functions. The default display method is cartesian, for all methods, but if
# the student answer is polar, even in part, then their answer will be displayed
# that way.
# 'strict_polar' This is still under developement. The idea is to check to make sure that there
# only a single term in front of the e and after it... but the method does not
# check to make sure that the i is in the exponent, nor does it handle cases
# where the polar has e** coefficients.
# 'strict_num_cartesian' This prefilter allows only complex numbers of the form "a+bi" where a and b
# are strictly numbers.
# 'strict_num_polar' This prefilter allows only complex numbers of the form "ae^(bi)" where a and b
# are strictly numbers.
# 'strict' This is a combination of strict_num_cartesian and strict_num_polar, so it
# allows complex numbers of either the form "a+bi" or "ae^(bi)" where a and b
# are strictly numbers.
compare_cplx
# This is a filter: it accepts and returns an AnswerHash object.
#
# Usage: compare_cplx(ans_hash, %options)
#
# Compares two complex numbers by comparing their real and imaginary parts
multi_cmp
#
# Checks a comma separated string of items against an array of evaluators.
# For example this is useful for checking all of the complex roots of an equation.
# Each student answer must be evaluated as correct by a DISTINCT answer evalutor.
#
# This answer checker will only work reliably if each answer checker corresponds
# to a distinct correct answer. For example if one answer checker requires
# any positive number, and the second requires the answer 1, then 1,2 might
# be judged incorrect since 1, satisifes the first answer checker, but 2 doesn't
# satisfy the second. 2,1 would work however. Avoid this type of use!!
#
# Including backtracking to fit the answers as best possible to each answer evaluator
# in the best possible way, is beyond the ambitions of this evaluator.
Utility functions
# for checking the form of a number or of the C<student_ans> field in an answer hash
single_term()
# This subroutine takes in a string, which is a mathematical expresion, and determines whether or not
# it is a single term. This is accoplished using a stack. Open parenthesis pluses and minuses are all
# added onto the stack, and when a closed parenthesis is reached, the stack is popped untill the open
# parenthesis is found. If the original was a single term, the stack should be empty after
# evaluation. If there is anything left ( + or - ) then false is returned.
# Of course, the unary operator "-" must be handled... if it is a unary operator, and not a regular -
# the only place it could occur unambiguously without being surrounded by parenthesis, is the very
# first position. So that case is checked before the loop begins.