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
/
complex_plane_operations.html
154 lines (144 loc) · 7.14 KB
/
complex_plane_operations.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html data-require="math math-format graphie interactive">
<head>
<title>Complex plane operations</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="REAL1">randRangeNonZero(-5, 5)</var>
<var id="REAL2">randRangeNonZero(-5, 5)</var>
<var id="COMPLEX1">randRangeNonZero(-5, 5)</var>
<var id="COMPLEX2">randRangeNonZero(-5, 5)</var>
</div>
<div class="problem">
<p>Let <code>a</code> and <code>b</code> be complex numbers:</p>
<p><code>\begin{align*}
a &= <var>REAL1</var> + <var>coefficient(COMPLEX1)</var>i \\
b &= <var>REAL2</var> + <var>coefficient(COMPLEX2)</var>i
\end{align*}</code></p>
</div>
<p class="question">What is <code>a + b</code>?</p>
<div class="graphie" id="graph">
graphInit({
range: 11,
scale: 20,
tickStep: 1,
labelStep: 1,
});
label([ 11, 1], "Re", "left");
label([ 0.5, 10], "Im", "right");
line([0, 0], [REAL1, COMPLEX1], { stroke: BLUE, arrows: "->" });
line([0, 0], [REAL2, COMPLEX2], { stroke: GREEN, arrows: "->" });
var AF = 1 + 0.8 / sqrt(REAL1 * REAL1 + COMPLEX1 * COMPLEX1);
label([AF * REAL1, AF * COMPLEX1], "a", { color: BLUE });
var BF = 1 + 0.8 / sqrt(REAL2 * REAL2 + COMPLEX2 * COMPLEX2);
label([BF * REAL2, BF * COMPLEX2], "b", { color: GREEN });
addMouseLayer();
graph.guessPoint = addMovablePoint({
constraints: {},
snapX: 0.5,
snapY: 0.5,
});
</div>
<div class="solution" data-type="custom">
<div class="instruction">
Drag the orange point to plot your answer.
</div>
<div class="guess">graph.guessPoint.coord</div>
<div class="validator-function">
if (guess[0] === ANSWER[0] && guess[1] === ANSWER[1]) {
return true;
} else {
return false;
}
</div>
<div class="show-guess">
graph.guessPoint.setCoord(guess);
</div>
</div>
<div class="problems">
<div id="complex-addition">
<div class="vars">
<var id="ANSWER">[REAL1 + REAL2, COMPLEX1 + COMPLEX2]</var>
</div>
<div class="hints">
<div>
<p>Sum the real and imaginary components separately.</p>
<p><code>
\qquad a + b =
(\purple{<var>REAL1</var>} + \pink{<var>coefficient(COMPLEX1)</var>i}) +
(\purple{<var>REAL2</var>} + \pink{<var>coefficient(COMPLEX2)</var>i})
</code></p>
</div>
<div>
<p><code>
\hphantom{a + b} =
\purple{(<var>REAL1</var> + <var>REAL2</var>)} +
\pink{(<var>COMPLEX1</var> + <var>COMPLEX2</var>)i}
</code></p>
<div class="graphie" data-update="graph">
line([REAL2, COMPLEX2], [REAL1 + REAL2, COMPLEX1 + COMPLEX2], { stroke: BLUE, arrows: "->" });
graph.guessPoint.toFront();
</div>
</div>
<div>
<p><code>
\hphantom{a + b} =
\purple{<var>REAL1 + REAL2</var>}
<span data-if="COMPLEX1 + COMPLEX2 >= 0">+</span>
\pink{<var>coefficient(COMPLEX1 + COMPLEX2)</var>i}
</code></p>
<div class="graphie" data-update="graph">
line([0, 0], [REAL1 + REAL2, COMPLEX1 + COMPLEX2], { stroke: ORANGE, arrows: "->" });
graph.guessPoint.toFront();
graph.guessPoint.moveTo(REAL1 + REAL2, COMPLEX1 + COMPLEX2);
</div>
</div>
</div>
</div>
<div id="complex-subtraction">
<div class="vars">
<var id="ANSWER">[REAL1 - REAL2, COMPLEX1 - COMPLEX2]</var>
</div>
<p class="question">What is <code>a - b</code>?</p>
<div class="hints">
<div>
<p>Subtract the real and imaginary components separately.</p>
<p><code>
\qquad a + b =
(\purple{<var>REAL1</var>} + \pink{<var>coefficient(COMPLEX1)</var>i}) -
(\purple{<var>REAL2</var>} + \pink{<var>coefficient(COMPLEX2)</var>i})
</code></p>
</div>
<div>
<p><code>
\hphantom{a + b} =
\purple{(<var>REAL1</var> - <var>REAL2</var>)} +
\pink{(<var>COMPLEX1</var> - <var>COMPLEX2</var>)i}
</code></p>
<div class="graphie" data-update="graph">
line([REAL1, COMPLEX1], [REAL1 - REAL2, COMPLEX1 - COMPLEX2], { stroke: GREEN, arrows: "->" });
graph.guessPoint.toFront();
</div>
</div>
<div>
<p><code>
\hphantom{a + b} =
\purple{<var>REAL1 - REAL2</var>}
<span data-if="COMPLEX1 - COMPLEX2 >= 0">+</span>
\pink{<var>coefficient(COMPLEX1 - COMPLEX2)</var>i}
</code></p>
<div class="graphie" data-update="graph">
line([0, 0], [REAL1 - REAL2, COMPLEX1 - COMPLEX2], { stroke: ORANGE, arrows: "->" });
graph.guessPoint.toFront();
graph.guessPoint.moveTo(REAL1 - REAL2, COMPLEX1 - COMPLEX2);
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>