Skip to content
Classroom

Complex Question Type

Students enter complex numbers in the form a + bi or a + b*i.

Basic Syntax

[complex]
answer = 3 + 2*i;

Options

answer (required)

The correct complex number.

[complex]
answer = 1 - 1*i;

tolerance

Acceptable error for both real and imaginary parts.

[complex]
answer = 2.5 + 1.732*i;
tolerance = 0.01;

displayformat

How to show the answer: - rectangular (default) — a + bi - polarr ∠ θ

[complex]
answer = 1 + 1*i;
displayformat = polar;  // Shows as: √2 ∠ 45°

Examples

Addition of Complex Numbers

$a_real = rand(1, 5);
$a_imag = rand(1, 5);
$b_real = rand(1, 5);
$b_imag = rand(1, 5);

Calculate: `($a_real + $a_imag*i) + ($b_real + $b_imag*i)`

[complex]
answer = ($a_real + $b_real) + ($a_imag + $b_imag)*i;
tolerance = 0.01;

Multiplication of Complex Numbers

Calculate: `(2 + 3i)(1 - 2i)`

[complex]
answer = 8 - 1*i;
tolerance = 0.01;

Powers of i

Simplify: `i^7`

[complex]
answer = -1*i;
tolerance = 0.01;

Quadratic with Complex Roots

$a = rand(1, 3);
$b = rand(1, 5);
$c = rand(3, 8);

Use the quadratic formula to find the complex roots of `$a*x^2 + $b*x + $c = 0`.
Enter one of the roots.

$discriminant = $b*$b - 4*$a*$c;
$real_part = -$b / (2*$a);
$imag_part = sqrt(-$discriminant) / (2*$a);

[complex]
answer = $real_part + $imag_part*i;
tolerance = 0.01;

Grading

The system compares both real and imaginary parts: - Real parts match (within tolerance) AND - Imaginary parts match (within tolerance) - → Correct

Student Input Format

Students can enter complex numbers as: - 3 + 2*i - 3 + 2i - 2i + 3 - 2*i + 3

All formats are recognized.

Tips

  • Use for algebra and engineering: Complex numbers appear frequently in these fields
  • Set tolerance for theoretical calculations: Accumulated rounding errors are normal
  • Provide context: Explain why complex roots appear (discriminant < 0)
  • Offer hints: Remind students of the complex definition: i^2 = -1

Polar Form Display

If displayformat = polar, the answer displays as:

√2 ∠ 45° or 1.414 ∠ 0.785 rad

Students still enter in rectangular form (a + bi), but the answer key shows the polar equivalent.

See Also

  • Number — For real numbers only
  • Calculated — For algebraic expressions with real coefficients
  • N-Tuple — For coordinates including complex points