This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
/
adding_and_subtracting_complex_numbers.html
90 lines (88 loc) · 3.72 KB
/
adding_and_subtracting_complex_numbers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html data-require="math math-format">
<head>
<meta charset="UTF-8" />
<title>Adding and subtracting complex numbers</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="A_REAL">randRange( -5, 5 )</var>
<var id="A_IMAG">randRange( -5, 5 )</var>
<var id="B_REAL">randRange( -5, 5 )</var>
<var id="B_IMAG">randRange( -5, 5 )</var>
<var id="OPERATION">randFromArray( [ "add", "subtract" ] )</var>
<var id="OPERATOR">( OPERATION === "add" ? "+" : "-" )</var>
<var id="ANSWER_REAL">
( OPERATION === "add" ? ( A_REAL + B_REAL ) : ( A_REAL - B_REAL ) )
</var>
<var id="ANSWER_IMAG">
( OPERATION === "add" ? ( A_IMAG + B_IMAG ) : ( A_IMAG - B_IMAG ) )
</var>
<var id="A_REP">
complexNumber( A_REAL, A_IMAG )
</var>
<var id="B_REP">
complexNumber( B_REAL, B_IMAG )
</var>
<var id="A_REP_COLORED">
"\\color{" + ORANGE + "}{" + A_REP + "}"
</var>
<var id="B_REP_COLORED">
"\\color{" + BLUE + "}{" + B_REP + "}"
</var>
<var id="A_REAL_COLORED">
"\\color{" + ORANGE + "}{" + A_REAL + "}"
</var>
<var id="A_IMAG_COLORED">
"\\color{" + ORANGE + "}{" + A_IMAG + "}"
</var>
<var id="B_REAL_COLORED">
"\\color{" + BLUE + "}{" + B_REAL + "}"
</var>
<var id="B_IMAG_COLORED">
"\\color{" + BLUE + "}{" + B_IMAG + "}"
</var>
</div>
<div class="problems">
<div>
<p class="question"><var>OPERATION == "add" ? "Add" : "Subtract"</var> the following complex numbers:</p>
<p>
<code>
(<var>A_REP_COLORED</var>) <var>OPERATOR</var> (<var>B_REP_COLORED</var>)
</code>
</p>
<div class="solution" data-type="complexNumberSeparate">
[ <var>ANSWER_REAL</var>, <var>ANSWER_IMAG</var> ]
</div>
<div class="hints">
<p>
Complex numbers can be <var>OPERATION</var>ed by separately <var>OPERATION</var>ing their real and imaginary components.
</p>
<p>
The real components of the two complex numbers are <code class="hint_orange"><var>A_REAL</var></code> and <code class="hint_blue"><var>B_REAL</var></code>, respectively,
so the real component of the result will be
<code>
<var>A_REAL_COLORED</var> <var>OPERATOR</var> \color{<var>BLUE</var>}{<var>negParens( B_REAL )</var>}
</code>,
which equals <code><var>ANSWER_REAL</var></code>.
</p>
<p>
The imaginary components of the two complex numbers are <code class="hint_orange"><var>A_IMAG</var></code> and <code class="hint_blue"><var>B_IMAG</var></code>, respectively,
so the imaginary component of the result will be
<code>
<var>A_IMAG_COLORED</var> <var>OPERATOR</var> \color{<var>BLUE</var>}{<var>negParens( B_IMAG )</var>}
</code>,
which equals <code><var>ANSWER_IMAG</var></code>.
</p>
<p>
The result is <code><var>complexNumber( ANSWER_REAL, ANSWER_IMAG )</var></code>; its real component is <code><var>ANSWER_REAL</var></code>
and its complex component is <code><var>ANSWER_IMAG</var></code>.
</p>
</div>
</div>
</div>
</div>
</body>
</html>