Complex Numbers¶
Answer type: complex
The student types a complex number, normally in a+bi form.
The minimum¶
Common Control:
$answer = "3+4i"
Options¶
| Variable | Effect |
|---|---|
$answer |
the correct complex number — required |
$answerformat |
accepted-format flags |
$ansprompt |
not shown before the box for this type; only used with $answerformat = "nosoln" or "nosolninf", as ;-separated labels for the choices (e.g. "One solution: ;No solution") |
$answerboxsize |
width of the input box |
Related types¶
| Type | Use when |
|---|---|
complex |
the student types plain numbers for both parts, like 1.5-2i; an entry such as 3/2-2i is rejected and scores 0 |
calccomplex |
the student may type a calculation, like 3/2-sqrt(3)i, which is evaluated before comparing |
complexmatrix, calccomplexmatrix |
a matrix of complex entries |
complexntuple, calccomplexntuple |
a tuple of complex entries |
Both complex and calccomplex compare the real and imaginary parts using $reltolerance (default 0.0015) or $abstolerance. If neither is set, $reqdecimals = n gives an absolute tolerance of 0.5×10⁻ⁿ. calccomplex additionally reads $requiretimes and $hidepreview.
Example¶
Common Control — setup:
$a = nonzerorand(-6, 6)
$b = nonzerorand(-6, 6)
$sol = "$a+$b i"
Question Text:
<p>Write the complex number with real part `$a` and imaginary part `$b`.</p>
Common Control, continued — answer and options:
$answer = $sol