Block F

Crash Course, Complex Numbers


z = a + bi where a, b are floating point (real) numbers.

a is the real part
b is imaginary part.

+

i terms are unlike non-i terms.
To add, combine like terms

3 + 4i + 7 - 6i  = 10 -2i


-

To subtract, distribute the - to the second operand.

3 + 4i - (7 - 6i)  =  -4 + 10i


*

To multiply
    i*i = = -1
    FOIL

(3 + 4i)*(7 - 6i) = 21 -18i + 28i - 24i^2
                  = 45 + 10i

        1           a - bi
    -------- = ----------------
    a  +  bi    (a + bi)*(a - bi)

                   a - bi
             = ----------------
                a^2   - b^2i^2

                   a - bi
             = ----------------
                a^2   + b^2

                   a                - b
             = ----------     i---------------
                a^2 + b^2        a^2  +  b^2

conjugate of a + bi  is a - bi.

 | a + bi |  = sqrt(a^2 + b^2)

tip: write a private method called reciprocal

/
a.multiply(b.reciprocal())

^
repeated multiplication