Skip to content
Newer
Older
100644 163 lines (149 sloc) 6.32 KB
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
1 <!DOCTYPE html>
007e23e Switch from KhanUtil.matrix* to kmatrix
Jack Toole authored Oct 29, 2013
2 <html data-require="math kmatrix matrix-input">
cde9e9f @jeresig Re-run the exercises through the updated cleaner.
jeresig authored Apr 24, 2013
3 <head>
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
5 <title>Multiplying a matrix by a vector</title>
ac1415e @spicyj Use requirejs for module loading
spicyj authored Mar 5, 2014
6 <script data-main="../local-only/main.js" src="../local-only/require.js"></script>
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
7 </head>
8 <body>
9 <div class="exercise">
10
11 <div class="vars">
12 <var id="DIM_3">DIM_2</var>
13 <var id="DIM_4">1</var>
14 <var id="MAT_1">makeMatrix(randRange(-2, 5, DIM_1, DIM_2))</var>
15 <var id="MAT_2">makeMatrix(randRange(-2, 5, DIM_3, DIM_4))</var>
16
17 <var id="SOLN_MAT">
18 matrixMult(MAT_1, MAT_2)
19 </var>
8fc85e7 Add exercises: Finding the determinant of a matrix, finding the inver…
Stephanie H. Chang authored Nov 17, 2012
20 <var id="PADDED_SOLN_MAT">matrixPad(SOLN_MAT, 3, 3)</var>
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
21
22 <var id="PRETTY_MAT_1_ID">"\\textbf " + randFromArray("ABCDEF")</var>
23 <var id="PRETTY_MAT_2_ID">"\\textbf " + randFromArray("vw")</var>
24
25 <!-- For generating hint matrices-->
26 <var id="ROW_COLORS">[GREEN, BLUE, GRAY]</var>
27 <var id="COL_COLORS">[ORANGE]</var>
28
29 <var id="FINAL_HINT_MAT">
30 makeMultHintMatrix(MAT_1, MAT_2, ROW_COLORS, COL_COLORS)
31 </var>
32
bd4e680 @csilvers Change from $._ and $.ngettext over to i18n._ and i18n.ngettext.
csilvers authored Oct 22, 2015
33 <var id="ROW">i18n._("row")</var>
34 <var id="COLUMN">i18n._("column")</var>
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
35 </div>
36
37 <div class="problem">
38 <p>
8fc85e7 Add exercises: Finding the determinant of a matrix, finding the inver…
Stephanie H. Chang authored Nov 18, 2012
39 <code><var>PRETTY_MAT_1_ID</var> = <var>printSimpleMatrix(MAT_1)</var></code>
40 </p>
41 <p>
42 <code><var>PRETTY_MAT_2_ID</var> = <var>printSimpleMatrix(MAT_2)</var></code>
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
43 </p>
44 </div>
45
46 <p class="question">
47 What is <code><var>PRETTY_MAT_1_ID + PRETTY_MAT_2_ID</var></code>?
48 </p>
49
50 <div class="hints">
51 <div>
52 <p>
53 Because <code><var>PRETTY_MAT_1_ID</var></code> has dimensions <code>(<var>DIM_1 + "\\times" + DIM_2</var>)</code> and <code><var>PRETTY_MAT_2_ID</var></code> has dimensions <code>(<var>DIM_3 + "\\times" + DIM_4</var>)</code>, the answer matrix will have dimensions <code>(<var>DIM_1 + "\\times" + DIM_4</var>)</code>.
54 </p>
55 <p>
56 <code>
57 <var>PRETTY_MAT_1_ID + PRETTY_MAT_2_ID</var>
58 =
59 <var>printColoredDimMatrix(MAT_1, ROW_COLORS, true)</var>
60 <var>printColoredDimMatrix(MAT_2, COL_COLORS, false)</var>
61 =
62 <var>
63 printSimpleMatrix(maskMatrix(FINAL_HINT_MAT, []))
64 </var>
65 </code>
66 </p>
67 </div>
68 <div>
69 <p>
70 To find the element at any row <code>i</code>, column <code>j</code> of the answer matrix, multiply the elements in row <code>i</code> of the first matrix, <code><var>PRETTY_MAT_1_ID</var></code>, with the corresponding elements in column <code>j</code> of the second matrix, <code><var>PRETTY_MAT_2_ID</var></code>, and add the products together.
71 </p>
72 </div>
73 <div>
74 <p>
cee8be0 @xymostech Don't use $._ inside of <var>s
xymostech authored Jun 11, 2013
75 So, to find the element at row 1, column 1 of the answer matrix, multiply the first element in <code><var>colorMarkup("\\text{" + ROW + " }1", ROW_COLORS[0])</var></code> of <code><var>PRETTY_MAT_1_ID</var></code> with the first element in <code><var>colorMarkup("\\text{" + COLUMN + " }1", COL_COLORS[0])</var></code> of <code><var>PRETTY_MAT_2_ID</var></code>, then multiply the second element in <code><var>colorMarkup("\\text{" + ROW + " }1", ROW_COLORS[0])</var></code> of <code><var>PRETTY_MAT_1_ID</var></code> with the second element in <code><var>colorMarkup("\\text{" + COLUMN + " }1", COL_COLORS[0])</var></code> of <code><var>PRETTY_MAT_2_ID</var></code>, and so on. Add the products together.
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
76 </p>
77 <p>
78 <code>
79 <var>
80 printSimpleMatrix(
81 maskMatrix(FINAL_HINT_MAT, [[1, 1]])
82 )
83 </var>
84 </code>
85 </p>
86 </div>
87 <div>
88 <p>
cee8be0 @xymostech Don't use $._ inside of <var>s
xymostech authored Jun 12, 2013
89 Likewise, to find the element at row 2, column 1 of the answer matrix, multiply the elements in <code><var>colorMarkup("\\text{" + ROW + " }2", ROW_COLORS[1])</var></code> of <code><var>PRETTY_MAT_1_ID</var></code> with the corresponding elements in <code><var>colorMarkup("\\text{" + COLUMN + " }1", COL_COLORS[0])</var></code> of <code><var>PRETTY_MAT_2_ID</var></code> and add the products together.
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
90 </p>
91 <p>
92 <code>
93 <var>
94 printSimpleMatrix(
95 maskMatrix(FINAL_HINT_MAT, [[1, 1], [2, 1]])
96 )
97 </var>
98 </code>
99 </p>
100 </div>
101 <div>
102 <p>
103 Fill out the rest:
104 </p>
105 <p>
106 <code>
107 <var>
108 printSimpleMatrix(FINAL_HINT_MAT)
109 </var>
110 </code>
111 </p>
112 </div>
113 <div>
114 <p>After simplifying, we end up with:</p>
115 <div>
116 <code>
117 <var>printSimpleMatrix(SOLN_MAT)</var>
118 </code>
119 </div>
120 </div>
121 </div>
122
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
123 <div class="solution" data-type="multiple">
124 <div class="matrix-row" data-each="PADDED_SOLN_MAT as row">
8fc85e7 Add exercises: Finding the determinant of a matrix, finding the inver…
Stephanie H. Chang authored Nov 18, 2012
125 <span data-each="row as elem">
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
126 <span class="sol" data-forms="integer" data-if="elem !== ''">
8fc85e7 Add exercises: Finding the determinant of a matrix, finding the inver…
Stephanie H. Chang authored Nov 18, 2012
127 <var>elem</var>
128 </span>
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
129 <span class="sol" data-else="" data-type="text">
8fc85e7 Add exercises: Finding the determinant of a matrix, finding the inver…
Stephanie H. Chang authored Nov 18, 2012
130 <var>elem</var>
131 </span>
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
132 </span>
8fc85e7 Add exercises: Finding the determinant of a matrix, finding the inver…
Stephanie H. Chang authored Nov 18, 2012
133 </div>
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
134 </div>
135
136 <div class="problems">
137
138 <!-- 2x1 solution dimensions -->
139 <div id="2x2-2x1">
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
140 <div class="vars" data-apply="prependVars">
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
141 <var id="DIM_1">2</var>
142 <var id="DIM_2">2</var>
143 </div>
144 </div>
145 <div id="2x3-3x1">
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
146 <div class="vars" data-apply="prependVars">
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
147 <var id="DIM_1">2</var>
148 <var id="DIM_2">3</var>
149 </div>
150 </div>
151
152 <!-- 3x1 solution dimensions -->
153 <div id="3x2-2x1">
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
154 <div class="vars" data-apply="prependVars">
9454903 Add exercises: Multiplying a matrix with a vector, multiplying a matr…
Stephanie H. Chang authored Oct 22, 2012
155 <var id="DIM_1">3</var>
156 <var id="DIM_2">2</var>
157 </div>
158 </div>
159 </div>
160 </div>
cde9e9f @jeresig Re-run the exercises through the updated cleaner.
jeresig authored Apr 24, 2013
161 </body>
162 </html>
Something went wrong with that request. Please try again.