An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
feat(linear-algebra): chapters 23-25 reviewed; Unit 3 on the contents
yzre1eab637fb77
diff --git a/site/linear-algebra/ch22/index.html b/site/linear-algebra/ch22/index.htmlindex df9fb53..d758350 100644--- a/site/linear-algebra/ch22/index.html+++ b/site/linear-algebra/ch22/index.html@@ -18,7 +18,7 @@<script src="audio/en/timings.js"></script><script>'use strict';-const CHAPTER = { number: 22, title: 'Row Exchanges as Matrices', minutes: 10, language: 'en', next: '../ch23/' };+const CHAPTER = { number: 22, title: 'Row Exchanges as Matrices', minutes: 10, language: 'en', next: '../ch23/' , next: '../ch23/' };/* ---------- chapter drawing helpers (chapter 21's) ---------- */const BLUE = LS_ROW[0], CORAL = LS_ROW[1], YELLOW = S3_ROW[2];diff --git a/site/linear-algebra/ch23/audio/en/cols2.mp3 b/site/linear-algebra/ch23/audio/en/cols2.mp3index df9219b..9fb8579 100644Binary files a/site/linear-algebra/ch23/audio/en/cols2.mp3 and b/site/linear-algebra/ch23/audio/en/cols2.mp3 differdiff --git a/site/linear-algebra/ch23/audio/en/timings.js b/site/linear-algebra/ch23/audio/en/timings.jsindex 6c58490..65b0796 100644--- a/site/linear-algebra/ch23/audio/en/timings.js+++ b/site/linear-algebra/ch23/audio/en/timings.js@@ -155,22 +155,22 @@ window.TIMINGS = {]},"cols2": {- "dur": 65.376,+ "dur": 64.776,"marks": {- "A": 2.812,- "a1": 3.112,- "a2": 5.925,- "B": 8.229,- "n": 15.208,- "c1": 19.023,- "c2": 26.927,- "c3": 35.365,- "ab": 42.487,- "r1": 43.086,- "r2": 46.276,- "change": 48.958,- "only": 54.987,- "why": 61.576+ "A": 2.865,+ "a1": 3.19,+ "a2": 5.951,+ "B": 7.878,+ "n": 14.44,+ "c1": 18.411,+ "c2": 26.784,+ "c3": 35.195,+ "ab": 41.797,+ "r1": 42.357,+ "r2": 45.703,+ "change": 48.151,+ "only": 54.036,+ "why": 60.807},"cues": [[@@ -178,63 +178,63 @@ window.TIMINGS = {"Another one, with three columns."],[- 2.812,+ 2.865,"A is one, minus one in the first row, and two, one in the second."],[- 8.229,- "B has three columns: one, one; then two, one; then zero, three."+ 7.878,+ "B has three columns: one, one; then two, one; then zero, two."],[- 15.208,+ 14.44,"Three columns in B, so three columns in A B."],[- 19.023,+ 18.411,"Column one: one of column one of A, plus one of column two."],[- 22.982,+ 22.448,"One, two plus minus one, one is zero, three."],[- 26.927,+ 26.784,"Column two: two of column one, plus one of column two."],[- 31.445,+ 31.367,"Two, four plus minus one, one is one, five."],[- 35.365,- "Column three: none of column one, and three of column two."+ 35.195,+ "Column three: none of column one, and two of column two."],[- 40.352,- "That's minus three, three."+ 40.169,+ "That's minus two, two."],[- 42.487,- "So A B is zero, one, minus three on top, and three, five, three below."+ 41.797,+ "So A B is zero, one, minus two on top, and three, five, two below."],[- 48.958,+ 48.151,"Now watch while one number of B changes."],[- 51.589,- "The bottom of column three goes from three down to one."+ 50.742,+ "The bottom of column three goes from two up to four."],[- 54.987,- "Only column three of A B moves, to minus one, one."+ 54.036,+ "Only column three of A B moves, to minus four, four."],[- 58.737,+ 57.904,"Columns one and two stay where they are."],[- 61.576,+ 60.807,"Each column of A B depends only on its own column of B."]]diff --git a/site/linear-algebra/ch23/index.html b/site/linear-algebra/ch23/index.htmlindex 7334cfc..922d6b7 100644--- a/site/linear-algebra/ch23/index.html+++ b/site/linear-algebra/ch23/index.html@@ -21,7 +21,7 @@ const CHAPTER = { number: 23, title: 'Matrix Times Matrix', minutes: 10, languag/* ---------- chapter drawing helpers ---------- */const GREEN = MM_COL[0], VIOLET = MM_COL[1];const A1 = [[2, 1], [1, 3]], B1 = [[1, 2], [1, -1]]; // the first pair: AB = [[3, 3], [4, −1]]-const A2 = [[1, -1], [2, 1]], B2 = [[1, 2, 0], [1, 1, 3]]; // three columns: AB = [[0, 1, −3], [3, 5, 3]]+const A2 = [[1, -1], [2, 1]], B2 = [[1, 2, 0], [1, 1, 2]]; // three columns: AB = [[0, 1, −2], [3, 5, 2]]const AT = [70, 260]; // where A B = AB starts beside the planeconst PLANE = { cx: 1190, cy: 450, u: 50 };const CARD = { x: 40, y: 610, w: 780, cls: 'side' };@@ -42,7 +42,7 @@ const pair = (p, A, B, { col = 0, dots = true, hideC = false, t0 = .1, at = AT,return { g, P: P_ };};// A line of vectors and words, each piece arriving on its own time: items are [t, parts] or [t, { v: [..], fill }].-const vline = (p, x, y, items, { size = 30 } = {}) => {+const vline = (p, x, y, items, { size = 38 } = {}) => {items.forEach(([t, it]) => {const e = G(p, { o: 0 });if (it.v) x += mmSmall(e, it.v.map(q => [q]), x, y, { size, fill: () => it.fill || COL.chalk }) + 10;@@ -53,7 +53,8 @@ const vline = (p, x, y, items, { size = 30 } = {}) => {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: 17, fill: 'none', stroke: COL.task, 'stroke-width': 3, 'stroke-dasharray': '5 5' }, g);- T(g, `target (${num(x)}, ${num(y)})`, { x: 22, y: 40, size: 22, fill: COL.task, font: MATH });+ const left = P2.PX(x) > 1380; // near the right edge the label goes on the left+ T(g, `target (${num(x)}, ${num(y)})`, { x: left ? -22 : 22, y: 40, size: 22, fill: COL.task, font: MATH, anchor: left ? 'end' : 'start' });show(g, t0, .4);return g;};@@ -102,9 +103,9 @@ const SIZEQ = [].map(({ s, r }) => ({ parts: [sizeEq(...s) + ' gives ', { box: String(r[0]) }, ' × ', { box: String(r[1]) }],why: `The outside numbers: ${r[0]} rows (from the first), ${r[1]} columns (from the second).`, hint: 'Rows from the first matrix, columns from the second.' }));const HANDS = [- { A: [[1, 1], [0, 1]], B: [[0, 0], [0, 0]], col: 0, tgt: [3, 1], ans: { b00: 2, b10: 1 }, prompt: 'Move column 1 of B (the ring x) until column 1 of AB lands on the target.',+ { A: [[1, 1], [0, 1]], B: [[0, 0], [-1, 0]], col: 0, tgt: [3, 1], ans: { b00: 2, b10: 1 }, prompt: 'Move column 1 of B (the ring x) until column 1 of AB lands on the target.',why: 'Column 1 of B = (2, 1): 2·(1, 0) + 1·(1, 1) = (3, 1).' },- { A: [[2, 0], [0, 1]], B: [[1, 0], [1, 0]], col: 1, tgt: [-2, 3], ans: { b01: -1, b11: 3 }, prompt: 'Now column 2: make column 2 of AB land on the target.',+ { A: [[2, 0], [0, 1]], B: [[1, 1], [1, -1]], col: 1, tgt: [-2, 3], ans: { b01: -1, b11: 3 }, prompt: 'Now column 2: make column 2 of AB land on the target.',why: 'Column 2 of B = (−1, 3): −1·(2, 0) + 3·(0, 1) = (−2, 3).' },{ A: [[1, 0], [0, 1]], B: [[1, 0], [0, 1]], col: 0, tgt: null, ans: { a00: 2, a01: 1, a10: 1, a11: 2 }, prompt: 'B is the identity. Change A (its numbers or its arrows) until AB = [2 1; 1 2].',why: 'B = I, so AB = A: A must be [2 1; 1 2] itself. Each column of I picks one column of A.' },@@ -147,6 +148,13 @@ const BEATS = [thick(g.cols[0], m('mix') + 2.2); thick(g.cols[1], m('mix') + 2.2);['x0', 'x1'].forEach((k, i) => g.num(k).forEach(e => flashEl(e, m(i ? 'o2' : 'o1'))));thick(g.combo[0], m('st1'), 4); thick(g.combo[1], m('st2'), 4); thick(g.combo[0], m('st3'), 4); thick(g.combo[1], m('st4'), 4);+ // the picture gives each answer when the voice does: the steps on "one of column one", the landing on "three, four";+ // the second x hides them again while it moves, and its own steps come on "two of column one" and "minus one"+ const ax = [g.axArrow, g.axDot, g.axLab];+ [...ax, ...g.combo].forEach(e => { put(e, { o: 0 }); hide(e, m('x2') - .2, .3); });+ ax.forEach(e => { show(e, m('land'), .4); show(e, m('land2'), .4); });+ show(g.combo[0], m('o1'), .4); show(g.combo[1], m('o2'), .4); show(g.combo[0], m('mix2'), .4); show(g.combo[1], m('mn'), .4);+ res.forEach(e => { hide(e, m('x2') - .2, .3); show(e, m('land2'), .4); });['x0', 'x1'].forEach((k, i) => g.num(k).forEach(e => flashEl(e, m(i ? 'mn' : 'mix2'))));}],@@ -181,13 +189,14 @@ const BEATS = [P_.flash('a', { row: 0 }, m('a1')); P_.flash('a', { row: 1 }, m('a2'));[0, 1, 2].forEach(j => P_.flash('b', { col: j }, m('B') + .8 + j * 1.1));P_.flash('c', 'all', m('n') + .5);- [['c1', 0], ['c2', 1], ['c3', 2]].forEach(([k, j]) => {- P_.linkCol(j, m(k)); P_.show('cols', j, m(k), { times: [m(k) + .2, m(k) + 2.4, m(k) + 3.6] });- P_.reveal({ col: j }, m(k) + 3.8);+ // the scaled columns come as the voice adds them, the column of AB as it says the answer+ [['c1', 0, 4, 6], ['c2', 1, 4.6, 6.6], ['c3', 2, 3.4, 5]].forEach(([k, j, t2, t3]) => {+ P_.linkCol(j, m(k)); P_.show('cols', j, m(k), { times: [m(k) + .5, m(k) + t2, m(k) + t3] });+ P_.reveal({ col: j }, m(k) + t3);});P_.show(null, null, m('ab')); P_.flash('c', { row: 0 }, m('r1')); P_.flash('c', { row: 1 }, m('r2'));P_.show('cols', 2, m('change'));- P_.to({ b12: 1 }, m('change') + 2.6, 1.8);+ P_.to({ b12: 4 }, m('change') + 2.6, 1.8);P_.flash('c', { col: 2 }, m('only') + .2);P_.flash('c', { col: 0 }, m('only') + 2.6); P_.flash('c', { col: 1 }, m('only') + 2.9);text(p, 'column j of AB uses only column j of B', 70, 740, m('why'), { size: 30, weight: 600 });@@ -233,7 +242,8 @@ const BEATS = [['entry2', 'Bigger numbers', (m) => {const p = panel(0);title(p, 'The rule on bigger numbers');- const P_ = mm(p, { A: [[1, 2], [3, 4]], B: [[5, 6], [7, 8]], at: [380, 270], size: 46, cw: 70, cwC: 92, rh: 68, hideC: true, t0: m('A') - .3, wsize: 34 });+ const P_ = mm(p, { A: [[1, 2], [3, 4]], B: [[5, 6], [7, 8]], at: [380, 270], size: 46, cw: 70, cwC: 92, rh: 68, hideC: true, t0: .6, wsize: 44 });+ put(P_.L.c.g, { o: 0 }); show(P_.L.c.g, m('B') + .8, .5);put(P_.L.b.g, { o: 0 }); show(P_.L.b.g, m('B'), .5);P_.flash('a', 'all', m('A') + .3); P_.flash('b', 'all', m('B') + .3);[['e11', [0, 0]], ['e12', [0, 1]], ['e21', [1, 0]], ['e22', [1, 1]]].forEach(([k, c]) => {@@ -241,13 +251,13 @@ const BEATS = [P_.reveal({ cell: c }, m(k) + 5.3);});P_.show(null, null, m('ab')); P_.flash('c', 'all', m('ab') + .3);- text(p, 'four entries, each one a row times a column', 380, 640, m('four'), { size: 30, weight: 600 });+ text(p, 'four entries, each one a row times a column', 380, 720, m('four'), { size: 30, weight: 600 });}],['q2', 'Your turn', () => {const p = panel(0);title(p, 'Your turn');- const t = pair(p, A2, [[1, 0], [1, 0]], { col: 1 });+ const t = pair(p, A2, [[1, 1], [1, 0]], { col: 1 });S.P = t.P; S.g = t.g;target(t.g.P, [1, 5], p, .3);t.P.show('cols', 1, .4);@@ -263,7 +273,8 @@ const BEATS = [title(p, 'Sizes: two by three times three by two');const P_ = S.P = mm(p, { A: [[1, 2, 0], [0, 1, 1]], B: [[1, 1], [2, 0], [0, 3]], at: [300, 260], hideC: true, t0: m('A') - .3 });put(P_.L.b.g, { o: 0 }); show(P_.L.b.g, m('B'), .5);- put(P_.L.sz, { o: 0 }); show(P_.L.sz, m('A') + 1.5, .5);+ put(P_.L.sa.g, { o: 0 }); show(P_.L.sa.g, m('A') + 1.5, .5);+ put(P_.L.c.g, { o: 0 }); show(P_.L.c.g, m('inner'), .5);P_.flash('a', { row: 0 }, m('A') + 1.5); P_.flash('a', { col: 2 }, m('A') + 3);P_.inner(m('inner'));P_.show('entry', [0, 0], m('inner') + .3);@@ -286,7 +297,8 @@ const BEATS = [const top = G(p, {});const P_ = mm(top, { A: [[1, 2, 0], [0, 1, 1]], B: [[1, 1], [2, 0], [0, 3]], at: [300, 260], t0: 0 });P_.inner(0);- P_.to({ nB: 2 }, m('drop') + .4, .1);+ P_.flash('b', { row: 2 }, m('drop'), { color: COL.bad });+ P_.to({ nB: 2 }, m('drop') + 1.3, .1);P_.flash('a', { row: 0 }, m('row') + .2); P_.flash('b', { col: 0 }, m('cb'));P_.flash('a', { cell: [0, 2] }, m('no'), { color: COL.bad }); P_.flash('a', { cell: [1, 2] }, m('no') + 1, { color: COL.bad });P_.flash('b', 'all', m('nd'), { color: COL.bad });diff --git a/site/linear-algebra/ch24/audio/en/columns2.mp3 b/site/linear-algebra/ch24/audio/en/columns2.mp3new file mode 100644index 0000000..4e866f1Binary files /dev/null and b/site/linear-algebra/ch24/audio/en/columns2.mp3 differdiff --git a/site/linear-algebra/ch24/audio/en/timings.js b/site/linear-algebra/ch24/audio/en/timings.jsindex 57fd2d8..11eb418 100644--- a/site/linear-algebra/ch24/audio/en/timings.js+++ b/site/linear-algebra/ch24/audio/en/timings.js@@ -169,6 +169,78 @@ window.TIMINGS = {]]},+ "columns2": {+ "dur": 57.72,+ "marks": {+ "A": 2.604,+ "B": 8.763,+ "c1": 12.135,+ "m1": 19.349,+ "r1": 21.953,+ "c2": 23.724,+ "m2": 30.469,+ "r2": 33.359,+ "ab": 35.3,+ "e12": 39.987,+ "p12": 49.115,+ "r12": 54.167,+ "same": 55.286+ },+ "cues": [+ [+ 0.091,+ "One more pair, worked both ways."+ ],+ [+ 2.604,+ "A is one, minus one, and one, two."+ ],+ [+ 5.729,+ "Its columns are one, one and minus one, two."+ ],+ [+ 8.763,+ "B is one, two, and one, minus one."+ ],+ [+ 12.135,+ "Way two, column one of B is one, one: one of column one of A, plus one of column two."+ ],+ [+ 19.349,+ "One, one plus minus one, two is zero, three."+ ],+ [+ 23.724,+ "Column two of B is two, minus one: two of column one, and minus one of column two."+ ],+ [+ 30.469,+ "Two, two plus one, minus two is three, zero."+ ],+ [+ 35.3,+ "So A B is zero, three, and three, zero."+ ],+ [+ 39.987,+ "Now check one number by way one: the top of column two."+ ],+ [+ 43.945,+ "Row one of A, one, minus one, times column two of B, two, minus one."+ ],+ [+ 49.115,+ "One times two, plus minus one times minus one: two plus one is three."+ ],+ [+ 55.286,+ "Three, the same number both ways."+ ]+ ]+ },"q1": {"dur": 3.432,"marks": {},diff --git a/site/linear-algebra/ch24/index.html b/site/linear-algebra/ch24/index.htmlindex 808ef5b..37b811f 100644--- a/site/linear-algebra/ch24/index.html+++ b/site/linear-algebra/ch24/index.html@@ -22,22 +22,23 @@ const CHAPTER = { number: 24, title: 'Four Ways to Multiply', minutes: 10, languconst GREEN = MM_COL[0], VIOLET = MM_COL[1], BLUE = MM_ROW[0], CORAL = MM_ROW[1];const A0 = [[2, 1], [1, 1]], B0 = [[1, -1], [2, 1]]; // the chapter's pair: AB = [[4, −1], [3, 0]]const AT = [70, 260];-const PLANE = { cx: 1190, cy: 450, u: 50 };+const PLANE = { cx: 1190, cy: 440, u: 60, x0: -5, x1: 5, y0: -5, y1: 5 }; // closer in: this pair's points are all within 5+const PLANE6 = { cx: 1190, cy: 450, u: 50 }; // rows2 goes to (−3, −6)const CARD = { x: 40, y: 610, w: 780, 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 = (e, t0, w = 5) => { tw(e, { 'a_stroke-width': w + 5 }, t0, .3); tw(e, { 'a_stroke-width': w }, t0 + 1.2, .6); };// The column way's picture (chapter 23): A's columns as arrows, x = a column of B, Ax = that column of AB.-const colPic = (p, P_, col = 0, t0 = .1) => {- const g = grid2(p, { A: [[P_.v.a00, P_.v.a01], [P_.v.a10, P_.v.a11]], x: [0, 0], mat: null, grid: false, square: false, units: false, brackets: true, plane: PLANE, t0 });+const colPic = (p, P_, col = 0, t0 = .1, plane = PLANE) => {+ const g = grid2(p, { A: [[P_.v.a00, P_.v.a01], [P_.v.a10, P_.v.a11]], x: [0, 0], mat: null, grid: false, square: false, units: false, brackets: true, plane, t0 });g.labels(['col 1', 'col 2']);P_.link(g, { col, dots: true });return g;};// The row way's picture: the arrows are the rows of B (blue, coral), x = a row of A, Ax = that row of AB.-const rowPic = (p, P_, row = 0, t0 = .1) => {- const g = grid2(p, { A: [[0, 0], [0, 0]], x: [0, 0], mat: null, grid: false, square: false, units: false, brackets: true, plane: PLANE, t0 });+const rowPic = (p, P_, row = 0, t0 = .1, plane = PLANE) => {+ const g = grid2(p, { A: [[0, 0], [0, 0]], x: [0, 0], mat: null, grid: false, square: false, units: false, brackets: true, plane, t0 });g.labels(['row 1 of B', 'row 2 of B']);[0, 1].forEach(j => {[g.cols[j], g.combo[j]].forEach(e => { e.setAttribute('stroke', MM_ROW[j]); e.setAttribute('fill', MM_ROW[j]); });@@ -50,7 +51,8 @@ const rowPic = (p, P_, row = 0, t0 = .1) => {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: 17, fill: 'none', stroke: COL.task, 'stroke-width': 3, 'stroke-dasharray': '5 5' }, g);- T(g, `target (${num(x)}, ${num(y)})`, { x: 22, y: 40, size: 22, fill: COL.task, font: MATH });+ const left = P2.PX(x) > 1380; // near the right edge the label goes on the left+ T(g, `target (${num(x)}, ${num(y)})`, { x: left ? -22 : 22, y: 40, size: 22, fill: COL.task, font: MATH, anchor: left ? 'end' : 'start' });show(g, t0, .4);return g;};@@ -93,9 +95,9 @@ const WAYQ = [['(column 1 of A)(row 1 of B) + (column 2 of A)(row 2 of B)', 'p'], ['row 2 of A times column 1 of B: one number', 'e'], ['row 2 of E mixes the rows of A (elimination)', 'r'],].map(([s, k]) => ({ parts: [s], ans: [k], why: { e: 'One entry: a row times a column.', c: 'A mix of the columns of A: one column of AB.', r: 'A mix of the rows of the right matrix: one row of the answer.', p: 'Pieces added: columns times rows.' }[k] }));const HANDS = [- { A: [[0, 0], [1, 1]], B: [[1, -1], [2, 1]], row: 0, tgt: [3, 0], ans: { a00: 1, a01: 1 }, prompt: 'Move row 1 of A (the ring x, or its numbers) until row 1 of AB lands on the target.',+ { A: [[1, 0], [0, 1]], B: [[1, -1], [2, 1]], row: 0, tgt: [3, 0], ans: { a00: 1, a01: 1 }, prompt: 'Move row 1 of A (the ring x, or its numbers) until row 1 of AB lands on the target.',why: 'Row 1 of A = (1, 1): (1, −1) + (2, 1) = (3, 0).' },- { A: [[1, 0], [0, 0]], B: [[1, 0], [1, 1]], row: 1, tgt: [-1, 2], ans: { a10: -3, a11: 2 }, prompt: 'New rows of B. Make row 2 of AB land on the target.',+ { A: [[1, 0], [0, 1]], B: [[1, 0], [1, 1]], row: 1, tgt: [-1, 2], ans: { a10: -3, a11: 2 }, prompt: 'New rows of B. Make row 2 of AB land on the target.',why: 'Row 2 of A = (−3, 2): −3·(1, 0) + 2·(1, 1) = (−1, 2).' },{ A: [[1, 0], [0, 1]], B: [[1, 0], [0, 1]], row: 0, tgt: null, ans: { b00: 1, b01: 2, b10: 3, b11: 1 }, prompt: 'A is the identity. Change B (its numbers, or drag the row arrows) until AB = [1 2; 3 1].',why: 'A = I, so each row of AB is just a row of B: B = [1 2; 3 1].' },@@ -172,6 +174,26 @@ const BEATS = [P_.linkCol(0, m('handy') + 2.5);}],+ ['columns2', 'Both ways', (m) => {+ const p = panel(0);+ title(p, 'One more pair, two ways');+ const P_ = mm(p, { A: [[1, -1], [1, 2]], B: [[1, 2], [1, -1]], at: AT, tintA: 'cols', hideC: true, t0: m('A') - .3 });+ const g = colPic(p, P_, 0, m('A') - .3);+ put(P_.L.b.g, { o: 0 }); show(P_.L.b.g, m('B'), .5);+ P_.flash('a', { col: 0 }, m('A') + 2.6); P_.flash('a', { col: 1 }, m('A') + 3.8); thick(g.cols[0], m('A') + 2.6); thick(g.cols[1], m('A') + 3.8);+ P_.show('cols', 0, m('c1'), { times: [m('c1') + 2.5, m('m1'), m('r1')] });+ P_.reveal({ col: 0 }, m('r1'));+ P_.linkCol(1, m('c2'));+ P_.show('cols', 1, m('c2'), { times: [m('c2') + 2.5, m('m2'), m('r2')] });+ P_.reveal({ col: 1 }, m('r2'));+ pulse(g.axDot, m('r2') + .2);+ P_.show(null, null, m('ab')); P_.flash('c', 'all', m('ab') + .3);+ P_.flash('a', { row: 0 }, m('e12') + 3.5); P_.flash('b', { col: 1 }, m('e12') + 5.5);+ P_.show('entry', [0, 1], m('e12') + 2.5, { times: [m('p12'), m('p12') + 2.6, m('r12')] });+ P_.flash('c', { cell: [0, 1] }, m('same'), { color: COL.good });+ text(p, 'way 1 and way 2: the same number', 70, 790, m('same') + .3, { size: 28, fill: COL.dim, weight: 600 });+ }],+['q1', 'Quick check', () => {const p = panel(0);title(p, 'Quick check');@@ -191,8 +213,8 @@ const BEATS = [title(p, 'Way 3: each row of A times B');const P_ = mm(p, { A: A0, B: B0, at: AT, tintB: 'rows', hideC: true, t0: .1 });const g = rowPic(p, P_, 0);- put(g.parts.cols, { o: 0 }); put(g.parts.x, { o: 0 });- show(g.parts.cols, m('pic1'), .5); show(g.parts.x, m('pic1') + 2, .5);+ put(g.parts.cols, { o: 0 }); put(g.parts.x, { o: 0 }); put(g.stage, { o: 0 });+ show(g.stage, m('pic1') - .3, .4); show(g.parts.cols, m('pic1'), .5); show(g.parts.x, m('pic1') + 2, .5);P_.flash('a', { row: 0 }, m('turn')); P_.flash('b', 'all', m('turn') + 1.2);P_.show('rows', 0, m('r1'), { times: [m('r1') + 1.5, m('m1'), m('s1')] });P_.flash('b', { row: 0 }, m('r1') + 2.5); P_.flash('b', { row: 1 }, m('r1') + 4.2);@@ -209,9 +231,9 @@ const BEATS = [['rows2', 'Elimination is the row way', (m) => {const p = panel(0);title(p, 'The row way is elimination');- const P_ = mm(p, { A: [[1, 0], [-3, 1]], B: [[1, 2], [3, 4]], names: ['E', 'A', 'EA'], at: AT, tintB: 'rows', hideC: true, t0: m('sys') - .3 });- const g = rowPic(p, P_, 0, m('sys') - .3);- text(p, 'chapter 21: numbers on the left mix the rows', 70, 180, m('E'), { size: 26, fill: COL.dim, weight: 600 });+ const P_ = mm(p, { A: [[1, 0], [-3, 1]], B: [[1, 2], [3, 4]], names: ['E', 'A', 'EA'], at: AT, tintB: 'rows', hideC: true, t0: m('E') + .3 });+ const g = rowPic(p, P_, 0, m('sys') - .3, PLANE6);+ text(p, 'chapter 21: numbers on the left mix the rows', 70, 162, m('E'), { size: 26, fill: COL.dim, weight: 600 });P_.flash('a', 'all', m('sys') + .3); P_.flash('b', 'all', m('sys') + 3);P_.show('rows', 0, m('r1'), { times: [m('r1') + 1.5, m('r1') + 2.5, m('r1') + 3.6] });P_.reveal({ row: 0 }, m('r1') + 3.6);@@ -230,7 +252,7 @@ const BEATS = [['q2', 'Your turn', () => {const p = panel(0);title(p, 'Your turn');- S.P = mm(p, { A: [[2, 1], [0, 0]], B: B0, at: AT, tintB: 'rows' });+ S.P = mm(p, { A: [[2, 1], [1, 0]], B: B0, at: AT, tintB: 'rows', wsize: 30 }); // one line of working, clear of the cardS.g = rowPic(p, S.P, 1);target(S.g.P, [5, -2], p, .3);S.P.show('rows', 1, .4);@@ -249,26 +271,25 @@ const BEATS = [Q.flash('a', 'all', m('cr') + 1); Q.flash('b', 'all', m('cr') + 2.5);Q.inner(m('sz') + 2);Q.outer(m('sz') + 4.5);- [[0, 0], [0, 1], [1, 0], [1, 1]].forEach((c, k) => Q.reveal({ cell: c }, m('each') + 1.2 + k * 2.2));+ [[0, 0], [0, 1], [1, 0], [1, 1]].forEach(([i, j], k) => { const t = m('each') + 1.2 + k * 2.2; Q.flash('a', { cell: [i, 0] }, t - .5); Q.flash('b', { cell: [0, j] }, t - .5); Q.reveal({ cell: [i, j] }, t + .4); });Q.flash('c', { row: 0 }, m('look') + .5); Q.flash('c', { row: 1 }, m('look') + 1.7);- say(one, ['every row a multiple of (1, −1)'], 90, 520, m('look') + 3, { size: 32 });+ text(one, 'every row is a multiple of (1, −1)', 90, 520, m('look') + 3, { size: 32, weight: 600 });Q.flash('c', { row: 0 }, m('look') + 5.5); Q.flash('c', { row: 1 }, m('look') + 6.5); Q.flash('b', 'all', m('look') + 7.5);hide(one, m('pair'), .5);const two = G(p, { o: 0 }); show(two, m('pair') + .3, .5);- const P_ = mm(two, { A: A0, B: B0, at: AT, tintA: 'cols', tintB: 'rows', hideC: true, t0: 0 });+ const P_ = mm(two, { A: A0, B: B0, at: AT, tintA: 'cols', tintB: 'rows', hideC: true, t0: 0, wsize: 40 });P_.show('outer', 0, m('p1'), { times: [m('p1'), m('p1') + 3] });P_.show('outer', 1, m('p2'), { times: [m('p2'), m('p2') + 5] });P_.flash('a', { col: 0 }, m('p1') + .5); P_.flash('b', { row: 0 }, m('p1') + 1.5); P_.flash('a', { col: 1 }, m('p2') + .5); P_.flash('b', { row: 1 }, m('p2') + 2.5);P_.show('sum', null, m('sum'), { times: [m('sum'), m('sum') + 1.2] });[[0, 0], [0, 1], [1, 0], [1, 1]].forEach((c, k) => P_.reveal({ cell: c }, m('sum') + 2.5 + k * 2.4));P_.flash('c', 'all', m('same'));- text(two, 'AB = (column 1)(row 1) + (column 2)(row 2)', 860, 300, m('sum') + .5, { size: 30, weight: 600 });}],['outer2', 'Pieces again', (m) => {const p = panel(0);title(p, 'Pieces, with bigger numbers');- const P_ = mm(p, { A: [[1, 2], [3, 4]], B: [[5, 6], [7, 8]], at: AT, tintA: 'cols', tintB: 'rows', hideC: true, t0: .1 });+ const P_ = mm(p, { A: [[1, 2], [3, 4]], B: [[5, 6], [7, 8]], at: AT, tintA: 'cols', tintB: 'rows', hideC: true, t0: .1, wsize: 40 });P_.flash('a', 'all', 2); P_.flash('b', 'all', 4.5);P_.show('outer', 0, m('p1'), { times: [m('p1'), m('p1') + 4.5] });P_.flash('a', { col: 0 }, m('p1') + 1); P_.flash('b', { row: 0 }, m('p1') + 3);@@ -371,7 +392,7 @@ const BEATS = [['final4', 'Chapter practice', () => {const p = panel(0);title(p, 'Hit the targets with rows');- S.P = mm(p, { A: HANDS[0].A, B: HANDS[0].B, at: AT, tintB: 'rows' });+ S.P = mm(p, { A: HANDS[0].A, B: HANDS[0].B, at: AT, tintB: 'rows', wsize: 30 });S.g = rowPic(p, S.P, 0); S.tg = G(p, {});}, { ask: done => quiz(CARD, HANDS.map((h, k) => ({id: `p-hand${k + 1}`, prompt: [h.prompt],@@ -391,7 +412,7 @@ const BEATS = [['play', 'Playground', (m, D) => {const p = panel(0);title(p, 'Playground');- S.P = mm(p, { A: A0, B: B0, at: AT, tintB: 'rows' });+ S.P = mm(p, { A: A0, B: B0, at: AT, tintB: 'rows', wsize: 30 });rowPic(p, S.P, 0);const hint = text(p, 'try: equal rows in B · a row of zeros in A · A = the identity', 70, 170, m('go'), { size: 24, fill: COL.dim });hide(hint, Math.min(m('go') + 9, D - .7), .6);diff --git a/site/linear-algebra/ch25/audio/en/assoc2.mp3 b/site/linear-algebra/ch25/audio/en/assoc2.mp3new file mode 100644index 0000000..b2ef460Binary files /dev/null and b/site/linear-algebra/ch25/audio/en/assoc2.mp3 differdiff --git a/site/linear-algebra/ch25/audio/en/dist2.mp3 b/site/linear-algebra/ch25/audio/en/dist2.mp3new file mode 100644index 0000000..5164325Binary files /dev/null and b/site/linear-algebra/ch25/audio/en/dist2.mp3 differdiff --git a/site/linear-algebra/ch25/audio/en/timings.js b/site/linear-algebra/ch25/audio/en/timings.jsindex 1e0f4b4..d73ec2e 100644--- a/site/linear-algebra/ch25/audio/en/timings.js+++ b/site/linear-algebra/ch25/audio/en/timings.js@@ -401,6 +401,68 @@ window.TIMINGS = {]]},+ "assoc2": {+ "dur": 42.408,+ "marks": {+ "left": 3.984,+ "ab": 18.477,+ "abc": 24.01,+ "right": 27.552,+ "bc": 29.453,+ "abc2": 31.536,+ "same": 36.771+ },+ "cues": [+ [+ 0.104,+ "One more time, with the swap, a stretch and the shear."+ ],+ [+ 3.984,+ "A is the swap: zero, one, one, zero."+ ],+ [+ 8.516,+ "B stretches sideways: two, zero, zero, one."+ ],+ [+ 12.878,+ "And C is the shear: one, one, zero, one."+ ],+ [+ 17.109,+ "A B first."+ ],+ [+ 18.477,+ "The swap on the left swaps the rows of B: zero, one, and two, zero."+ ],+ [+ 24.01,+ "Times C: zero, one, and two, two."+ ],+ [+ 27.552,+ "Now B C first."+ ],+ [+ 29.453,+ "Two, two, and zero, one."+ ],+ [+ 31.536,+ "And the swap on the left swaps its rows: zero, one, and two, two."+ ],+ [+ 36.771,+ "The same matrix again."+ ],+ [+ 38.281,+ "The brackets moved, but the order A, B, C did not."+ ]+ ]+ },"dist": {"dur": 48.216,"marks": {@@ -461,6 +523,64 @@ window.TIMINGS = {]]},+ "dist2": {+ "dur": 43.44,+ "marks": {+ "add": 3.177,+ "bc": 9.609,+ "lhs": 18.451,+ "ab": 25.299,+ "ac": 30.794,+ "sum": 35.677,+ "same": 39.492+ },+ "cues": [+ [+ 0.104,+ "Once more, with two matrices we know well."+ ],+ [+ 3.177,+ "A is two, one, zero, one."+ ],+ [+ 5.69,+ "B is the identity, and C is the swap."+ ],+ [+ 9.609,+ "B plus C: one plus zero, zero plus one, zero plus one, one plus zero."+ ],+ [+ 17.357,+ "All ones."+ ],+ [+ 18.451,+ "A times all ones: each row of A just adds up its two numbers."+ ],+ [+ 23.229,+ "Three, three, and one, one."+ ],+ [+ 25.299,+ "Now A times the identity is A itself: two, one, zero, one."+ ],+ [+ 30.794,+ "A times the swap swaps the columns of A: one, two, one, zero."+ ],+ [+ 35.677,+ "Add them: three, three, and one, one."+ ],+ [+ 39.492,+ "The same as A times B plus C, just as the rule says."+ ]+ ]+ },"q2": {"dur": 7.272,"marks": {},diff --git a/site/linear-algebra/ch25/index.html b/site/linear-algebra/ch25/index.htmlindex 9bd862d..05f8020 100644--- a/site/linear-algebra/ch25/index.html+++ b/site/linear-algebra/ch25/index.html@@ -49,6 +49,42 @@ const cellBands = (p, mats, i, j, ymid, t0, size = 34) => mats.forEach(([rows, xput(r, { o: 0 }); show(r, t0, .25); hide(r, t0 + 1.7, .3);});const mmS = (p, A, B, at, names, o = {}) => mm(p, { A, B, at, names, size: 34, cw: 50, rh: 52, sizes: false, ...o });+// (AB)C on the top line, A(BC) under it, revealed on the marks left, ab, abc, right, bc, abc2.+const brackets = (p, m, A, B, C) => {+ const o = { hideC: true };+ const m1 = mmS(p, A, B, [70, 260], ['A', 'B', 'AB'], { ...o, t0: m('left') - .3 });+ const m2 = mmS(p, mul(A, B), C, [760, 260], ['AB', 'C', '(AB)C'], { ...o, t0: m('ab') + .8 });+ const m3 = mmS(p, B, C, [70, 560], ['B', 'C', 'BC'], { ...o, t0: m('right') - .3 });+ const m4 = mmS(p, A, mul(B, C), [760, 560], ['A', 'BC', 'A(BC)'], { ...o, t0: m('bc') + .8 });+ [m1, m2, m3, m4].forEach(q => put(q.W, { o: 0 }));+ [[m1, 'left'], [m2, 'ab'], [m3, 'right'], [m4, 'bc']].forEach(([q, k]) => { put(q.g, { o: 0 }); show(q.g, m(k) - .2 + (k === 'ab' || k === 'bc' ? 1 : 0), .5); });+ m1.reveal('all', m('ab')); m2.reveal('all', m('abc'));+ m3.reveal('all', m('bc')); m4.reveal('all', m('abc2'));+ return { m1, m2, m3, m4 };+};+// B + C number by number (the same place lit in all three, `step` seconds apart from bc + off), then A(B + C) on lhs,+// AB on ab, AC on ac and their sum on sum.+const madd = (X, Y) => X.map((r, i) => r.map((v, j) => v + Y[i][j]));+const sums = (p, m, A, B, C, step, off) => {+ const BC = madd(B, C);+ const ad = G(p, { o: 0 }); show(ad, m('add'), .5);+ let x = 70;+ const BX = [];+ [['B + C ='], B, ['+'], C, ['='], BC].forEach((it, k) => {+ if (typeof it[0] === 'string') { const w = M(ad, it, { x, y: 272, size: 34, anchor: 'start' }); x += (w._w || 20) + 12; }+ else { BX.push(x); const g0 = G(ad, {}); x += mmSmall(g0, it, x, 260, { size: 34 }) + 12; if (k === 5) { put(g0, { o: 0 }); show(g0, m('bc'), .4); } }+ });+ const L = mmS(p, A, BC, [760, 260], ['A', 'B + C', 'A(B + C)'], { hideC: true, t0: m('lhs') - .3 });+ put(L.W, { o: 0 }); put(L.g, { o: 0 }); show(L.g, m('lhs') - .2, .5); L.reveal('all', m('lhs') + 1);+ const P1 = mmS(p, A, B, [70, 560], ['A', 'B', 'AB'], { hideC: true, t0: m('ab') - .3 });+ const P2 = mmS(p, A, C, [620, 560], ['A', 'C', 'AC'], { hideC: true, t0: m('ac') - .3 });+ [P1, P2].forEach(q => put(q.W, { o: 0 }));+ put(P1.g, { o: 0 }); show(P1.g, m('ab') - .2, .5); P1.reveal('all', m('ab') + 1);+ put(P2.g, { o: 0 }); show(P2.g, m('ac') - .2, .5); P2.reveal('all', m('ac') + 1);+ const S_ = named(p, 'AB + AC', madd(mul(A, B), mul(A, C)), 1170, 584, m('sum'), { fill: () => COL.task });+ [[0, 0], [0, 1], [1, 0], [1, 1]].forEach(([i, j], k) => cellBands(p, [[B, BX[0]], [C, BX[1]], [BC, BX[2]]], i, j, 260, m('bc') + off + k * step));+ return { L, S_ };+};// Two products side by side, A B and B A, each with the plane it makes; the second follows the first.const commute = (p, A, B, { t0 = .1 } = {}) => {const P_ = mmS(p, A, B, [60, 230], ['A', 'B', 'AB'], { t0 });@@ -64,6 +100,7 @@ const commute = (p, A, B, { t0 = .1 } = {}) => {P_.onChange(sync); sync(P_.v);return { P: P_, Q, gL, gR };};+const rowsStr = X => `[${X.map(r => r.map(num).join(' ')).join('; ')}]`; // [0 −1; 1 1]const same = (C, D_) => C.every((r, i) => r.every((v, j) => Math.abs(v - D_[i][j]) < 1e-9));const pairEl = (A, B) => ['A = ', mmEl(A), ' B = ', mmEl(B)];const boxes = rows => rows.flatMap((r, i) => [...(i ? ['; '] : []), ...r.flatMap((v, j) => [...(j ? [' '] : []), { box: String(v) }])]);@@ -83,9 +120,9 @@ const RULEQ = [['(AB)² = A²B² for every A and B', false, '(AB)² = ABAB; turning the middle BA into AB needs AB = BA.'],].map(([s, ok, why]) => ({ parts: [s], ans: [ok ? 't' : 'f'], why }));const HANDS = [- { A: TURN, B: SHEAR, prompt: 'A is a quarter turn. Change B until AB = BA: both planes end the same way.', why: 'Any B of the form [a −b; b a] works (a turn and a stretch), for example I, or the turn itself.' },- { A: [[2, 0], [0, 1]], B: SHEAR, prompt: 'A stretches sideways. Change B until AB = BA.', why: 'B must not mix x and y: its corner numbers must be 0, as in [a 0; 0 d].' },- { A: SHEAR, B: [[1, 0], [1, 1]], prompt: 'A is the shear. Change B until AB = BA.', why: 'B must be [a b; 0 a]: another shear (times a number), or the identity.' },+ { A: TURN, B: SHEAR, tip: 'Try B with equal diagonal numbers and opposite corners.', prompt: 'A is a quarter turn. Change B until AB = BA: both planes end the same way.', why: 'Any B of the form [a −b; b a] works (a turn and a stretch), for example I, or the turn itself.' },+ { A: [[2, 0], [0, 1]], B: SHEAR, tip: 'Watch the corner numbers of AB and BA: they differ unless the corners of B are 0.', prompt: 'A stretches sideways. Change B until AB = BA.', why: 'B must not mix x and y: its corner numbers must be 0, as in [a 0; 0 d].' },+ { A: SHEAR, B: [[1, 0], [1, 1]], tip: 'Start from B = A, then try other numbers on the top right.', prompt: 'A is the shear. Change B until AB = BA.', why: 'B must be [a b; 0 a]: another shear (times a number), or the identity.' },];/* ---------- beats ---------- */@@ -125,15 +162,16 @@ const BEATS = [['motion', 'First B, then A', (m, D) => {const p = panel(0);title(p, 'A B x = A (B x): first B, then A');- const P_ = mm(p, { A: TURN, B: SHEAR, at: [70, 280], hideC: true, t0: m('ex') - .3 });- put(P_.W, { o: 0 });+ const P_ = mm(p, { A: TURN, B: SHEAR, at: [70, 280], hideC: true, t0: m('ex') - .3, wsize: 32 });+ put(P_.W, { o: 0 }); show(P_.W, m('ab') - .2, .3);put(P_.g, { o: 0 }); show(P_.g, m('ex'), .5);const na = text(p, 'A: quarter turn', P_.L.a.x + P_.L.a.W / 2, 450, m('ex') + 4, { size: 26, fill: COL.dim, weight: 600, anchor: 'middle' });const nb = text(p, 'B: shear', P_.L.b.x + P_.L.b.W / 2, 450, m('ex') + 2, { size: 26, fill: COL.dim, weight: 600, anchor: 'middle' });[nb, na].forEach(e => hide(e, m('ab') - .4, .3));const sx = say(p, ['AB x = A (B x)'], 70, 200, m('x'), { size: 36 });hide(sx, m('ex') - .3, .3);- [text(p, 'B acts first', 340, 250, m('first') + .4, { size: 26, fill: COL.dim, weight: 600 }), text(p, 'then A', 175, 250, m('first') + 3, { size: 26, fill: COL.dim, weight: 600 })].forEach(e => hide(e, m('ex') - .3, .3));+ [text(p, '1. B stands next to x: B acts first, making B x', 70, 270, m('first') + .4, { size: 28, fill: COL.dim, weight: 600 }),+ text(p, '2. then A acts on what B made: A (B x)', 70, 320, m('first') + 3, { size: 28, fill: COL.dim, weight: 600 })].forEach(e => hide(e, m('ex') - .3, .3));const g = motion(p, 1150, 450, 56, 5);P_.flash('b', 'all', m('b'));prog(q => g.set(gv(shear(q))), m('b') + .4, 2.4, io);@@ -181,7 +219,7 @@ const BEATS = [S.P = mmS(p, A, B, [90, 260], ['A', 'B', 'AB'], { hideC: true });S.Q = mmS(p, B, A, [860, 260], ['B', 'A', 'BA'], { hideC: true });}, { ask: done => quiz({ x: 40, y: 470, w: 860, cls: 'side' }, [{- id: 'c-order', prompt: ['B swaps. Work out both orders, row by row.'],+ id: 'c-order', prompt: ['B swaps. Work out both orders.'],build: blanks([{ parts: ['AB = [', ...boxes([[0, 1], [2, 0]]), ']'], why: 'B on the right swaps the columns of A: [0 1; 2 0].', hint: 'By columns: column 1 of B, (0, 1), takes column 2 of A.',fx: () => fxp(q => { if (q > 0) S.P.uncover('all'); }, 0, .1) },@@ -232,17 +270,8 @@ const BEATS = [['assoc', 'Brackets can move', (m) => {const p = panel(0);title(p, '(A B) C = A (B C)');- const A = [[1, 1], [0, 1]], B = [[2, 0], [0, 1]], C = [[1, 0], [1, 1]];- const o = { hideC: true };- const m1 = mmS(p, A, B, [70, 260], ['A', 'B', 'AB'], { ...o, t0: m('left') - .3 });- const m2 = mmS(p, mul(A, B), C, [760, 260], ['AB', 'C', '(AB)C'], { ...o, t0: m('ab') + .8 });- const m3 = mmS(p, B, C, [70, 560], ['B', 'C', 'BC'], { ...o, t0: m('right') - .3 });- const m4 = mmS(p, A, mul(B, C), [760, 560], ['A', 'BC', 'A(BC)'], { ...o, t0: m('bc') + .8 });- [m1, m2, m3, m4].forEach(q => put(q.W, { o: 0 }));- [[m1, 'left'], [m2, 'ab'], [m3, 'right'], [m4, 'bc']].forEach(([q, k]) => { put(q.g, { o: 0 }); show(q.g, m(k) - .2 + (k === 'ab' || k === 'bc' ? 1 : 0), .5); });+ const { m1, m2, m3, m4 } = brackets(p, m, [[1, 1], [0, 1]], [[2, 0], [0, 1]], [[1, 0], [1, 1]]);text(p, 'A, B, C', 1440, 200, m('three'), { size: 30, weight: 600, anchor: 'end' });- m1.reveal('all', m('ab')); m2.reveal('all', m('abc'));- m3.reveal('all', m('bc')); m4.reveal('all', m('abc2'));m2.flash('c', 'all', m('rule')); m4.flash('c', 'all', m('rule') + .2);m1.flash('a', 'all', m('rule') + 3); m1.flash('b', 'all', m('rule') + 3.6); m2.flash('b', 'all', m('rule') + 4.2);m4.flash('a', 'all', m('rule') + 5.5); m3.flash('a', 'all', m('rule') + 6.1); m3.flash('b', 'all', m('rule') + 6.7);@@ -252,32 +281,38 @@ const BEATS = [text(p, 'chapter 21: E₃₂ (E₂₁ A) = (E₃₂ E₂₁) A', 900, 860, m('e'), { size: 26, fill: COL.dim, weight: 600 });}],+ ['assoc2', 'Brackets, again', (m) => {+ const p = panel(0);+ title(p, '(A B) C = A (B C), once more');+ const { m1, m2, m3, m4 } = brackets(p, m, [[0, 1], [1, 0]], [[2, 0], [0, 1]], SHEAR);+ text(p, 'A: the swap B: a stretch C: the shear', 1500, 170, m('left') + .5, { size: 24, fill: COL.dim, weight: 600, anchor: 'end' });+ // each matrix lit as it is named; C comes in (under B, in B C) on "and C is the shear"+ m1.flash('a', 'all', m('left') + .4); m1.flash('b', 'all', m('left') + 4.8);+ show(m3.g, m('left') + 8.9, .5); m3.flash('b', 'all', m('left') + 9.4);+ m1.flash('b', { row: 0 }, m('ab') + 1.2); m1.flash('b', { row: 1 }, m('ab') + 1.8);+ m4.flash('b', { row: 0 }, m('abc2') + 1.2); m4.flash('b', { row: 1 }, m('abc2') + 1.8);+ m2.flash('c', 'all', m('same'), { color: COL.good }); m4.flash('c', 'all', m('same') + .2, { color: COL.good });+ text(p, 'the brackets moved; the order A, B, C did not', 70, 810, m('same') + 2, { size: 30, weight: 600 });+ }],+['dist', 'Multiplying a sum', (m) => {const p = panel(0);title(p, 'A (B + C) = A B + A C');- const A = [[1, 2], [0, 1]], B = [[1, 0], [2, 1]], C = [[0, 1], [1, 0]], BC = [[1, 1], [3, 1]];- const ad = G(p, { o: 0 }); show(ad, m('add'), .5);- let x = 70;- const BX = [];- [['B + C ='], B, ['+'], C, ['='], BC].forEach((it, k) => {- if (typeof it[0] === 'string') { const w = M(ad, it, { x, y: 272, size: 34, anchor: 'start' }); x += (w._w || 20) + 12; }- else { BX.push(x); const g0 = G(ad, {}); x += mmSmall(g0, it, x, 260, { size: 34 }) + 12; if (k === 5) { put(g0, { o: 0 }); show(g0, m('bc'), .4); } }- });- const L = mmS(p, A, BC, [760, 260], ['A', 'B + C', 'A(B + C)'], { hideC: true, t0: m('lhs') - .3 });- put(L.W, { o: 0 }); put(L.g, { o: 0 }); show(L.g, m('lhs') - .2, .5); L.reveal('all', m('lhs') + 1);- const P1 = mmS(p, A, B, [70, 560], ['A', 'B', 'AB'], { hideC: true, t0: m('ab') - .3 });- const P2 = mmS(p, A, C, [620, 560], ['A', 'C', 'AC'], { hideC: true, t0: m('ac') - .3 });- [P1, P2].forEach(q => put(q.W, { o: 0 }));- put(P1.g, { o: 0 }); show(P1.g, m('ab') - .2, .5); P1.reveal('all', m('ab') + 1);- put(P2.g, { o: 0 }); show(P2.g, m('ac') - .2, .5); P2.reveal('all', m('ac') + 1);- named(p, 'AB + AC', [[7, 3], [3, 1]], 1170, 584, m('sum'), { fill: () => COL.task });- // B + C read entry by entry: the same place lit in all three- [[0, 0], [0, 1], [1, 0], [1, 1]].forEach(([i, j], k) => cellBands(p, [[B, BX[0]], [C, BX[1]], [BC, BX[2]]], i, j, 260, m('bc') + 1.3 + k * 2.1));+ const { L } = sums(p, m, [[1, 2], [0, 1]], [[1, 0], [2, 1]], [[0, 1], [1, 0]], 2.1, 1.3);L.flash('c', 'all', m('sum') + 2.4);text(p, 'column by column: A(b + c) = Ab + Ac', 70, 790, m('why'), { size: 28, fill: COL.dim, weight: 600 });text(p, 'A stays on the left: AB + AC, never BA', 70, 850, m('keep'), { size: 28, weight: 600 });}],+ ['dist2', 'A sum, again', (m) => {+ const p = panel(0);+ title(p, 'A (B + C) = A B + A C, once more');+ const { L, S_ } = sums(p, m, [[2, 1], [0, 1]], [[1, 0], [0, 1]], [[0, 1], [1, 0]], 1.6, 1.3);+ L.flash('a', { row: 0 }, m('lhs') + 2.5); L.flash('a', { row: 1 }, m('lhs') + 4.5);+ L.flash('c', 'all', m('same'), { color: COL.good }); pulse(S_, m('same') + .2);+ text(p, 'B = I, C = the swap', 70, 170, m('add') + 1.5, { size: 24, fill: COL.dim, weight: 600 });+ }],+['q2', 'Quick check', () => {const p = panel(0);title(p, 'Quick check');@@ -309,15 +344,15 @@ const BEATS = [prog(q => g.set(gv(rot(90 * q))), m('t') + .8, 1.6, io);named(p, 'T²', [[-1, 0], [0, -1]], 460, 380, m('t2'));prog(q => g.set(gv(rot(90 + 90 * q))), m('t2') + .3, 1.6, io);- const wn = named(p, 'not', [[0, 1], [1, 0]], 90, 640, m('warn'), { fill: () => COL.bad });+ const wn = named(p, 'not T²', [[0, 1], [1, 0]], 90, 640, m('warn'), { fill: () => COL.bad });prog(q => g.set(gv([[-1 + q, q], [q, -1 + q]])), m('warn') + 3.5, 1.4, io);prog(q => g.set(gv([[-q, 1 - q], [1 - q, -q]])), m('warn') + 6.5, 1.4, io);text(p, 'each number squared: a flip, not a turn', 90, 730, m('warn') + 2, { size: 26, fill: COL.bad, weight: 600 });hide(wn, m('order'), .3);named(p, 'T³', [[0, 1], [-1, 0]], 460, 500, m('t3'));prog(q => g.set(gv(rot(180 + 90 * q))), m('t3') + .3, 1.6, io);- named(p, 'T⁴', [[1, 0], [0, 1]], 760, 260, m('t4'));- text(p, '= I', 760, 340, m('t4') + 1.5, { size: 28, fill: COL.dim, weight: 600 });+ const t4 = named(p, 'T⁴', [[1, 0], [0, 1]], 460, 620, m('t4'));+ text(p, '= I', 700, 632, m('t4') + 1.5, { size: 34, weight: 600 });prog(q => g.set(gv(rot(270 + 90 * q))), m('t4') + .3, 1.6, io);text(p, 'A² A = A A² = A³', 90, 820, m('order'), { size: 34, weight: 600 });prog(q => g.set(gv(rot(180 * q))), m('order') + 1, 1.6, io); prog(q => g.set(gv(rot(180 + 90 * q))), m('order') + 2.9, 1.2, io);@@ -331,7 +366,7 @@ const BEATS = [}, { ask: done => quiz({ x: 460, y: 470, w: 560, cls: 'side' }, [{id: 'c-commute', prompt: ['Change B until AB = BA.'],build: mmTask(S.P, (v, C) => same(C, S.Q.C()), 'AB = BA. For a quarter turn A, B must be [a −b; b a]: a turn with a stretch (I and A itself work too).',- (v, C) => `AB = [${C.flat().map(num).join(' ')}] but BA = [${S.Q.C().flat().map(num).join(' ')}]. Try B with equal diagonal numbers and opposite corners.`,+ (v, C) => `AB = ${rowsStr(C)} but BA = ${rowsStr(S.Q.C())}. Try B with equal diagonal numbers and opposite corners.`,() => S.P.set({ b00: 1, b01: 0, b10: 0, b11: 1 }), { only: ['b00', 'b01', 'b10', 'b11'] }),}], done) }],@@ -382,7 +417,7 @@ const BEATS = [build: (body, api) => {S.P.set({ ...Object.fromEntries(Object.entries(gv(h.A)).map(([kk, v]) => [kk, v])), b00: h.B[0][0], b01: h.B[0][1], b10: h.B[1][0], b11: h.B[1][1] });return mmTask(S.P, (v, C) => same(C, S.Q.C()), h.why,- (v, C) => `AB = [${C.flat().map(num).join(' ')}] but BA = [${S.Q.C().flat().map(num).join(' ')}].`,+ (v, C) => `AB = ${rowsStr(C)} but BA = ${rowsStr(S.Q.C())}. ${h.tip}`,() => S.P.set({ b00: 1, b01: 0, b10: 0, b11: 1 }), { only: ['b00', 'b01', 'b10', 'b11'] })(body, api);},})), done, 'Chapter practice · set 4 of 4') }],diff --git a/site/linear-algebra/index.html b/site/linear-algebra/index.htmlindex ace6d87..7cff5f7 100644--- a/site/linear-algebra/index.html+++ b/site/linear-algebra/index.html@@ -74,6 +74,7 @@ Contents.book({units: [ // [unit title, [[chapter title, minutes], ...]]['The Geometry of Linear Equations', [['One Equation, One Line', 10], ['Two Equations, One Point', 11], ['Crossing, Parallel or the Same Line', 10], ['Vectors: Arrows and Columns of Numbers', 9], ['Adding and Stretching Vectors', 10], ['Linear Combinations', 10], ['The Column Picture', 10], ['Matrices and Ax = b', 10], ['Matrix Times Vector, Two Ways', 10], ['A Matrix Moves the Whole Plane', 10], ['Three Unknowns: A Plane in Space', 12], ['Three Planes, One Point', 14], ['Three Columns in Space', 13], ['Can We Solve for Every b?', 10], ['More Numbers Than Axes', 9]]],['Elimination with Matrices', [['Elimination: Two Equations', 12], ['Pivots and Multipliers', 10], ['Elimination: Three Equations', 11], ['Back Substitution', 11], ['When Elimination Breaks Down', 11], ['Elimination Matrices', 11], ['Row Exchanges as Matrices', 10]]],+ ['Multiplication and Inverse Matrices', [['Matrix Times Matrix', 10], ['Four Ways to Multiply', 10], ['Rules for Matrix Arithmetic', 10]]],],hues: ['#f4a48c', '#86c9e8', '#f3c95c', '#e8a0c8', '#8fd6b0', '#bba8ee', '#f0b45a'], // one colour per unit, cycling});diff --git a/site/linear-algebra/lib/mm.js b/site/linear-algebra/lib/mm.jsindex a1b2442..002fe64 100644--- a/site/linear-algebra/lib/mm.js+++ b/site/linear-algebra/lib/mm.js@@ -11,6 +11,8 @@// P.to({ b01: 3 }, at, dur) // beat clock: numbers (and sizes mA nA nB pB) move, the product follows// P.reveal({ col: 0 }, at) // with hideC: true the product shows ? until revealed ('all', {col}, {row}, {cell: [i, j]})// P.link(g, { col: 0 }) // a grid2 made with x: A and column `col` of B drive it, its drags drive them+// (Ax and the dots follow reveal(): the picture never shows what AB still hides;+// a legend under the plane says which column of B and of AB x and Ax are)// P.live(true, { only: ['b01', 'b11'], sizes: false }) // hands on; mmTask is the question type; playAsk works//// Keys: a<i><j>, b<i><j> (rows and columns from 0), the sizes mA × nA and nB × pB (1 … 3). Loads after engine.js.@@ -46,7 +48,7 @@ function mmEl(rows, { size = 26, fill = () => 'currentColor' } = {}) {}function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null, rh = 60, gap = 44, names = ['A', 'B', 'AB'],- tintA = null, tintB = null, hideC = false, fillC = COL.task, t0 = .1, work: wpos = null, wsize = 30, sizes = true, o = 0, range = 9 } = {}) {+ tintA = null, tintB = null, hideC = false, fillC = COL.task, t0 = .1, work: wpos = null, wsize = 36, sizes = true, o = 0, range = 9 } = {}) {const svg = $('stage'), K3 = [0, 1, 2];const s = { mA: A.length, nA: A[0].length, nB: B.length, pB: B[0].length };K3.forEach(i => K3.forEach(j => { s[`a${i}${j}`] = A[i]?.[j] ?? 0; s[`b${i}${j}`] = B[i]?.[j] ?? 0; }));@@ -121,9 +123,11 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,M(mg, [name], { x: x + W / 2, y: top - 16, size: 28, fill: COL.dim, anchor: 'middle' });return { g: mg, back, x, W, top, bot, cx, ry, c, cs, rows, cols };}- // the size under a matrix: "2 × 3", each number scrubbable when sizes are live+ // the size under a matrix: "2 × 3", each number scrubbable when sizes are live. It lives in its matrix's group, so a+ // matrix hidden on the beat clock hides its size too.function sizeLab(m, kr, kc, rows, cols, yS) {- const mid = m.x + m.W / 2, sg = G(body, {});+ const mid = m.x + m.W / 2, sg = G(m.g, {});+ if (!sizes) put(sg, { o: 0 });const part = (k, v, dx) => {const t = T(sg, String(v), { x: mid + dx, y: yS, size: 28, fill: COL.dim, font: MATH, anchor: 'middle', weight: 600 });t.style.pointerEvents = 'none';@@ -142,15 +146,14 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,const a = mat('a', d.mA, d.nA, x0, cw, tintA, names[0]);const b = mat('b', d.nB, d.pB, a.x + a.W + gap, cw, tintB, names[1]);const eqx = b.x + b.W + 40, cx0 = eqx + 40;- const midY = y0 + (Math.max(d.mA, d.nB) - 1) * rh / 2 + size * .3;- const eq = M(body, ['='], { x: eqx, y: midY, size: size * 1.1, fill: COL.chalk, anchor: 'middle' });+ const midY = y0 + (d.mA - 1) * rh / 2 + size * .3; // level with the middle of A and AB (B may be taller)const ok = d.nA === d.nB;const c = ok ? mat('c', d.mA, d.pB, cx0, cwc, null, names[2]) : null;+ const eq = M(ok ? c.g : body, ['='], { x: eqx, y: midY, size: size * 1.1, fill: COL.chalk, anchor: 'middle' }); // comes with the productconst yS = y0 + (Math.max(d.mA, d.nB) - 1) * rh + size * .35 + 42;const sa = sizeLab(a, 'mA', 'nA', d.mA, d.nA, yS), sb = sizeLab(b, 'nB', 'pB', d.nB, d.pB, yS);const sc = ok ? sizeLab(c, null, null, d.mA, d.pB, yS) : null;- const sz = G(body, {});- [sa, sb, sc].forEach(q => q && sz.append(q.g));+ const sz = G(body, {}); // the "must match" join and the rings (the size labels themselves are in the matrices)if (!sizes) put(sz, { o: 0 });// the inner sizes joined under the matrices: they must matchconst yA = yS + 14, inner = G(sz, { o: innerOn || !ok ? 1 : 0 });@@ -163,12 +166,12 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,let no = null;if (!ok) {no = G(body, {});- const top = y0 - size * .95, hh = Math.max(d.mA, d.nB) * rh + 10;- mk('rect', { x: cx0, y: top, width: 330, height: hh, rx: 14, fill: COL.bad, 'fill-opacity': .1, stroke: COL.bad, 'stroke-width': 3, 'stroke-dasharray': '8 6' }, no);- T(no, 'no product', { x: cx0 + 165, y: top + hh / 2 - 4, size: 34, fill: COL.bad, anchor: 'middle', weight: 700 });- T(no, `a row of ${names[0]} has ${d.nA}, a column of ${names[1]} has ${d.nB}`, { x: cx0 + 165, y: top + hh / 2 + 32, size: 19, fill: COL.bad, anchor: 'middle', weight: 600 });+ const top = y0 - size * .95, hh = Math.max(d.mA, d.nB) * rh + 10, bw = 420;+ mk('rect', { x: cx0, y: top, width: bw, height: hh, rx: 14, fill: COL.bad, 'fill-opacity': .1, stroke: COL.bad, 'stroke-width': 3, 'stroke-dasharray': '8 6' }, no);+ T(no, 'no product', { x: cx0 + bw / 2, y: top + hh / 2 - 4, size: 34, fill: COL.bad, anchor: 'middle', weight: 700 });+ T(no, `a row of ${names[0]} has ${d.nA}, a column of ${names[1]} has ${d.nB}`, { x: cx0 + bw / 2, y: top + hh / 2 + 32, size: 21, fill: COL.bad, anchor: 'middle', weight: 600 });}- L = { a, b, c, eq, ok, sz, inner, outer, no, sa, sb, sc, right: ok ? c.x + c.W : cx0 + 330, bottom: yA + 66 };+ L = { a, b, c, eq, ok, sz, inner, outer, no, sa, sb, sc, right: ok ? c.x + c.W : cx0 + 420, bottom: yA + 66 };rebands();boxesLive();}@@ -199,7 +202,7 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,/* ---------- the working ---------- */const W = G(g, {});let wMode = null, wIdx = null, wN = 99, wKey = '';- const wx = () => wpos ? wpos[0] : x0, wy = () => wpos ? wpos[1] : L.bottom + 84;+ const wx = () => wpos ? wpos[0] : x0, wy = () => wpos ? wpos[1] : L.bottom + 104;function drawWork() {const C = prod();if (wMode === null || !C) { if (wKey) { W.replaceChildren(); wKey = ''; } return; }@@ -210,12 +213,14 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,if (kk === wKey) return;wKey = kk;W.replaceChildren();- const y = wy(), fs = wsize;- let x = wx();+ let y = wy(), x = wx();+ const fs = wsize;const txt = (st, str, fill = COL.chalk) => { if (st > wN) return; const e = M(W, [].concat(str), { x, y: y + fs * .36, size: fs, fill, anchor: 'start' }); x += (e._w || 20) + 10; };const sm = (st, rows, fill) => { if (st > wN) return; x += mmSmall(W, rows, x, y, { size: fs, fill }) + 10; };+ // a second line, under the first, for working too long for one (a row way at full size)+ const nl = st => { if (st > wN) return; y += fs * 1.75; x = wx() + fs * .8; };const tall = Math.max(wMode === 'rows' ? 1 : d.mA, 1);- const cap = str => T(W, str, { x: wx(), y: y - Math.max(48, tall * fs * .55 + 30), size: 24, fill: COL.dim, weight: 600 });+ const cap = str => T(W, str, { x: wx(), y: y - Math.max(48, tall * fs * .55 + 30), size: 26, fill: COL.dim, weight: 600 });const col = v => v.map(q => [q]);const [nA, nB, nC] = names;if (wMode === 'cols') {@@ -235,6 +240,7 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,const i = wIdx, a = Arow(i);cap(`row ${i + 1} of ${nC} = row ${i + 1} of ${nA} times ${nB}: a mix of the rows of ${nB}`);a.forEach((v, k) => { if (k) txt(1, '+'); txt(1, [...mmFac(v), '·']); sm(1, [Brow(k)], () => tint(tintB, k, 0)); });+ if (fs > 30) nl(2);txt(2, '=');a.forEach((v, k) => { if (k) txt(2, '+'); sm(2, [Brow(k).map(b => b * v)], () => tint(tintB, k, 0)); });txt(3, '='); sm(3, [C[i]], () => fillC);@@ -275,14 +281,25 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,pic.g.set(pic.rows ? { a00: s.b00, a01: s.b10, a10: s.b01, a11: s.b11, x0: s[`a${c}0`], x1: s[`a${c}1`] }: { a00: s.a00, a01: s.a01, a10: s.a10, a11: s.a11, x0: s[`b0${c}`], x1: s[`b1${c}`] });quiet = false;+ // The picture never shows a number AB still hides: Ax (the arrow, its steps and its label) and the numbered dots+ // appear when their column (row) of AB is revealed. The dot of the column in the picture is Ax itself.+ const d = D(), n = pic.rows ? d.mA : d.pB;+ const shown = j => pic.rows ? known[j].slice(0, d.pB).every(Boolean) : known.slice(0, d.mA).every(r => r[j]);+ const axOn = shown(c);+ [pic.g.axArrow, pic.g.axDot, pic.g.axLab, ...pic.g.combo].forEach(e => { e.style.visibility = axOn ? '' : 'hidden'; });if (pic.dots) {- const C = prod(), d = D(), n = pic.rows ? d.mA : d.pB;+ const C = prod();pic.dots.forEach((dt, j) => {- const on = j < n;+ const on = j < n && j !== c && shown(j);dt.style.display = on ? '' : 'none';if (on) put(dt, pic.rows ? { x: pic.g.P.PX(C[j][0]), y: pic.g.P.PY(C[j][1]) } : { x: pic.g.P.PX(C[0][j]), y: pic.g.P.PY(C[1][j]) });});}+ // grid2 calls the ring x and the arrow Ax; say which column of B and of AB they are here+ if (pic.say) {+ const [nA, nB, nC] = names, what = pic.rows ? 'row' : 'column', of = pic.rows ? nA : nB;+ pic.say.textContent = `here x is ${what} ${c + 1} of ${of}, and Ax is ${what} ${c + 1} of ${nC}`;+ }}// a number the reader touches brings its column of B (or row of A) into the picturefunction follow(k) { if (pic && (pic.rows ? k[0] === 'a' : k[0] === 'b')) followCol(+(pic.rows ? k[1] : k[2])); }@@ -378,6 +395,10 @@ function mm(p, { A, B, at: [x0, y0] = [70, 300], size = 40, cw = 62, cwC = null,link(gr, { col = 0, dots = false, rows = false } = {}) {picCol = col;pic = { g: gr, dots: null, rows };+ const P2 = gr.P;+ // the legend sits with the ring x, so it is hidden whenever x is+ pic.say = T(gr.parts.x, '', { x: P2.cx, y: P2.PY(P2.y0) + 44, size: 24, fill: COL.dim, weight: 600, anchor: 'middle' });+ pic.say.style.pointerEvents = 'none';if (dots) {pic.dotsG = G(gr.P.g, {});pic.dotsG.style.pointerEvents = 'none'; // never over a handle