# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
140 lines (138 sloc) 7.41 KB
 Dividing complex numbers
randRange(-5, 5) randRange(-5, 5) randRange(-5, 5) randRangeNonZero(-5, 5) ANSWER_REAL * B_REAL - ANSWER_IMAG * B_IMAG ANSWER_REAL * B_IMAG + ANSWER_IMAG * B_REAL A_IMAG > 0 ? "+" : "-" B_REAL * B_REAL + B_IMAG * B_IMAG (A_REAL * B_REAL) + (A_IMAG * B_IMAG) (A_IMAG * B_REAL) - (A_REAL * B_IMAG) complexNumber(ANSWER_REAL, ANSWER_IMAG) complexNumber(A_REAL, A_IMAG) complexNumber(B_REAL, B_IMAG) -B_IMAG complexNumber(B_REAL, B_CONJUGATE_IMAG)

Divide the following complex numbers.

Since we're dividing by a single term, we can simply divide each term in the numerator separately.

\qquad \dfrac{A_REP}{B_REP} = \dfrac{A_REAL}{B_REP} SIGN \dfrac{coefficient(abs(A_IMAG))i}{B_REP}

Factor out \dfrac 1i.

\qquad = \dfrac 1i \left( \dfrac{A_REAL}{B_IMAG} SIGN \dfrac{coefficient(abs(A_IMAG))i}{B_IMAG} \right)

\qquad \dfrac 1i = \dfrac 1i \cdot \dfrac ii = \dfrac{1 \cdot i}{i \cdot i} = \dfrac{i}{-1} = -i

Substitute -i for \dfrac 1i:

We can divide complex numbers by multiplying both numerator and denominator by the denominator's complex conjugate, which is \green{CONJUGATE}.

\qquad \dfrac{A_REP}{B_REP} = \dfrac{A_REP}{B_REP} \cdot \dfrac{\green{CONJUGATE}}{\green{CONJUGATE}}

We can simplify the denominator using the fact (a + b) \cdot (a - b) = a^2 - b^2.

\qquad = \dfrac{(A_REP) \cdot (CONJUGATE)} {negParens(B_REAL)^2 - (coefficient(B_IMAG)i)^2}

Evaluate the squares in the denominator and subtract them.

\qquad = \dfrac{(A_REP) \cdot (CONJUGATE)} {(B_REAL)^2 - (coefficient(B_IMAG)i)^2}

\qquad = \dfrac{(A_REP) \cdot (CONJUGATE)} {B_REAL * B_REAL + B_IMAG * B_IMAG}

\qquad = \dfrac{(A_REP) \cdot (CONJUGATE)} {B_REAL * B_REAL + B_IMAG * B_IMAG}

The denominator now doesn't contain any imaginary unit multiples, so it is a real number.

Note that when a complex number, a + bi is multiplied by its conjugate, the product is always a^2 + b^2.

Now, we can multiply out the two factors in the numerator.