# Khan/khan-exercises

Make-better the dividing complex numbers exercise

Summary: Now the answer is always an integer and the hints make more sense when dividing by a single term.

Test Plan: ...looked at the hints?

Reviewers: eater

Reviewed By: eater

1 parent b2c978b commit eb0d23311acbcab124fe5a72990854b85e14585b spicyj committed Dec 13, 2012
Showing with 59 additions and 50 deletions.
1. +58 −49 exercises/dividing_complex_numbers.html
2. +1 −1 utils/math-format.js
107 exercises/dividing_complex_numbers.html
 @@ -12,130 +12,139 @@
-
- randRange( -5, 5 ) - randRange( -5, 5 ) +
+ 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 ) - fraction( REAL_NUMERATOR, DENOMINATOR, true, true ) - fraction( IMAG_NUMERATOR, DENOMINATOR, true, true ) - complexFraction( REAL_NUMERATOR, DENOMINATOR, IMAG_NUMERATOR, DENOMINATOR ) - REAL_NUMERATOR / DENOMINATOR - IMAG_NUMERATOR / DENOMINATOR - roundTo( 2, ANSWER_REAL_UNROUNDED ) - roundTo( 2, ANSWER_IMAG_UNROUNDED ) + complexNumber( ANSWER_REAL, ANSWER_IMAG ) complexNumber( A_REAL, A_IMAG ) complexNumber( B_REAL, B_IMAG ) - "\\color{" + ORANGE + "}{" + A_REP + "}" - "\\color{" + BLUE + "}{" + B_REP + "}" - "\\color{" + ORANGE + "}{" + A_REAL + "}" - "\\color{" + ORANGE + "}{" + A_IMAG + "}" - "\\color{" + BLUE + "}{" + B_REAL + "}" - "\\color{" + BLUE + "}{" + B_IMAG + "}" -B_IMAG - "\\color{" + BLUE + "}{" + negParens( B_CONJUGATE_IMAG ) +"}" complexNumber( B_REAL, B_CONJUGATE_IMAG ) - "\\color{" + BLUE + "}{" + CONJUGATE + "}"
-

Divide the following complex numbers. You can round the real and imaginary parts of the result to 2 decimal digits.

+

Divide the following complex numbers.

Two numbers for both the real and imaginary parts
- Example: 2 + 3i + Example: 2 + 3i
+
+

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:

+

+
+
+
+

- Complex number division is converted to complex multiplication using the denominator's complex conjugate. + 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_COLORED}{B_REP_COLORED} = - \dfrac{A_REP_COLORED}{B_REP_COLORED} \cdot - \dfrac{CONJUGATE_COLORED}{CONJUGATE_COLORED} + \qquad \dfrac{A_REP}{B_REP} = + \dfrac{A_REP}{B_REP} \cdot + \dfrac{\green{CONJUGATE}}{\green{CONJUGATE}}

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

- \qquad \dfrac{(A_REP_COLORED) \cdot (CONJUGATE_COLORED)} - {(B_REP_COLORED) \cdot (CONJUGATE_COLORED)} = - \dfrac{(A_REP_COLORED) \cdot (CONJUGATE_COLORED)} - {(B_REAL_COLORED)^2 - (\color{BLUE}{B_IMAGi})^2} + \qquad \dfrac{(A_REP) \cdot (CONJUGATE)} + {(B_REP) \cdot (CONJUGATE)} = + \dfrac{(A_REP) \cdot (CONJUGATE)} + {negParens(B_REAL)^2 - (B_IMAGi)^2} -

- 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.
-

- The squares in the denominator are evaluated and subtracted. + Evaluate the squares in the denominator and subtract them.

- \qquad \dfrac{(A_REP_COLORED) \cdot (CONJUGATE_COLORED)} - {(B_REAL_COLORED)^2 - (B_IMAG_COLOREDi)^2} = + \qquad \dfrac{(A_REP) \cdot (CONJUGATE)} + {(B_REAL)^2 - (B_IMAGi)^2} =

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

- \qquad \dfrac{(A_REP_COLORED) \cdot (CONJUGATE_COLORED)} + \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.
+

- Afterwards, the numerator is multiplied using the distributive property. + Now, we can multiply out the two factors in the numerator.

- \qquad \dfrac{(A_REP_COLORED) \cdot (CONJUGATE_COLORED)} + \qquad \dfrac{(\blue{A_REP}) \cdot (\red{CONJUGATE})} {DENOMINATOR} =

- \qquad \dfrac{(A_REAL_COLORED \cdot \color{BLUE}{negParens( B_REAL )}) + (A_IMAG_COLORED \cdot \color{BLUE}{negParens( B_REAL )} i) + (A_REAL_COLORED \cdot \color{BLUE}{ B_CONJUGATE_IMAG_COLORED }i) + (A_IMAG_COLORED \cdot \color{BLUE}{ B_CONJUGATE_IMAG_COLORED } i^2)} + \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}

- All multiplications are evaluated. + 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)} + \qquad \dfrac{A_REAL * B_REAL + A_IMAG * B_REALi + A_REAL * B_CONJUGATE_IMAGi + A_IMAG * B_CONJUGATE_IMAG i^2} {DENOMINATOR}

- Finally, the fraction is simplified. + 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 + ANSWER_REP
+
2 utils/math-format.js
 @@ -485,7 +485,7 @@ \$.extend(KhanUtil, { if (real === 0 && imaginary === 0) { return "0"; } else if (real === 0) { - return imaginary + "i"; + return (imaginary === 1 ? "" : imaginary === -1 ? "-" : imaginary) + "i"; } else if (imaginary === 0) { return real; } else {