number fields

Number fields

All variables and functions are interpreted in a number field which can be defined within the
question environment by the \field{...} command. It can take one of the following values:

number field Description
real real numbers (i.e. decimal numbers); this is the default value if the \field{number field} command is omitted
integer integer numbers
rational rational numbers
complex complex numbers with real numbers as real and imaginary parts
complex-rational complex numbers with rational numbers as real and imaginary parts
    \field{...} %  set for this question and all their answers

Precision of real numbers

If the number field is chosen to be real or complex, there is the issue of precision -
on one hand for displaying the numbers/functions, and on the other for the correction.

The display precision always has to be greater of equal to the corrector precision.

Display precision

For displaying variables defined by \number,\randdouble, or \randrat one uses the
command \displayprecision{\} which defines the number of digits
used for displaying.
If not specified, then the generic problem will use the default value of 2.

When a number was created by the \function-command (or \substitute or \derivative)
using the calculate option, the precision defined with the above command will be
ignored. This is because computations should not be rounded while not visible to the user.
In case you do want to display the calculated value then set the precision within the command,


Again this value should be $$\geq$$ corrector precision.

Corrector precision

The precision used for correction depends on the type of the answer.

For type input.number, one uses the command
similar to \displayprecision, but with an optional argument as follows:

  1. atleast means that the answer must be typed in (rounded) with atleast the given precision. This is the default option.
  2. rounded means that the answer must be rounded.

    If you use this option, make sure you tell the user that they must round the result with the given precision

  3. truncate means that the answer should not be rounded, and should just be typed in up to the defined number of decimal digits.

If \correctorprecision is not specified, then the generic problem will use the default
value of 2.

For answers of type input.function the precision is given as an optional argument in the
command that specifies how to check the given answer for correctness.
See Corrector commands for input.function.