Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

feat(linear-algebra): Unit 5 begins: chapters 35-37; mmT for the transpose

yzr4ffb6d24ab0c
diff --git a/site/linear-algebra/ch35/audio/en/cols.mp3 b/site/linear-algebra/ch35/audio/en/cols.mp3
new file mode 100644
index 0000000..fd1372b
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/cols.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/diag.mp3 b/site/linear-algebra/ch35/audio/en/diag.mp3
new file mode 100644
index 0000000..fd2ed4c
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/diag.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/entry.mp3 b/site/linear-algebra/ch35/audio/en/entry.mp3
new file mode 100644
index 0000000..25c49d3
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/entry.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/final1.mp3 b/site/linear-algebra/ch35/audio/en/final1.mp3
new file mode 100644
index 0000000..daddc98
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/final1.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/final2.mp3 b/site/linear-algebra/ch35/audio/en/final2.mp3
new file mode 100644
index 0000000..d56d097
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/final2.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/final3.mp3 b/site/linear-algebra/ch35/audio/en/final3.mp3
new file mode 100644
index 0000000..07ad4f2
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/final3.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/final4.mp3 b/site/linear-algebra/ch35/audio/en/final4.mp3
new file mode 100644
index 0000000..0c78964
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/final4.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/finish.mp3 b/site/linear-algebra/ch35/audio/en/finish.mp3
new file mode 100644
index 0000000..475b078
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/finish.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/flip.mp3 b/site/linear-algebra/ch35/audio/en/flip.mp3
new file mode 100644
index 0000000..4d2f15a
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/flip.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/intro.mp3 b/site/linear-algebra/ch35/audio/en/intro.mp3
new file mode 100644
index 0000000..58cff78
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/intro.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/live.mp3 b/site/linear-algebra/ch35/audio/en/live.mp3
new file mode 100644
index 0000000..56f8f53
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/live.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/order.mp3 b/site/linear-algebra/ch35/audio/en/order.mp3
new file mode 100644
index 0000000..578c2b3
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/order.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/plane.mp3 b/site/linear-algebra/ch35/audio/en/plane.mp3
new file mode 100644
index 0000000..6187b47
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/plane.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/play.mp3 b/site/linear-algebra/ch35/audio/en/play.mp3
new file mode 100644
index 0000000..5600b82
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/play.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/q1.mp3 b/site/linear-algebra/ch35/audio/en/q1.mp3
new file mode 100644
index 0000000..e361bb4
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/q1.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/q2.mp3 b/site/linear-algebra/ch35/audio/en/q2.mp3
new file mode 100644
index 0000000..7ce712f
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/q2.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/q3.mp3 b/site/linear-algebra/ch35/audio/en/q3.mp3
new file mode 100644
index 0000000..18893f7
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/q3.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/recall.mp3 b/site/linear-algebra/ch35/audio/en/recall.mp3
new file mode 100644
index 0000000..8e10b59
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/recall.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/sizes.mp3 b/site/linear-algebra/ch35/audio/en/sizes.mp3
new file mode 100644
index 0000000..1c7d405
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/sizes.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/timings.js b/site/linear-algebra/ch35/audio/en/timings.js
new file mode 100644
index 0000000..603089c
--- /dev/null
+++ b/site/linear-algebra/ch35/audio/en/timings.js
@@ -0,0 +1,798 @@
+window.TIMINGS = {
+ "intro": {
+ "dur": 12.216,
+ "marks": {
+ "sub": 2.904,
+ "move": 4.297
+ },
+ "cues": [
+ [
+ 0.104,
+ "Unit five, chapter thirty-five."
+ ],
+ [
+ 2.904,
+ "The transpose."
+ ],
+ [
+ 4.297,
+ "Take the rows of a matrix and stand them up as columns."
+ ],
+ [
+ 8.151,
+ "That is the whole move, and this chapter looks at it slowly."
+ ]
+ ]
+ },
+ "recall": {
+ "dur": 31.104,
+ "marks": {
+ "A": 1.81,
+ "rows": 3.529,
+ "r1": 5.195,
+ "r2": 7.656,
+ "cols": 10.078,
+ "c1": 11.536,
+ "c2": 12.539,
+ "c3": 13.893,
+ "size": 15.417,
+ "last": 20.013
+ },
+ "cues": [
+ [
+ 0.156,
+ "First, the words we need."
+ ],
+ [
+ 1.81,
+ "Here is a matrix A."
+ ],
+ [
+ 3.529,
+ "Rows run across."
+ ],
+ [
+ 5.195,
+ "Row one is one, two, three."
+ ],
+ [
+ 7.656,
+ "Row two is four, five, six."
+ ],
+ [
+ 10.078,
+ "Columns run down: one and four, two and five, three and six."
+ ],
+ [
+ 15.417,
+ "So A is two by three: rows first, then columns."
+ ],
+ [
+ 20.013,
+ "In chapter thirty-four we flipped a permutation matrix across its diagonal, and gave the result a name: the transpose."
+ ],
+ [
+ 28.685,
+ "Now we do it for any matrix."
+ ]
+ ]
+ },
+ "flip": {
+ "dur": 23.112,
+ "marks": {
+ "r1": 1.602,
+ "c1": 4.154,
+ "r2": 7.904,
+ "c2": 9.766,
+ "name": 11.38,
+ "size": 16.211
+ },
+ "cues": [
+ [
+ 0.117,
+ "Here is the rule."
+ ],
+ [
+ 1.602,
+ "Take row one of A: one, two, three."
+ ],
+ [
+ 4.154,
+ "Stand it up, and it becomes column one of a new matrix."
+ ],
+ [
+ 7.904,
+ "Row two, four, five, six, becomes column two."
+ ],
+ [
+ 11.38,
+ "The new matrix is called A transpose, written A with a small T up high."
+ ],
+ [
+ 16.211,
+ "A was two by three."
+ ],
+ [
+ 17.708,
+ "A transpose is three by two."
+ ],
+ [
+ 20.156,
+ "The two numbers of the size swap places too."
+ ]
+ ]
+ },
+ "cols": {
+ "dur": 24.432,
+ "marks": {
+ "col1": 3.49,
+ "row1": 5.938,
+ "col2": 9.232,
+ "row2": 12.253,
+ "col3": 13.503,
+ "row3": 16.549,
+ "same": 17.839
+ },
+ "cues": [
+ [
+ 0.091,
+ "Now read the same two matrices the other way."
+ ],
+ [
+ 3.49,
+ "Column one of A is one and four."
+ ],
+ [
+ 5.938,
+ "In A transpose, one and four are row one."
+ ],
+ [
+ 9.232,
+ "Column two of A, two and five, is row two."
+ ],
+ [
+ 13.503,
+ "And column three, three and six, is row three."
+ ],
+ [
+ 17.839,
+ "Rows become columns, and columns become rows."
+ ],
+ [
+ 21.549,
+ "It is one move, seen from both sides."
+ ]
+ ]
+ },
+ "entry": {
+ "dur": 30.312,
+ "marks": {
+ "pick": 2.982,
+ "from": 7.917,
+ "two": 11.589,
+ "from2": 16.901,
+ "rule": 20.312,
+ "swap": 26.927
+ },
+ "cues": [
+ [
+ 0.091,
+ "Every single number moves by the same rule."
+ ],
+ [
+ 2.982,
+ "Look at the four in A transpose."
+ ],
+ [
+ 5.443,
+ "It sits in row one, column two."
+ ],
+ [
+ 7.917,
+ "Where did it come from?"
+ ],
+ [
+ 9.128,
+ "From row two, column one of A."
+ ],
+ [
+ 11.589,
+ "Another one: the three in A transpose sits in row three, column one."
+ ],
+ [
+ 16.901,
+ "It came from row one, column three of A."
+ ],
+ [
+ 20.312,
+ "So the number in row i, column j of A transpose is the number in row j, column i of A."
+ ],
+ [
+ 26.927,
+ "Swap the two numbers of the address, and you have found it."
+ ]
+ ]
+ },
+ "diag": {
+ "dur": 41.952,
+ "marks": {
+ "sq": 3.099,
+ "diag": 9.766,
+ "stay": 14.883,
+ "pair1": 25.195,
+ "pair2": 32.161,
+ "pair3": 34.232,
+ "mirror": 36.38
+ },
+ "cues": [
+ [
+ 0.091,
+ "Now a square matrix, three by three."
+ ],
+ [
+ 3.099,
+ "Its rows are one, two, seven; three, four, five; six, eight, nine."
+ ],
+ [
+ 9.766,
+ "Draw the line from the top left corner to the bottom right."
+ ],
+ [
+ 13.086,
+ "This is the main diagonal."
+ ],
+ [
+ 14.883,
+ "The numbers on it, one, four and nine, have addresses like row two, column two."
+ ],
+ [
+ 20.56,
+ "Swapping the two numbers changes nothing, so they stay where they are."
+ ],
+ [
+ 25.195,
+ "Every other number jumps across the diagonal to its mirror spot."
+ ],
+ [
+ 29.57,
+ "The two and the three trade places."
+ ],
+ [
+ 32.161,
+ "The seven and the six trade."
+ ],
+ [
+ 34.232,
+ "The five and the eight trade."
+ ],
+ [
+ 36.38,
+ "So for a square matrix, the transpose is a mirror image across the diagonal."
+ ]
+ ]
+ },
+ "q1": {
+ "dur": 4.032,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.12,
+ "Write down A transpose, one row at a time."
+ ]
+ ]
+ },
+ "twice": {
+ "dur": 37.464,
+ "marks": {
+ "again": 2.773,
+ "back": 8.438,
+ "rule": 14.766,
+ "vec": 17.956,
+ "col": 22.148,
+ "row": 27.318,
+ "name": 33.711
+ },
+ "cues": [
+ [
+ 0.104,
+ "What happens if we transpose twice?"
+ ],
+ [
+ 2.773,
+ "Start from A, two by three."
+ ],
+ [
+ 5.104,
+ "Flip it: A transpose, three by two."
+ ],
+ [
+ 8.438,
+ "Flip that again."
+ ],
+ [
+ 9.466,
+ "Rows become columns once more, and we are back to A, two by three."
+ ],
+ [
+ 14.766,
+ "A transpose, transposed, is A again."
+ ],
+ [
+ 17.956,
+ "A column vector is a matrix too, with just one column."
+ ],
+ [
+ 22.148,
+ "Here x is one, two, three, standing up: three by one."
+ ],
+ [
+ 27.318,
+ "Its transpose is the same three numbers lying down, in one row: one by three."
+ ],
+ [
+ 33.711,
+ "From now on, this is how we write a row: x transpose."
+ ]
+ ]
+ },
+ "plane": {
+ "dur": 56.496,
+ "marks": {
+ "A": 1.159,
+ "cols": 6.875,
+ "rows": 16.771,
+ "these": 25.195,
+ "change": 28.802,
+ "both": 33.685,
+ "diag": 41.055,
+ "d2": 44.023,
+ "same": 49.948
+ },
+ "cues": [
+ [
+ 0.091,
+ "Now a picture."
+ ],
+ [
+ 1.159,
+ "Take a two by two matrix A: two, one; minus one, three."
+ ],
+ [
+ 6.875,
+ "Chapter nine drew its columns as arrows."
+ ],
+ [
+ 9.831,
+ "Column one goes to two, minus one, in green."
+ ],
+ [
+ 13.581,
+ "Column two goes to one, three, in violet."
+ ],
+ [
+ 16.771,
+ "Now draw its rows as arrows too, dashed."
+ ],
+ [
+ 19.688,
+ "Row one goes to two, one, in blue."
+ ],
+ [
+ 21.927,
+ "Row two goes to minus one, three, in coral."
+ ],
+ [
+ 25.195,
+ "These dashed arrows are the columns of A transpose."
+ ],
+ [
+ 28.802,
+ "Change one number, the one in row one, column two, from one to three."
+ ],
+ [
+ 33.685,
+ "That number sits in one column and in one row, so two arrows move: column two, and row one."
+ ],
+ [
+ 41.055,
+ "Now change the number in the corner, from two to four."
+ ],
+ [
+ 44.023,
+ "It is on the diagonal, so column one and row one both start with it, and both move."
+ ],
+ [
+ 49.948,
+ "One set of numbers, two sets of arrows: the columns of A, and the columns of A transpose."
+ ]
+ ]
+ },
+ "q2": {
+ "dur": 3.888,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Your turn."
+ ],
+ [
+ 1.003,
+ "Move the blue dashed arrow onto the target."
+ ]
+ ]
+ },
+ "order": {
+ "dur": 53.232,
+ "marks": {
+ "ab": 10.13,
+ "abc": 17.135,
+ "flip": 20.56,
+ "guess": 25.443,
+ "wrong": 32.5,
+ "swap": 36.901,
+ "right": 41.289,
+ "match": 43.906,
+ "rule": 45.208
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now products."
+ ],
+ [
+ 1.406,
+ "Chapter twenty-five showed that order matters: A times B is usually not B times A."
+ ],
+ [
+ 7.773,
+ "So what is the transpose of A B?"
+ ],
+ [
+ 10.13,
+ "Take A: one, two; zero, one."
+ ],
+ [
+ 13.216,
+ "And B: one, zero; three, one."
+ ],
+ [
+ 17.135,
+ "A B is seven, two; three, one."
+ ],
+ [
+ 20.56,
+ "Flip it."
+ ],
+ [
+ 21.315,
+ "A B transpose is seven, three; two, one."
+ ],
+ [
+ 25.443,
+ "A first guess: transpose each one, and multiply, A transpose times B transpose."
+ ],
+ [
+ 32.5,
+ "That gives one, three; two, seven."
+ ],
+ [
+ 35.768,
+ "Not the same."
+ ],
+ [
+ 36.901,
+ "Now swap the order: B transpose times A transpose."
+ ],
+ [
+ 41.289,
+ "Seven, three; two, one."
+ ],
+ [
+ 43.906,
+ "That matches."
+ ],
+ [
+ 45.208,
+ "The transpose of A B is B transpose times A transpose."
+ ],
+ [
+ 50.534,
+ "Flip each one, and reverse the order."
+ ]
+ ]
+ },
+ "live": {
+ "dur": 18.36,
+ "marks": {
+ "go": 2.37,
+ "again": 11.003,
+ "wrong": 13.776
+ },
+ "cues": [
+ [
+ 0.117,
+ "Here is the rule at work."
+ ],
+ [
+ 2.37,
+ "Change a number of A."
+ ],
+ [
+ 3.906,
+ "A B changes, its flip changes, and B transpose A transpose changes with it."
+ ],
+ [
+ 9.753,
+ "They stay equal."
+ ],
+ [
+ 11.003,
+ "Change a number of B."
+ ],
+ [
+ 12.448,
+ "Still equal."
+ ],
+ [
+ 13.776,
+ "The guess in the wrong order, A transpose B transpose, does not keep up."
+ ]
+ ]
+ },
+ "why": {
+ "dur": 39.912,
+ "marks": {
+ "ent": 2.969,
+ "ab": 9.232,
+ "ba": 15.286,
+ "same": 23.906,
+ "sum": 30.768,
+ "every": 35.859
+ },
+ "cues": [
+ [
+ 0.104,
+ "Why does the order turn around?"
+ ],
+ [
+ 1.81,
+ "Look at one number."
+ ],
+ [
+ 2.969,
+ "Row one, column two of A B transpose is row two, column one of A B: three."
+ ],
+ [
+ 9.232,
+ "That is row two of A times column one of B: zero times one, plus one times three."
+ ],
+ [
+ 15.286,
+ "In B transpose A transpose, the same spot is row one of B transpose, times column two of A transpose."
+ ],
+ [
+ 23.906,
+ "But row one of B transpose is column one of B."
+ ],
+ [
+ 27.174,
+ "And column two of A transpose is row two of A."
+ ],
+ [
+ 30.768,
+ "The same numbers, multiplied in pairs and added: three again."
+ ],
+ [
+ 35.859,
+ "Every spot works this way, so the two matrices are equal."
+ ]
+ ]
+ },
+ "sizes": {
+ "dur": 45.888,
+ "marks": {
+ "ex": 2.253,
+ "ab": 5.716,
+ "t": 13.294,
+ "wrongs": 19.102,
+ "rights": 26.042,
+ "nums": 33.958,
+ "abt": 37.526,
+ "match": 44.857
+ },
+ "cues": [
+ [
+ 0.104,
+ "The sizes tell the same story."
+ ],
+ [
+ 2.253,
+ "Take A two by three, and B three by two."
+ ],
+ [
+ 5.716,
+ "A B fits: the inside numbers, three and three, match, and A B is two by two."
+ ],
+ [
+ 13.294,
+ "Now A transpose is three by two, and B transpose is two by three."
+ ],
+ [
+ 19.102,
+ "A transpose times B transpose would be three by three: far too big for the flip of a two by two."
+ ],
+ [
+ 26.042,
+ "B transpose times A transpose is two by three, times three by two: two by two, the right size."
+ ],
+ [
+ 33.958,
+ "Work it out: one, two; seven, three."
+ ],
+ [
+ 37.526,
+ "And A B was one, seven; two, three."
+ ],
+ [
+ 41.458,
+ "Flipped, it is one, two; seven, three."
+ ],
+ [
+ 44.857,
+ "They match."
+ ]
+ ]
+ },
+ "q3": {
+ "dur": 3.768,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.12,
+ "Which one is A B transpose?"
+ ]
+ ]
+ },
+ "wrap": {
+ "dur": 29.688,
+ "marks": {
+ "w1": 1.042,
+ "w2": 7.409,
+ "w3": 17.422,
+ "w4": 20.586,
+ "end": 28.359
+ },
+ "cues": [
+ [
+ 0.104,
+ "Let's sum up."
+ ],
+ [
+ 1.042,
+ "The rows of A become the columns of A transpose, so an m by n matrix becomes n by m."
+ ],
+ [
+ 7.409,
+ "The number in row i, column j of A transpose is the number in row j, column i of A."
+ ],
+ [
+ 13.997,
+ "A square matrix flips across its diagonal."
+ ],
+ [
+ 17.422,
+ "Transpose twice, and you are back where you started."
+ ],
+ [
+ 20.586,
+ "And the transpose of A B is B transpose times A transpose: flip each one, and reverse the order."
+ ],
+ [
+ 28.359,
+ "Now practice."
+ ]
+ ]
+ },
+ "final1": {
+ "dur": 3.6,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Chapter practice."
+ ],
+ [
+ 1.536,
+ "Write each transpose."
+ ]
+ ]
+ },
+ "final2": {
+ "dur": 2.808,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Set two."
+ ],
+ [
+ 1.081,
+ "Sizes and addresses."
+ ]
+ ]
+ },
+ "final3": {
+ "dur": 2.952,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Set three."
+ ],
+ [
+ 1.146,
+ "Transposes of products."
+ ]
+ ]
+ },
+ "final4": {
+ "dur": 3.624,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Last set."
+ ],
+ [
+ 1.185,
+ "Build the matrix with your own hands."
+ ]
+ ]
+ },
+ "play": {
+ "dur": 12.096,
+ "marks": {
+ "go": 3.711
+ },
+ "cues": [
+ [
+ 0.104,
+ "Playground."
+ ],
+ [
+ 1.068,
+ "Nothing here is marked right or wrong."
+ ],
+ [
+ 3.711,
+ "Change any number of A or of A transpose, change the size, or drag the arrows, and watch the other side follow."
+ ]
+ ]
+ },
+ "finish": {
+ "dur": 9.6,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Well done."
+ ],
+ [
+ 1.081,
+ "That's the end of chapter thirty-five, the transpose."
+ ],
+ [
+ 4.753,
+ "Next: symmetric matrices, the ones a flip does not change at all."
+ ]
+ ]
+ }
+};
diff --git a/site/linear-algebra/ch35/audio/en/twice.mp3 b/site/linear-algebra/ch35/audio/en/twice.mp3
new file mode 100644
index 0000000..f20a0dd
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/twice.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/why.mp3 b/site/linear-algebra/ch35/audio/en/why.mp3
new file mode 100644
index 0000000..5e53545
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/why.mp3 differ
diff --git a/site/linear-algebra/ch35/audio/en/wrap.mp3 b/site/linear-algebra/ch35/audio/en/wrap.mp3
new file mode 100644
index 0000000..bb69b9c
Binary files /dev/null and b/site/linear-algebra/ch35/audio/en/wrap.mp3 differ
diff --git a/site/linear-algebra/ch35/index.html b/site/linear-algebra/ch35/index.html
new file mode 100644
index 0000000..53a9688
--- /dev/null
+++ b/site/linear-algebra/ch35/index.html
@@ -0,0 +1,486 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>The Transpose</title>
+<link rel="stylesheet" href="../lib/engine.css">
+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->
+</head>
+<body>
+<script src="../lib/engine.js"></script>
+<script src="../lib/math.js"></script>
+<script src="../lib/mm.js"></script>
+<script src="../lib/play.js"></script>
+<script src="audio/en/timings.js"></script>
+<script>
+'use strict';
+const CHAPTER = { number: 35, title: 'The Transpose', minutes: 11, language: 'en', next: '../ch36/' };
+
+/* ---------- chapter helpers ---------- */
+const A1 = [[1, 2, 3], [4, 5, 6]]; // the first example: 2 × 3, Aᵀ = [1 4; 2 5; 3 6]
+const SQ = [[1, 2, 7], [3, 4, 5], [6, 8, 9]]; // square: the mirror across the diagonal
+const PA = [[2, 1], [-1, 3]]; // the plane: columns (2, −1), (1, 3); rows (2, 1), (−1, 3)
+const OA = [[1, 2], [0, 1]], OB = [[1, 0], [3, 1]]; // (AB)ᵀ: AB = [7 2; 3 1], BᵀAᵀ = [7 3; 2 1], AᵀBᵀ = [1 3; 2 7]
+const ZA = [[1, 0, 2], [0, 1, 1]], ZB = [[1, 1], [2, 0], [0, 3]]; // sizes: AB = [1 7; 2 3], BᵀAᵀ = [1 2; 7 3]
+const tr = M_ => M_[0].map((_, j) => M_.map(r => r[j]));
+const mul = (X, Y) => X.map(r => Y[0].map((_, j) => r.reduce((t, v, k) => t + v * Y[k][j], 0)));
+const AT = [140, 300]; // A and Aᵀ, large, on the left; notes on the right from x 900
+const CARD = { x: 40, y: 450, w: 740, cls: 'side' };
+const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
+const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
+const title = (p, str) => text(p, str, 60, 110, .2, { size: 40, weight: 600 });
+// A chalk ring around a box, drawn on at t0.
+const ring = (p, x, y, w, h, t0, color = COL.chalk) => { const r = path(p, `M${x + 14} ${y}H${x + w - 14}Q${x + w} ${y} ${x + w} ${y + 14}V${y + h - 14}Q${x + w} ${y + h} ${x + w - 14} ${y + h}H${x + 14}Q${x} ${y + h} ${x} ${y + h - 14}V${y + 14}Q${x} ${y} ${x + 14} ${y}Z`, { stroke: color, 'stroke-width': 3, fill: 'none' }, { d: 0 }); draw(r, t0, .6); return r; };
+// A curved arrow from (x1, y1) to (x2, y2), bulging by `bend`, drawn on at t0.
+const bow = (p, x1, y1, x2, y2, t0, { bend = -60, color = COL.chalk, w = 3 } = {}) => {
+ const mx = (x1 + x2) / 2, my = (y1 + y2) / 2, L = Math.hypot(x2 - x1, y2 - y1), nx = -(y2 - y1) / L, ny = (x2 - x1) / L;
+ const cx = mx + nx * bend, cy = my + ny * bend, tx = x2 - cx, ty = y2 - cy, tl = Math.hypot(tx, ty), ux = tx / tl, uy = ty / tl;
+ const g = G(p, {});
+ draw(path(g, `M${x1} ${y1}Q${cx} ${cy} ${x2} ${y2}`, { stroke: color, 'stroke-width': w, fill: 'none' }, { d: 0 }), t0, .6);
+ const hd = path(g, `M${x2 - 14 * ux - 8 * uy} ${y2 - 14 * uy + 8 * ux}L${x2} ${y2}L${x2 - 14 * ux + 8 * uy} ${y2 - 14 * uy - 8 * ux}`, { stroke: color, 'stroke-width': w, fill: 'none', o: 0 });
+ show(hd, t0 + .5, .2);
+ return g;
+};
+// The size label under a matrix of mmT / mm: a ring around "m × n".
+const sizeRing = (p, Mx, y, t0) => ring(p, Mx.x + Mx.W / 2 - 58, y - 32, 116, 44, t0);
+// Thicken an arrow of mmT's plane for a moment.
+const thick = (tp, t0) => { const w = tp.dash ? 4 : 6; tw(tp.shaft, { 'a_stroke-width': w + 5 }, t0, .3); tw(tp.shaft, { 'a_stroke-width': w }, t0 + 1.2, .6); };
+// mmT's plane arrows hidden, to be shown on their words
+const hideArrows = T_ => [...T_.arrows.cols, ...T_.arrows.rows].forEach(tp => put(tp.ag, { o: 0 }));
+// The transpose of a product shown beside it: a hidden mmT whose A sits exactly on P_'s product, its Aᵀ beside.
+const flipOf = (p, P_, { size, rh, names = ['AB', '(AB)ᵀ'], gap = 90, hideT = true, t0 = .1 } = {}) => {
+ const L = P_.L;
+ const TT = mmT(p, { A: P_.C(), at: [L.c.x, L.c.ry(0)], size, cw: L.c.c, rh, gap, names, tint: null, sizes: false, hideT, t0 });
+ put(TT.L.a.g, { o: 0 });
+ P_.onChange(() => { const c = P_.C(); if (c) TT.set(Object.fromEntries(c.flatMap((r, i) => r.map((v, j) => [`a${i}${j}`, v])))); });
+ return TT;
+};
+const target = (P2, [x, y], into, t0 = .3) => {
+ const g = G(into, { x: P2.PX(x), y: P2.PY(y), o: 0 });
+ mk('circle', { r: 18, fill: 'none', stroke: COL.task, 'stroke-width': 3, 'stroke-dasharray': '5 5' }, g);
+ T(g, `target (${num(x)}, ${num(y)})`, { x: 24, y: 40, size: 22, fill: COL.task, font: MATH });
+ show(g, t0, .4);
+ return g;
+};
+const matEl = rows => mmEl(rows, { size: 22 });
+
+/* ---------- practice data (every answer read off twice: by rows of A and by columns of Aᵀ) ---------- */
+const TRQ = [
+ { parts: [matEl([[2, -1], [0, 5]]), ' Aᵀ: row 1 = (', { box: '2' }, ', ', { box: '0' }, '), row 2 = (', { box: '-1' }, ', ', { box: '5' }, ')'],
+ why: 'Column 1 of A is (2, 0): that is row 1 of Aᵀ. Column 2 is (−1, 5).', hint: 'Row 1 of Aᵀ is column 1 of A: read down the first column.' },
+ { parts: [matEl([[1, 4, -3]]), ' Aᵀ is one column: (', { box: '1' }, ', ', { box: '4' }, ', ', { box: '-3' }, ') standing up'],
+ why: 'A row of three numbers stands up as a column of three: 1, 4, −3 from the top.', hint: 'The one row of A becomes the one column of Aᵀ, in the same order.' },
+ { parts: [matEl([[3, 1], [0, 2], [-4, 6]]), ' Aᵀ: row 1 = (', { box: '3' }, ', ', { box: '0' }, ', ', { box: '-4' }, '), row 2 = (', { box: '1' }, ', ', { box: '2' }, ', ', { box: '6' }, ')'],
+ why: 'A is 3 × 2, so Aᵀ is 2 × 3. Its rows are A’s columns: (3, 0, −4) and (1, 2, 6).', hint: 'Aᵀ has two rows: the two columns of A, read from the top down.' },
+ { parts: [matEl([[0, 7, 1], [2, 0, 0], [5, 3, 0]]), ' Aᵀ: row 2 = (', { box: '7' }, ', ', { box: '0' }, ', ', { box: '3' }, '), row 3 = (', { box: '1' }, ', ', { box: '0' }, ', ', { box: '0' }, ')'],
+ why: 'Row 2 of Aᵀ is column 2 of A: (7, 0, 3). Row 3 is column 3: (1, 0, 0).', hint: 'Row 2 of Aᵀ is column 2 of A, row 3 is column 3.' },
+];
+const SIZEQ = [
+ { parts: ['A is 4 × 2. Aᵀ is ', { box: '2' }, ' × ', { box: '4' }], why: 'Rows and columns trade: 4 rows of 2 become 2 rows of 4.', hint: 'The two numbers of the size swap places.' },
+ { parts: ['A is 1 × 5 (one row). Aᵀ is ', { box: '5' }, ' × ', { box: '1' }], why: 'One row of five numbers stands up as one column of five.', hint: 'The two numbers of the size swap places: a row becomes a column.' },
+ { parts: ['Row 3, column 1 of Aᵀ is the number in row ', { box: '1' }, ', column ', { box: '3' }, ' of A'], why: 'Swap the address: row 3, column 1 of Aᵀ is row 1, column 3 of A.', hint: 'Swap the two numbers of the address.' },
+ { parts: [matEl([[6, 2, 9], [1, 8, 4]]), ' row 3, column 2 of Aᵀ = ', { box: '4' }], why: 'It is row 2, column 3 of A: the 4.', hint: 'Swap the address: look in row 2, column 3 of A.' },
+ { parts: [matEl([[1, 2], [3, 4]]), ' (Aᵀ)ᵀ: row 1 = (', { box: '1' }, ', ', { box: '2' }, ')'], why: 'Two flips undo each other: (Aᵀ)ᵀ = A, so row 1 is (1, 2) again.', hint: 'Flip once: (1, 3) is row 1. Flip again: back to A.' },
+];
+const TFQ = [
+ { parts: ['The transpose of a 2 × 3 matrix is 3 × 2.'], ans: ['t'], why: 'Rows and columns trade, so the size numbers swap.' },
+ { parts: ['On a square matrix, the numbers on the main diagonal stay in place.'], ans: ['t'], why: 'Their address is row k, column k: swapping it changes nothing.' },
+ { parts: ['(AB)ᵀ = AᵀBᵀ for every A and B.'], ans: ['f'], why: 'The order turns around: (AB)ᵀ = BᵀAᵀ. Chapter example: AᵀBᵀ gave (1, 3), (2, 7), not (7, 3), (2, 1).' },
+ { parts: ['The transpose of a column is a row.'], ans: ['t'], why: 'n × 1 becomes 1 × n: the same numbers lying down.' },
+ { parts: ['(Aᵀ)ᵀ = A.'], ans: ['t'], why: 'Flip twice and every number is back in its place.' },
+ { parts: ['Iᵀ = I (the identity).'], ans: ['t'], why: 'Its 1s are on the diagonal and stay; every other number is 0, and a 0 lands on a 0.' },
+];
+const PRODQ = [
+ { parts: ['A = ', matEl([[1, 1], [0, 2]]), ', B = ', matEl([[3, 0], [1, 1]]), '. BᵀAᵀ: row 1 = (', { box: '4' }, ', ', { box: '2' }, '), row 2 = (', { box: '1' }, ', ', { box: '2' }, ')'],
+ why: 'AB = (4, 1), (2, 2). BᵀAᵀ = (AB)ᵀ = (4, 2), (1, 2). Check one: row 1 of Bᵀ (3, 1) times column 1 of Aᵀ (1, 1) = 3 + 1 = 4.', hint: 'Easiest: find AB first, then flip it. BᵀAᵀ is (AB)ᵀ.' },
+ { parts: ['A = ', matEl([[2, 0], [1, 3]]), ', x = (1, 2) as a column. xᵀAᵀ = (', { box: '2' }, ', ', { box: '7' }, ')'],
+ why: 'Ax = (2, 7) as a column. xᵀAᵀ = (Ax)ᵀ: the same numbers as a row.', hint: 'xᵀAᵀ is the transpose of Ax. Work out Ax, then lay it down as a row.' },
+ { parts: ['A is 2 × 3, B is 3 × 5. (AB)ᵀ is ', { box: '5' }, ' × ', { box: '2' }, ', Bᵀ is ', { box: '5' }, ' × ', { box: '3' }],
+ why: 'AB is 2 × 5, so (AB)ᵀ is 5 × 2. Bᵀ is 5 × 3, and BᵀAᵀ = (5 × 3)(3 × 2) = 5 × 2 agrees.', hint: 'Find the size of AB first (outside numbers), then swap. For Bᵀ, swap B’s size.' },
+];
+const HANDQ = [
+ { id: 'p-hand1', start: { mA: 2, nA: 2, a00: 0, a01: 0, a10: 0, a11: 0 }, prompt: ['Change A until Aᵀ = ', matEl([[1, 4], [-2, 0]]), '.'],
+ test: (v, T_) => v.mA === 2 && v.nA === 2 && T_.T(0, 0) === 1 && T_.T(0, 1) === 4 && T_.T(1, 0) === -2 && T_.T(1, 1) === 0,
+ why: 'A = (1, −2), (4, 0): its columns (1, 4) and (−2, 0) are the rows of Aᵀ.', hint: 'Row 1 of Aᵀ, (1, 4), must be column 1 of A. You can also type straight into Aᵀ.',
+ ans: { a00: 1, a01: -2, a10: 4, a11: 0 } },
+ { id: 'p-hand2', start: { mA: 2, nA: 2, a00: 1, a01: 0, a10: 0, a11: 1 }, prompt: ['Make column 2 of Aᵀ (the coral dashed arrow) end at (−3, 2). Drag it, or change numbers.'],
+ test: v => v.mA === 2 && v.nA === 2 && v.a10 === -3 && v.a11 === 2,
+ why: 'Column 2 of Aᵀ is row 2 of A: (−3, 2) across the bottom of A.', hint: v => v.a01 === -3 && v.a11 === 2 ? 'That moved the violet arrow, column 2 of A. The coral dashed one is row 2 of A: the bottom row.' : 'The coral dashed arrow is row 2 of A. Its numbers are the bottom row of A.',
+ ans: { a10: -3, a11: 2 } },
+ { id: 'p-hand3', start: { mA: 2, nA: 2, a00: 0, a01: 0, a10: 0, a11: 0 }, prompt: ['Change the size and the numbers of A so that Aᵀ is the row (1, 2, 3).'],
+ test: v => v.mA === 3 && v.nA === 1 && v.a00 === 1 && v.a10 === 2 && v.a20 === 3,
+ why: 'A must be the column (1, 2, 3): 3 × 1. Its transpose lies down as a row.', hint: v => v.mA === 1 && v.nA === 3 ? 'A is a row now, so Aᵀ is a column. Make A the column: 3 rows, 1 column.' : 'Aᵀ is 1 × 3, so A must be 3 × 1: three rows, one column. Change the size numbers under A.',
+ ans: { mA: 3, nA: 1, a00: 1, a10: 2, a20: 3 } },
+];
+
+/* ---------- beats ---------- */
+const BEATS = [
+ ['intro', 'The transpose', (m, D) => {
+ const g = G(scene, { o: 0, y: 24 });
+ T(g, 'Unit 5 · Transposes, permutations, spaces', { x: 800, y: 205, size: 24, fill: COL.faint, anchor: 'middle' });
+ T(g, 'Unit 5, Chapter 35', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });
+ T(g, 'The Transpose', { x: 800, y: 360, size: 88, weight: 600, anchor: 'middle' });
+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);
+ const r = text(scene, 'rows become columns', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });
+ const lg = G(scene, { o: 0 });
+ const T0 = mmT(lg, { A: A1, at: [586, 640], size: 36, cw: 56, rh: 52, gap: 100, hideT: true, sizes: false, t0: 0 });
+ show(lg, m('sub') + .6, .5);
+ T0.show('row', 0, m('move')); T0.show('row', 1, m('move') + 1.4); T0.show(null, null, m('move') + 3.2);
+ T0.fly(m('move') + .2, { by: 'rows', step: 1.4, dur: .9 });
+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);
+ }],
+
+ ['recall', 'Rows and columns', (m) => {
+ const p = S.p = panel(0);
+ title(p, 'Rows and columns, again');
+ const T_ = S.T = mmT(p, { A: A1, at: AT, size: 54, cw: 86, rh: 76, gap: 200, hideT: true, t0: m('A') - .4 });
+ put(T_.L.t.g, { o: 0 });
+ const a = T_.L.a;
+ [0, 1].forEach(i => text(p, `row ${i + 1}`, a.x - 16, a.ry(i) - 8, m(`r${i + 1}`), { size: 26, fill: MMT_ROW[i], anchor: 'end', weight: 600 }));
+ T_.show('row', 0, m('r1'), { side: 'a' }); T_.show('row', 1, m('r2'), { side: 'a' });
+ [0, 1, 2].forEach(j => { T_.show('col', j, m(`c${j + 1}`), { side: 'a' }); text(p, `col ${j + 1}`, a.cx(j), T_.L.bottom + 44, m(`c${j + 1}`), { size: 24, fill: COL.dim, anchor: 'middle', weight: 600 }); });
+ T_.show(null, null, m('size'));
+ const n = S.note = G(p, {});
+ hide(sizeRing(p, a, T_.L.bottom - 12, m('size')), m('last') - .3, .3);
+ const s1 = G(n, { o: 0 });
+ M(s1, ['2 × 3'], { x: 900, y: 300, size: 44, fill: COL.chalk });
+ T(s1, '2 rows, 3 columns: rows first', { x: 900, y: 350, size: 28, fill: COL.dim, weight: 600 });
+ show(s1, m('size') + .3, .4); hide(s1, m('last') - .3, .3);
+ // chapter 34: the permutation P and its flip
+ const P3 = [[0, 0, 1], [1, 0, 0], [0, 1, 0]], s2 = G(n, { o: 0 });
+ T(s2, 'chapter 34', { x: 900, y: 270, size: 26, fill: COL.dim, weight: 600 });
+ const TP = mmT(s2, { A: P3, at: [900, 350], size: 32, cw: 48, rh: 44, gap: 90, names: ['P', 'Pᵀ'], tint: null, sizes: false, hideT: true, t0: 0 });
+ TP.diag(m('last') + 2.2);
+ TP.fly(m('last') + 3, { by: 'rows', step: 1.2, dur: 1 });
+ TP.show('diag', null, m('last') + 7.4); TP.show(null, null, m('last') + 9);
+ T(s2, 'flipped across its diagonal', { x: 900, y: 520, size: 28, fill: COL.chalk, weight: 600 });
+ show(s2, m('last') + .2, .5);
+ }],
+
+ ['flip', 'Rows stand up as columns', (m) => {
+ const p = S.p, T_ = S.T, { a, t } = T_.L;
+ hide(S.note, .1, .4);
+ show(t.g, m('r1') + .3, .4);
+ T_.show('row', 0, m('r1')); T_.show('row', 1, m('r2'));
+ T_.fly(m('c1'), { by: (i, j) => (i ? m('c2') - m('c1') : 0) + j * .2, dur: 1.1 });
+ bow(p, a.x + a.W + 24, T_.L.midY + 10, t.x - 24, T_.L.midY + 10, m('c1') - .4, { bend: -50 });
+ T_.show(null, null, m('name'));
+ const n = S.note = G(p, {});
+ const nm = G(n, { o: 0 });
+ M(nm, ['Aᵀ'], { x: 900, y: 320, size: 54 });
+ T(nm, 'say: “A transpose”', { x: 900, y: 372, size: 28, fill: COL.dim, weight: 600 });
+ show(nm, m('name') + .2, .4);
+ sizeRing(p, a, T_.L.bottom - 12, m('size')); sizeRing(p, t, T_.L.bottom - 12, m('size') + .5);
+ const sz = G(n, { o: 0 });
+ M(sz, ['2 × 3 → 3 × 2'], { x: 900, y: 560, size: 40 });
+ T(sz, 'the size numbers swap too', { x: 900, y: 606, size: 28, fill: COL.dim, weight: 600 });
+ show(sz, m('size') + 1, .4);
+ }],
+
+ ['cols', 'Columns lie down as rows', (m) => {
+ const p = S.p, T_ = S.T, { t } = T_.L;
+ hide(S.note, .1, .4);
+ [0, 1, 2].forEach(j => {
+ T_.show('col', j, m(`col${j + 1}`), { side: 'a' });
+ T_.show('col', j, m(`row${j + 1}`));
+ text(p, `row ${j + 1}`, t.x + t.W + 16, t.ry(j) - 8, m(`row${j + 1}`), { size: 24, fill: COL.dim, weight: 600 });
+ });
+ T_.show(null, null, m('same') + 1.5);
+ const n = S.note = G(p, { o: 0 });
+ T(n, 'rows of A → columns of Aᵀ', { x: 960, y: 330, size: 32, weight: 600 });
+ T(n, 'columns of A → rows of Aᵀ', { x: 960, y: 384, size: 32, weight: 600 });
+ show(n, m('same'), .5);
+ }],
+
+ ['entry', 'One number at a time', (m) => {
+ const p = S.p, T_ = S.T, { a, t } = T_.L;
+ hide(S.note, .1, .4);
+ const n = S.note = G(p, {});
+ T_.show('cell', [1, 0], m('pick'), { side: 't' }); T_.show('cell', [1, 0], m('from'));
+ say(n, ['row 1, column 2 of Aᵀ: 4'], 960, 300, m('pick') + .3, { size: 32 });
+ say(n, ['= row 2, column 1 of A'], 960, 350, m('from') + .3, { size: 32 });
+ bow(n, a.cx(0) + 20, a.ry(1) + 20, t.cx(1) - 10, t.ry(0) + 22, m('from'), { bend: 90 });
+ T_.show('cell', [0, 2], m('two'), { side: 't' }); T_.show('cell', [0, 2], m('from2'));
+ say(n, ['row 3, column 1 of Aᵀ: 3'], 960, 440, m('two') + .3, { size: 32 });
+ say(n, ['= row 1, column 3 of A'], 960, 490, m('from2') + .3, { size: 32 });
+ bow(n, a.cx(2), a.ry(0) - 50, t.cx(0) - 20, t.ry(2) - 40, m('from2'), { bend: -70 });
+ T_.show(null, null, m('rule'));
+ const r = G(n, { o: 0 });
+ M(r, ['row i, column j of Aᵀ'], { x: 960, y: 610, size: 34, fill: COL.chalk });
+ M(r, ['= row j, column i of A'], { x: 960, y: 660, size: 34, fill: COL.chalk });
+ show(r, m('rule') + .2, .5);
+ text(n, 'swap the address', 960, 730, m('swap'), { size: 30, weight: 600 });
+ [[0, 1], [2, 1], [1, 1], [0, 0]].forEach(([i, j], k) => T_.show('cell', [i, j], m('rule') + 1 + k * 1.4));
+ T_.show(null, null, m('rule') + 6.6);
+ }],
+
+ ['diag', 'A square matrix: the mirror', (m) => {
+ const p = S.p = panel(0);
+ title(p, 'A square matrix: a mirror');
+ const T_ = S.T = mmT(p, { A: SQ, at: [140, 290], size: 54, cw: 86, rh: 76, gap: 200, hideT: true, t0: m('sq') - .5 });
+ put(T_.L.t.g, { o: 0 }); show(T_.L.t.g, m('diag') - .2, .4);
+ T_.diag(m('diag'));
+ const t0 = m('stay');
+ const when = (i, j) => i === j ? .5 + i * .35 : ({ '01': m('pair1'), '02': m('pair2'), '12': m('pair3') }[`${Math.min(i, j)}${Math.max(i, j)}`] - t0 + .4 + (i > j ? .25 : 0));
+ T_.fly(t0, { by: when, dur: 1.2, lift: 70 });
+ T_.show('diag', null, m('stay'));
+ [0, 1, 2].forEach(k => { T_.flash('a', [[k, k]], m('stay') + 3.2 + k * .9); T_.flash('t', [[k, k]], m('stay') + 6.4 + k * .5); });
+ [['pair1', [[0, 1], [1, 0]]], ['pair2', [[0, 2], [2, 0]]], ['pair3', [[1, 2], [2, 1]]]].forEach(([k, cs]) => { T_.flash('a', cs, m(k)); T_.flash('t', cs, m(k) + 1.4); });
+ T_.show(null, null, m('pair1'));
+ text(p, 'main diagonal', T_.L.a.x + T_.L.a.W + 14, T_.L.a.ry(2) + 40, m('diag') + .5, { size: 24, fill: COL.dim, weight: 600 });
+ const n = G(p, { o: 0 });
+ T(n, 'the diagonal stays;', { x: 1000, y: 360, size: 32, weight: 600 });
+ T(n, 'every other number', { x: 1000, y: 410, size: 32, weight: 600 });
+ T(n, 'jumps to its mirror spot', { x: 1000, y: 460, size: 32, weight: 600 });
+ show(n, m('mirror'), .5);
+ }],
+
+ ['q1', 'Quick check', () => {
+ const p = panel(0);
+ title(p, 'Quick check');
+ S.T = mmT(p, { A: [[1, 0, -2], [3, 4, 5]], at: [90, 235], size: 44, cw: 72, rh: 62, gap: 130, hideT: true });
+ }, { ask: done => quiz({ x: 40, y: 405, w: 740, cls: 'side' }, [{
+ id: 'c-rows', prompt: ['Write Aᵀ one row at a time.'],
+ build: blanks([
+ { parts: ['row 1 of Aᵀ = (', { box: '1' }, ', ', { box: '3' }, ')'], why: 'Row 1 of Aᵀ is column 1 of A: 1 and 3.', hint: 'Row 1 of Aᵀ is column 1 of A. Read down the first column of A.', fx: () => S.T.uncover([[0, 0], [0, 1]]) },
+ { parts: ['row 2 of Aᵀ = (', { box: '0' }, ', ', { box: '4' }, ')'], why: 'Column 2 of A: 0 and 4.', hint: 'Row 2 of Aᵀ is column 2 of A, read from the top.', fx: () => S.T.uncover([[1, 0], [1, 1]]) },
+ { parts: ['row 3 of Aᵀ = (', { box: '-2' }, ', ', { box: '5' }, ')'], why: 'Column 3 of A: −2 and 5. The minus sign travels with its number.', hint: 'Row 3 of Aᵀ is column 3 of A. Keep the sign of −2.', fx: () => S.T.uncover([[2, 0], [2, 1]]) },
+ ]),
+ }], done) }],
+
+ ['twice', 'Twice, and a row', (m) => {
+ const p = panel(0);
+ title(p, 'Transpose twice; a column lies down');
+ const T1 = mmT(p, { A: A1, at: [90, 270], size: 44, cw: 72, rh: 62, gap: 110, hideT: true, t0: .1 });
+ put(T1.L.t.g, { o: 0 }); show(T1.L.t.g, m('again') + 1.2, .3);
+ T1.fly(m('again') + 1.4, { by: 'rows', step: .8, dur: .9 });
+ const T2 = mmT(p, { A: tr(A1), at: [T1.L.t.x, 270], size: 44, cw: 72, rh: 62, gap: 110, names: ['Aᵀ', '(Aᵀ)ᵀ'], tint: 'cols', hideT: true, t0: .1 });
+ put(T2.L.a.g, { o: 0 }); put(T2.L.t.g, { o: 0 }); show(T2.L.t.g, m('back') - .2, .3);
+ T2.fly(m('back'), { by: 'rows', step: .6, dur: .9 });
+ bow(p, T1.L.a.x + T1.L.a.W + 14, T1.L.midY, T1.L.t.x - 14, T1.L.midY, m('again') + 1, { bend: -40 });
+ bow(p, T2.L.a.x + T2.L.a.W + 14, T2.L.midY, T2.L.t.x - 14, T2.L.midY, m('back') - .3, { bend: -40 });
+ const r = G(p, { o: 0 });
+ M(r, ['(Aᵀ)ᵀ = A'], { x: 1100, y: 330, size: 54 });
+ T(r, 'two flips undo each other', { x: 1100, y: 380, size: 28, fill: COL.dim, weight: 600 });
+ show(r, m('rule'), .5);
+ T1.flash('a', 'all', m('rule') + .3); T2.flash('t', 'all', m('rule') + .9);
+ const xg = G(p, { o: 0 }); show(xg, m('vec'), .4);
+ const X = mmT(xg, { A: [[1], [2], [3]], at: [90, 600], size: 40, cw: 64, rh: 54, gap: 110, names: ['x', 'xᵀ'], tint: null, hideT: true, t0: 0 });
+ put(X.L.t.g, { o: 0 }); show(X.L.t.g, m('row') - .2, .3);
+ X.fly(m('row'), { by: 'cells', step: .3, dur: .9 });
+ X.show('col', 0, m('col'), { side: 'a' }); X.show(null, null, m('row'));
+ const nm = G(p, { o: 0 });
+ M(nm, ['xᵀ = a row'], { x: 1100, y: 640, size: 44 });
+ T(nm, 'a column (3 × 1) lies down: 1 × 3', { x: 1100, y: 690, size: 28, fill: COL.dim, weight: 600 });
+ show(nm, m('name'), .5);
+ }],
+
+ ['plane', 'Rows as arrows', (m) => {
+ const p = panel(0);
+ title(p, 'The columns of Aᵀ are the rows of A');
+ const T_ = S.T = mmT(p, { A: PA, at: [90, 300], size: 50, cw: 80, rh: 72, gap: 150, plane: { cx: 1190, cy: 470, u: 44 }, t0: m('A') - .4 });
+ hideArrows(T_);
+ const { cols, rows } = T_.arrows;
+ cols.forEach((tp, j) => show(tp.ag, m('cols') + 1 + j * 2.6, .5));
+ rows.forEach((tp, i) => show(tp.ag, m('rows') + 1.4 + i * 2.6, .5));
+ T_.show('col', 0, m('cols') + 1, { side: 'a' }); T_.show('col', 1, m('cols') + 3.6, { side: 'a' });
+ T_.show('row', 0, m('rows') + 1.4, { side: 'a' }); T_.show('row', 1, m('rows') + 4, { side: 'a' });
+ cols.forEach((tp, j) => { thick(tp, m('cols') + 1.4 + j * 2.6); T_.flash('a', [[0, j], [1, j]], m('cols') + 1.4 + j * 2.6); });
+ rows.forEach((tp, i) => { thick(tp, m('rows') + 1.8 + i * 2.6); T_.flash('a', [[i, 0], [i, 1]], m('rows') + 1.8 + i * 2.6); });
+ T_.show('row', 0, m('these')); T_.show('row', 1, m('these') + 1.6); T_.show(null, null, m('change'));
+ rows.forEach((tp, i) => thick(tp, m('these') + i * 1.6));
+ const n = G(p, { o: 0 });
+ T(n, 'solid: columns of A', { x: 90, y: 520, size: 28, weight: 600 });
+ T(n, 'dashed: rows of A = columns of Aᵀ', { x: 90, y: 566, size: 28, weight: 600 });
+ show(n, m('these'), .5);
+ T_.to({ a01: 3 }, m('change') + 1.6, 1.4); T_.flash('a', [[0, 1]], m('change') + 1.6); T_.flash('t', [[1, 0]], m('change') + 1.6);
+ thick(cols[1], m('both') + 2.8); thick(rows[0], m('both') + 3.6);
+ T_.to({ a00: 4 }, m('diag') + .6, 1.4); T_.flash('a', [[0, 0]], m('diag') + .6); T_.flash('t', [[0, 0]], m('diag') + .6);
+ thick(cols[0], m('d2') + 1.6); thick(rows[0], m('d2') + 2.2);
+ text(p, 'one set of numbers, two sets of arrows', 90, 650, m('same'), { size: 28, weight: 600 });
+ T_.flash('a', 'all', m('same') + .8); [...cols, ...rows].forEach((tp, k) => thick(tp, m('same') + 2 + k * .5));
+ }],
+
+ ['q2', 'Your turn', () => {
+ const p = panel(0);
+ title(p, 'Your turn');
+ const T_ = S.T = mmT(p, { A: [[-2, 1], [2, 3]], at: [90, 290], size: 50, cw: 80, rh: 72, gap: 150, plane: { cx: 1190, cy: 470, u: 44 } });
+ target(T_.P, [3, -2], p);
+ }, { ask: done => quiz({ x: 40, y: 470, w: 740, cls: 'side' }, [{
+ id: 'c-arrow', prompt: ['Make the blue dashed arrow, column 1 of Aᵀ, end on the target (3, −2).'],
+ build: mmTTask(S.T, v => v.a00 === 3 && v.a01 === -2, 'Column 1 of Aᵀ is row 1 of A: A’s top row is now (3, −2).',
+ v => v.a00 === 3 && v.a10 === -2 ? 'That moved the green arrow, column 1 of A. The blue dashed arrow is row 1 of A: change the top row.' : 'The blue dashed arrow is row 1 of A. Its two numbers are the top row of A.',
+ () => S.T.set({ a00: 3, a01: -2 })),
+ }], done) }],
+
+ ['order', 'The transpose of a product', (m) => {
+ const p = S.p = panel(0);
+ title(p, 'The transpose of a product');
+ const o = { size: 36, cw: 56, rh: 54, sizes: false, hideC: true, fillC: COL.chalk };
+ const P1 = S.P1 = mm(p, { A: OA, B: OB, at: [70, 250], ...o, t0: .3 });
+ put(P1.W, { o: 0 });
+ const da = P1.L.b.x - P1.L.a.x;
+ put(P1.L.a.g, { x: 0 }); put(P1.L.b.g, { x: 0 });
+ tw(P1.L.a.g, { x: da }, 3.4, 1.1); tw(P1.L.b.g, { x: -da }, 3.4, 1.1);
+ tw(P1.L.a.g, { x: 0 }, 6.4, 1.1); tw(P1.L.b.g, { x: 0 }, 6.4, 1.1);
+ const ne = text(p, 'AB ≠ BA', 860, 270, 3.6, { size: 36, fill: COL.dim, weight: 600 }); hide(ne, m('ab') - .3, .3);
+ put(P1.L.c.g, { o: 0 }); show(P1.L.c.g, m('ab') + 5, .4);
+ P1.flash('a', 'all', m('ab') + .4); P1.flash('b', 'all', m('ab') + 2.6);
+ [[0, 0], [0, 1], [1, 0], [1, 1]].forEach((ij, k) => { P1.show('entry', ij, m('abc') + k * .7); P1.reveal({ cell: ij }, m('abc') + k * .7 + .2); });
+ P1.show(null, null, m('flip'));
+ const TT = S.TT = flipOf(p, P1, { size: 36, rh: 54, t0: m('flip') - .3 });
+ put(TT.L.t.g, { o: 0 }); show(TT.L.t.g, m('flip') - .1, .3);
+ TT.fly(m('flip') + .2, { by: 'cells', step: .3, dur: .9 });
+ const P3 = S.P3 = mm(p, { A: tr(OA), B: tr(OB), at: [70, 480], names: ['Aᵀ', 'Bᵀ', 'AᵀBᵀ'], ...o, t0: m('guess') - .2 });
+ P3.reveal('all', m('wrong'));
+ put(P3.g, { x: -40 }); tw(P3.g, { x: 0 }, m('guess') - .2, .8, out);
+ P3.flash('a', 'all', m('guess') + 2.2); P3.flash('b', 'all', m('guess') + 3.6);
+ const P2 = S.P2 = mm(p, { A: tr(OB), B: tr(OA), at: [70, 710], names: ['Bᵀ', 'Aᵀ', 'BᵀAᵀ'], ...o, t0: m('swap') - .2 });
+ P2.reveal('all', m('right'));
+ P2.flash('a', 'all', m('swap') + 1.2); P2.flash('b', 'all', m('swap') + 2.4);
+ // the verdicts beside the two guesses, live: they follow every change of A and B
+ const vx = P3.L.right + 40;
+ const v3 = G(p, { o: 0 }), v2 = G(p, { o: 0 });
+ const t3 = T(v3, '', { x: vx, y: 480 + 40, size: 34, weight: 700 }), t2 = T(v2, '', { x: vx, y: 710 + 40, size: 34, weight: 700 });
+ const same = (X, Y) => !!X && !!Y && X.every((r, i) => r.every((v, j) => Math.abs(v - Y[i][j]) < 1e-9));
+ const verdict = () => {
+ const C = P1.C(), CT = C && tr(C);
+ [[P3, t3], [P2, t2]].forEach(([Q, te]) => { const ok = same(Q.C(), CT); te.textContent = ok ? '= (AB)ᵀ ✓' : '≠ (AB)ᵀ'; te.setAttribute('fill', ok ? COL.good : COL.bad); });
+ };
+ P1.onChange(v => {
+ P3.set({ a00: v.a00, a01: v.a10, a10: v.a01, a11: v.a11, b00: v.b00, b01: v.b10, b10: v.b01, b11: v.b11 });
+ P2.set({ a00: v.b00, a01: v.b10, a10: v.b01, a11: v.b11, b00: v.a00, b01: v.a10, b10: v.a01, b11: v.a11 });
+ verdict();
+ });
+ verdict();
+ show(v3, m('wrong') + 1.5, .4); show(v2, m('match'), .4);
+ const r = S.rule = G(p, { o: 0 });
+ M(r, ['(AB)ᵀ = BᵀAᵀ'], { x: 1080, y: 300, size: 54 });
+ T(r, 'flip each one, and reverse the order', { x: 1080, y: 350, size: 28, fill: COL.dim, weight: 600 });
+ show(r, m('rule'), .5);
+ P2.flash('a', 'all', m('rule') + 2.6); P2.flash('b', 'all', m('rule') + 3.2); TT.flash('t', 'all', m('rule') + 4.2); P2.flash('c', 'all', m('rule') + 4.2);
+ }],
+
+ ['live', 'The rule at work', (m) => {
+ const P1 = S.P1;
+ P1.to({ a01: -1 }, m('go') + .3, 1.4); P1.flash('a', { cell: [0, 1] }, m('go') + .3);
+ S.TT.flash('t', 'all', m('go') + 2.2); S.P2.flash('c', 'all', m('go') + 2.6);
+ P1.to({ b10: 2 }, m('again') + .3, 1.4); P1.flash('b', { cell: [1, 0] }, m('again') + .3);
+ S.TT.flash('t', 'all', m('again') + 2); S.P2.flash('c', 'all', m('again') + 2.3);
+ S.P3.flash('c', 'all', m('wrong') + .5, { color: COL.bad });
+ }],
+
+ ['why', 'Why the order turns', (m) => {
+ const p = panel(0);
+ title(p, 'Why the order turns around');
+ const o = { size: 36, cw: 56, rh: 54, sizes: false, fillC: COL.chalk };
+ const P1 = mm(p, { A: OA, B: OB, at: [70, 230], work: [90, 410], wsize: 32, ...o });
+ const TT = flipOf(p, P1, { size: 36, rh: 54, hideT: false });
+ const P2 = mm(p, { A: tr(OB), B: tr(OA), at: [70, 590], names: ['Bᵀ', 'Aᵀ', 'BᵀAᵀ'], work: [90, 770], wsize: 32, ...o });
+ TT.show('cell', [1, 0], m('ent'));
+ P1.show('entry', [1, 0], m('ab'), { times: [m('ab') + .4, m('ab') + 3.4, m('ab') + 5.4] });
+ P2.show('entry', [0, 1], m('ba'), { times: [m('ba') + .4, m('sum'), m('sum') + 2.4] });
+ P2.flash('a', { row: 0 }, m('ba') + 2.6); P2.flash('b', { col: 1 }, m('ba') + 4.6); TT.flash('t', [[0, 1]], m('ba') + 6.4);
+ const n = G(p, {});
+ say(n, ['row 1 of Bᵀ = column 1 of B'], 980, 560, m('same') + .2, { size: 30 });
+ say(n, ['column 2 of Aᵀ = row 2 of A'], 980, 610, m('same') + 3.2, { size: 30 });
+ P2.flash('a', { row: 0 }, m('same') + .2); P1.flash('b', { col: 0 }, m('same') + .8);
+ P2.flash('b', { col: 1 }, m('same') + 3.2); P1.flash('a', { row: 1 }, m('same') + 3.8);
+ text(n, 'the same pairs, the same sum', 980, 700, m('sum') + 1, { size: 30, weight: 600 });
+ text(n, 'every spot: (AB)ᵀ = BᵀAᵀ', 980, 300, m('every'), { size: 34, weight: 600 });
+ }],
+
+ ['sizes', 'The sizes agree', (m) => {
+ const p = panel(0);
+ title(p, 'The sizes tell the same story');
+ const o = { size: 32, cw: 50, rh: 48, hideC: true, fillC: COL.chalk };
+ const P1 = mm(p, { A: ZA, B: ZB, at: [70, 230], ...o, t0: m('ex') - .3 });
+ P1.inner(m('ab') + .3); P1.outer(m('ab') + 2.6);
+ P1.reveal('all', m('abt'));
+ const TT = flipOf(p, P1, { size: 32, rh: 48, gap: 70, t0: m('abt') });
+ put(TT.L.t.g, { o: 0 }); show(TT.L.t.g, m('abt') + 1.6, .3);
+ TT.fly(m('abt') + 1.8, { by: 'cells', step: .25, dur: .8 });
+ const P3 = mm(p, { A: tr(ZA), B: tr(ZB), at: [900, 560], names: ['Aᵀ', 'Bᵀ', 'AᵀBᵀ'], ...o, t0: m('t') - .2 });
+ put(P3.L.c.g, { o: 0 }); show(P3.L.c.g, m('wrongs') + .2, .4);
+ P3.outer(m('wrongs') + 1.4);
+ const bad = G(p, { o: 0 });
+ T(bad, '3 × 3: too big to be (AB)ᵀ', { x: 1560, y: 470, size: 26, fill: COL.bad, weight: 700, anchor: 'end' });
+ show(bad, m('wrongs') + 2.4, .4);
+ const P2 = mm(p, { A: tr(ZB), B: tr(ZA), at: [70, 560], names: ['Bᵀ', 'Aᵀ', 'BᵀAᵀ'], ...o, t0: m('rights') - .2 });
+ P2.inner(m('rights') + 1.4); P2.outer(m('rights') + 3.4);
+ P2.reveal('all', m('nums') + .3);
+ text(p, '(AB)ᵀ = BᵀAᵀ ✓', 1100, 300, m('match'), { size: 34, fill: COL.good, weight: 700 });
+ P2.flash('c', 'all', m('match')); TT.flash('t', 'all', m('match'));
+ }],
+
+ ['q3', 'Quick check', () => {
+ const p = panel(0);
+ title(p, 'Quick check');
+ say(p, ['A: 2 × 3'], 90, 230, .3, { size: 40 });
+ say(p, ['B: 3 × 4'], 90, 300, .5, { size: 40 });
+ say(p, ['AB: 2 × 4'], 400, 265, .7, { size: 40, fill: COL.dim });
+ }, { ask: done => quiz({ x: 40, y: 380, w: 740, cls: 'side' }, [{
+ id: 'c-order', prompt: ['Which one is (AB)ᵀ?'],
+ build: choice(['AᵀBᵀ', 'BᵀAᵀ', 'BA', 'AB again'], 1,
+ 'Flip each one and reverse the order: BᵀAᵀ = (4 × 3)(3 × 2) = 4 × 2, the flip of 2 × 4.',
+ ['Aᵀ is 3 × 2 and Bᵀ is 4 × 3: the inside numbers 2 and 4 do not even match. The order must turn around.', null,
+ 'B A has no flips in it, and (3 × 4)(2 × 3) does not even fit.', 'AB is 2 × 4; its transpose is 4 × 2, a different shape.']),
+ }], done) }],
+
+ ['wrap', 'Summary', (m) => {
+ const p = panel(0);
+ [['The rows of A become the columns of Aᵀ: m × n becomes n × m.', 'w1'], ['Row i, column j of Aᵀ is row j, column i of A: a mirror across the diagonal.', 'w2'],
+ ['Transpose twice and you are back: (Aᵀ)ᵀ = A.', 'w3'], ['(AB)ᵀ = BᵀAᵀ: flip each one, reverse the order.', 'w4']].forEach(([str, mark], i) => {
+ const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });
+ mk('circle', { cx: 120, cy: -12, r: 26, fill: COL.chalk }, g);
+ T(g, String(i + 1), { x: 120, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
+ T(g, str, { x: 170, size: 34, weight: 600 });
+ tw(g, { o: 1, x: 0 }, m(mark), .6);
+ });
+ }],
+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{
+ id: 'p-tr', prompt: ['Write the rows of Aᵀ. (Row k of Aᵀ is column k of A.)'],
+ build: blanks(TRQ),
+ }], done, 'Chapter practice · set 1 of 4') }],
+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
+ id: 'p-size', prompt: ['Sizes and addresses.'],
+ build: blanks(SIZEQ),
+ }, {
+ id: 'p-tf', prompt: ['True or false?'],
+ build: grid(TFQ, [['t', 'True', COL.good, 'T'], ['f', 'False', COL.bad, 'F']], { multi: false, text: true }),
+ }], done, 'Chapter practice · set 2 of 4') }],
+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
+ id: 'p-prod', prompt: ['Transposes of products.'],
+ build: blanks(PRODQ),
+ }, {
+ id: 'p-abc', prompt: ['Three matrices: (ABC)ᵀ = (AB · C)ᵀ. Use the rule twice. Which is it?'],
+ build: choice(['AᵀBᵀCᵀ', 'CᵀBᵀAᵀ', 'CᵀAᵀBᵀ', 'CBA'], 1,
+ '(AB · C)ᵀ = Cᵀ(AB)ᵀ = CᵀBᵀAᵀ: flip each, and the whole order turns around.',
+ ['That keeps the order. Every flip of a product reverses it.', null, '(AB)ᵀ is BᵀAᵀ, not AᵀBᵀ: the inside pair turns around too.', 'Those are not flipped: each factor needs its own ᵀ.']),
+ }], done, 'Chapter practice · set 3 of 4') }],
+ ['final4', 'Chapter practice', () => {
+ const p = panel(0);
+ title(p, 'Build it');
+ S.T = mmT(p, { A: [[0, 0], [0, 0]], at: [90, 270], size: 44, cw: 70, rh: 62, gap: 130, plane: { cx: 1190, cy: 470, u: 44 } });
+ }, { ask: done => quiz({ x: 40, y: 500, w: 740, cls: 'side' }, HANDQ.map(q => ({
+ id: q.id, prompt: q.prompt,
+ build: (body, api) => { S.T.set(q.start); return mmTTask(S.T, q.test, q.why, q.hint, () => S.T.set(q.ans), { sizes: q.id === 'p-hand3' })(body, api); },
+ })), done, 'Chapter practice · set 4 of 4') }],
+ ['play', 'Playground', (m) => {
+ const p = panel(0);
+ title(p, 'Playground');
+ S.T = mmT(p, { A: PA, at: [90, 250], size: 40, cw: 64, rh: 56, gap: 120, plane: { cx: 1190, cy: 470, u: 44 } });
+ const hint = G(p, { o: 0 });
+ T(hint, 'try: put each dashed arrow on a solid one', { x: 1190, y: 790, size: 24, fill: COL.dim, anchor: 'middle' });
+ T(hint, 'make A 3 × 1 · type into Aᵀ and watch A', { x: 1190, y: 824, size: 24, fill: COL.dim, anchor: 'middle' });
+ show(hint, m('go'), .5);
+ }, { ask: playAsk(() => S.T, { pos: { x: 40, y: 470, w: 740, cls: 'side' }, live: { sizes: true, drag: true },
+ tip: 'Your A and its transpose. Change any number of either, change the size under A, or drag an arrow by its tip. Nothing is marked.' }) }],
+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
+
+boot();
+</script>
+</body>
+</html>
diff --git a/site/linear-algebra/ch36/audio/en/ex3.mp3 b/site/linear-algebra/ch36/audio/en/ex3.mp3
new file mode 100644
index 0000000..03298bc
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/ex3.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/final1.mp3 b/site/linear-algebra/ch36/audio/en/final1.mp3
new file mode 100644
index 0000000..47a8ee8
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/final1.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/final2.mp3 b/site/linear-algebra/ch36/audio/en/final2.mp3
new file mode 100644
index 0000000..f53efac
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/final2.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/final3.mp3 b/site/linear-algebra/ch36/audio/en/final3.mp3
new file mode 100644
index 0000000..5628d34
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/final3.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/final4.mp3 b/site/linear-algebra/ch36/audio/en/final4.mp3
new file mode 100644
index 0000000..38dc6f9
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/final4.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/finish.mp3 b/site/linear-algebra/ch36/audio/en/finish.mp3
new file mode 100644
index 0000000..2294b05
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/finish.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/intro.mp3 b/site/linear-algebra/ch36/audio/en/intro.mp3
new file mode 100644
index 0000000..ae610fb
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/intro.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/live.mp3 b/site/linear-algebra/ch36/audio/en/live.mp3
new file mode 100644
index 0000000..b2b0393
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/live.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/not.mp3 b/site/linear-algebra/ch36/audio/en/not.mp3
new file mode 100644
index 0000000..83adbc1
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/not.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/pairs.mp3 b/site/linear-algebra/ch36/audio/en/pairs.mp3
new file mode 100644
index 0000000..3d39818
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/pairs.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/plane.mp3 b/site/linear-algebra/ch36/audio/en/plane.mp3
new file mode 100644
index 0000000..7292022
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/plane.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/play.mp3 b/site/linear-algebra/ch36/audio/en/play.mp3
new file mode 100644
index 0000000..63b4629
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/play.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/q1.mp3 b/site/linear-algebra/ch36/audio/en/q1.mp3
new file mode 100644
index 0000000..6917ed8
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/q1.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/q2.mp3 b/site/linear-algebra/ch36/audio/en/q2.mp3
new file mode 100644
index 0000000..9bec17f
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/q2.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/q3.mp3 b/site/linear-algebra/ch36/audio/en/q3.mp3
new file mode 100644
index 0000000..c45e160
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/q3.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/q4.mp3 b/site/linear-algebra/ch36/audio/en/q4.mp3
new file mode 100644
index 0000000..0724d11
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/q4.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/recall.mp3 b/site/linear-algebra/ch36/audio/en/recall.mp3
new file mode 100644
index 0000000..c40f091
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/recall.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/rtr.mp3 b/site/linear-algebra/ch36/audio/en/rtr.mp3
new file mode 100644
index 0000000..7579f88
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/rtr.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/rtr2.mp3 b/site/linear-algebra/ch36/audio/en/rtr2.mp3
new file mode 100644
index 0000000..5e4c3df
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/rtr2.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/rule.mp3 b/site/linear-algebra/ch36/audio/en/rule.mp3
new file mode 100644
index 0000000..afa39a4
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/rule.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/sym.mp3 b/site/linear-algebra/ch36/audio/en/sym.mp3
new file mode 100644
index 0000000..785e18a
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/sym.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/timings.js b/site/linear-algebra/ch36/audio/en/timings.js
new file mode 100644
index 0000000..0fb6895
--- /dev/null
+++ b/site/linear-algebra/ch36/audio/en/timings.js
@@ -0,0 +1,725 @@
+window.TIMINGS = {
+ "intro": {
+ "dur": 7.296,
+ "marks": {
+ "sub": 1.81,
+ "move": 3.789
+ },
+ "cues": [
+ [
+ 0.104,
+ "Chapter thirty-six."
+ ],
+ [
+ 1.81,
+ "Symmetric matrices."
+ ],
+ [
+ 3.789,
+ "These are the matrices that a flip does not change at all."
+ ]
+ ]
+ },
+ "recall": {
+ "dur": 23.664,
+ "marks": {
+ "A": 2.24,
+ "flip": 6.445,
+ "diff": 14.961,
+ "most": 21.133
+ },
+ "cues": [
+ [
+ 0.091,
+ "Last chapter, the transpose."
+ ],
+ [
+ 2.24,
+ "Take A: one, two; three, four."
+ ],
+ [
+ 6.445,
+ "Flip it across the diagonal."
+ ],
+ [
+ 8.815,
+ "Rows become columns, and A transpose is one, three; two, four."
+ ],
+ [
+ 14.961,
+ "The two and the three traded places, so A transpose is a different matrix."
+ ],
+ [
+ 21.133,
+ "That is what happens to most matrices."
+ ]
+ ]
+ },
+ "sym": {
+ "dur": 26.232,
+ "marks": {
+ "S": 1.406,
+ "flip": 4.753,
+ "same": 12.93,
+ "name": 18.034,
+ "eq": 23.555
+ },
+ "cues": [
+ [
+ 0.091,
+ "But not to all of them."
+ ],
+ [
+ 1.406,
+ "Take S: two, five; five, three."
+ ],
+ [
+ 4.753,
+ "Flip it."
+ ],
+ [
+ 5.508,
+ "Row one, two and five, stands up as column one."
+ ],
+ [
+ 9.336,
+ "Row two, five and three, becomes column two."
+ ],
+ [
+ 12.93,
+ "S transpose is two, five; five, three."
+ ],
+ [
+ 16.471,
+ "Exactly S again."
+ ],
+ [
+ 18.034,
+ "A matrix like this is called symmetric: its transpose is itself."
+ ],
+ [
+ 23.555,
+ "S transpose equals S."
+ ]
+ ]
+ },
+ "pairs": {
+ "dur": 25.2,
+ "marks": {
+ "diag": 1.68,
+ "pair": 6.771,
+ "equal": 12.37,
+ "rule": 16.771,
+ "free": 22.383
+ },
+ "cues": [
+ [
+ 0.104,
+ "Why did nothing change?"
+ ],
+ [
+ 1.68,
+ "The diagonal never moves in a flip."
+ ],
+ [
+ 4.596,
+ "Here it holds two and three."
+ ],
+ [
+ 6.771,
+ "The only numbers that move are the two off the diagonal, and they trade places."
+ ],
+ [
+ 12.37,
+ "Both of them are five."
+ ],
+ [
+ 13.737,
+ "Trading a five for a five changes nothing."
+ ],
+ [
+ 16.771,
+ "So the test is: every number must equal its mirror number across the diagonal."
+ ],
+ [
+ 22.383,
+ "The diagonal itself can hold anything."
+ ]
+ ]
+ },
+ "ex3": {
+ "dur": 45.72,
+ "marks": {
+ "S": 2.474,
+ "diag": 10.13,
+ "p1": 13.854,
+ "p2": 22.513,
+ "p3": 28.607,
+ "yes": 36.732,
+ "flip": 41.471
+ },
+ "cues": [
+ [
+ 0.104,
+ "A bigger one, three by three."
+ ],
+ [
+ 2.474,
+ "Rows: one, four, zero; four, two, minus three; zero, minus three, six."
+ ],
+ [
+ 10.13,
+ "The diagonal, one, two, six, is free."
+ ],
+ [
+ 13.854,
+ "Now check the pairs."
+ ],
+ [
+ 15.534,
+ "Row one, column two is four."
+ ],
+ [
+ 17.956,
+ "Its mirror, row two, column one, is four."
+ ],
+ [
+ 21.693,
+ "Equal."
+ ],
+ [
+ 22.513,
+ "Row one, column three is zero, and its mirror is zero."
+ ],
+ [
+ 27.799,
+ "Equal."
+ ],
+ [
+ 28.607,
+ "Row two, column three is minus three, and its mirror is minus three."
+ ],
+ [
+ 34.844,
+ "Equal, sign and all."
+ ],
+ [
+ 36.732,
+ "Three pairs, all equal: this matrix is symmetric."
+ ],
+ [
+ 41.471,
+ "Flip it to be sure: every number lands on a copy of itself."
+ ]
+ ]
+ },
+ "not": {
+ "dur": 28.464,
+ "marks": {
+ "A": 1.576,
+ "pair": 3.854,
+ "sign": 6.823,
+ "B": 13.516,
+ "shape": 17.852,
+ "square": 25.169
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now two that fail."
+ ],
+ [
+ 1.576,
+ "One, two; minus two, one."
+ ],
+ [
+ 3.854,
+ "The mirror pair is two and minus two."
+ ],
+ [
+ 6.823,
+ "They differ in sign, so they are not equal, and the flip changes the matrix."
+ ],
+ [
+ 12.201,
+ "Not symmetric."
+ ],
+ [
+ 13.516,
+ "Next, a matrix with two rows and three columns."
+ ],
+ [
+ 17.852,
+ "Its transpose has three rows and two columns: a different shape, so it can never be the same matrix."
+ ],
+ [
+ 25.169,
+ "A symmetric matrix is always square."
+ ]
+ ]
+ },
+ "q1": {
+ "dur": 2.736,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.12,
+ "Which of these are symmetric?"
+ ]
+ ]
+ },
+ "plane": {
+ "dur": 44.04,
+ "marks": {
+ "S": 2.201,
+ "cols": 5.156,
+ "rows": 9.219,
+ "on": 12.747,
+ "break": 21.758,
+ "apart": 28.737,
+ "fix": 33.177,
+ "back": 39.818
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now the picture from last chapter."
+ ],
+ [
+ 2.201,
+ "Take S: three, one; one, two."
+ ],
+ [
+ 5.156,
+ "Its columns are the solid arrows, green and violet."
+ ],
+ [
+ 9.219,
+ "Its rows are the dashed arrows, blue and coral."
+ ],
+ [
+ 12.747,
+ "For a symmetric matrix, column one is row one, and column two is row two."
+ ],
+ [
+ 18.333,
+ "Each dashed arrow lies right on top of a solid one."
+ ],
+ [
+ 21.758,
+ "Now break the symmetry."
+ ],
+ [
+ 23.841,
+ "Change the number in row one, column two, from one to minus two."
+ ],
+ [
+ 28.737,
+ "Column two and row one move, and the arrows come apart."
+ ],
+ [
+ 33.177,
+ "To fix it, give its mirror the same number: row two, column one, also minus two."
+ ],
+ [
+ 39.818,
+ "The arrows join again, in new places."
+ ],
+ [
+ 42.839,
+ "Symmetric again."
+ ]
+ ]
+ },
+ "q2": {
+ "dur": 6.24,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Your turn."
+ ],
+ [
+ 1.016,
+ "Make A symmetric, so that every dashed arrow lies on a solid one."
+ ]
+ ]
+ },
+ "rtr": {
+ "dur": 34.512,
+ "marks": {
+ "R": 3.255,
+ "rt": 13.333,
+ "mult": 17.617,
+ "size": 20.365,
+ "work": 24.557,
+ "c11": 25.482,
+ "c12": 26.393,
+ "c21": 27.266,
+ "c22": 27.982,
+ "sym": 29.023
+ },
+ "cues": [
+ [
+ 0.117,
+ "Here is where symmetric matrices come from."
+ ],
+ [
+ 3.255,
+ "Take any matrix R, even one that is not square."
+ ],
+ [
+ 6.875,
+ "This R is three by two: one, three; two, three; four, one."
+ ],
+ [
+ 13.333,
+ "Its transpose, R transpose, is two by three."
+ ],
+ [
+ 17.617,
+ "Multiply R transpose times R."
+ ],
+ [
+ 20.365,
+ "Two by three times three by two: the answer is two by two."
+ ],
+ [
+ 24.557,
+ "Work it out."
+ ],
+ [
+ 25.482,
+ "Twenty-one, thirteen, thirteen, nineteen."
+ ],
+ [
+ 29.023,
+ "Look at the two thirteens, in mirror spots."
+ ],
+ [
+ 32.266,
+ "R transpose R is symmetric."
+ ]
+ ]
+ },
+ "rtr2": {
+ "dur": 21.6,
+ "marks": {
+ "R": 2.096,
+ "prod": 5.0,
+ "sym": 9.323,
+ "other": 13.268
+ },
+ "cues": [
+ [
+ 0.104,
+ "Another one, to be sure."
+ ],
+ [
+ 2.096,
+ "R is one, two; zero, one."
+ ],
+ [
+ 5.0,
+ "R transpose R is one, two; two, five."
+ ],
+ [
+ 9.323,
+ "The two twos sit in mirror spots: symmetric again."
+ ],
+ [
+ 13.268,
+ "And the other order, R times R transpose, is five, two; two, one."
+ ],
+ [
+ 18.997,
+ "A different matrix, but symmetric too."
+ ]
+ ]
+ },
+ "why": {
+ "dur": 43.896,
+ "marks": {
+ "ent": 4.427,
+ "col1": 9.831,
+ "pairs": 12.812,
+ "mirror": 23.659,
+ "same": 29.336,
+ "always": 37.682
+ },
+ "cues": [
+ [
+ 0.104,
+ "Why must this always happen?"
+ ],
+ [
+ 1.823,
+ "Look at one number of R transpose R."
+ ],
+ [
+ 4.427,
+ "Row one, column two is row one of R transpose, times column two of R."
+ ],
+ [
+ 9.831,
+ "Row one of R transpose is just column one of R."
+ ],
+ [
+ 12.812,
+ "So this number multiplies column one of R with column two, number by number: one times three, plus two times three, plus four times one."
+ ],
+ [
+ 22.721,
+ "Thirteen."
+ ],
+ [
+ 23.659,
+ "Its mirror, row two, column one, multiplies column two with column one."
+ ],
+ [
+ 29.336,
+ "The same pairs, in the other order: three times one, plus three times two, plus one times four."
+ ],
+ [
+ 36.536,
+ "Thirteen again."
+ ],
+ [
+ 37.682,
+ "Swapping which column comes first never changes the sum, so the mirror numbers always agree."
+ ]
+ ]
+ },
+ "rule": {
+ "dur": 22.032,
+ "marks": {
+ "start": 3.138,
+ "rev": 5.82,
+ "get": 8.607,
+ "back": 12.422,
+ "end": 14.688
+ },
+ "cues": [
+ [
+ 0.104,
+ "The rule from last chapter says it in one line."
+ ],
+ [
+ 3.138,
+ "Take the transpose of R transpose R."
+ ],
+ [
+ 5.82,
+ "Reverse the order and flip each one: R transpose, times R transpose transposed."
+ ],
+ [
+ 12.422,
+ "But flipping twice gives back R."
+ ],
+ [
+ 14.688,
+ "So the transpose of R transpose R is R transpose R itself."
+ ],
+ [
+ 19.688,
+ "That is exactly what symmetric means."
+ ]
+ ]
+ },
+ "q3": {
+ "dur": 3.24,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.185,
+ "Work out R transpose R."
+ ]
+ ]
+ },
+ "live": {
+ "dur": 14.976,
+ "marks": {
+ "go": 2.109,
+ "stay": 7.669,
+ "again": 11.523
+ },
+ "cues": [
+ [
+ 0.117,
+ "Here it is with moving numbers."
+ ],
+ [
+ 2.109,
+ "Change a number of R."
+ ],
+ [
+ 3.633,
+ "R transpose follows it, and R transpose R changes."
+ ],
+ [
+ 7.669,
+ "But its two mirror numbers change together, and stay equal."
+ ],
+ [
+ 11.523,
+ "Change another."
+ ],
+ [
+ 12.617,
+ "Still symmetric, whatever R is."
+ ]
+ ]
+ },
+ "q4": {
+ "dur": 6.912,
+ "marks": {},
+ "cues": [
+ [
+ 0.091,
+ "Your turn."
+ ],
+ [
+ 0.99,
+ "Change R until the top right number of R transpose R is zero, and watch its mirror."
+ ]
+ ]
+ },
+ "wrap": {
+ "dur": 28.896,
+ "marks": {
+ "w1": 1.055,
+ "w2": 7.175,
+ "w3": 13.464,
+ "w4": 18.88,
+ "end": 27.552
+ },
+ "cues": [
+ [
+ 0.104,
+ "Let's sum up."
+ ],
+ [
+ 1.055,
+ "A symmetric matrix equals its own transpose: S transpose equals S."
+ ],
+ [
+ 7.175,
+ "Test it by pairs: every number equals its mirror across the diagonal, and the diagonal is free."
+ ],
+ [
+ 13.464,
+ "A symmetric matrix is square, and in the plane its rows lie on its columns."
+ ],
+ [
+ 18.88,
+ "R transpose R is always symmetric, for any R: the transpose rule says so, and so does every pair of columns."
+ ],
+ [
+ 27.552,
+ "Now practice."
+ ]
+ ]
+ },
+ "final1": {
+ "dur": 3.048,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Chapter practice."
+ ],
+ [
+ 1.523,
+ "Symmetric or not?"
+ ]
+ ]
+ },
+ "final2": {
+ "dur": 4.944,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Set two."
+ ],
+ [
+ 1.12,
+ "Fill in the numbers that make each matrix symmetric."
+ ]
+ ]
+ },
+ "final3": {
+ "dur": 3.672,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Set three."
+ ],
+ [
+ 1.146,
+ "Build symmetric matrices from R."
+ ]
+ ]
+ },
+ "final4": {
+ "dur": 3.552,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Last set."
+ ],
+ [
+ 1.185,
+ "Make it symmetric with your own hands."
+ ]
+ ]
+ },
+ "play": {
+ "dur": 10.752,
+ "marks": {
+ "go": 3.984
+ },
+ "cues": [
+ [
+ 0.117,
+ "Playground."
+ ],
+ [
+ 1.081,
+ "Nothing here is marked right or wrong."
+ ],
+ [
+ 3.984,
+ "Change any number, drag the arrows, and watch the rings: green when the mirror numbers agree."
+ ]
+ ]
+ },
+ "finish": {
+ "dur": 13.296,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Well done."
+ ],
+ [
+ 1.107,
+ "That's the end of chapter thirty-six, symmetric matrices."
+ ],
+ [
+ 5.482,
+ "Next: a new idea, the vector space, a world of vectors you can add and stretch without ever leaving it."
+ ]
+ ]
+ }
+};
diff --git a/site/linear-algebra/ch36/audio/en/why.mp3 b/site/linear-algebra/ch36/audio/en/why.mp3
new file mode 100644
index 0000000..f1e5e5b
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/why.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/wrap.mp3 b/site/linear-algebra/ch36/audio/en/wrap.mp3
new file mode 100644
index 0000000..ed88853
Binary files /dev/null and b/site/linear-algebra/ch36/audio/en/wrap.mp3 differ
diff --git a/site/linear-algebra/ch36/index.html b/site/linear-algebra/ch36/index.html
new file mode 100644
index 0000000..4c12e8c
--- /dev/null
+++ b/site/linear-algebra/ch36/index.html
@@ -0,0 +1,428 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Symmetric Matrices</title>
+<link rel="stylesheet" href="../lib/engine.css">
+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->
+</head>
+<body>
+<script src="../lib/engine.js"></script>
+<script src="../lib/math.js"></script>
+<script src="../lib/mm.js"></script>
+<script src="../lib/play.js"></script>
+<script src="audio/en/timings.js"></script>
+<script>
+'use strict';
+const CHAPTER = { number: 36, title: 'Symmetric Matrices', minutes: 11, language: 'en', next: '../ch37/' };
+
+/* ---------- chapter helpers ---------- */
+const S2 = [[2, 5], [5, 3]]; // the first symmetric matrix
+const S3 = [[1, 4, 0], [4, 2, -3], [0, -3, 6]]; // three pairs, all equal
+const PS = [[3, 1], [1, 2]]; // the plane: rows on columns
+const R1 = [[1, 3], [2, 3], [4, 1]]; // RᵀR = [21 13; 13 19] (the lecture's 3 × 2)
+const R2 = [[1, 2], [0, 1]]; // RᵀR = [1 2; 2 5], RRᵀ = [5 2; 2 1]
+const tr = M_ => M_[0].map((_, j) => M_.map(r => r[j]));
+const AT = [140, 300];
+const CARD = { x: 40, y: 450, w: 740, cls: 'side' };
+const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
+const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
+const title = (p, str) => text(p, str, 60, 110, .2, { size: 40, weight: 600 });
+const thick = (tp, t0) => { const w = tp.dash ? 4 : 6; tw(tp.shaft, { 'a_stroke-width': w + 5 }, t0, .3); tw(tp.shaft, { 'a_stroke-width': w }, t0 + 1.2, .6); };
+const hideArrows = T_ => [...T_.arrows.cols, ...T_.arrows.rows].forEach(tp => put(tp.ag, { o: 0 }));
+// One mirror pair of a matrix laid out by mmT or mm (cx, ry): two rings and a bow between them, drawn at t0.
+const pairRing = (into, Mx, i, j, t0, color, size) => {
+ const g = G(into, { o: 0 }), c = (r, k) => [Mx.cx(k), Mx.ry(r) - size * .3];
+ [c(i, j), c(j, i)].forEach(([x, y]) => mk('circle', { cx: x, cy: y, r: size * .62, fill: 'none', stroke: color, 'stroke-width': 3 }, g));
+ const [x1, y1] = c(i, j), [x2, y2] = c(j, i), bend = 18 + 10 * (j - i);
+ path(g, `M${x1 - size * .5} ${y1 + size * .4}Q${(x1 + x2) / 2 + bend} ${(y1 + y2) / 2 + bend} ${x2 + size * .5} ${y2 - size * .4}`, { stroke: color, 'stroke-width': 2.5, fill: 'none', 'stroke-opacity': .8 });
+ show(g, t0, .4);
+ return g;
+};
+// Rings on every mirror pair of a product's answer (mm), green while equal, red when not; live.
+const symRings = (into, P_, size, t0) => {
+ const g = G(into, { o: 0 });
+ const redraw = () => {
+ g.replaceChildren();
+ const C = P_.C(), c = P_.L.c;
+ if (!C || C.length !== C[0].length) return;
+ for (let i = 0; i < C.length; i++) for (let j = i + 1; j < C.length; j++) {
+ const ok = Math.abs(C[i][j] - C[j][i]) < 1e-9, col = ok ? COL.good : COL.bad;
+ [[i, j], [j, i]].forEach(([r, k]) => mk('circle', { cx: c.cx(k), cy: c.ry(r) - size * .3, r: size * .66, fill: 'none', stroke: col, 'stroke-width': 3 }, g));
+ }
+ };
+ P_.onChange(redraw); redraw();
+ show(g, t0, .4);
+ return g;
+};
+// Rᵀ follows R in an mm made as mm(Rᵀ, R): the reader may touch either.
+const rtrLink = P_ => {
+ let last = P_.v;
+ P_.onChange(v => {
+ const fromB = [0, 1, 2].some(i => [0, 1, 2].some(j => v[`b${i}${j}`] !== last[`b${i}${j}`]));
+ last = { ...v };
+ const set = {};
+ for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) { if (fromB) set[`a${j}${i}`] = v[`b${i}${j}`]; else set[`b${i}${j}`] = v[`a${j}${i}`]; }
+ P_.set(set); last = P_.v;
+ });
+};
+const matEl = rows => mmEl(rows, { size: 22 });
+
+/* ---------- practice data (every matrix checked pair by pair, every product by columns of R) ---------- */
+const YN = [['y', 'Symmetric', COL.good, 'Y'], ['n', 'Not', COL.bad, 'N']];
+const Q1 = [
+ { parts: [matEl([[1, 7], [7, 1]])], ans: ['y'], why: 'The one pair is 7 and 7.' },
+ { parts: [matEl([[0, 3], [-3, 0]])], ans: ['n'], why: '3 and −3 differ in sign.' },
+ { parts: [matEl([[1, 2, 3], [2, 1, 2]])], ans: ['n'], why: 'Not square: 2 × 3 flips to 3 × 2.' },
+ { parts: [matEl([[4, 1, 2], [1, 0, 5], [2, 6, 3]])], ans: ['n'], why: 'Row 2, column 3 is 5, its mirror is 6.' },
+];
+const SYMQ = [
+ { parts: [matEl([[2, -1], [-1, 2]])], ans: ['y'], why: '−1 and −1: equal.' },
+ { parts: [matEl([[0, 1], [1, 0]])], ans: ['y'], why: 'The swap permutation: 1 and 1 across the diagonal.' },
+ { parts: [matEl([[1, 2], [3, 1]])], ans: ['n'], why: '2 and 3 differ.' },
+ { parts: [matEl([[3, 0], [0, -3]])], ans: ['y'], why: 'The pair is 0 and 0; the diagonal (3, −3) is free.' },
+ { parts: [matEl([[1, 0, 1], [0, 1, 0], [1, 0, 1]])], ans: ['y'], why: 'Pairs: 0 and 0, 1 and 1, 0 and 0.' },
+ { parts: [matEl([[1, 2, 0], [2, 1, 0], [0, 1, 1]])], ans: ['n'], why: 'Row 2, column 3 is 0; its mirror, row 3, column 2, is 1.' },
+ { parts: [matEl([[1, 1]])], ans: ['n'], why: '1 × 2 is not square: its transpose is 2 × 1.' },
+];
+const FILLQ = [
+ { parts: [matEl([[4, 0], [-3, 1]]), ' row 1, column 2 must be ', { box: '-3' }], why: 'Its mirror, row 2, column 1, is −3.', hint: 'Look across the diagonal: the mirror number is in row 2, column 1.' },
+ { parts: [matEl([[0, 2, 0], [0, 5, 6], [7, 0, 1]]), ' (zeros show the gaps) row 1, column 3 = ', { box: '7' }, ', row 2, column 1 = ', { box: '2' }, ', row 3, column 2 = ', { box: '6' }],
+ why: 'Each gap copies its mirror: 7 from row 3, column 1; 2 from row 1, column 2; 6 from row 2, column 3.', hint: 'Swap the address of each gap and copy the number you find there.' },
+ { parts: ['Pairs 1, 2, 3 given; the diagonal is yours: ', matEl([[0, 1, 2], [1, 0, 3], [2, 3, 0]]), ' diagonal = (', { box: '0' }, ', ', { box: '0' }, ', ', { box: '0' }, ')'],
+ test: () => true, why: 'Any numbers work: the diagonal never moves in a flip, so it is free.', hint: 'The diagonal stays in place when you flip. Does it have to match anything?' },
+ { parts: [matEl([[1, -4], [0, 0]]), ' row 2, column 1 must be ', { box: '-4' }], why: 'Copy its mirror, −4, sign and all.', hint: 'The mirror of row 2, column 1 is row 1, column 2.' },
+];
+const RTRQ = [
+ { parts: ['R = ', matEl([[1, 0], [2, 1]]), ' RᵀR: row 1 = (', { box: '5' }, ', ', { box: '2' }, '), row 2 = (', { box: '2' }, ', ', { box: '1' }, ')'],
+ why: 'Columns of R: (1, 2) and (0, 1). 1·1 + 2·2 = 5, 1·0 + 2·1 = 2, 0·0 + 1·1 = 1.', hint: 'Each number of RᵀR is a column of R times a column of R, number by number, added.' },
+ { parts: ['R = ', matEl([[1, 2, 3]]), ' (one row). RᵀR is ', { box: '3' }, ' × ', { box: '3' }, '; its row 2 = (', { box: '2' }, ', ', { box: '4' }, ', ', { box: '6' }, ')'],
+ why: 'Rᵀ is 3 × 1, R is 1 × 3: RᵀR is 3 × 3. Row 2 is 2 times (1, 2, 3).', hint: 'Rᵀ is a column (1, 2, 3); times the row (1, 2, 3), row k is the k-th number times the row.' },
+ { parts: ['R = ', matEl([[1, 1], [1, -1], [0, 2]]), ' RᵀR: row 1 = (', { box: '2' }, ', ', { box: '0' }, '), row 2 = (', { box: '0' }, ', ', { box: '6' }, ')'],
+ why: 'Columns (1, 1, 0) and (1, −1, 2): 1 + 1 + 0 = 2, 1 − 1 + 0 = 0, 1 + 1 + 4 = 6.', hint: 'Column 1 times column 2: 1·1 + 1·(−1) + 0·2.' },
+ { parts: ['R = ', matEl([[1, 3], [0, 2]]), ' RRᵀ (the other order): row 1 = (', { box: '10' }, ', ', { box: '6' }, '), row 2 = (', { box: '6' }, ', ', { box: '4' }, ')'],
+ why: 'RRᵀ multiplies rows of R: (1, 3)·(1, 3) = 10, (1, 3)·(0, 2) = 6, (0, 2)·(0, 2) = 4. Symmetric too.', hint: 'In R Rᵀ, each number is a row of R times a row of R.' },
+];
+const HANDQ = [
+ { id: 'p-sym1', start: { a00: 2, a01: 3, a10: -1, a11: 1 }, only: ['a10', 't01'], prompt: ['Make A symmetric by changing only the number in row 2, column 1.'],
+ why: 'Row 2, column 1 must copy its mirror, 3. Now column 1 is (2, 3) = row 1.', hint: 'Its mirror is row 1, column 2. Copy that number.', ans: { a10: 3 } },
+ { id: 'p-sym2', start: { a00: 0, a01: 0, a10: 0, a11: 0 }, only: null, prompt: ['Make A symmetric with column 1 equal to (1, 4). Then the blue dashed arrow must lie on the green one.'],
+ why: 'Column 1 = (1, 4), so row 2, column 1 is 4; symmetric, so row 1, column 2 is 4 too. Row 2, column 2 is free.', hint: v => v.a00 === 1 && v.a10 === 4 ? 'Column 1 is right. Now its mirror: row 1 must be (1, 4) as well.' : 'Column 1 is the left column of A: 1 on top, 4 under it.',
+ test: (v, T_) => v.a00 === 1 && v.a10 === 4 && T_.sym(), ans: { a00: 1, a10: 4, a01: 4 } },
+];
+
+/* ---------- beats ---------- */
+const BEATS = [
+ ['intro', 'Symmetric matrices', (m, D) => {
+ const g = G(scene, { o: 0, y: 24 });
+ T(g, 'Unit 5, Chapter 36', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });
+ T(g, 'Symmetric Matrices', { x: 800, y: 360, size: 88, weight: 600, anchor: 'middle' });
+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);
+ const r = text(scene, 'the flip changes nothing', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });
+ const lg = G(scene, { o: 0 });
+ const T0 = mmT(lg, { A: S2, at: [622, 640], size: 36, cw: 56, rh: 52, gap: 100, hideT: true, sizes: false, t0: 0 });
+ show(lg, m('sub') + .4, .5);
+ T0.diag(m('move'));
+ T0.fly(m('move') + .4, { by: 'rows', step: 1.1, dur: .9 });
+ T0.pairs(m('move') + 2.6);
+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);
+ }],
+
+ ['recall', 'A flip changes most matrices', (m) => {
+ const p = panel(0);
+ title(p, 'A flip changes most matrices');
+ const T_ = mmT(p, { A: [[1, 2], [3, 4]], at: AT, size: 54, cw: 86, rh: 76, gap: 200, hideT: true, t0: m('A') - .4 });
+ put(T_.L.t.g, { o: 0 }); show(T_.L.t.g, m('flip') - .2, .4);
+ T_.diag(m('flip'));
+ T_.fly(m('flip') + .6, { by: 'rows', step: 1.3, dur: 1 });
+ T_.flash('a', [[0, 1], [1, 0]], m('diff')); T_.flash('t', [[0, 1], [1, 0]], m('diff') + .3);
+ pairRing(T_.front, T_.L.a, 0, 1, m('diff') + .2, COL.bad, 54);
+ const n = G(p, { o: 0 });
+ M(n, ['Aᵀ ≠ A'], { x: 980, y: 330, size: 54, fill: COL.bad });
+ T(n, 'the 2 and the 3 traded places', { x: 980, y: 380, size: 28, fill: COL.dim, weight: 600 });
+ show(n, m('diff') + 1, .5);
+ text(p, 'most matrices change', 980, 470, m('most'), { size: 30, weight: 600 });
+ }],
+
+ ['sym', 'When the flip changes nothing', (m) => {
+ const p = panel(0);
+ title(p, 'When the flip changes nothing');
+ const T_ = S.T = mmT(p, { A: S2, at: AT, size: 54, cw: 86, rh: 76, gap: 200, names: ['S', 'Sᵀ'], hideT: true, t0: m('S') - .4 });
+ put(T_.L.t.g, { o: 0 }); show(T_.L.t.g, m('flip') - .2, .4);
+ T_.show('row', 0, m('flip') + .3); T_.show('row', 1, m('flip') + 3.6); T_.show(null, null, m('same'));
+ T_.fly(m('flip') + .9, { by: 'rows', step: 3.3, dur: 1 });
+ T_.flash('a', 'all', m('same') + .4); T_.flash('t', 'all', m('same') + .4);
+ const n = S.note = G(p, {});
+ const s1 = G(n, { o: 0 });
+ T(s1, 'symmetric', { x: 980, y: 330, size: 54, weight: 700 });
+ T(s1, 'its transpose is itself', { x: 980, y: 380, size: 28, fill: COL.dim, weight: 600 });
+ show(s1, m('name'), .5);
+ say(n, ['Sᵀ = S'], 980, 470, m('eq'), { size: 54 });
+ }],
+
+ ['pairs', 'Mirror pairs', (m) => {
+ const T_ = S.T;
+ hide(S.note, .1, .4);
+ T_.diag(m('diag')); T_.show('diag', null, m('diag'));
+ T_.show(null, null, m('pair'));
+ T_.flash('a', [[0, 1], [1, 0]], m('pair')); T_.flash('t', [[0, 1], [1, 0]], m('pair'));
+ T_.pairs(m('equal'));
+ const n = G(S.T.g, {});
+ const r = G(n, { o: 0 });
+ T(r, 'every number = its mirror', { x: 980, y: 330, size: 34, weight: 700 });
+ T(r, 'across the diagonal', { x: 980, y: 378, size: 28, fill: COL.dim, weight: 600 });
+ show(r, m('rule'), .5);
+ text(n, 'the diagonal is free', 980, 470, m('free'), { size: 30, weight: 600 });
+ }],
+
+ ['ex3', 'Three by three', (m) => {
+ const p = panel(0);
+ title(p, 'Three by three: check the pairs');
+ const T_ = mmT(p, { A: S3, at: [140, 290], size: 54, cw: 86, rh: 76, gap: 200, names: ['S', 'Sᵀ'], hideT: true, t0: m('S') - .4 });
+ put(T_.L.t.g, { o: 0 }); show(T_.L.t.g, m('flip') - .2, .4);
+ [0, 1, 2].forEach(k => T_.show('row', k, m('S') + .8 + k * 2.4, { side: 'a' }));
+ T_.diag(m('diag')); T_.show('diag', null, m('diag'), { side: 'a' }); T_.show(null, null, m('p1'));
+ [['p1', 0, 1], ['p2', 0, 2], ['p3', 1, 2]].forEach(([k, i, j]) => { T_.flash('a', [[i, j]], m(k) + .2); T_.flash('a', [[j, i]], m(k) + 2.2); pairRing(T_.front, T_.L.a, i, j, m(k) + 3, COL.good, 54); });
+ T_.fly(m('flip') + .4, { by: 'rows', step: .7, dur: 1 });
+ const n = G(p, { o: 0 });
+ T(n, '3 pairs, all equal:', { x: 1040, y: 330, size: 32, weight: 600 });
+ T(n, 'symmetric', { x: 1040, y: 380, size: 40, weight: 700 });
+ show(n, m('yes'), .5);
+ }],
+
+ ['not', 'Two that fail', (m) => {
+ const p = panel(0);
+ title(p, 'Two that fail');
+ const T1 = mmT(p, { A: [[1, 2], [-2, 1]], at: [140, 270], size: 48, cw: 76, rh: 66, gap: 160, hideT: true, t0: m('A') - .4 });
+ put(T1.L.t.g, { o: 0 }); show(T1.L.t.g, m('sign') + .5, .4);
+ pairRing(T1.front, T1.L.a, 0, 1, m('pair'), COL.bad, 48);
+ T1.fly(m('sign') + .8, { by: 'rows', step: .8, dur: .9 });
+ say(p, ['Aᵀ ≠ A: 2 ≠ −2'], 860, 300, m('sign') + 2.4, { size: 36, fill: COL.bad });
+ const bg = G(p, { o: 0 }); show(bg, m('B') - .3, .4);
+ const T2 = mmT(bg, { A: [[1, 0, 2], [0, 3, 1]], at: [140, 600], size: 44, cw: 70, rh: 62, gap: 140, names: ['B', 'Bᵀ'], hideT: true, t0: 0 });
+ put(T2.L.t.g, { o: 0 }); show(T2.L.t.g, m('shape') - .2, .4);
+ T2.fly(m('shape'), { by: 'rows', step: .7, dur: .9 });
+ say(p, ['2 × 3 → 3 × 2'], 860, 640, m('shape') + 2.2, { size: 36, fill: COL.bad });
+ text(p, 'a different shape: never equal', 860, 690, m('shape') + 2.8, { size: 28, fill: COL.dim, weight: 600 });
+ text(p, 'symmetric ⇒ square', 860, 780, m('square'), { size: 34, weight: 700 });
+ }],
+
+ ['q1', 'Quick check', () => {
+ const p = panel(0);
+ title(p, 'Quick check');
+ }, { ask: done => quiz({ x: 40, y: 170, w: 900, cls: 'side' }, [{
+ id: 'c-which', prompt: ['Symmetric or not? Check each pair across the diagonal.'],
+ build: grid(Q1, YN, { multi: false, text: true }),
+ }], done) }],
+
+ ['plane', 'Rows on columns', (m) => {
+ const p = panel(0);
+ title(p, 'Symmetric: the rows lie on the columns');
+ const T_ = mmT(p, { A: PS, at: [90, 300], size: 50, cw: 80, rh: 72, gap: 150, names: ['S', 'Sᵀ'], plane: { cx: 1190, cy: 470, u: 44 }, t0: m('S') - .4 });
+ hideArrows(T_);
+ const { cols, rows } = T_.arrows;
+ cols.forEach(tp => show(tp.ag, m('cols') + .2, .5));
+ rows.forEach(tp => show(tp.ag, m('rows') + .2, .5));
+ T_.show('col', 0, m('on') + 1, { side: 'a' }); T_.show('row', 0, m('on') + 2.4, { side: 'a' });
+ T_.show('col', 1, m('on') + 3.8, { side: 'a' }); T_.show('row', 1, m('on') + 5, { side: 'a' }); T_.show(null, null, m('break'));
+ thick(cols[0], m('on') + 1); thick(rows[0], m('on') + 2.4); thick(cols[1], m('on') + 3.8); thick(rows[1], m('on') + 5);
+ T_.pairs(m('break'));
+ T_.to({ a01: -2 }, m('break') + 2.2, 1.4); T_.flash('a', [[0, 1]], m('break') + 2.2);
+ thick(cols[1], m('apart') + .4); thick(rows[0], m('apart') + 1.4);
+ T_.to({ a10: -2 }, m('fix') + 2.6, 1.4); T_.flash('a', [[1, 0]], m('fix') + 2.6);
+ text(p, 'symmetric again', 90, 600, m('back') + 1.6, { size: 30, fill: COL.good, weight: 700 });
+ }],
+
+ ['q2', 'Your turn', () => {
+ const p = panel(0);
+ title(p, 'Your turn');
+ const T_ = S.T = mmT(p, { A: [[3, 1], [-2, 1]], at: [90, 290], size: 50, cw: 80, rh: 72, gap: 150, plane: { cx: 1190, cy: 470, u: 44 } });
+ T_.pairs(0);
+ }, { ask: done => quiz({ x: 40, y: 470, w: 740, cls: 'side' }, [{
+ id: 'c-make', prompt: ['Make A symmetric: every dashed arrow on a solid one, the ring green.'],
+ build: mmTTask(S.T, (v, T_) => T_.sym(), 'Its mirror numbers now agree, so Aᵀ = A: each row lies on its column.',
+ v => `Row 1, column 2 holds ${num(v.a01)}; its mirror, row 2, column 1, holds ${num(v.a10)}. Make them equal.`,
+ () => S.T.set({ a10: 1 })),
+ }], done) }],
+
+ ['rtr', 'RᵀR', (m) => {
+ const p = panel(0);
+ title(p, 'Where symmetric matrices come from');
+ const P_ = mm(p, { A: tr(R1), B: R1, at: [70, 260], size: 40, cw: 62, rh: 60, names: ['Rᵀ', 'R', 'RᵀR'], tintB: 'cols', hideC: true, fillC: COL.chalk, work: [90, 640], wsize: 32, t0: m('R') - .4 });
+ put(P_.L.a.g, { o: 0 }); show(P_.L.a.g, m('rt') + .2, .4);
+ put(P_.L.c.g, { o: 0 }); show(P_.L.c.g, m('mult') + .2, .4);
+ [0, 1, 2].forEach(i => P_.flash('b', { row: i }, m('R') + 5.2 + i * 1.3));
+ P_.flash('a', { row: 0 }, m('rt') + .6); P_.flash('a', { row: 1 }, m('rt') + 1.4);
+ P_.inner(m('size') + .4); P_.outer(m('size') + 2.6);
+ [['c11', [0, 0]], ['c12', [0, 1]], ['c21', [1, 0]], ['c22', [1, 1]]].forEach(([k, ij], n) => {
+ P_.show('entry', ij, m(k) - (n ? .2 : 1.2), { times: [m(k) - (n ? .2 : 1.2)] });
+ P_.reveal({ cell: ij }, m(k) + .1);
+ });
+ P_.show(null, null, m('sym'));
+ symRings(p, P_, 40, m('sym') + .4);
+ const n = G(p, { o: 0 });
+ M(n, ['RᵀR is symmetric'], { x: 1000, y: 330, size: 40 });
+ T(n, '13 and 13 in mirror spots', { x: 1000, y: 380, size: 28, fill: COL.dim, weight: 600 });
+ show(n, m('sym') + 1.4, .5);
+ }],
+
+ ['rtr2', 'Another R', (m) => {
+ const p = panel(0);
+ title(p, 'Another R, and the other order');
+ const o = { size: 40, cw: 62, rh: 60, sizes: false, hideC: true, fillC: COL.chalk };
+ const P1 = mm(p, { A: tr(R2), B: R2, at: [70, 260], names: ['Rᵀ', 'R', 'RᵀR'], tintB: 'cols', ...o, t0: m('R') - .4 });
+ P1.reveal('all', m('prod') + .3);
+ symRings(p, P1, 40, m('sym') + .3);
+ const P2 = mm(p, { A: R2, B: tr(R2), at: [70, 580], names: ['R', 'Rᵀ', 'RRᵀ'], tintA: 'cols', ...o, t0: m('other') - .3 });
+ P2.reveal('all', m('other') + 2.4);
+ symRings(p, P2, 40, m('other') + 4.4);
+ text(p, 'RᵀR ≠ RRᵀ, but both are symmetric', 860, 470, m('other') + 4.8, { size: 30, weight: 600 });
+ }],
+
+ ['why', 'Why: columns times columns', (m) => {
+ const p = panel(0);
+ title(p, 'Why: a column times a column');
+ const P_ = mm(p, { A: tr(R1), B: R1, at: [70, 240], size: 40, cw: 62, rh: 60, names: ['Rᵀ', 'R', 'RᵀR'], tintB: 'cols', sizes: false, fillC: COL.chalk });
+ put(P_.W, { o: 0 });
+ P_.show('entry', [0, 1], m('ent'));
+ P_.flash('a', { row: 0 }, m('col1')); P_.flash('b', { col: 0 }, m('col1') + .8);
+ say(p, ['row 1 of Rᵀ = column 1 of R'], 90, 520, m('col1') + .3, { size: 30, fill: COL.dim });
+ const G1 = MM_COL[0], V1 = MM_COL[1];
+ say(p, ['row 1, column 2:'], 90, 600, m('pairs'), { size: 32, fill: COL.dim });
+ say(p, ['1·3 + 2·3 + 4·1'], 380, 600, m('pairs') + 3.4, { size: 36 });
+ say(p, ['= 13'], 680, 600, m('pairs') + 8.6, { size: 36 });
+ P_.show('entry', [1, 0], m('mirror'));
+ say(p, ['row 2, column 1:'], 90, 680, m('mirror') + .3, { size: 32, fill: COL.dim });
+ say(p, ['3·1 + 3·2 + 1·4'], 380, 680, m('same') + 1.6, { size: 36 });
+ say(p, ['= 13'], 680, 680, m('same') + 7, { size: 36 });
+ // the two columns of R, side by side: their numbers pair up the same way either way round
+ const cg = G(p, { o: 0 });
+ T(cg, 'column 1', { x: 1050, y: 470, size: 26, fill: G1, weight: 600, anchor: 'middle' });
+ T(cg, 'column 2', { x: 1250, y: 470, size: 26, fill: V1, weight: 600, anchor: 'middle' });
+ R1.forEach((r, i) => {
+ M(cg, [num(r[0])], { x: 1050, y: 530 + i * 56, size: 36, fill: G1, anchor: 'middle' });
+ M(cg, ['×'], { x: 1150, y: 530 + i * 56, size: 30, fill: COL.dim, anchor: 'middle' });
+ M(cg, [num(r[1])], { x: 1250, y: 530 + i * 56, size: 36, fill: V1, anchor: 'middle' });
+ });
+ show(cg, m('pairs') + 1, .5);
+ const sw = G(p, { o: 0 });
+ T(sw, 'either way round: the same pairs', { x: 1150, y: 730, size: 26, fill: COL.chalk, weight: 600, anchor: 'middle' });
+ show(sw, m('always'), .5);
+ // "in the other order": the two columns hop, the pairs stay pairs
+ prog(q => put(cg, { x: 0, y: -14 * Math.sin(Math.PI * q) }), m('mirror') + .4, 1.2, io);
+ }],
+
+ ['rule', 'Why: the transpose rule', (m) => {
+ const p = panel(0);
+ title(p, 'Why: by the rule (AB)ᵀ = BᵀAᵀ');
+ const X = 200, Y = [300, 430, 560];
+ say(p, ['(RᵀR)ᵀ'], X, Y[0], m('start') + .2, { size: 56 });
+ // the two factors leave line one, trade places and each take a flip
+ const a = G(p, { o: 0 }), b = G(p, { o: 0 });
+ M(a, ['Rᵀ'], { size: 56, anchor: 'middle' }); M(b, ['R'], { size: 56, anchor: 'middle' });
+ put(a, { x: X + 46, y: Y[0] }); put(b, { x: X + 118, y: Y[0] });
+ show(a, m('rev'), .1); show(b, m('rev'), .1);
+ tw(a, { x: X + 236, y: Y[1] }, m('rev') + .2, 1.2); tw(b, { x: X + 106, y: Y[1] }, m('rev') + .2, 1.2);
+ hide(a, m('get'), .2); hide(b, m('get'), .2);
+ say(p, ['='], X, Y[1], m('rev') + .4, { size: 56 });
+ say(p, ['Rᵀ'], X + 80, Y[1], m('get'), { size: 56 });
+ say(p, ['(Rᵀ)ᵀ'], X + 180, Y[1], m('get'), { size: 56 });
+ text(p, 'reverse the order, flip each', 720, Y[1] - 10, m('rev') + .6, { size: 28, fill: COL.dim, weight: 600 });
+ say(p, ['= RᵀR'], X, Y[2], m('back') + 1, { size: 56 });
+ text(p, '(Rᵀ)ᵀ = R: two flips undo each other', 720, Y[2] - 10, m('back'), { size: 28, fill: COL.dim, weight: 600 });
+ const e = G(p, { o: 0 });
+ M(e, ['(RᵀR)ᵀ = RᵀR'], { x: X, y: 720, size: 56 });
+ T(e, 'symmetric, for every R', { x: X + 440, y: 712, size: 34, fill: COL.good, weight: 700 });
+ show(e, m('end') + .5, .5);
+ draw(path(p, `M${X} 742H${X + 410}`, { stroke: COL.good, 'stroke-width': 4 }, { d: 0 }), m('end') + 3, .8);
+ }],
+
+ ['q3', 'Quick check', () => {
+ const p = panel(0);
+ title(p, 'Quick check');
+ S.P = mm(p, { A: [[1, 0], [1, 2]], B: [[1, 1], [0, 2]], at: [70, 260], size: 40, cw: 62, rh: 60, names: ['Rᵀ', 'R', 'RᵀR'], tintB: 'cols', sizes: false, hideC: true, fillC: COL.chalk });
+ }, { ask: done => quiz(CARD, [{
+ id: 'c-rtr', prompt: ['R = ', matEl([[1, 1], [0, 2]]), '. Work out RᵀR: each number is a column of R times a column of R.'],
+ build: blanks([{ parts: ['row 1 of RᵀR = (', { box: '1' }, ', ', { box: '1' }, ')'], why: 'Column 1 (1, 0) times itself: 1. Times column 2 (1, 2): 1·1 + 0·2 = 1.',
+ hint: 'Row 1, column 2 is column 1 of R times column 2: 1·1 + 0·2.', fx: () => S.P.uncover({ row: 0 }) },
+ { parts: ['row 2 of RᵀR = (', { box: '1' }, ', ', { box: '5' }, ')'], why: 'The mirror of the first 1 is 1 again; column 2 times itself: 1·1 + 2·2 = 5.',
+ hint: 'Row 2, column 1 is the mirror of row 1, column 2. Row 2, column 2 is column 2 times itself.', fx: () => S.P.uncover({ row: 1 }) }]),
+ }], done) }],
+
+ ['live', 'Any R at all', (m) => {
+ const p = panel(0);
+ title(p, 'Any R at all');
+ const P_ = S.P = mm(p, { A: tr(R1), B: R1, at: [70, 260], size: 40, cw: 62, rh: 60, names: ['Rᵀ', 'R', 'RᵀR'], tintB: 'cols', sizes: false, fillC: COL.chalk });
+ rtrLink(P_);
+ symRings(p, P_, 40, .4);
+ P_.to({ b00: -2 }, m('go') + .4, 1.4); P_.flash('b', { cell: [0, 0] }, m('go') + .4); P_.flash('a', { cell: [0, 0] }, m('go') + 1.8);
+ P_.flash('c', { cell: [0, 1] }, m('stay')); P_.flash('c', { cell: [1, 0] }, m('stay'));
+ P_.to({ b21: 5 }, m('again') + .4, 1.4); P_.flash('b', { cell: [2, 1] }, m('again') + .4);
+ P_.flash('c', 'all', m('again') + 2);
+ }],
+
+ ['q4', 'Your turn', () => {
+ S.P.set({ b00: 1, b01: 3, b10: 2, b11: 3, b20: 4, b21: 1 });
+ }, { ask: done => quiz({ x: 860, y: 460, w: 700, cls: 'side' }, [{
+ id: 'c-zero', prompt: ['Change R until the top-right number of RᵀR is 0. Watch its mirror.'],
+ build: mmTask(S.P, (v, C) => C[0][1] === 0, 'Column 1 times column 2 is now 0, and the mirror number is 0 with it: RᵀR is still symmetric.',
+ (v, C) => `Row 1, column 2 is column 1 of R times column 2: now ${num(C[0][1])}. Try changing column 2 of R so the products cancel.`,
+ () => S.P.set({ b01: 2, b11: -1, b21: 0 }), { only: ['b00', 'b01', 'b10', 'b11', 'b20', 'b21'] }),
+ }], done) }],
+
+ ['wrap', 'Summary', (m) => {
+ const p = panel(0);
+ [['Symmetric: Sᵀ = S, the flip changes nothing.', 'w1'], ['Test by pairs: each number equals its mirror; the diagonal is free.', 'w2'],
+ ['A symmetric matrix is square; its rows lie on its columns.', 'w3'], ['RᵀR is symmetric for every R: (RᵀR)ᵀ = Rᵀ(Rᵀ)ᵀ = RᵀR.', 'w4']].forEach(([str, mark], i) => {
+ const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });
+ mk('circle', { cx: 120, cy: -12, r: 26, fill: COL.chalk }, g);
+ T(g, String(i + 1), { x: 120, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
+ T(g, str, { x: 170, size: 34, weight: 600 });
+ tw(g, { o: 1, x: 0 }, m(mark), .6);
+ });
+ }],
+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{
+ id: 'p-sym', prompt: ['Symmetric or not?'],
+ build: grid(SYMQ, YN, { multi: false, text: true }),
+ }], done, 'Chapter practice · set 1 of 4') }],
+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
+ id: 'p-fill', prompt: ['Fill the gaps so that each matrix is symmetric.'],
+ build: blanks(FILLQ),
+ }], done, 'Chapter practice · set 2 of 4') }],
+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
+ id: 'p-rtr', prompt: ['Work out RᵀR (columns of R times columns of R) or RRᵀ (rows times rows).'],
+ build: blanks(RTRQ),
+ }, {
+ id: 'p-square', prompt: ['R is 4 × 2. What is RᵀR?'],
+ build: choice(['2 × 2 and symmetric', '4 × 4 and symmetric', '2 × 2, symmetric only by luck', 'it does not fit'], 0,
+ 'Rᵀ is 2 × 4, so RᵀR = (2 × 4)(4 × 2) = 2 × 2; and RᵀR is always symmetric.',
+ [null, 'That is R Rᵀ: (4 × 2)(2 × 4) = 4 × 4. RᵀR has the inside numbers 4 and 4.', 'Never luck: (RᵀR)ᵀ = RᵀR for every R.', 'Rᵀ is 2 × 4 and R is 4 × 2: the inside numbers, 4 and 4, match.']),
+ }], done, 'Chapter practice · set 3 of 4') }],
+ ['final4', 'Chapter practice', () => {
+ const p = panel(0);
+ title(p, 'Make it symmetric');
+ S.T = mmT(p, { A: [[2, 3], [-1, 1]], at: [90, 290], size: 50, cw: 80, rh: 72, gap: 150, plane: { cx: 1190, cy: 470, u: 44 } });
+ S.T.pairs(0);
+ }, { ask: done => quiz({ x: 40, y: 470, w: 740, cls: 'side' }, HANDQ.map(q => ({
+ id: q.id, prompt: q.prompt,
+ build: (body, api) => { S.T.set(q.start); return mmTTask(S.T, q.test || ((v, T_) => T_.sym()), q.why, q.hint, () => S.T.set(q.ans), { only: q.only })(body, api); },
+ })), done, 'Chapter practice · set 4 of 4') }],
+ ['play', 'Playground', (m) => {
+ const p = panel(0);
+ title(p, 'Playground');
+ S.T = mmT(p, { A: PS, at: [90, 250], size: 40, cw: 64, rh: 56, gap: 120, names: ['S', 'Sᵀ'], plane: { cx: 1190, cy: 470, u: 44 } });
+ S.T.pairs(0);
+ const hint = G(p, { o: 0 });
+ T(hint, 'try: break it and mend it · make it 3 × 3 and symmetric', { x: 1190, y: 790, size: 24, fill: COL.dim, anchor: 'middle' });
+ T(hint, 'drag a dashed arrow off its solid one, then fix it', { x: 1190, y: 824, size: 24, fill: COL.dim, anchor: 'middle' });
+ show(hint, m('go'), .5);
+ }, { ask: playAsk(() => S.T, { pos: { x: 40, y: 470, w: 740, cls: 'side' }, live: { sizes: true, drag: true },
+ tip: 'Your matrix and its transpose. The rings join mirror numbers: green when they agree. Nothing is marked.' }) }],
+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
+
+boot();
+</script>
+</body>
+</html>
diff --git a/site/linear-algebra/ch37/audio/en/combos.mp3 b/site/linear-algebra/ch37/audio/en/combos.mp3
new file mode 100644
index 0000000..afd72c9
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/combos.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/dots.mp3 b/site/linear-algebra/ch37/audio/en/dots.mp3
new file mode 100644
index 0000000..e79551e
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/dots.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/final1.mp3 b/site/linear-algebra/ch37/audio/en/final1.mp3
new file mode 100644
index 0000000..0ec72d3
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/final1.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/final2.mp3 b/site/linear-algebra/ch37/audio/en/final2.mp3
new file mode 100644
index 0000000..194911a
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/final2.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/final3.mp3 b/site/linear-algebra/ch37/audio/en/final3.mp3
new file mode 100644
index 0000000..7da1f83
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/final3.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/final4.mp3 b/site/linear-algebra/ch37/audio/en/final4.mp3
new file mode 100644
index 0000000..2c64544
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/final4.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/finish.mp3 b/site/linear-algebra/ch37/audio/en/finish.mp3
new file mode 100644
index 0000000..b50ad0d
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/finish.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/intro.mp3 b/site/linear-algebra/ch37/audio/en/intro.mp3
new file mode 100644
index 0000000..c5ce968
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/intro.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/play.mp3 b/site/linear-algebra/ch37/audio/en/play.mp3
new file mode 100644
index 0000000..c2be05a
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/play.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/q1.mp3 b/site/linear-algebra/ch37/audio/en/q1.mp3
new file mode 100644
index 0000000..68c3017
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/q1.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/q2.mp3 b/site/linear-algebra/ch37/audio/en/q2.mp3
new file mode 100644
index 0000000..6c89189
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/q2.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/q3.mp3 b/site/linear-algebra/ch37/audio/en/q3.mp3
new file mode 100644
index 0000000..219f1ba
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/q3.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/quad.mp3 b/site/linear-algebra/ch37/audio/en/quad.mp3
new file mode 100644
index 0000000..0f6b94f
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/quad.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/r3.mp3 b/site/linear-algebra/ch37/audio/en/r3.mp3
new file mode 100644
index 0000000..7dd9cf2
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/r3.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/recall.mp3 b/site/linear-algebra/ch37/audio/en/recall.mp3
new file mode 100644
index 0000000..d3c5884
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/recall.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/rn.mp3 b/site/linear-algebra/ch37/audio/en/rn.mp3
new file mode 100644
index 0000000..d09fb0c
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/rn.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/space.mp3 b/site/linear-algebra/ch37/audio/en/space.mp3
new file mode 100644
index 0000000..0a5dd1f
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/space.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/timings.js b/site/linear-algebra/ch37/audio/en/timings.js
new file mode 100644
index 0000000..8a599c9
--- /dev/null
+++ b/site/linear-algebra/ch37/audio/en/timings.js
@@ -0,0 +1,608 @@
+window.TIMINGS = {
+ "intro": {
+ "dur": 9.072,
+ "marks": {
+ "sub": 1.758,
+ "move": 3.503
+ },
+ "cues": [
+ [
+ 0.104,
+ "Chapter thirty-seven."
+ ],
+ [
+ 1.758,
+ "What is a vector space?"
+ ],
+ [
+ 3.503,
+ "A collection of vectors where you can add and stretch as much as you like, and never fall out."
+ ]
+ ]
+ },
+ "recall": {
+ "dur": 29.832,
+ "marks": {
+ "v": 2.161,
+ "w": 9.062,
+ "add": 11.966,
+ "sum": 15.013,
+ "stretch": 17.682,
+ "mix": 20.924
+ },
+ "cues": [
+ [
+ 0.143,
+ "First, what we already know."
+ ],
+ [
+ 2.161,
+ "Chapter four: a vector is an arrow, and a column of numbers."
+ ],
+ [
+ 7.148,
+ "Here v is two, one."
+ ],
+ [
+ 9.062,
+ "And w is minus one, two."
+ ],
+ [
+ 11.966,
+ "Chapter five added them, tip to tail: v plus w is one, three."
+ ],
+ [
+ 17.682,
+ "And stretched them: two v is four, two."
+ ],
+ [
+ 20.924,
+ "Chapter six mixed both at once: c times v, plus d times w."
+ ],
+ [
+ 26.641,
+ "Every pair c, d gives a new arrow."
+ ]
+ ]
+ },
+ "space": {
+ "dur": 51.936,
+ "marks": {
+ "word": 1.237,
+ "rule1": 5.755,
+ "rule2": 12.253,
+ "plane": 18.841,
+ "add": 29.01,
+ "in1": 31.914,
+ "scale": 34.531,
+ "in2": 38.138,
+ "neg": 39.349,
+ "so": 45.065
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now a new word."
+ ],
+ [
+ 1.237,
+ "A vector space is a collection of vectors that obeys two rules."
+ ],
+ [
+ 5.755,
+ "Rule one: add any two vectors of the collection, and the answer is in the collection too."
+ ],
+ [
+ 12.253,
+ "Rule two: multiply any one of them by any number, and the answer is in the collection too."
+ ],
+ [
+ 18.841,
+ "Our first example is the whole plane: every pair of numbers x, y."
+ ],
+ [
+ 24.453,
+ "Its name is R two: R for the real numbers, two for two of them."
+ ],
+ [
+ 29.01,
+ "Add v and w: one, three."
+ ],
+ [
+ 31.914,
+ "Two numbers, so it is in R two."
+ ],
+ [
+ 34.531,
+ "Multiply v by three: six, three."
+ ],
+ [
+ 38.138,
+ "Two numbers again."
+ ],
+ [
+ 39.349,
+ "Multiply by minus one: minus two, minus one."
+ ],
+ [
+ 43.477,
+ "Still two numbers."
+ ],
+ [
+ 45.065,
+ "Whatever we do, we get a pair, and every pair is in R two."
+ ],
+ [
+ 49.544,
+ "So R two is a vector space."
+ ]
+ ]
+ },
+ "zero": {
+ "dur": 23.016,
+ "marks": {
+ "zero": 3.294,
+ "shrink": 5.391,
+ "must": 11.081,
+ "also": 17.982
+ },
+ "cues": [
+ [
+ 0.104,
+ "One thing every vector space must hold."
+ ],
+ [
+ 3.294,
+ "Multiply v by zero."
+ ],
+ [
+ 5.391,
+ "The arrow shrinks to nothing: zero, zero, the point at the origin."
+ ],
+ [
+ 11.081,
+ "Rule two allows multiplying by zero, so the zero vector is inside every vector space."
+ ],
+ [
+ 17.982,
+ "Adding gets there too: v plus minus v is zero, zero."
+ ]
+ ]
+ },
+ "combos": {
+ "dur": 23.328,
+ "marks": {
+ "cv": 2.135,
+ "dw": 4.883,
+ "both": 8.021,
+ "all": 10.625
+ },
+ "cues": [
+ [
+ 0.104,
+ "Now put the two rules together."
+ ],
+ [
+ 2.135,
+ "c times v is inside, by rule two."
+ ],
+ [
+ 4.883,
+ "d times w is inside, by rule two."
+ ],
+ [
+ 8.021,
+ "And their sum is inside, by rule one."
+ ],
+ [
+ 10.625,
+ "So every combination of vectors in a vector space stays in the space."
+ ],
+ [
+ 15.26,
+ "Let c and d run through many numbers: the combinations land all over the plane, and none of them leaves it."
+ ]
+ ]
+ },
+ "q1": {
+ "dur": 2.544,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.146,
+ "Which of these are in R two?"
+ ]
+ ]
+ },
+ "r3": {
+ "dur": 28.56,
+ "marks": {
+ "three": 1.562,
+ "v": 9.792,
+ "w": 12.461,
+ "add": 14.349,
+ "in": 18.32,
+ "scale": 21.055,
+ "in2": 24.987,
+ "so": 26.25
+ },
+ "cues": [
+ [
+ 0.156,
+ "Three numbers next."
+ ],
+ [
+ 1.562,
+ "A list of three numbers is an arrow in space, as in chapter eleven."
+ ],
+ [
+ 6.797,
+ "All of them together are called R three."
+ ],
+ [
+ 9.792,
+ "Take v, one, two, zero, and w, zero, one, two."
+ ],
+ [
+ 14.349,
+ "Add them, number by number: one, three, two."
+ ],
+ [
+ 18.32,
+ "Three numbers, so it is in R three."
+ ],
+ [
+ 21.055,
+ "Stretch w by two: zero, two, four."
+ ],
+ [
+ 24.987,
+ "Three numbers again."
+ ],
+ [
+ 26.25,
+ "R three is a vector space too."
+ ]
+ ]
+ },
+ "rn": {
+ "dur": 42.816,
+ "marks": {
+ "four": 1.94,
+ "v": 7.096,
+ "w": 12.904,
+ "add": 17.331,
+ "sum": 18.763,
+ "scale": 25.078,
+ "n": 33.099
+ },
+ "cues": [
+ [
+ 0.104,
+ "And more numbers than axes?"
+ ],
+ [
+ 1.94,
+ "Chapter fifteen drew those as bars: one bar for each number."
+ ],
+ [
+ 7.096,
+ "Here v has five numbers: one, minus two, zero, three, one."
+ ],
+ [
+ 12.904,
+ "And w: two, one, minus one, zero, two."
+ ],
+ [
+ 17.331,
+ "Add them bar by bar."
+ ],
+ [
+ 18.763,
+ "Three, minus one, minus one, three, three."
+ ],
+ [
+ 22.812,
+ "Five numbers: in R five."
+ ],
+ [
+ 25.078,
+ "Stretch v by two: every bar doubles."
+ ],
+ [
+ 28.19,
+ "Two, minus four, zero, six, two."
+ ],
+ [
+ 31.198,
+ "Still five numbers."
+ ],
+ [
+ 33.099,
+ "For any count n, all lists of n numbers form a vector space, called R n."
+ ],
+ [
+ 39.076,
+ "Adding and stretching never change how many numbers there are."
+ ]
+ ]
+ },
+ "q2": {
+ "dur": 3.0,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Quick check."
+ ],
+ [
+ 1.146,
+ "Add and stretch in R four."
+ ]
+ ]
+ },
+ "quad": {
+ "dur": 37.872,
+ "marks": {
+ "quarter": 1.94,
+ "v": 7.435,
+ "w": 9.167,
+ "add": 12.344,
+ "ok": 14.635,
+ "scale": 20.026,
+ "neg": 24.193,
+ "out": 26.693,
+ "fail": 31.146
+ },
+ "cues": [
+ [
+ 0.091,
+ "Now a collection that fails."
+ ],
+ [
+ 1.94,
+ "Keep only the arrows that point into the top right quarter: both numbers zero or more."
+ ],
+ [
+ 7.435,
+ "v is two, one, and w is one, three."
+ ],
+ [
+ 11.172,
+ "Both are inside."
+ ],
+ [
+ 12.344,
+ "Add them: three, four."
+ ],
+ [
+ 14.635,
+ "Inside."
+ ],
+ [
+ 15.638,
+ "Adding two arrows of the quarter always stays in the quarter."
+ ],
+ [
+ 20.026,
+ "Now stretch v by two: four, two."
+ ],
+ [
+ 22.943,
+ "Inside too."
+ ],
+ [
+ 24.193,
+ "But multiply v by minus one."
+ ],
+ [
+ 26.693,
+ "Minus two, minus one: it points the other way, out of the quarter."
+ ],
+ [
+ 31.146,
+ "Rule two says every number."
+ ],
+ [
+ 33.607,
+ "One failure is enough: the quarter is not a vector space."
+ ]
+ ]
+ },
+ "dots": {
+ "dur": 24.12,
+ "marks": {
+ "dots": 1.927,
+ "add": 6.107,
+ "scale": 13.594,
+ "half": 16.432,
+ "fail": 20.326
+ },
+ "cues": [
+ [
+ 0.104,
+ "Another one that fails."
+ ],
+ [
+ 1.927,
+ "Keep only the points with whole number coordinates, the dots of the grid."
+ ],
+ [
+ 6.107,
+ "Add one, two and two, one: three, three."
+ ],
+ [
+ 9.948,
+ "A dot."
+ ],
+ [
+ 10.964,
+ "Adding whole numbers gives whole numbers."
+ ],
+ [
+ 13.594,
+ "But multiply one, one by one half."
+ ],
+ [
+ 16.432,
+ "One half, one half: it lands between the dots."
+ ],
+ [
+ 20.326,
+ "Not in the collection, so this is not a vector space either."
+ ]
+ ]
+ },
+ "q3": {
+ "dur": 9.264,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Your turn."
+ ],
+ [
+ 1.042,
+ "Show that the quarter is not a vector space: find a v in the quarter, and a number c that throws c v out of it."
+ ]
+ ]
+ },
+ "wrap": {
+ "dur": 29.928,
+ "marks": {
+ "w1": 1.003,
+ "w2": 11.354,
+ "w3": 16.953,
+ "w4": 23.685,
+ "end": 28.646
+ },
+ "cues": [
+ [
+ 0.104,
+ "Let's sum up."
+ ],
+ [
+ 1.003,
+ "A vector space is a collection of vectors closed under two moves: adding any two, and multiplying any one by any number."
+ ],
+ [
+ 9.753,
+ "The answers stay inside."
+ ],
+ [
+ 11.354,
+ "So every combination stays inside, and the zero vector is always there."
+ ],
+ [
+ 16.953,
+ "R two, R three, and R n, all lists of n numbers, are vector spaces."
+ ],
+ [
+ 23.685,
+ "The quarter plane and the grid dots are not: a stretch can throw a vector out."
+ ],
+ [
+ 28.646,
+ "Now practice."
+ ]
+ ]
+ },
+ "final1": {
+ "dur": 3.96,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Chapter practice."
+ ],
+ [
+ 1.51,
+ "Which space is each vector in?"
+ ]
+ ]
+ },
+ "final2": {
+ "dur": 3.576,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Set two."
+ ],
+ [
+ 1.081,
+ "Add and stretch, number by number."
+ ]
+ ]
+ },
+ "final3": {
+ "dur": 2.88,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Set three."
+ ],
+ [
+ 1.211,
+ "Is it a vector space?"
+ ]
+ ]
+ },
+ "final4": {
+ "dur": 3.552,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Last set."
+ ],
+ [
+ 1.341,
+ "Break the rules with your own hands."
+ ]
+ ]
+ },
+ "play": {
+ "dur": 11.832,
+ "marks": {
+ "go": 4.167
+ },
+ "cues": [
+ [
+ 0.104,
+ "Playground."
+ ],
+ [
+ 1.068,
+ "Nothing here is marked right or wrong."
+ ],
+ [
+ 4.167,
+ "Change v, w, c and d, drag the tips, and watch whether the combination stays in the quarter."
+ ]
+ ]
+ },
+ "finish": {
+ "dur": 11.76,
+ "marks": {},
+ "cues": [
+ [
+ 0.104,
+ "Well done."
+ ],
+ [
+ 1.107,
+ "That's the end of chapter thirty-seven, what is a vector space."
+ ],
+ [
+ 5.404,
+ "Next: subspaces of the plane, the lines through the origin, which are vector spaces of their own."
+ ]
+ ]
+ }
+};
diff --git a/site/linear-algebra/ch37/audio/en/wrap.mp3 b/site/linear-algebra/ch37/audio/en/wrap.mp3
new file mode 100644
index 0000000..7329d96
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/wrap.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/zero.mp3 b/site/linear-algebra/ch37/audio/en/zero.mp3
new file mode 100644
index 0000000..d618140
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/zero.mp3 differ
diff --git a/site/linear-algebra/ch37/index.html b/site/linear-algebra/ch37/index.html
new file mode 100644
index 0000000..7d050bb
--- /dev/null
+++ b/site/linear-algebra/ch37/index.html
@@ -0,0 +1,441 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>What Is a Vector Space?</title>
+<link rel="stylesheet" href="../lib/engine.css">
+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->
+</head>
+<body>
+<script src="../lib/engine.js"></script>
+<script src="../lib/math.js"></script>
+<script src="../lib/vecs.js"></script>
+<script src="../lib/bars.js"></script>
+<script src="../lib/space3.js"></script>
+<script src="../lib/play.js"></script>
+<script src="audio/en/timings.js"></script>
+<script>
+'use strict';
+const CHAPTER = { number: 37, title: 'What Is a Vector Space?', minutes: 11, language: 'en', next: '../ch38/' };
+
+/* ---------- chapter helpers ---------- */
+const GREEN = VS_COL[0], VIOLET = VS_COL[1];
+const V2 = { v: [2, 1], w: [-1, 2] }; // the plane's pair: v + w = (1, 3)
+const Q2 = { v: [2, 1], w: [1, 3] }; // the quarter: v + w = (3, 4)
+const RV = [1, -2, 0, 3, 1], RW = [2, 1, -1, 0, 2]; // R⁵: v + w = (3, −1, −1, 3, 3), 2v = (2, −4, 0, 6, 2)
+const CARD = { x: 40, y: 450, w: 740, cls: 'side' };
+const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
+const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
+const title = (p, str) => text(p, str, 60, 110, .2, { size: 40, weight: 600 });
+const showRow = (r, t0, dur = .4) => r.parts.forEach(e => show(e, t0, dur));
+const thick = (vs, id, t0, w = 5) => { tw(vs.A[id].path, { 'a_stroke-width': w + 5 }, t0, .3); tw(vs.A[id].path, { 'a_stroke-width': w }, t0 + 1.2, .6); };
+const pair = (x, y) => `(${num(Math.round(x * 10) / 10)}, ${num(Math.round(y * 10) / 10)})`;
+// "2v − w", "½v", "−v + 3w": the combination's name, as it is written (no 1s, no + −, no 0 terms)
+const comboLabel = (vs, c, d) => {
+ const term = (k, n) => Math.abs(k) === 1 ? [n] : [...vs.parts(Math.abs(k)), n];
+ const out = [];
+ if (Math.abs(c) > 1e-9) out.push(...(c < 0 ? ['−'] : []), ...term(c, 'v'));
+ if (Math.abs(d) > 1e-9) out.push(out.length ? (d < 0 ? ' − ' : ' + ') : (d < 0 ? '−' : ''), ...term(d, 'w'));
+ return vs.nice(c) && vs.nice(d) ? out : [];
+};
+// The plane's vectors: v and w, c·v + d·w drawn tip to tail, the combination as the amber arrow.
+const plane2 = (p, { v, w }, { c = 1, d = 1, show: sh = ['v', 'w'], t0 = .1, steps } = {}) => {
+ const vs = vecs(p, { vecs: { v, w }, c, d, show: sh, plane: { cx: 1160, cy: 460, u: 50 }, t0, steps });
+ vs.label('sum', v_ => comboLabel(vs, v_.c, v_.d));
+ vs.label('cv', ['']); vs.label('dw', ['']);
+ return vs;
+};
+// A region of the plane drawn under the arrows: 'quarter' (x, y ≥ 0), 'half' (y ≥ 0), 'dots' (whole-number points).
+const region = (vs, kind, t0 = .3) => {
+ const { PX, PY, x0, x1, y0, y1 } = vs.P, g = G(vs.P.g, { o: 0 });
+ vs.P.g.insertBefore(g, vs.layer);
+ if (kind === 'dots') { for (let x = x0; x <= x1; x++) for (let y = y0; y <= y1; y++) mk('circle', { cx: PX(x), cy: PY(y), r: 5, fill: COL.chalk, 'fill-opacity': .55 }, g); }
+ else {
+ const yb = kind === 'half' ? y0 : 0;
+ mk('rect', { x: PX(kind === 'half' ? x0 : 0), y: PY(y1), width: PX(x1) - PX(kind === 'half' ? x0 : 0), height: PY(yb) - PY(y1), fill: COL.chalk, 'fill-opacity': .1 }, g);
+ path(g, kind === 'half' ? `M${PX(x0)} ${PY(0)}H${PX(x1)}` : `M${PX(0)} ${PY(y1)}V${PY(0)}H${PX(x1)}`, { stroke: COL.chalk, 'stroke-width': 4, 'stroke-opacity': .6, fill: 'none' });
+ }
+ if (t0 != null) show(g, t0, .5);
+ return g;
+};
+const IN = {
+ quarter: ([x, y]) => x > -1e-9 && y > -1e-9,
+ half: ([x, y]) => y > -1e-9,
+ dots: ([x, y]) => Math.abs(x - Math.round(x)) < 1e-9 && Math.abs(y - Math.round(y)) < 1e-9,
+};
+// A live line under the algebra: the combination's numbers and whether it is inside the region.
+const verdict = (p, vs, kind, x, y, t0, { name = 'the arrow' } = {}) => {
+ const g = G(p, { o: 0 }), t = T(g, '', { x, y, size: 30, weight: 700 });
+ const up = () => {
+ const s = vs.calc().sum, ok = IN[kind](s), str = `${name} = ${pair(s[0], s[1])}: ${ok ? 'inside ✓' : 'outside ✗'}`;
+ if (t.textContent !== str) t.textContent = str;
+ t.setAttribute('fill', ok ? COL.good : COL.bad);
+ };
+ vs.onChange(up); up();
+ if (t0 != null) show(g, t0, .4);
+ return g;
+};
+// R⁵ (or any n) as bars: v and w, and x₁v + x₂w; b is not part of this chapter, so it is hidden.
+const barsVW = (p, v, w, mix, { t0 = .1, top = 240, band = 86 } = {}) => {
+ const bs = bars(p, { A: v.map((a, i) => [a, w[i]]), b: v.map(() => 99), mix, names: ['v', 'w', 'x₁v + x₂w'], top, band, unit: 9, t0 });
+ put(bs.b.g, { o: 0 }); bs.eqs.forEach(e => put(e, { o: 0 })); bs.ax.goal.forEach(r => { r.style.display = 'none'; });
+ return bs;
+};
+const col = xs => h('span', 'vcol', xs.map(x => h('span', '', [num(x)])));
+
+/* ---------- practice data (every sum and multiple worked twice, number by number) ---------- */
+const INR2 = [
+ { parts: [hcol(3, -1)], ans: ['y'], why: 'Two real numbers: a pair, so it is in R².' },
+ { parts: [hcol('1.5', 0)], ans: ['y'], why: 'Fractions and decimals are real numbers too: in R².' },
+ { parts: [col([2, 4, 1])], ans: ['n'], why: 'Three numbers: that is a vector of R³, not R².' },
+ { parts: [hcol(0, 0)], ans: ['y'], why: 'The zero vector of the plane: in R² (in every vector space).' },
+];
+const YN = [['y', 'In R²', COL.good, 'Y'], ['n', 'Not in R²', COL.bad, 'N']];
+const WHICH = [
+ { parts: [hcol(1, 2)], ans: ['2'] }, { parts: [col([0, 0, 0])], ans: ['3'] }, { parts: [col([3, -1, 4, 1, 5])], ans: ['5'] },
+ { parts: [col([2, 2, 2, 2])], ans: ['4'] }, { parts: [hcol(-1, '0.5')], ans: ['2'] }, { parts: [col([7, 0, 0, 0, 0])], ans: ['5'] },
+].map(r => ({ ...r, why: `It has ${r.ans[0]} numbers: in R${'⁰¹²³⁴⁵'[+r.ans[0]]}. Zeros count as numbers too.` }));
+const SPACES = [['2', 'R²', null, '2'], ['3', 'R³', null, '3'], ['4', 'R⁴', null, '4'], ['5', 'R⁵', null, '5']];
+const ADDQ = [
+ { parts: ['(1, 2, 3) + (4, 0, −1) = (', { box: '5' }, ', ', { box: '2' }, ', ', { box: '2' }, ')'], why: '1 + 4 = 5, 2 + 0 = 2, 3 + (−1) = 2.', hint: 'Add number by number: first with first, second with second, third with third.' },
+ { parts: ['3 · (2, −1, 0) = (', { box: '6' }, ', ', { box: '-3' }, ', ', { box: '0' }, ')'], why: 'Every number times 3: 6, −3, 0.', hint: 'Multiply every number by 3, the sign included.' },
+ { parts: ['(1, 1, 0, 2) + (−1, 3, 1, 0) = (', { box: '0' }, ', ', { box: '4' }, ', ', { box: '1' }, ', ', { box: '2' }, ')'], why: '1 − 1 = 0, 1 + 3 = 4, 0 + 1 = 1, 2 + 0 = 2: four numbers, in R⁴.', hint: 'Four numbers each: add them in pairs, in order.' },
+ { parts: ['2 · (1, 0, −1, 3, 1) − (0, 1, 1, 2, 2) = (', { box: '2' }, ', ', { box: '-1' }, ', ', { box: '-3' }, ', ', { box: '4' }, ', ', { box: '0' }, ')'], why: '2·(1, 0, −1, 3, 1) = (2, 0, −2, 6, 2); minus (0, 1, 1, 2, 2) gives (2, −1, −3, 4, 0).', hint: 'Double the first list, then subtract the second number by number.' },
+ { parts: ['0 · (5, −2, 7) = (', { box: '0' }, ', ', { box: '0' }, ', ', { box: '0' }, ')'], why: 'Zero times anything is zero: the zero vector of R³.', hint: 'Every number times 0.' },
+];
+const ISQ = [
+ { parts: ['All of R³ (every list of three numbers)'], ans: ['y'], why: 'Adding or stretching lists of three numbers gives lists of three numbers.' },
+ { parts: ['The top right quarter: x ≥ 0 and y ≥ 0'], ans: ['n'], why: '−1 times (2, 1) is (−2, −1): outside.' },
+ { parts: ['The upper half: y ≥ 0'], ans: ['n'], why: '−1 times (0, 1) is (0, −1): below, outside.' },
+ { parts: ['The points with whole-number coordinates'], ans: ['n'], why: '½ times (1, 1) is (½, ½): between the dots.' },
+ { parts: ['All of R⁵'], ans: ['y'], why: 'Five numbers in, five numbers out, whatever you add or multiply.' },
+ { parts: ['Every pair (x, y) except (0, 0)'], ans: ['n'], why: '0 times any v is (0, 0), which was left out. Every vector space holds the zero vector.' },
+ { parts: ['The single vector (1, 1), alone'], ans: ['n'], why: '(1, 1) + (1, 1) = (2, 2) is not in the collection.' },
+];
+const YN2 = [['y', 'A vector space', COL.good, 'Y'], ['n', 'Not one', COL.bad, 'N']];
+const HANDQ = [
+ { id: 'p-half', kind: 'half', start: { v0: 1, v1: 2, w0: 0, w1: 0, c: 1, d: 0 }, prompt: ['The shaded half is every arrow with y ≥ 0. Find v in it and a c that throws c·v out.'],
+ why: (v, k) => `v = ${pair(v.v0, v.v1)} is in the half, but c·v = ${pair(k.sum[0], k.sum[1])} is below the x-axis: the half is not a vector space.`,
+ hint: (v, k) => !IN.half([v.v0, v.v1]) ? 'Start with v inside: its second number must be 0 or more.' : v.v1 === 0 ? 'v lies on the x-axis: any multiple stays there. Give v a second number above 0.' : 'Try a negative c: it turns the arrow round.',
+ ans: { c: -1 } },
+ { id: 'p-dots', kind: 'dots', start: { v0: 1, v1: 1, w0: 0, w1: 0, c: 1, d: 0 }, prompt: ['The dots are the whole-number points. Find a c (in halves) that throws c·v off the dots.'],
+ why: (v, k) => `c·v = ${pair(k.sum[0], k.sum[1])} is not a dot: the dots are not a vector space.`,
+ hint: () => 'A whole c keeps whole numbers. Try c = ½ (scrub c by halves).', ans: { c: .5 } },
+];
+const testOut = kind => (v, k) => IN[kind]([v.v0, v.v1]) && !(v.v0 === 0 && v.v1 === 0) && !IN[kind](k.sum);
+
+/* ---------- beats ---------- */
+const BEATS = [
+ ['intro', 'What is a vector space?', (m, D) => {
+ const g = G(scene, { o: 0, y: 24 });
+ T(g, 'Unit 5, Chapter 37', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });
+ T(g, 'What Is a Vector Space?', { x: 800, y: 360, size: 84, weight: 600, anchor: 'middle' });
+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);
+ const r = text(scene, 'add, stretch, and stay inside', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });
+ // a small sheet with two arrows that add and stretch inside it
+ const lg = G(scene, { x: 800, y: 680, o: 0 });
+ mk('rect', { x: -230, y: -110, width: 460, height: 200, rx: 18, fill: COL.chalk, 'fill-opacity': .07, stroke: COL.faint, 'stroke-width': 2 }, lg);
+ const arr = (c, w) => { const e = path(lg, '', { stroke: c, 'stroke-width': w, 'stroke-linecap': 'round', fill: 'none' }); return e; };
+ const a1 = arr(GREEN, 6), a2 = arr(VIOLET, 6), s = arr(COL.task, 7);
+ show(lg, m('move') - .2, .5);
+ prog(q => {
+ const k = 1 + .8 * Math.sin(Math.PI * Math.min(1, q * 1.4));
+ a1.setAttribute('d', `M-60 40l${70 * k} -40`); a2.setAttribute('d', `M-60 40l${-20} -70`);
+ s.setAttribute('d', q > .2 ? `M-60 40l${70 * k - 20} -110` : '');
+ }, m('move'), 4, lin);
+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);
+ }],
+
+ ['recall', 'Vectors so far', (m) => {
+ const p = panel(0);
+ title(p, 'Vectors so far: arrows you add and stretch');
+ const vs = plane2(p, V2, { show: [], t0: m('v') - .4, c: 1, d: 1 });
+ vs.label('cv', v_ => comboLabel(vs, v_.c, 0)); vs.label('dw', ['w']);
+ vs.row([{ t: 'v', fill: GREEN }, '=', { col: 'v', fixed: true }], { x: 90, y: 250 });
+ vs.show('v', m('v') + .3);
+ thick(vs, 'v', m('v') + 2); vs.flash('v0', m('v') + 3.6); vs.flash('v1', m('v') + 3.6);
+ const rw = vs.row([{ t: 'w', fill: VIOLET }, '=', { col: 'w', fixed: true }], { x: 380, y: 250, o: 0 }); showRow(rw, m('w'), .4);
+ vs.show('w', m('w') + .3);
+ vs.show(['dw'], m('add') + .6); vs.dim('w', m('add') + .6, .25);
+ vs.show('sum', m('sum') + .2);
+ const rs = vs.row(['v + w', '=', { fn: () => ['2 + (−1)', '1 + 2'], w: 200 }, '=', { fn: () => ['1', '3'], w: 70, fill: COL.task }], { x: 90, y: 450, o: 0 }); showRow(rs, m('sum'), .4);
+ vs.hide(['dw', 'sum'], m('stretch') - .2); vs.dim('w', m('stretch') - .2, 1);
+ vs.to({ c: 2, d: 0 }, m('stretch'), .1);
+ vs.show('cv', m('stretch') + .3); vs.dim('v', m('stretch') + .3, .3);
+ const r2 = vs.row(['2v', '=', { fn: () => ['2 · 2', '2 · 1'], w: 140 }, '=', { fn: () => ['4', '2'], w: 70, fill: GREEN }], { x: 90, y: 640, o: 0 }); showRow(r2, m('stretch') + .6, .4);
+ vs.hide('cv', m('mix') - .2); vs.dim('v', m('mix') - .2, 1);
+ vs.to({ c: 1, d: 1 }, m('mix'), .1);
+ vs.show(['cv', 'dw', 'sum'], m('mix') + .3);
+ vs.to({ c: 2, d: 1 }, m('mix') + 2.5, 1.2); vs.to({ c: -1, d: 1.5 }, m('mix') + 4.2, 1.4); vs.to({ c: .5, d: -1 }, m('mix') + 6, 1.4);
+ }],
+
+ ['space', 'Two rules', (m) => {
+ const p = panel(0);
+ title(p, 'A vector space: two rules');
+ const vs = S.vs = plane2(p, V2, { show: [], c: 1, d: 1 });
+ const rules = G(p, {});
+ text(rules, 'A vector space is a collection of vectors where', 90, 200, m('word'), { size: 28, fill: COL.dim, weight: 600 });
+ text(rules, '1. v + w is inside, for any two inside', 90, 260, m('rule1'), { size: 32, weight: 700 });
+ text(rules, '2. c·v is inside, for any one and any number c', 90, 310, m('rule2'), { size: 32, weight: 700 });
+ // each rule underlined as it is read
+ [['rule1', 260, 560], ['rule2', 310, 690]].forEach(([k, y, w]) => draw(path(rules, `M90 ${y + 12}h${w}`, { stroke: COL.chalk, 'stroke-width': 3, 'stroke-opacity': .6 }, { d: 0 }), m(k) + .4, 4.2, lin));
+ const whole = G(p, { o: 0 }), { PX, PY } = vs.P;
+ mk('rect', { x: PX(-6), y: PY(6), width: PX(6) - PX(-6), height: PY(-6) - PY(6), fill: COL.chalk, 'fill-opacity': .08 }, whole);
+ vs.P.g.insertBefore(whole, vs.layer);
+ tw(whole, { o: 1 }, m('plane'), .8);
+ say(p, ['R² = every pair (x, y)'], 90, 410, m('plane') + 3, { size: 34 });
+ // "every pair": pairs land all over the plane
+ const dotsG = G(p, {}), { PX: px, PY: py } = vs.P;
+ [[3, 4], [-5, 2], [1.5, -3], [-2, -4.5], [5, -1], [-.5, 3.5], [4, 2.5], [-4, -1.5], [2, -5], [0, 1], [-3, 5], [5.5, 4.5]].forEach(([x, y], k) => {
+ const d_ = mk('circle', { cx: px(x), cy: py(y), r: 7, fill: COL.chalk }, dotsG); put(d_, { o: 0 }); show(d_, m('plane') + 1 + k * .45, .2);
+ });
+ hide(dotsG, m('add') - .3, .4);
+ vs.show(['v', 'w'], m('plane') + 1.5);
+ vs.show(['cv', 'dw', 'sum'], m('add')); vs.dim(['v', 'w'], m('add'), .25);
+ const row = vs.row([{ col: 'sum', fixed: true }], { x: 90, y: 560, o: 0 }); showRow(row, m('add') + .4, .4);
+ const ok = (t0, t1) => { const e = text(p, 'two numbers: in R² ✓', 260, 572, t0, { size: 30, fill: COL.good, weight: 700 }); hide(e, t1, .3); };
+ ok(m('in1'), m('scale') - .2);
+ vs.to({ c: 3, d: 0 }, m('scale'), 1.2); vs.hide('dw', m('scale'), .4); vs.flash('sum0', m('scale') + 1.2); vs.flash('sum1', m('scale') + 1.2);
+ ok(m('in2'), m('neg') - .2);
+ vs.to({ c: -1, d: 0 }, m('neg'), 1.4);
+ ok(m('neg') + 2, m('so') + 3);
+ vs.to({ c: 1.5, d: -1 }, m('so') + .3, 1.4); vs.show('dw', m('so') + .3); vs.to({ c: -.5, d: 1.5 }, m('so') + 2, 1.4);
+ text(p, 'R² is a vector space', 90, 680, m('so') + 4.2, { size: 36, weight: 700 });
+ }],
+
+ ['zero', 'The zero vector', (m) => {
+ const p = panel(0);
+ title(p, 'Every vector space holds the zero vector');
+ const vs = plane2(p, { v: V2.v, w: [-2, -1] }, { show: ['cv'], c: 1, d: 0 });
+ vs.label('dw', ['−v']); vs.label('sum', ['']);
+ vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, '=', { col: 'cv', fixed: true }], { x: 90, y: 280 });
+ vs.to({ c: 0 }, m('zero') + .3, 2.4, io); vs.flash('c', m('zero') + .3);
+ const o = G(p, { o: 0 }); vs.P.dot(0, 0, COL.chalk, 0, { into: o, label: '(0, 0)', dx: 16, dy: 36 }); show(o, m('shrink') + .4, .4);
+ text(p, 'rule 2 with c = 0: 0·v = (0, 0)', 90, 470, m('must'), { size: 32, weight: 600 });
+ vs.flash('c', m('must') + .3); vs.flash('cv0', m('must') + 1.6); vs.flash('cv1', m('must') + 1.6);
+ text(p, 'so (0, 0) is in every vector space', 90, 520, m('must') + 2.4, { size: 32, weight: 700 });
+ // v, then −v from its tip: back to the origin
+ vs.to({ c: 1 }, m('also'), 1);
+ vs.show('dw', m('also') + 1.2);
+ vs.to({ d: 1 }, m('also') + 1.2, 1.4);
+ text(p, 'v + (−v) = (0, 0)', 90, 620, m('also') + 1.4, { size: 36, weight: 600 });
+ }],
+
+ ['combos', 'Every combination stays in', (m) => {
+ const p = panel(0);
+ title(p, 'Both rules together: every combination');
+ const vs = plane2(p, V2, { show: ['v', 'w'], c: 2, d: 1 });
+ vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { col: 'sum', fixed: true }], { x: 90, y: 300 });
+ vs.show('cv', m('cv')); vs.flash('c', m('cv'));
+ vs.show('dw', m('dw')); vs.flash('d', m('dw'));
+ vs.show('sum', m('both'));
+ text(p, 'c·v: rule 2 d·w: rule 2 sum: rule 1', 90, 440, m('both') + .4, { size: 28, weight: 600 });
+ // the combination runs through many c and d, and leaves a dot wherever it lands
+ const trail = G(p, {}), { PX, PY } = vs.P;
+ const path_ = [[2, 1], [1, 2], [-1, 2], [-2, 0], [-1, -2], [1, -1], [2.5, -.5], [0, 1.5], [-1.5, 1], [.5, -2]];
+ path_.forEach(([c, d], k) => {
+ const t0 = m('all') + 2 + k * .9;
+ vs.to({ c, d }, t0, .7);
+ const s = [c * 2 - d, c + 2 * d];
+ const dt = mk('circle', { cx: PX(s[0]), cy: PY(s[1]), r: 7, fill: COL.task, 'fill-opacity': .7 }, trail);
+ put(dt, { o: 0 }); show(dt, t0 + .7, .2);
+ });
+ text(p, 'every combination stays in R²', 90, 520, m('all') + .3, { size: 32, weight: 700 });
+ }],
+
+ ['q1', 'Quick check', () => {
+ const p = panel(0);
+ title(p, 'Quick check');
+ plane2(p, V2, { show: [] });
+ }, { ask: done => quiz({ x: 40, y: 200, w: 760, cls: 'side' }, [{
+ id: 'c-in', prompt: ['Is it in R², the plane of all pairs?'],
+ build: grid(INR2, YN, { multi: false, text: true }),
+ }], done) }],
+
+ ['r3', 'R³', (m) => {
+ const p = panel(0);
+ title(p, 'R³: every list of three numbers');
+ const V = space3(p, { cx: 1150, cy: 480, size: 600, range: 4, yaw: -35, pitch: 20, t0: m('three') - .3 });
+ V.sway(8, 16);
+ const O = [0, 0, 0], v = [1, 2, 0], w = [0, 1, 2], s = [1, 3, 2];
+ const av = V.arrow(O, v, { color: GREEN }), aw = V.arrow(O, w, { color: VIOLET }), aw2 = V.arrow(v, v, { color: VIOLET, dash: '8 6' }), as = V.arrow(O, O, { color: COL.task, w: 6 });
+ [av, aw, aw2, as].forEach(a => put(a.e, { o: 0 }));
+ show(av.e, m('v') + .2, .4); show(aw.e, m('w') + .2, .4);
+ const pv = V.point(v, { color: GREEN, r: 6, label: 'v' }), pw = V.point(w, { color: VIOLET, r: 6, label: 'w' });
+ put(pv.e, { o: 0 }); put(pw.e, { o: 0 }); show(pv.e, m('v') + .4, .4); show(pw.e, m('w') + .4, .4);
+ show(aw2.e, m('add'), .3);
+ prog(q => aw2.set(v, [v[0] + w[0] * q, v[1] + w[1] * q, v[2] + w[2] * q]), m('add'), 1.2);
+ show(as.e, m('add') + 1.3, .3);
+ prog(q => as.set(O, s.map(x => x * q)), m('add') + 1.3, .9);
+ hide(aw2.e, m('scale') - .2, .3);
+ prog(q => { const k = 1 + q; as.set(O, w.map(x => x * k)); }, m('scale') + .3, 1.4);
+ prog(q => { if (q > 0) as.set(O, w.map(x => x * 2)); }, m('scale') + 1.7, 0);
+ const L = G(p, {});
+ say(L, ['v = (1, 2, 0)'], 90, 260, m('v'), { size: 38, fill: GREEN });
+ say(L, ['w = (0, 1, 2)'], 90, 330, m('w'), { size: 38, fill: VIOLET });
+ say(L, ['v + w = (1 + 0, 2 + 1, 0 + 2) = (1, 3, 2)'], 90, 430, m('add') + .4, { size: 34 });
+ text(L, 'three numbers: in R³ ✓', 90, 480, m('in'), { size: 30, fill: COL.good, weight: 700 });
+ say(L, ['2w = (0, 2, 4)'], 90, 580, m('scale') + .4, { size: 34 });
+ text(L, 'three numbers: in R³ ✓', 90, 630, m('in2'), { size: 30, fill: COL.good, weight: 700 });
+ text(L, 'R³ is a vector space', 90, 730, m('so'), { size: 36, weight: 700 });
+ }],
+
+ ['rn', 'Rⁿ as bars', (m) => {
+ const p = panel(0);
+ title(p, 'More numbers than axes: bars');
+ const bs = S.bs = barsVW(p, RV, RW, [0, 0], { t0: m('four') - .3 });
+ const [cv, cw] = bs.cols;
+ put(cv.g, { o: 0 }); put(cw.g, { o: 0 }); bs.mixG.forEach(e => put(e, { o: 0 })); bs.plusSigns.forEach(e => put(e, { o: 0 })); put(bs.eqSign, { o: 0 }); put(bs.ax.g, { o: 0 });
+ show(cv.g, m('v') + .2, .4); show(bs.mixG[0], m('add'), .4);
+ show(cw.g, m('w') + .2, .4); show(bs.mixG[1], m('add'), .4); show(bs.plusSigns[0], m('add'), .4);
+ // a ring that reads down the bars as the voice reads the numbers
+ [[cv, 'v'], [cw, 'w']].forEach(([c_, k]) => {
+ const rr = mk('rect', { x: c_.x - 6, y: 0, width: 150, height: bs.zeroY(1) - bs.zeroY(0) - 6, rx: 10, fill: 'none', stroke: COL.chalk, 'stroke-width': 3 }, p);
+ put(rr, { o: 0, y: bs.zeroY(0) - 40 });
+ show(rr, m(k) + 1.6, .2);
+ [1, 2, 3, 4].forEach(i => tw(rr, { y: bs.zeroY(i) - 40 }, m(k) + 1.6 + i * .75, .3));
+ hide(rr, m(k) + 1.6 + 5 * .75, .3);
+ });
+ show(bs.eqSign, m('add') + .4, .4); show(bs.ax.g, m('add') + .4, .4);
+ bs.to({ x0: 1, x1: 1 }, m('add') + .8, 1.6);
+ bs.to({ x0: 2, x1: 0 }, m('scale') + .3, 1.6);
+ bs.to({ x0: 1, x1: -1 }, m('n') + 4, 1.4); bs.to({ x0: -1, x1: 2 }, m('n') + 6, 1.4);
+ const R = G(p, {});
+ text(R, 'one bar for each number', 1120, 270, m('four') + 1, { size: 28, fill: COL.dim, weight: 600 });
+ text(R, 'five numbers: in R⁵ ✓', 1120, 380, m('sum') + 3, { size: 30, fill: COL.good, weight: 700 });
+ text(R, 'still five numbers ✓', 1120, 440, m('scale') + 4, { size: 30, fill: COL.good, weight: 700 });
+ const n = G(R, { o: 0 });
+ T(n, 'Rⁿ = every list of n numbers', { x: 1120, y: 560, size: 32, weight: 700 });
+ T(n, 'a vector space, for every n', { x: 1120, y: 606, size: 28, fill: COL.dim, weight: 600 });
+ show(n, m('n') + .3, .5);
+ }],
+
+ ['q2', 'Quick check', () => {
+ const p = panel(0);
+ title(p, 'Quick check');
+ const bs = S.bs = barsVW(p, [1, 0, -2, 3], [2, 5, 1, -1], [1, 1], { top: 220, band: 90 });
+ put(bs.ax.g, { o: 0 });
+ }, { ask: done => quiz({ x: 860, y: 230, w: 700, cls: 'side' }, [{
+ id: 'c-r4', prompt: ['v = (1, 0, −2, 3) and w = (2, 5, 1, −1) are in R⁴.'],
+ build: blanks([
+ { parts: ['v + w = (', { box: '3' }, ', ', { box: '5' }, ', ', { box: '-1' }, ', ', { box: '2' }, ')'], why: '1 + 2, 0 + 5, −2 + 1, 3 − 1: four numbers, in R⁴.', hint: 'Add number by number: 1 + 2, then 0 + 5, …',
+ fx: () => { fx(S.bs.ax.g, { o: 1 }, 0, .4); S.bs.set({ x0: 1, x1: 1 }); } },
+ { parts: ['2w = (', { box: '4' }, ', ', { box: '10' }, ', ', { box: '2' }, ', ', { box: '-2' }, ')'], why: 'Every number of w doubled: 4, 10, 2, −2.', hint: 'Double every number of w, sign included.',
+ fx: () => { fx(S.bs.ax.g, { o: 1 }, 0, .4); S.bs.set({ x0: 0, x1: 2 }); } },
+ ]),
+ }], done) }],
+
+ ['quad', 'The quarter fails', (m) => {
+ const p = panel(0);
+ title(p, 'A collection that fails: the quarter');
+ const vs = S.vs = plane2(p, Q2, { show: [], c: 1, d: 1, t0: .1 });
+ region(vs, 'quarter', m('quarter'));
+ text(p, 'only arrows with x ≥ 0 and y ≥ 0', 90, 220, m('quarter') + .5, { size: 30, weight: 600 });
+ vs.show('v', m('v')); vs.show('w', m('w'));
+ vs.show(['cv', 'dw', 'sum'], m('add')); vs.dim(['v', 'w'], m('add'), .25);
+ const vd = verdict(p, vs, 'quarter', 90, 400, m('add') + .8, { name: 'c·v + d·w' });
+ vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }], { x: 90, y: 320 });
+ vs.flash('sum0', m('ok')); vs.flash('sum1', m('ok'));
+ vs.to({ v0: 4, v1: .5, w0: .5, w1: 2 }, m('ok') + 2.2, 1.4); vs.to({ v0: 1, v1: 0, w0: 0, w1: 4 }, m('ok') + 3.8, 1.4); vs.to({ v0: 2, v1: 1, w0: 1, w1: 3 }, m('ok') + 5.4, 1.2);
+ vs.hide('dw', m('scale') - .2); vs.dim(['v', 'w'], m('scale') - .2, 1); vs.hide('w', m('scale') - .2);
+ vs.to({ c: 2, d: 0 }, m('scale'), 1.2); vs.flash('c', m('scale'));
+ vs.to({ c: -1 }, m('neg') + .3, 1.8); vs.flash('c', m('neg') + .3);
+ thick(vs, 'sum', m('out') + .4, 6);
+ const no = G(p, { o: 0 });
+ T(no, 'rule 2 broken: not a vector space', { x: 90, y: 520, size: 32, fill: COL.bad, weight: 700 });
+ show(no, m('fail') + 1, .5);
+ void vd;
+ }],
+
+ ['dots', 'The dots fail', (m) => {
+ const p = panel(0);
+ title(p, 'Another that fails: the grid dots');
+ const vs = plane2(p, { v: [1, 2], w: [2, 1] }, { show: [], c: 1, d: 1 });
+ region(vs, 'dots', m('dots'));
+ text(p, 'only points with whole-number coordinates', 90, 220, m('dots') + .5, { size: 30, weight: 600 });
+ vs.show(['cv', 'dw', 'sum'], m('add'));
+ vs.to({ v0: 2, v1: 1, w0: 1, w1: 3 }, m('add') + 2.6, 1.2); vs.to({ v0: 1, v1: 2, w0: 2, w1: 1 }, m('add') + 4.2, 1.2);
+ verdict(p, vs, 'dots', 90, 400, m('add') + .8, { name: 'the tip' });
+ vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }], { x: 90, y: 320 });
+ vs.hide(['dw'], m('scale') - .3);
+ vs.to({ v0: 1, v1: 1, d: 0 }, m('scale'), 1.2);
+ vs.to({ c: .5 }, m('half'), 1.4); vs.flash('c', m('half'));
+ thick(vs, 'sum', m('half') + 1.6, 6);
+ text(p, 'between the dots: not a vector space', 90, 520, m('fail'), { size: 32, fill: COL.bad, weight: 700 });
+ }],
+
+ ['q3', 'Your turn', () => {
+ const p = panel(0);
+ title(p, 'Your turn');
+ const vs = S.vs = plane2(p, Q2, { show: ['sum'], c: 1, d: 0 });
+ vs.label('sum', v_ => comboLabel(vs, v_.c, 0));
+ region(vs, 'quarter', .2);
+ vs.row([{ key: 'c' }, { col: 'v' }, '=', { col: 'sum', fixed: true }], { x: 90, y: 260 });
+ verdict(p, vs, 'quarter', 90, 400, .4, { name: 'c·v' });
+ }, { ask: done => quiz({ x: 40, y: 470, w: 740, cls: 'side' }, [{
+ id: 'c-break', prompt: ['Keep v in the quarter. Change c (or v) until c·v is outside it.'],
+ build: vsTask(S.vs, testOut('quarter'), (v, k) => `c·v = ${pair(k.sum[0], k.sum[1])} left the quarter, while v was inside: rule 2 fails.`,
+ v => !IN.quarter([v.v0, v.v1]) ? 'v itself must be in the quarter: both its numbers 0 or more.' : 'A positive c keeps the arrow in the quarter. Try a negative c.',
+ () => S.vs.set({ c: -1 }), { only: ['c', 'v0', 'v1'], drag: [] }),
+ }], done) }],
+
+ ['wrap', 'Summary', (m) => {
+ const p = panel(0);
+ [['A vector space: adding any two, or multiplying one by any number, stays inside.', 'w1'], ['So every combination stays inside, and the zero vector is always there.', 'w2'],
+ ['R², R³ and Rⁿ (every list of n numbers) are vector spaces.', 'w3'], ['The quarter and the grid dots are not: a stretch throws a vector out.', 'w4']].forEach(([str, mark], i) => {
+ const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });
+ mk('circle', { cx: 120, cy: -12, r: 26, fill: COL.chalk }, g);
+ T(g, String(i + 1), { x: 120, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
+ T(g, str, { x: 170, size: 34, weight: 600 });
+ tw(g, { o: 1, x: 0 }, m(mark), .6);
+ });
+ }],
+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{
+ id: 'p-which', prompt: ['Which space is each vector in? Count its numbers.'],
+ build: grid(WHICH, SPACES, { multi: false, text: true }),
+ }], done, 'Chapter practice · set 1 of 4') }],
+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
+ id: 'p-add', prompt: ['Add and stretch, number by number.'],
+ build: blanks(ADDQ),
+ }], done, 'Chapter practice · set 2 of 4') }],
+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
+ id: 'p-is', prompt: ['Is it a vector space? (Add any two, multiply any one by any number: does it stay inside?)'],
+ build: grid(ISQ, YN2, { multi: false, text: true }),
+ }], done, 'Chapter practice · set 3 of 4') }],
+ ['final4', 'Chapter practice', () => {
+ const p = panel(0);
+ title(p, 'Break the rules');
+ const vs = S.vs = plane2(p, Q2, { show: ['sum'], c: 1, d: 0, steps: { c: .5 } });
+ vs.label('sum', v_ => comboLabel(vs, v_.c, 0));
+ S.reg = { half: region(vs, 'half', null), dots: region(vs, 'dots', null) };
+ vs.row([{ key: 'c' }, { col: 'v' }, '=', { col: 'sum', fixed: true }], { x: 90, y: 260 });
+ S.vd = { half: verdict(p, vs, 'half', 90, 400, null, { name: 'c·v' }), dots: verdict(p, vs, 'dots', 90, 400, null, { name: 'c·v' }) };
+ }, { ask: done => quiz({ x: 40, y: 470, w: 740, cls: 'side' }, HANDQ.map(q => ({
+ id: q.id, prompt: q.prompt,
+ build: (body, api) => {
+ Object.entries(S.reg).forEach(([k, g]) => put(g, { o: k === q.kind ? 1 : 0 }));
+ Object.entries(S.vd).forEach(([k, g]) => put(g, { o: k === q.kind ? 1 : 0 }));
+ S.vs.set(q.start);
+ return vsTask(S.vs, testOut(q.kind), q.why, q.hint, () => S.vs.set(q.ans), { only: q.kind === 'dots' ? ['c'] : ['c', 'v0', 'v1'], drag: [] })(body, api);
+ },
+ })), done, 'Chapter practice · set 4 of 4') }],
+ ['play', 'Playground', (m) => {
+ const p = panel(0);
+ title(p, 'Playground');
+ const vs = S.vs = plane2(p, Q2, { show: ['v', 'w', 'cv', 'dw', 'sum'], c: 1, d: 1 });
+ region(vs, 'quarter', .2);
+ vs.row([{ key: 'c' }, { col: 'v' }, { key: 'd', signed: true }, { col: 'w' }, '=', { col: 'sum', fixed: true }], { x: 90, y: 260 });
+ verdict(p, vs, 'quarter', 90, 400, .4, { name: 'c·v + d·w' });
+ const hint = G(p, { o: 0 });
+ T(hint, 'try: a negative c · a w outside the quarter · c = d = 0', { x: 1160, y: 820, size: 24, fill: COL.dim, anchor: 'middle' });
+ show(hint, m('go'), .5);
+ }, { ask: playAsk(() => S.vs, { pos: { x: 40, y: 470, w: 740, cls: 'side' },
+ tip: 'Your two vectors and their combination. Change any number or drag a tip; the line under the algebra says whether it stays in the quarter. Nothing is marked.' }) }],
+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
+
+boot();
+</script>
+</body>
+</html>
diff --git a/site/linear-algebra/lib/mm.js b/site/linear-algebra/lib/mm.js
index 002fe64..4613721 100644
--- a/site/linear-algebra/lib/mm.js
+++ b/site/linear-algebra/lib/mm.js
@@ -429,3 +429,317 @@ const mmTask = (P_, test, why, hint, reveal, { only = null, sizes = false } = {}
hint: [kbd('Tab'), ' to a number, ', kbd('↑'), kbd('↓'), ' to change it, or drag it sideways'],
};
};
+
+/* ---------- the transpose: A and Aᵀ side by side (chapters 35–36) ---------- */
+// mmT draws A (m × n) and its transpose Aᵀ (n × m) from one state: row i of A is column i of Aᵀ, entry (i, j) of A is
+// entry (j, i) of Aᵀ. Every number of either matrix is scrubbable (the twin in the other follows), and the sizes too.
+// With tint 'rows' each number keeps the colour of A's row it came from, so A's blue row is Aᵀ's blue column ('cols':
+// coloured by A's column, for a matrix that is itself a transpose; null: chalk).
+// With plane: { cx, cy, u } a 2 × 2 A is also drawn in the plane: its columns as solid green and violet arrows (chapter
+// 9), its rows as dashed blue and coral arrows, which are the columns of Aᵀ; drag a tip and the numbers follow.
+//
+// const T = mmT(p, { A: [[1, 2, 3], [4, 5, 6]], at: [70, 300], hideT: true, plane: null });
+// T.fly(at, { by: 'rows' | 'cols' | 'cells' | 'all' | (i, j) => offset, step, dur }) // A's numbers fly into Aᵀ; returns the end
+// T.reveal(at, 'all' | [[r, c], …]) // with hideT: Aᵀ's numbers appear at once (T.uncover(which): now)
+// T.show('row' | 'col' | 'cell' | 'diag', i | [i, j], at, { side: 'a' | 't' }) // light row i of A with column i of Aᵀ
+// (and so on; side: only in A or only in Aᵀ); show(null, null, at) clears
+// T.diag(at, on) // the dashed main diagonal through both (square or not, from the top-left corner)
+// T.pairs(at, on) // square A: each pair across the diagonal joined, green when equal, red when not
+// T.flash('a' | 't', [[i, j], …] | 'all', at)
+// T.to({ a01: 3, mA: 3 }, at, dur) · T.set(v) · T.v · T.sym() · T.onChange(f) · T.arrows.cols / .rows (groups)
+// T.live(true, { only: ['a01', 't10', 'mA'], sizes: false, drag: true }) // mmTTask is its question type; playAsk works
+// Keys: a<i><j> (A's numbers), t<j><i> (the same number, touched in Aᵀ), mA, nA (A's size, 1 … 3).
+const MMT_ROW = [COL.whole, COL.nat, COL.int], MMT_COL = [COL.irr, COL.real];
+
+function mmT(p, { A, at: [x0, y0] = [70, 300], size = 40, cw = 62, rh = 60, gap = 120, names = ['A', 'Aᵀ'], hideT = false,
+ tint = 'rows', sizes = true, plane: po = null, t0 = .1, o = 0, range = 9 } = {}) {
+ const svg = $('stage'), K3 = [0, 1, 2];
+ const s = { mA: A.length, nA: A[0].length };
+ K3.forEach(i => K3.forEach(j => { s[`a${i}${j}`] = A[i]?.[j] ?? 0; }));
+ let plan = { ...s };
+ const known = K3.map(() => K3.map(() => !hideT)); // known[r][c]: Aᵀ's entry (r, c) shown
+ const g = G(p, { o });
+ show(g, t0 + .2);
+ const D = () => ({ m: Math.round(s.mA), n: Math.round(s.nA) });
+ const keyOf = k => k[0] === 't' ? `a${k[2]}${k[1]}` : k; // t<j><i> is a<i><j>
+ // A's entry (i, j) in the colour of its row ('rows') or column ('cols'); it keeps that colour in Aᵀ
+ const fillA = (i, j) => tint === 'rows' ? MMT_ROW[i] : tint === 'cols' ? MMT_ROW[j] : COL.chalk;
+
+ /* ---------- hands on ---------- */
+ const cells = [];
+ let live = false, allowed = null, sizesLive = false, dragOn = false;
+ const can = k => live && (k.length === 2 ? sizesLive : (!allowed || allowed.has(k) || allowed.has(keyOf(k))));
+ const step = (k, v) => edit({ [keyOf(k)]: k.length === 2 ? Math.round(v) : Math.max(-range, Math.min(range, Math.round(v))) });
+ function wire(box, k) {
+ box.setAttribute('aria-label', k);
+ cells.push({ k, box });
+ let drag = null;
+ box.addEventListener('pointerdown', e => {
+ if (!can(k)) return;
+ e.preventDefault(); drag = { x: e.clientX, from: Math.round(s[keyOf(k)]) }; box.setPointerCapture(e.pointerId);
+ });
+ box.addEventListener('pointermove', e => { if (!drag) return; const kx = svg.getScreenCTM().a; step(k, drag.from + Math.round((e.clientX - drag.x) / kx / (k.length === 2 ? 40 : 24))); });
+ const end = () => { drag = null; };
+ box.addEventListener('pointerup', end); box.addEventListener('lostpointercapture', end);
+ box.addEventListener('keydown', e => {
+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); box.blur(); P.keys?.(e); return; }
+ if (!can(k)) return;
+ const dd = { ArrowUp: 1, ArrowRight: 1, ArrowDown: -1, ArrowLeft: -1 }[e.key];
+ if (!dd) return;
+ e.preventDefault(); e.stopPropagation();
+ step(k, Math.round(s[keyOf(k)]) + dd);
+ if (!box.isConnected) g.querySelector(`[aria-label="${k}"][tabindex]`)?.focus(); // a size change rebuilt the boxes
+ });
+ }
+ function boxesLive() {
+ cells.forEach(c => {
+ const ok = can(c.k);
+ c.box.style.cursor = ok ? 'ew-resize' : '';
+ c.box.setAttribute('stroke', ok ? COL.faint : 'none');
+ if (ok) c.box.setAttribute('tabindex', 0); else c.box.removeAttribute('tabindex');
+ });
+ tips.forEach(tp => { tp.hit.style.cursor = live && dragOn && tp.keys.every(k => can(k)) ? 'move' : ''; });
+ }
+
+ /* ---------- the two matrices (rebuilt when a size changes) ---------- */
+ const back = G(g, {}), body = G(g, {}), front = G(g, {});
+ let L = null, shape = '';
+ function mat(key, rows, cols, x, name) {
+ const mg = G(body, {});
+ const top = y0 - size * .95, bot = y0 + (rows - 1) * rh + size * .35, W = cols * cw + 24;
+ path(mg, `M${x + 13} ${top}H${x}V${bot}H${x + 13}M${x + W - 13} ${top}H${x + W}V${bot}H${x + W - 13}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });
+ const cx = j => x + 12 + cw * (j + .5), ry = i => y0 + i * rh;
+ const cs = [...Array(rows).keys()].map(i => [...Array(cols).keys()].map(j => {
+ const cg = G(mg, { x: cx(j), y: ry(i) });
+ const glow = mk('rect', { x: -cw / 2 + 3, y: -size * .9, width: cw - 6, height: size * 1.2, rx: 10, fill: COL.chalk }, cg);
+ put(glow, { o: 0 });
+ const holder = G(cg, {});
+ holder.style.pointerEvents = 'none';
+ wire(mk('rect', { x: -cw / 2 + 3, y: -size * .92, width: cw - 6, height: size * 1.24, rx: 9, fill: 'transparent', 'stroke-dasharray': '4 6' }, cg), `${key}${i}${j}`);
+ return { glow, holder, txt: null, fill: key === 'a' ? fillA(i, j) : fillA(j, i) };
+ }));
+ M(mg, [name], { x: x + W / 2, y: top - 16, size: 30, fill: COL.dim, anchor: 'middle' });
+ return { g: mg, x, W, top, bot, cx, ry, cs, rows, cols };
+ }
+ function sizeLab(m, rows, cols, yS, keys) {
+ const mid = m.x + m.W / 2, sg = G(m.g, {});
+ if (!sizes) put(sg, { o: 0 });
+ [[rows, -30, keys?.[0]], [cols, 30, keys?.[1]]].forEach(([v, dx, k]) => {
+ T(sg, String(v), { x: mid + dx, y: yS, size: 28, fill: COL.dim, font: MATH, anchor: 'middle', weight: 600 }).style.pointerEvents = 'none';
+ if (k) wire(mk('rect', { x: mid + dx - 20, y: yS - 26, width: 40, height: 34, rx: 8, fill: 'transparent', 'stroke-dasharray': '4 5' }, sg), k);
+ });
+ T(sg, '×', { x: mid, y: yS, size: 26, fill: COL.dim, font: MATH, anchor: 'middle' });
+ return sg;
+ }
+ function layout() {
+ const d = D(), sh = `${d.m},${d.n}`;
+ if (sh === shape) return;
+ shape = sh;
+ body.replaceChildren(); back.replaceChildren(); cells.length = 0;
+ const a = mat('a', d.m, d.n, x0, names[0]);
+ const t = mat('t', d.n, d.m, a.x + a.W + gap, names[1]);
+ const yS = y0 + (Math.max(d.m, d.n) - 1) * rh + size * .35 + 42;
+ sizeLab(a, d.m, d.n, yS, ['mA', 'nA']); sizeLab(t, d.n, d.m, yS, null);
+ // each diagonal lives in its own matrix's group (under the numbers), so a hidden Aᵀ hides its diagonal too
+ const dg = [a, t].map(M_ => {
+ const dd = G(M_.g, { o: diagOn ? 1 : 0 });
+ M_.g.insertBefore(dd, M_.g.firstChild);
+ const k = Math.min(M_.rows, M_.cols) - 1;
+ path(dd, `M${M_.cx(0) - cw * .45} ${M_.ry(0) - size * .78}L${M_.cx(k) + cw * .45} ${M_.ry(k) + size * .3}`, { stroke: COL.chalk, 'stroke-width': 2.5, 'stroke-dasharray': '8 7', 'stroke-opacity': .7, fill: 'none' });
+ return dd;
+ });
+ L = { a, t, dg, bottom: yS + 12, right: t.x + t.W, mid: a.x + a.W + gap / 2, midY: y0 + (Math.max(d.m, d.n) - 1) * rh / 2 - size * .3 };
+ rebands();
+ boxesLive();
+ }
+
+ /* ---------- lit rows and columns ---------- */
+ let lit = [], bandStamp = -1, diagOn = false, pairsOn = false;
+ const bandRect = (M_, kind, i, j) => {
+ if (!M_ || (kind !== 'col' && i >= M_.rows) || (kind !== 'row' && j >= M_.cols)) return null;
+ const h0 = size * 1.24;
+ let x, y, w, hh;
+ if (kind === 'row') { x = M_.x + 4; y = M_.ry(i) - size * .95; w = M_.W - 8; hh = h0; }
+ else if (kind === 'col') { x = M_.cx(j) - cw / 2 + 2; y = M_.top + 2; w = cw - 4; hh = M_.bot - M_.top - 4; }
+ else { x = M_.cx(j) - cw / 2 + 2; y = M_.ry(i) - size * .95; w = cw - 4; hh = h0; }
+ return mk('rect', { x: x - 3, y, width: w + 6, height: hh, rx: 12, fill: COL.chalk, 'fill-opacity': .13, stroke: COL.chalk, 'stroke-opacity': .6, 'stroke-width': 2.5 }, back);
+ };
+ function rebands() { lit.forEach(b => { b.e = bandRect(L[b.m], b.kind, b.i, b.j); }); }
+ const partsOf = (kind, idx) => kind === 'row' ? [['a', 'row', idx, 0], ['t', 'col', 0, idx]]
+ : kind === 'col' ? [['a', 'col', 0, idx], ['t', 'row', idx, 0]]
+ : kind === 'cell' ? [['a', 'cell', idx[0], idx[1]], ['t', 'cell', idx[1], idx[0]]]
+ : kind === 'diag' ? K3.flatMap(k => [['a', 'cell', k, k], ['t', 'cell', k, k]]) : [];
+ function showWay(kind, idx, at, { dur = .35, side = null } = {}) {
+ prog(q => { if (q > 0 && at >= bandStamp) { bandStamp = at; lit.forEach(b => b.e?.remove()); lit = partsOf(kind, idx).filter(([m]) => !side || m === side).map(([m, k, i, j]) => ({ m, kind: k, i, j })); rebands(); lit.forEach(b => b.e && put(b.e, { o: 0 })); } }, at, 0, lin);
+ prog(q => { if (bandStamp === at) lit.forEach(b => b.e && put(b.e, { o: q })); }, at, dur, lin);
+ }
+
+ /* ---------- pairs across the diagonal (square A) ---------- */
+ const pairG = G(front, {});
+ function drawPairs() {
+ pairG.replaceChildren();
+ const d = D();
+ if (!pairsOn || d.m !== d.n) return;
+ const a = L.a;
+ for (let i = 0; i < d.m; i++) for (let j = i + 1; j < d.m; j++) {
+ const ok = Math.abs(s[`a${i}${j}`] - s[`a${j}${i}`]) < 1e-9, c = ok ? COL.good : COL.bad;
+ const P1 = [a.cx(j), a.ry(i) - size * .3], P2 = [a.cx(i), a.ry(j) - size * .3];
+ [P1, P2].forEach(([x, y]) => mk('circle', { cx: x, cy: y, r: size * .62, fill: 'none', stroke: c, 'stroke-width': 3 }, pairG));
+ const bend = 18 + 10 * (j - i);
+ path(pairG, `M${P1[0] - size * .5} ${P1[1] + size * .4}Q${(P1[0] + P2[0]) / 2 + bend} ${(P1[1] + P2[1]) / 2 + bend} ${P2[0] + size * .5} ${P2[1] - size * .4}`, { stroke: c, 'stroke-width': 2.5, 'stroke-dasharray': ok ? 'none' : '6 6', fill: 'none', 'stroke-opacity': .8 });
+ }
+ }
+
+ /* ---------- the plane: A's columns and rows as arrows (2 × 2 only) ---------- */
+ let PL = null;
+ const tips = [];
+ const arrows = { cols: [], rows: [] };
+ if (po) {
+ PL = plane(g, { x0: -5, x1: 5, y0: -5, y1: 5, u: 44, cx: 1190, cy: 470, t0, ...po });
+ const AG = G(PL.g, {});
+ const mkArrow = (color, dash, label, keys) => {
+ const ag = G(AG, {});
+ const shaft = path(ag, '', { stroke: color, 'stroke-width': dash ? 4 : 6, 'stroke-linecap': 'round', ...(dash ? { 'stroke-dasharray': '10 8' } : {}), fill: 'none' });
+ const head = path(ag, '', { fill: color, stroke: 'none' });
+ const lab = T(ag, label, { size: 24, fill: color, weight: 600, anchor: 'middle' });
+ lab.style.pointerEvents = 'none';
+ const hit = mk('circle', { r: 22, fill: 'transparent' }, ag);
+ const tp = { ag, shaft, head, lab, hit, keys, color, dash };
+ tips.push(tp);
+ let on = false;
+ const to = e => {
+ const q = svg.createSVGPoint(); q.x = e.clientX; q.y = e.clientY;
+ const w = q.matrixTransform(PL.g.getScreenCTM().inverse());
+ const cl = v => Math.max(PL.x0, Math.min(PL.x1, Math.round(v)));
+ edit({ [keys[0]]: cl((w.x - PL.cx) / PL.u), [keys[1]]: cl((PL.cy - w.y) / PL.u) });
+ };
+ hit.addEventListener('pointerdown', e => { if (!(live && dragOn && keys.every(k => can(k)))) return; e.preventDefault(); ag.parentNode.append(ag); on = true; hit.setPointerCapture(e.pointerId); });
+ hit.addEventListener('pointermove', e => { if (on) to(e); });
+ hit.addEventListener('pointerup', () => { on = false; });
+ hit.addEventListener('lostpointercapture', () => { on = false; });
+ return tp;
+ };
+ // columns of A: (a0j, a1j); rows of A = columns of Aᵀ: (ai0, ai1)
+ arrows.cols = [0, 1].map(j => mkArrow(MMT_COL[j], false, `col ${j + 1}`, [`a0${j}`, `a1${j}`]));
+ arrows.rows = [0, 1].map(i => mkArrow(MMT_ROW[i], true, `row ${i + 1}`, [`a${i}0`, `a${i}1`]));
+ }
+ function drawPlane() {
+ if (!PL) return;
+ const d = D(), two = d.m === 2 && d.n === 2, { PX, PY } = PL, placed = [];
+ tips.forEach((tp, k) => {
+ tp.ag.style.display = two ? '' : 'none';
+ if (!two) return;
+ const x = s[tp.keys[0]], y = s[tp.keys[1]], X2 = PX(x), Y2 = PY(y), X1 = PX(0), Y1 = PY(0);
+ const Ln = Math.hypot(X2 - X1, Y2 - Y1), ux = Ln ? (X2 - X1) / Ln : 1, uy = Ln ? (Y2 - Y1) / Ln : 0, h = Math.min(20, Ln * .45);
+ tp.shaft.setAttribute('d', Ln < 1 ? '' : `M${X1} ${Y1}L${X2 - ux * h * .7} ${Y2 - uy * h * .7}`);
+ tp.head.setAttribute('d', Ln < 1 ? '' : `M${X2} ${Y2}L${X2 - h * ux - h * .55 * uy} ${Y2 - h * uy + h * .55 * ux}L${X2 - h * ux + h * .55 * uy} ${Y2 - h * uy - h * .55 * ux}Z`);
+ // the name just past the tip, along the arrow; a name that would sit on an earlier one (two tips close together)
+ // steps to the side that clears it
+ const rx = Ln ? ux : 1, ry = Ln ? uy : 0, bx = X2 + rx * 40, by = Y2 + ry * 34 + 8;
+ const cands = [[bx, by], [bx - ry * 40, by + rx * 30], [bx + ry * 40, by - rx * 30], [bx, by + 30], [bx, by - 30], [bx + 70 * (rx >= 0 ? 1 : -1), by]];
+ const hits = ([cx_, cy_]) => placed.some(([px, py]) => Math.abs(px - cx_) < 66 && Math.abs(py - cy_) < 26);
+ const at_ = cands.find(c => !hits(c)) || cands[0];
+ placed.push(at_);
+ put(tp.lab, { x: at_[0], y: at_[1] });
+ tp.hit.setAttribute('cx', X2); tp.hit.setAttribute('cy', Y2);
+ });
+ }
+
+ /* ---------- numbers ---------- */
+ const listeners = [];
+ function draw() {
+ layout();
+ const d = D();
+ L.a.cs.forEach((r, i) => r.forEach((cl, j) => {
+ const ps = mmParts(s[`a${i}${j}`]), kk = mmKey(ps);
+ if (kk === cl.txt) return;
+ cl.txt = kk; cl.holder.replaceChildren();
+ M(cl.holder, ps, { size, fill: cl.fill, anchor: 'middle' });
+ }));
+ L.t.cs.forEach((r, i) => r.forEach((cl, j) => {
+ const ps = known[i][j] ? mmParts(s[`a${j}${i}`]) : [''], kk = mmKey(ps);
+ if (kk === cl.txt) return;
+ cl.txt = kk; cl.holder.replaceChildren();
+ if (known[i][j]) M(cl.holder, ps, { size, fill: cl.fill, anchor: 'middle' });
+ }));
+ drawPairs();
+ drawPlane();
+ listeners.forEach(f => f(s, d));
+ }
+ function edit(to) {
+ let ch = false;
+ for (const k in to) {
+ const v = k.length === 2 ? Math.max(1, Math.min(3, to[k])) : to[k];
+ if (s[k] !== v) { s[k] = v; ch = true; }
+ }
+ if (ch) draw();
+ }
+ draw();
+
+ const hitOf = which => which === 'all' ? () => true : (i, j) => which.some(([a, b]) => a === i && b === j);
+ const api = {
+ g, front, get L() { return L; }, get v() { return { ...s }; }, get plan() { return plan; }, P: PL, arrows, known,
+ T: (i, j) => s[`a${j}${i}`],
+ sym() { const d = D(); if (d.m !== d.n) return false; for (let i = 0; i < d.m; i++) for (let j = 0; j < d.m; j++) if (Math.abs(s[`a${i}${j}`] - s[`a${j}${i}`]) > 1e-9) return false; return true; },
+ set(vals) { const o_ = {}; for (const k in vals) o_[keyOf(k)] = vals[k]; plan = { ...plan, ...o_ }; edit(o_); },
+ to(next, at, dur = 1.4, ease = io) {
+ const n2 = {}; for (const k in next) n2[keyOf(k)] = next[k];
+ const from = { ...plan };
+ plan = { ...plan, ...n2 };
+ const goal = { ...plan }, ks = Object.keys(n2);
+ prog(q => edit(Object.fromEntries(ks.map(k => [k, k.length === 2 ? (q < 1 ? from[k] : goal[k]) : from[k] + (goal[k] - from[k]) * q]))), at, dur, ease);
+ return at + dur;
+ },
+ show: showWay,
+ diag(at, on = true) { prog(q => { if (q > 0) { diagOn = on; } L.dg.forEach(d => put(d, { o: on ? q : 1 - q })); }, at, .5, lin); },
+ pairs(at, on = true) { prog(q => { if (q > 0 && pairsOn !== on) { pairsOn = on; drawPairs(); } }, at, 0, lin); },
+ flash(m, which, at, { color = COL.chalk } = {}) {
+ const hit = hitOf(which), env = t => t < .25 ? t / .25 : t < 1.1 ? 1 : t < 1.7 ? 1 - (t - 1.1) / .6 : 0;
+ prog(q => L[m]?.cs.forEach((r, i) => r.forEach((cl, j) => {
+ if (!hit(i, j)) return;
+ cl.glow.setAttribute('fill', color);
+ put(cl.glow, { o: .32 * env(q * 1.7) });
+ })), at, 1.7, lin);
+ },
+ // Aᵀ's numbers appear at once, at `at`
+ reveal(at, which = 'all') { prog(q => { if (q > 0) api.uncover(which); }, at, 0, lin); },
+ // Aᵀ's entries (r, c) shown: 'all' or a list [[r, c], …]
+ uncover(which = 'all') { const hit = hitOf(which); K3.forEach(i => K3.forEach(j => { if (hit(i, j)) known[i][j] = true; })); L.t.cs.flat().forEach(cl => { cl.txt = null; }); draw(); },
+ // A's numbers (as planned at this point of the beat) fly across into Aᵀ: entry (i, j) lands on (j, i), arcing over.
+ fly(at, { by = 'rows', step = 1.2, dur = 1, lift = 50 } = {}) {
+ const { m, n } = { m: Math.round(plan.mA), n: Math.round(plan.nA) };
+ let end = at;
+ for (let i = 0; i < m; i++) for (let j = 0; j < n; j++) {
+ const t1 = at + (typeof by === 'function' ? by(i, j) : by === 'rows' ? i * step + j * .12 : by === 'cols' ? j * step + i * .12 : by === 'cells' ? (i * n + j) * step : 0);
+ const c = G(front, { o: 0 });
+ M(c, mmParts(plan[`a${i}${j}`]), { size, fill: fillA(i, j), anchor: 'middle' });
+ prog(q => {
+ const a = L.a, t = L.t;
+ if (!a || !t || i >= t.cols || j >= t.rows) return;
+ const xa = a.cx(j), ya = a.ry(i), xb = t.cx(i), yb = t.ry(j);
+ put(c, { x: xa + (xb - xa) * q, y: ya + (yb - ya) * q - lift * Math.sin(Math.PI * q), o: q > 0 && q < 1 ? 1 : 0 });
+ }, t1, dur, io);
+ prog(q => { if (q > 0 && !known[j][i]) { known[j][i] = true; if (L.t.cs[j]?.[i]) L.t.cs[j][i].txt = null; draw(); } }, t1 + dur, 0, lin);
+ end = Math.max(end, t1 + dur);
+ }
+ return end;
+ },
+ live(on, { only = null, sizes: sz = false, drag = true } = {}) {
+ live = on; allowed = on && only ? new Set(only.map(keyOf)) : null; sizesLive = on && sz; dragOn = on && drag;
+ boxesLive();
+ },
+ onChange(f) { listeners.push(f); },
+ };
+ return api;
+}
+
+// A question on A and Aᵀ: the reader changes the allowed numbers (or drags the arrows) until test(v, T) holds.
+const mmTTask = (T_, test, why, hint, reveal, { only = null, sizes = false, drag = true } = {}) => (body, api) => {
+ T_.live(true, { only, sizes, drag });
+ return {
+ check: () => { const v = T_.v, ok = test(v, T_); api.grade(ok, ok ? why : typeof hint === 'function' ? hint(v, T_) : hint); },
+ reveal: () => { reveal?.(); return why; },
+ lock: () => T_.live(false),
+ hint: [kbd('Tab'), ' to a number, ', kbd('↑'), kbd('↓'), ' to change it, or drag it sideways', ...(T_.P && drag ? ['; drag an arrow by its tip'] : [])],
+ };
+};