# Khan/khan-exercises

### Subversion checkout URL

You can clone with
or
.
Fetching contributors…
Cannot retrieve contributors at this time
134 lines (132 sloc) 7.62 KB
 Dividing complex numbers
randRange(-5, 5) randRange(-5, 5) randRange(-5, 5) randRange(-5, 5) ANSWER_REAL * B_REAL - ANSWER_IMAG * B_IMAG ANSWER_REAL * B_IMAG + ANSWER_IMAG * B_REAL 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} A_IMAG > 0 ? "+" : "-" \dfrac{abs(A_IMAG) === 1 ? "" : abs(A_IMAG)i}{B_REP}

Simplifying the two terms gives ANSWER_REP.

Factor out a 1/i.

\dfrac{A_REAL}{B_REP} A_IMAG > 0 ? "+" : "-" \dfrac{abs(A_IMAG) === 1 ? "" : abs(A_IMAG)i}{B_REP} = \dfrac 1i \left( \dfrac{A_REAL}{B_IMAG} A_IMAG > 0 ? "+" : "-" \dfrac{abs(A_IMAG) === 1 ? "" : abs(A_IMAG)i}{B_IMAG} \right) = \dfrac 1i (complexNumber(-ANSWER_IMAG, ANSWER_REAL))

After simplification, 1/i is equal to -i, so we have:

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)} {(B_REP) \cdot (CONJUGATE)} = \dfrac{(A_REP) \cdot (CONJUGATE)} {negParens(B_REAL)^2 - (B_IMAGi)^2}

Evaluate the squares in the denominator and subtract them.

\qquad \dfrac{(A_REP) \cdot (CONJUGATE)} {(B_REAL)^2 - (B_IMAGi)^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}

Note that the denominator now doesn't contain any imaginary unit multiples, so it is a real number, simplifying the problem to complex number multiplication.

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

\qquad \dfrac{(\blue{A_REP}) \cdot (\red{CONJUGATE})} {DENOMINATOR} =

\qquad \dfrac{\blue{A_REAL} \cdot \red{negParens(B_REAL)} + \blue{A_IMAG} \cdot \red{negParens(B_REAL) i} + \blue{A_REAL} \cdot \red{B_CONJUGATE_IMAG i} + \blue{A_IMAG} \cdot \red{B_CONJUGATE_IMAG i^2}} {DENOMINATOR}

Evaluate each product of two numbers.

\qquad \dfrac{A_REAL * B_REAL + A_IMAG * B_REALi + A_REAL * B_CONJUGATE_IMAGi + A_IMAG * B_CONJUGATE_IMAG i^2} {DENOMINATOR}

Finally, simplify the fraction.

\qquad \dfrac{A_REAL * B_REAL + A_IMAG * B_REALi + A_REAL * B_CONJUGATE_IMAGi - A_IMAG * B_CONJUGATE_IMAG} {DENOMINATOR} = \dfrac{REAL_NUMERATOR + IMAG_NUMERATORi} {DENOMINATOR} = ANSWER_REP
Something went wrong with that request. Please try again.