# Complex Numbers

Computer Science I · Algebra · https://tryals.app/learn/computer-science-i/complex-numbers

## The Imaginary Unit

Some equations, like $x^2 = -1$, have no real solution. Mathematicians extend the reals by introducing the **imaginary unit** $i$, defined by $i^2 = -1$. A **complex number** takes the form $z = a + bi$, with **real part** $a$ and **imaginary part** $b$.

Arithmetic treats $i$ as a symbol alongside real numbers:

| Operation | Rule |
| --- | --- |
| **Addition** | $(a + bi) + (c + di) = (a + c) + (b + d)i$ |
| **Multiplication** | $(a + bi)(c + di) = (ac - bd) + (ad + bc)i$ |
| **Conjugate** | $\overline{a + bi} = a - bi$ (yields $a^2 + b^2$) |

**Common pitfall:** Always remember $i^2 = -1$, not $+1$. A product like $(bi)(di) = -bd$ contributes to the real part, whereas addition strictly keeps real and imaginary parts separate.

## Geometry of Complex Numbers

Geometrically, a **complex number** is a point in the plane with its real part on the horizontal axis and imaginary part on the vertical.

Key geometric terms:

| Term | Formula / Meaning |
| --- | --- |
| **Modulus** | $|z| = \sqrt{a^2 + b^2}$, distance from origin |
| **Argument** | The angle the vector makes with the axis |

**Multiplying complex numbers** adds their arguments and multiplies their moduli. Thus, multiplying by a unit complex number is a **rotation**.

This deep link powers signal processing, computer graphics, and quantum computing. It ensures every polynomial equation is solvable, known as the **Fundamental Theorem of Algebra**.

## Practice questions

4 of this lesson's 10 practice questions, with answers. The full set is in the app.

### 1. Let z = 3 + 2i and w = 1 + 5i. Select every TRUE statement about z + w.

A. The real part is 3
B. z + w = 4 + 7i
C. z + w = 3 + 10i
D. The real part is 4
E. The imaginary part is 7

**Answer:** B. z + w = 4 + 7i; D. The real part is 4; E. The imaginary part is 7

**Why:** (3+2i)+(1+5i) = (3+1)+(2+5)i = 4 + 7i, so its real part is 4 and imaginary part 7. The two distractors leave one of the parts unadded.

Page: https://tryals.app/practice/computer-science-i/complex-numbers/let-z-3-2i-and-w-1-5i-select-every-true-statement-about-z

### 2. Least squares minimises squared error, which makes it sensitive to outliers. Why is that sensitivity accepted so widely?

A. Because outliers are rare enough in practice to ignore
B. Because squaring makes the objective smooth, convex and solvable directly
C. Because squared error is a more accurate measure of fit than absolute error
D. Because absolute error cannot be minimised at all

**Answer:** B. Because squaring makes the objective smooth, convex and solvable directly

**Why:** Squaring buys a differentiable convex objective with an exact solution via the normal equations; absolute error has a corner at zero and needs iteration. The outlier sensitivity is the price, which is why robust regression exists and is used where outliers are expected rather than exceptional.

Page: https://tryals.app/practice/computer-science-i/complex-numbers/least-squares-minimises-squared-error-which-makes-it-sensitive-to

### 3. Sort each number by whether it is real, purely imaginary, or a general complex number.

**Answer:**

- Real: 7, -1
- Purely imaginary: 5i, -4i
- General complex: 2 + 3i

**Why:** 7 and -1 have no imaginary part (real). 5i and -4i have no real part (purely imaginary). 2 + 3i has both parts nonzero (general complex).

Page: https://tryals.app/practice/computer-science-i/complex-numbers/sort-each-number-by-whether-it-is-real-purely-imaginary-or-a

### 4. Least-squares fitting minimises the sum of SQUARED residuals rather than the sum of absolute ones. What does squaring change, and what does it cost?

A. It gives a closed-form solution, at the cost of weighting outliers heavily.
B. Squaring makes all residuals positive, which absolute values do not.
C. Squaring is required because negative residuals would otherwise cancel positive ones.
D. Squaring produces a smaller total error, so the fit is more accurate.

**Answer:** A. It gives a closed-form solution, at the cost of weighting outliers heavily.

**Why:** Squaring buys a smooth convex objective solvable in closed form through the normal equations, where absolute error has a corner at zero and needs iteration. The cost is sensitivity: a residual of 10 contributes 100, so the fit works disproportionately hard on large errors. Absolute values also prevent cancellation, so that is not what distinguishes them, the trade is exactness against robustness.

Page: https://tryals.app/practice/computer-science-i/complex-numbers/least-squares-fitting-minimises-the-sum-of-squared-residuals-rather
