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 26-28 reviewed; Unit 3 complete on the contents
yzr9f7db26ff322
diff --git a/site/linear-algebra/ch26/audio/en/fex1.mp3 b/site/linear-algebra/ch26/audio/en/fex1.mp3index 9d33334..fd76384 100644Binary files a/site/linear-algebra/ch26/audio/en/fex1.mp3 and b/site/linear-algebra/ch26/audio/en/fex1.mp3 differdiff --git a/site/linear-algebra/ch26/audio/en/fex1c.mp3 b/site/linear-algebra/ch26/audio/en/fex1c.mp3new file mode 100644index 0000000..8ba0030Binary files /dev/null and b/site/linear-algebra/ch26/audio/en/fex1c.mp3 differdiff --git a/site/linear-algebra/ch26/audio/en/fex2.mp3 b/site/linear-algebra/ch26/audio/en/fex2.mp3index 109a072..202f98c 100644Binary files a/site/linear-algebra/ch26/audio/en/fex2.mp3 and b/site/linear-algebra/ch26/audio/en/fex2.mp3 differdiff --git a/site/linear-algebra/ch26/audio/en/fex2c.mp3 b/site/linear-algebra/ch26/audio/en/fex2c.mp3new file mode 100644index 0000000..85a0978Binary files /dev/null and b/site/linear-algebra/ch26/audio/en/fex2c.mp3 differdiff --git a/site/linear-algebra/ch26/audio/en/live.mp3 b/site/linear-algebra/ch26/audio/en/live.mp3index 0756a7d..94982ff 100644Binary files a/site/linear-algebra/ch26/audio/en/live.mp3 and b/site/linear-algebra/ch26/audio/en/live.mp3 differdiff --git a/site/linear-algebra/ch26/audio/en/timings.js b/site/linear-algebra/ch26/audio/en/timings.jsindex 84897d8..9e8e5f0 100644--- a/site/linear-algebra/ch26/audio/en/timings.js+++ b/site/linear-algebra/ch26/audio/en/timings.js@@ -353,19 +353,14 @@ window.TIMINGS = {]},"fex1": {- "dur": 52.728,+ "dur": 35.208,"marks": {- "A": 1.12,- "det": 6.042,- "sw": 12.109,- "sg": 14.675,- "res": 19.102,- "check": 28.555,- "c2": 35.117,- "c3": 39.336,- "c4": 43.633,- "I": 47.422,- "grid": 48.568+ "A": 1.107,+ "det": 5.911,+ "sw": 11.823,+ "sg": 14.505,+ "res": 18.958,+ "grid": 28.086},"cues": [[@@ -373,23 +368,23 @@ window.TIMINGS = {"Let's use it."],[- 1.12,+ 1.107,"A is two, one in the first row, and one, one in the second."],[- 6.042,+ 5.911,"a d minus b c is two times one, minus one times one: one."],[- 12.109,+ 11.823,"Swap the two and the one on the diagonal."],[- 14.675,+ 14.505,"Put minus signs on the other two: minus one, and minus one."],[- 19.102,+ 18.958,"Divide by one, which changes nothing."],[@@ -397,50 +392,69 @@ window.TIMINGS = {"A inverse is one, minus one in the first row, and minus one, two in the second."],[- 28.555,- "Check: A inverse times A."+ 28.086,+ "Now let A inverse act on the moved plane."],[- 30.794,+ 31.263,+ "Every grid line slides back, and the plane is home."+ ]+ ]+ },+ "fex1c": {+ "dur": 23.112,+ "marks": {+ "c1": 4.388,+ "c2": 8.307,+ "c3": 12.604,+ "c4": 16.979,+ "I": 20.651+ },+ "cues": [+ [+ 0.104,+ "Is it right?"+ ],+ [+ 1.055,+ "Check by multiplying: A inverse times A."+ ],+ [+ 4.388,"One times two, plus minus one times one: one."],[- 35.117,+ 8.307,"One times one, plus minus one times one: zero."],[- 39.336,+ 12.604,"Minus one times two, plus two times one: zero."],[- 43.633,+ 16.979,"Minus one times one, plus two times one: one."],[- 47.422,+ 20.651,"The identity."],[- 48.568,- "And on the plane: A moves it, and A inverse brings it home."+ 21.797,+ "The formula worked."]]},"fex2": {- "dur": 62.28,+ "dur": 34.392,"marks": {- "A": 2.63,- "det": 8.073,- "sw": 16.81,- "sg": 18.893,- "div": 21.406,- "res": 24.115,- "check": 30.039,- "c2": 41.003,- "c3": 48.789,- "c4": 53.62,- "I": 57.982,- "home": 59.401+ "A": 2.721,+ "det": 8.125,+ "sw": 17.135,+ "sg": 19.219,+ "div": 21.797,+ "res": 24.492,+ "home": 30.404},"cues": [[@@ -448,56 +462,72 @@ window.TIMINGS = {"A second example, with a fraction."],[- 2.63,+ 2.721,"A is three, one in the first row, and four, two in the second."],[- 8.073,+ 8.125,"a d minus b c: three times two is six, minus one times four, which is four."],[- 15.039,+ 15.352,"Six minus four is two."],[- 16.81,+ 17.135,"Swap the three and the two."],[- 18.893,+ 19.219,"Minus signs on the one and the four."],[- 21.406,+ 21.797,"Now divide every number by two: one, minus one half in the first row, and minus two, three halves in the second."],[- 30.039,+ 30.404,+ "And on the plane, A inverse takes the moved plane home."+ ]+ ]+ },+ "fex2c": {+ "dur": 31.728,+ "marks": {+ "c1": 4.245,+ "c2": 11.237,+ "c3": 18.867,+ "c4": 23.372,+ "I": 27.565+ },+ "cues": [+ [+ 0.104,"Check, this time in the other order: A times A inverse."],[- 34.154,+ 4.245,"Row three, one, times column one, minus two: three minus two is one."],[- 41.003,+ 11.237,"Three times minus one half, plus one times three halves: minus three halves plus three halves is zero."],[- 48.789,+ 18.867,"Row four, two, times column one: four minus four, zero."],[- 53.62,+ 23.372,"And times column two: minus two plus three, one."],[- 57.982,+ 27.565,"The identity again."],[- 59.401,- "And on the plane, A inverse brings it home."+ 28.997,+ "A inverse undoes A from either side."]]},@@ -568,17 +598,16 @@ window.TIMINGS = {]},"live": {- "dur": 41.472,+ "dur": 55.968,"marks": {- "set": 3.268,- "b": 17.07,- "grow": 20.586,- "s4": 22.917,- "s3": 23.529,- "s2": 24.44,- "s1": 24.688,- "big": 25.443,- "zero": 32.109+ "set": 3.438,+ "b": 17.266,+ "s4": 20.664,+ "s3": 26.172,+ "s2": 30.534,+ "s1": 33.034,+ "big": 40.091,+ "zero": 46.536},"cues": [[@@ -586,35 +615,47 @@ window.TIMINGS = {"Now let's change A, and watch its inverse follow."],[- 3.268,+ 3.438,"Here is A, two, one, one, three, with its inverse beside it, built by the formula."],[- 10.859,+ 10.872,"a d minus b c is six minus one, five, so the inverse has fifths in it."],[- 17.07,+ 17.266,"Now push the top right number up, one step at a time."],[- 20.586,- "a d minus b c shrinks: four, three, two, one."+ 20.664,+ "Two: a d minus b c is four, and the inverse has quarters."+ ],+ [+ 26.172,+ "Three: a d minus b c is three, so thirds."+ ],+ [+ 30.534,+ "Four: it's two, so halves."+ ],+ [+ 33.034,+ "Five: it's one, and the inverse is whole numbers: three, minus five, minus one, two."],[- 25.443,- "And the numbers in the inverse grow."+ 40.091,+ "The numbers in the inverse grow."],[- 27.604,+ 42.044,"The plane is getting thinner, so undoing it takes a bigger stretch."],[- 32.109,+ 46.536,"At six, a d minus b c is zero."],[- 35.964,+ 50.365,"The two columns lie on one line, the plane is flat, and there is no inverse."]]diff --git a/site/linear-algebra/ch26/index.html b/site/linear-algebra/ch26/index.htmlindex 2527c4b..930d24a 100644--- a/site/linear-algebra/ch26/index.html+++ b/site/linear-algebra/ch26/index.html@@ -146,9 +146,13 @@ const BEATS = [g.to({ p00: 2 }, m('a1') + .3, 1.6);lab('(6, 1)', 5.6, 1, m('a1') + 1.9, m('a2') + .2);g.to({ a00: .5 }, m('a2') + .3, 1.6);- lab('(3, 1) again', 3, 1, m('a2') + 1.9);+ const again = T(p, '(3, 1) again', { x: PX(3) + 16, y: PY(1) - 16, size: 24, fill: COL.chalk, font: MATH, anchor: 'start', o: 0 }); show(again, m('a2') + 1.9, .3);+ const how = G(p, {});+ say(how, ['A: (3, 1) → (6, 1)'], 90, 230, m('a1') + .3, { size: 34 });+ say(how, [...INV, ': (6, 1) → (3, 1)'], 90, 300, m('a2') + .3, { size: 34 });+ hide(how, m('mult') - .1, .3);say(p, ['first A, then ', ...INV, ': ', ...INV, 'A'], 90, 210, m('mult') + .2, { size: 34 });- text(p, 'A acts first, so it stands on the right, next to x', 90, 260, m('mult') + 3, { size: 24, fill: COL.dim });+ text(p, 'A acts on x first, so A stands on the right: A⁻¹(A x)', 90, 260, m('mult') + 3, { size: 24, fill: COL.dim });const pr = ivProd(p, [[.5, 0], [0, 1]], [[2, 0], [0, 1]], { at: [90, 380], size: 42, names: [INV, 'A', 'I'], work: [90, 560], o: 0 });show(pr.g, m('mult') + .3, .5);pr.entry(0, 0, m('rc'), m('rc2') - m('rc') - .2); pr.entry(0, 1, m('rc2'), m('rc3') - m('rc2') - .2);@@ -184,7 +188,8 @@ const BEATS = [['shear', 'Undo a shear, undo a flip', (m) => {const p = panel(0);- title(p, 'Undo a shear: slide back');+ const tt = title(p, 'Undo a shear: slide back'); hide(tt, m('flip') - .1, .3);+ text(p, 'Undo a flip: flip again', 60, 110, m('flip') + .2, { size: 40, weight: 600 });const g = S.g = grid2(p, { A: I2, pre: I2, mat: null, shape: true, plane: ZOOM });put(g.parts.cols, { o: 0 });const a = mat(p, [[1, 1], [0, 1]], 90, 260, m('A'));@@ -201,19 +206,19 @@ const BEATS = [[a.g, b.g, t1, r1, r2].forEach(e => hide(e, m('flip') - .1, .4));// reset to home without a jump (pre and A cancel throughout), then the flipg.to({ p01: 0, a01: 0 }, m('flip') - .2, .05);- mat(p, [[-1, 0], [0, 1]], 90, 600, m('flip') + .2);- text(p, 'a flip', 90, 520, m('flip') + .2, { size: 30, weight: 600 });- g.to({ p00: -1 }, m('flip') + .6, 1.8);- mat(p, [[-1, 0], [0, 1]], 420, 600, m('flip2') + .2, { name: INV });- g.to({ a00: -1 }, m('flip2') + .6, 1.8);- say(p, [...INV, ' = A: its own inverse'], 90, 830, m('flip2') + 2.6, { size: 32 });+ mat(p, [[-1, 0], [0, 1]], 90, 260, m('flip') + .2);+ text(p, 'a flip: left and right change places', 90, 480, m('flip') + .6, { size: 28, weight: 600 });+ g.to({ p00: -1 }, m('flip') + .8, .8); // quick: a flip passes through flat only for a blink+ mat(p, [[-1, 0], [0, 1]], 420, 260, m('flip2') + .2, { name: INV });+ g.to({ a00: -1 }, m('flip2') + .8, .8);+ say(p, [...INV, ' = A: its own inverse'], 90, 550, m('flip2') + 2.6, { size: 32 });}],['q1', 'Quick check', () => {const p = panel(0);title(p, 'Quick check');mat(p, [[1, 0], [2, 1]], 90, 250, .3, { size: 44 });- text(p, 'A sheared the plane up', 90, 370, .4, { size: 26, fill: COL.dim });+ text(p, 'A sheared the plane up', 90, 402, .4, { size: 24, fill: COL.dim });const g = S.g = grid2(p, { A: I2, pre: [[1, 0], [2, 1]], mat: [420, 250], size: 44, shape: true, name: 'B' });g.labels(['col 1', 'col 2']);}, { ask: done => quiz(LEFT, [{@@ -229,7 +234,7 @@ const BEATS = [const s = 56, gg = G(p, {});say(gg, ['A ='], 90, 290, m('gen') - .4, { size: s });const br = (x0, y0, w, t0) => { const e = path(gg, `M${x0 + 14} ${y0 - s}H${x0}V${y0 + 80 + s * .45}H${x0 + 14}M${x0 + w - 14} ${y0 - s}H${x0 + w}V${y0 + 80 + s * .45}H${x0 + w - 14}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' }, { o: 0 }); show(e, t0); return e; };- br(200, 260, 230, m('gen') - .4);+ br(218, 260, 212, m('gen') - .4);const L = { a: [260, 260, COLC[0]], b: [370, 260, COLC[1]], c: [260, 340, COLC[0]], d: [370, 340, COLC[1]] };const letter = (k, t0) => { const g = G(gg, { x: L[k][0], y: L[k][1], o: 0 }); M(g, [k], { size: s, fill: L[k][2], anchor: 'middle' }); show(g, t0, .3); return g; };['a', 'b', 'c', 'd'].forEach((k, i) => letter(k, m('gen') + .3 + i * .5));@@ -241,21 +246,22 @@ const BEATS = [fly('d', m('swap') + .3); fly('a', m('swap') + .7);fly('b', m('sign') + .3); fly('c', m('sign') + .6);say(gg, ['−'], 662, 530, m('sign') + 1.6, { size: s, fill: COLC[1] }); say(gg, ['−'], 502, 610, m('sign') + 1.9, { size: s, fill: COLC[0] });- const fr = say(gg, [F('1', 'ad − bc')], 330, 590, m('div') + .4, { size: s * .8 });+ const fr = say(gg, [F('1', 'ad − bc')], 290, 590, m('div') + .4, { size: s * .95 });// the recipe on the right, one step at a timeconst step = (n, words, t0) => { const g = G(p, { o: 0, x: 20 }); mk('circle', { cx: 900, cy: -12, r: 24, fill: COL.chalk }, g); T(g, String(n), { x: 900, y: -2, size: 28, fill: COL.board, weight: 700, anchor: 'middle' }); M(g, words, { x: 945, size: 34, anchor: 'start' }); tw(g, { o: 1, x: 0 }, t0, .5); put(g, { y: 280 + n * 100 }); return g; };const s1 = step(1, ['swap a and d'], m('swap') + .2), s2 = step(2, ['minus signs on b and c'], m('sign') + .2), s3 = step(3, ['divide by ad − bc'], m('div') + .2);const hl = mk('rect', { x: 860, y: 340, width: 600, height: 64, rx: 14, fill: COL.chalk }, p); put(hl, { o: 0 }); // the recipe read once more, step by steptw(hl, { o: .12 }, m('all'), .3); [1, 2].forEach(k => tw(hl, { a_y: 340 + k * 100 }, m('all') + k * 1.1, .4)); tw(hl, { o: 0 }, m('all') + 3.6, .4);[s1, s2, s3].forEach((e, i) => pulse(e, m('all') + .2 + i * 1, 1));- pulse(fr, m('all') + 2.2, 1);+ pulse(g2mid(fr), m('all') + 2.2, 1.15);}],['fex1', 'Example: the formula', (m) => {const p = panel(0);title(p, 'Use it: A = [2 1; 1 1]');text(p, 'swap a and d · minus signs on b and c · divide by ad − bc', 60, 165, .3, { size: 24, fill: COL.dim });- const g = S.g = grid2(p, { A: [[2, 1], [1, 1]], mat: [90, 290], size: 50, shape: true, t0: m('A') - .5 });+ const A0 = [[2, 1], [1, 1]];+ const g = S.g = grid2(p, { A: A0, mat: [90, 290], size: 50, shape: true, t0: m('A') - .5 });g.labels(['col 1', 'col 2']);const iv = g.inverse({ at: [90, 475], size: 40 });['det', 'lhs', 'scale', 'adj', 'eq', 'res'].forEach(k => put(iv[k], { o: 0 }));@@ -264,22 +270,29 @@ const BEATS = [[1, 2].forEach(k => { put(iv.adjCells[k].g, { o: 0 }); show(iv.adjCells[k].g, m('sg') + .3 + (k - 1) * .5, .3); });[0, 3].forEach(k => pulse(iv.adjCells[k].g, m('sw') + .5, 1.2));show(iv.scale, m('res'), .3);- [0, 1, 2, 3].forEach(k => pulse(iv.resCells[k].g, m('res') + 3.6 + k * 1.1, 1)); show(iv.eq, m('res') + 1, .3); show(iv.res, m('res') + 1.4, .4);- hide(iv.root, m('check') - .2, .4);- const pr = ivProd(p, [[1, -1], [-1, 2]], [[2, 1], [1, 1]], { at: [90, 490], size: 40, names: [INV, 'A', 'I'], work: [90, 660], o: 0 });- show(pr.g, m('check'), .5);- pr.entry(0, 0, m('check') + 1.2, m('c2') - m('check') - 1.4); pr.entry(0, 1, m('c2'), m('c3') - m('c2') - .2);- pr.entry(1, 0, m('c3'), m('c4') - m('c3') - .2); pr.entry(1, 1, m('c4'), 2);- hide(g.M, m('grid') + .1, .3);- g.to(keysOf(I2), m('grid') + 2.2, 2.4);- text(p, 'A⁻¹ brings the plane home', 90, 770, m('grid') + 2.2, { size: 30, weight: 600 });+ [0, 1, 2, 3].forEach(k => pulse(iv.resCells[k].g, m('res') + 3.6 + k * 1.1, 1.2)); show(iv.eq, m('res') + 1, .3); show(iv.res, m('res') + 1.4, .4);+ // A⁻¹ acts on the moved plane (the plane is A, then A⁻¹: arrows put away, A and its panel stay as they are)+ hide(g.parts.cols, m('grid') + .2, .4);+ g.to(keysOf(inv2(A0), 'p'), m('grid') + .9, 2.6);+ text(p, 'A⁻¹ brings the plane home', 90, 820, m('grid') + .9, { size: 30, weight: 600 });+ }],++ ['fex1c', 'Check by multiplying', (m) => {+ const p = panel(0);+ title(p, 'Check: A⁻¹ times A');+ const pr = ivProd(p, [[1, -1], [-1, 2]], [[2, 1], [1, 1]], { at: [150, 330], size: 52, names: [INV, 'A', 'I'], work: [150, 560], workSize: 40, o: 0 });+ show(pr.g, .3, .5);+ pr.entry(0, 0, m('c1'), m('c2') - m('c1') - .2); pr.entry(0, 1, m('c2'), m('c3') - m('c2') - .2);+ pr.entry(1, 0, m('c3'), m('c4') - m('c3') - .2); pr.entry(1, 1, m('c4'), m('I') - m('c4'));+ text(p, 'A⁻¹A = I: the formula worked', 150, 680, m('I') + .3, { size: 32, weight: 600, fill: COL.good });}],['fex2', 'Example with fractions', (m) => {const p = panel(0);title(p, 'A second one: A = [3 1; 4 2]');text(p, 'swap a and d · minus signs on b and c · divide by ad − bc', 60, 165, .3, { size: 24, fill: COL.dim });- const g = S.g = grid2(p, { A: [[3, 1], [4, 2]], mat: [90, 290], size: 50, shape: true, t0: m('A') - .5 });+ const A0 = [[3, 1], [4, 2]];+ const g = S.g = grid2(p, { A: A0, mat: [90, 290], size: 50, shape: true, t0: m('A') - .5 });g.labels(['col 1', 'col 2']);const iv = g.inverse({ at: [90, 475], size: 40 });['det', 'lhs', 'scale', 'adj', 'eq', 'res'].forEach(k => put(iv[k], { o: 0 }));@@ -287,15 +300,21 @@ const BEATS = [show(iv.lhs, m('sw'), .3); show(iv.adj, m('sw'), .3);[1, 2].forEach(k => { put(iv.adjCells[k].g, { o: 0 }); show(iv.adjCells[k].g, m('sg') + .3 + (k - 1) * .5, .3); });[0, 3].forEach(k => pulse(iv.adjCells[k].g, m('sw') + .5, 1.2));- show(iv.scale, m('div') + .3, .3); show(iv.eq, m('res'), .3); show(iv.res, m('res') + .3, .4);- hide(iv.root, m('check') - .2, .4);- const pr = ivProd(p, [[3, 1], [4, 2]], [[1, -.5], [-2, 1.5]], { at: [90, 490], size: 40, names: ['A', INV, 'I'], work: [90, 680], o: 0 });- show(pr.g, m('check'), .5);- pr.entry(0, 0, m('check') + 2.4, m('c2') - m('check') - 2.6); pr.entry(0, 1, m('c2'), m('c3') - m('c2') - .2);- pr.entry(1, 0, m('c3'), m('c4') - m('c3') - .2); pr.entry(1, 1, m('c4'), m('I') - m('c4') + 1);- hide(g.M, m('home') - .1, .3);- g.to(keysOf(I2), m('home') + .3, 2.4);- text(p, 'A⁻¹ brings the plane home', 90, 800, m('home') + .3, { size: 30, weight: 600 });+ show(iv.scale, m('div') + .3, .3); pulse(g2mid(iv.scale), m('div') + .8, 1.25); show(iv.eq, m('res'), .3); show(iv.res, m('res') + .3, .4);+ [0, 1, 2, 3].forEach(k => pulse(iv.resCells[k].g, m('res') + .9 + k * 1.3, 1.2));+ hide(g.parts.cols, m('home') + .1, .4);+ g.to(keysOf(inv2(A0), 'p'), m('home') + .7, 2.6);+ text(p, 'A⁻¹ brings the plane home', 90, 820, m('home') + .7, { size: 30, weight: 600 });+ }],++ ['fex2c', 'Check in the other order', (m) => {+ const p = panel(0);+ title(p, 'Check, the other order: A times A⁻¹');+ const pr = ivProd(p, [[3, 1], [4, 2]], [[1, -.5], [-2, 1.5]], { at: [150, 330], size: 52, names: ['A', INV, 'I'], work: [150, 580], workSize: 40, o: 0 });+ show(pr.g, .3, .5);+ pr.entry(0, 0, m('c1'), m('c2') - m('c1') - .2); pr.entry(0, 1, m('c2'), m('c3') - m('c2') - .2);+ pr.entry(1, 0, m('c3'), m('c4') - m('c3') - .2); pr.entry(1, 1, m('c4'), m('I') - m('c4'));+ text(p, 'A A⁻¹ = I as well: A⁻¹ works on either side', 150, 700, m('I') + .3, { size: 32, weight: 600, fill: COL.good });}],['why', 'Why the formula works', (m) => {diff --git a/site/linear-algebra/ch27/audio/en/divp.mp3 b/site/linear-algebra/ch27/audio/en/divp.mp3new file mode 100644index 0000000..0908188Binary files /dev/null and b/site/linear-algebra/ch27/audio/en/divp.mp3 differdiff --git a/site/linear-algebra/ch27/audio/en/ex2.mp3 b/site/linear-algebra/ch27/audio/en/ex2.mp3index 27150f9..d5d9d87 100644Binary files a/site/linear-algebra/ch27/audio/en/ex2.mp3 and b/site/linear-algebra/ch27/audio/en/ex2.mp3 differdiff --git a/site/linear-algebra/ch27/audio/en/timings.js b/site/linear-algebra/ch27/audio/en/timings.jsindex afb8df0..6967867 100644--- a/site/linear-algebra/ch27/audio/en/timings.js+++ b/site/linear-algebra/ch27/audio/en/timings.js@@ -352,18 +352,14 @@ window.TIMINGS = {]},"ex2": {- "dur": 67.2,+ "dur": 37.704,"marks": {- "A": 3.164,- "down": 7.721,- "d2": 14.427,- "up": 19.414,- "u2": 24.622,- "div": 29.349,- "d3": 34.284,- "read": 42.331,- "check": 49.284,- "plane": 61.797+ "A": 3.333,+ "down": 7.852,+ "d2": 14.323,+ "up": 19.323,+ "u2": 24.779,+ "left": 29.388},"cues": [[@@ -371,64 +367,84 @@ window.TIMINGS = {"A second example, where the pivots are not one."],[- 3.164,+ 3.333,"A is two, one in the first row, and six, four in the second."],[- 7.721,+ 7.852,"Down: the multiplier is six over two, three."],[- 11.602,+ 11.758,"Row two minus three times row one."],[- 14.427,+ 14.323,"Row two becomes zero, one, and on the right, minus three, one."],[- 19.414,+ 19.323,"Up: above the second pivot there's a one."],[- 22.266,+ 22.161,"Row one minus one times row two."],[- 24.622,+ 24.779,"Row one becomes two, zero, and on the right, four, minus one."],[- 29.349,- "The left half isn't I yet: the first pivot is two."+ 29.388,+ "Now the left half is two, zero, zero, one."+ ],+ [+ 32.982,+ "That's not I yet: on the plane, everything is still twice as wide."+ ]+ ]+ },+ "divp": {+ "dur": 42.288,+ "marks": {+ "piv": 1.224,+ "d3": 5.052,+ "nums": 11.029,+ "read": 22.591,+ "check": 29.974+ },+ "cues": [+ [+ 0.104,+ "One more step."+ ],+ [+ 1.224,+ "The first pivot is two, so divide row one by two."],[- 32.552,- "Divide row one by two."+ 5.052,+ "Watch the plane: dividing by two squeezes it to half the width, and now it's home."],[- 34.284,- "Two over two is one."+ 11.029,+ "In the table: two over two is one, and zero over two is zero."],[- 36.276,+ 16.641,"On the right: four over two is two, and minus one over two is minus one half."],[- 42.331,+ 22.591,"So A inverse is two, minus one half in the first row, and minus three, one in the second."],[- 49.284,+ 29.974,"Check with the formula from chapter twenty-six: a d minus b c is eight minus six, two."],[- 56.302,+ 36.81,"One half of four, minus one, minus six, two gives the same matrix."- ],- [- 61.797,- "On the plane, that last step was a squeeze to half the width, and it brought the plane home."]]},diff --git a/site/linear-algebra/ch27/index.html b/site/linear-algebra/ch27/index.htmlindex b600d5f..cf671b6 100644--- a/site/linear-algebra/ch27/index.html+++ b/site/linear-algebra/ch27/index.html@@ -161,7 +161,7 @@ const BEATS = [title(p, 'Step 2: eliminate up');const { g, t } = table2(p, LEC, { rows: [[1, 3, 1, 0], [0, 1, -2, 1]] });text(p, 'back substitution would stop here; Gauss–Jordan goes on', 90, 470, 1, { size: 24, fill: COL.dim });- const upA = G(p, {}); draw(path(upA, `M${t.cx(3) + 70} ${t.ry(1) - 10}V${t.ry(0) - 30}M${t.cx(3) + 58} ${t.ry(0) - 16}L${t.cx(3) + 70} ${t.ry(0) - 32}L${t.cx(3) + 82} ${t.ry(0) - 16}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' }, { d: 0 }), 3, 1.2); hide(upA, m('op') - .3, .3);+ const upA = G(p, {}); draw(path(upA, `M${t.cx(3) + 100} ${t.ry(1) - 10}V${t.ry(0) - 30}M${t.cx(3) + 88} ${t.ry(0) - 16}L${t.cx(3) + 100} ${t.ry(0) - 32}L${t.cx(3) + 112} ${t.ry(0) - 16}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' }, { d: 0 }), 3, 1.2); hide(upA, m('op') - .3, .3);t.ring(1, 1, m('above') - .3, m('op'));t.ring(0, 1, m('above') + .4, m('op'), { dash: true });t.sub(0, 1, 3, m('go') + .2, 2.6, { lead: m('go') + .2 - m('op') });@@ -206,7 +206,7 @@ const BEATS = [const t = gj(sm, LEC, { at: [900, 300], size: 36 });put(t.g, { o: 1 });show(sm, m('E') + .5, .4);- t.sub(1, 0, 2, m('E') + 2, 1.2, { lead: .6 }); t.sub(0, 1, 3, m('E') + 4.5, 1.2, { lead: .6 }); t.done(m('all'));+ t.sub(1, 0, 2, m('E') + 2, 1.2, { lead: .6 }); t.sub(0, 1, 3, m('E') + 4.5, 1.2, { lead: .6 }); t.done(m('all')); t.names(['I', INV], m('left') + .4);t.block(1, m('right') + .5, m('rec') + 3); t.block(0, m('left') + 1, m('right'));}],@@ -230,16 +230,26 @@ const BEATS = [t.ring(1, 1, m('up') + .3, m('up') + 3);t.sub(0, 1, 1, m('u2') - .4, 2, { lead: m('u2') - .4 - (m('up') + 3) });say(p, ['ℓ = 1 ÷ 1 = 1'], 90, 530, m('up') + 1, { size: 30 });- t.ring(0, 0, m('div') + .4, m('div') + 3.5, { color: COL.bad });- t.div(0, 2, m('d3') - .3, 1.8, { lead: m('d3') - .3 - (m('div') + 3.2) });- say(p, ['pivot 2: divide row 1 by 2'], 90, 590, m('div') + 3.2, { size: 30 });+ t.done(m('left'));+ t.block(0, m('left') + .2, m('left') + 4);+ text(p, 'left half [2 0; 0 1]: not I yet, the plane is twice as wide', 90, 610, m('left') + .4, { size: 28, weight: 600 });+ }],++ ['divp', 'Divide by the pivots', (m) => {+ const p = panel(0);+ title(p, 'Step 3: divide by the pivots');+ const { g, t } = table2(p, EX2, { rows: [[2, 0, 4, -1], [0, 1, -3, 1]] });+ t.ring(0, 0, m('piv') + .2, m('d3'));+ t.div(0, 2, m('d3') + .4, 2.6, { lead: m('d3') + .4 - m('piv') - 1.6 });+ say(p, ['pivot 2: divide row 1 by 2'], 90, 470, m('piv') + 1.6, { size: 30 });+ text(p, '÷ 2 squeezes the plane to half the width: home', 90, 540, m('d3') + 1.2, { size: 28, weight: 600 });+ say(p, ['2 ÷ 2 = 1, 0 ÷ 2 = 0'], 90, 610, m('nums') + .6, { size: 28 });+ say(p, ['4 ÷ 2 = 2, −1 ÷ 2 = −', F(1, 2)], 90, 665, m('nums') + 3.2, { size: 28, fill: COL.task });t.names(['I', INV], m('read')); t.done(m('read'));- say(p, ['4 ÷ 2 = 2, −1 ÷ 2 = −', F(1, 2)], 90, 650, m('d3') + 2.6, { size: 28, fill: COL.task });[0, 1].forEach(i => rowBand(p, t, i, m('read') + .8 + i * 2.6, m('read') + 3.2 + i * 2.6));- const ck = say(p, ['check: ad − bc = 8 − 6 = 2,'], 90, 720, m('check') + .5, { size: 28 });- const ck2 = say(p, [F(1, 2), '·[4 −1; −6 2]'], 90 + ck._w + 14, 720, m('check') + 5.2, { size: 28 });- say(p, ['= [2 −', F(1, 2), '; −3 1]'], 90 + ck._w + ck2._w + 26, 720, m('check') + 9, { size: 28 });- text(p, 'the last step, ÷ 2, squeezed the plane home', 90, 790, m('plane') + .3, { size: 28, weight: 600 });+ const ck = say(p, ['check: ad − bc = 8 − 6 = 2,'], 90, 750, m('check') + .5, { size: 28 });+ const ck2 = say(p, [F(1, 2), '·[4 −1; −6 2]'], 90 + ck._w + 14, 750, m('check') + 5.2, { size: 28 });+ say(p, ['= [2 −', F(1, 2), '; −3 1]'], 90 + ck._w + ck2._w + 26, 750, m('check') + 9, { size: 28 });}],['q2', 'Quick check', () => {@@ -270,7 +280,8 @@ const BEATS = [t.sub(1, 0, 2, m('c1') + 2.2, 1.4, { lead: 1.2 });t.sub(2, 0, 1, m('c1b') + 1.3, 1.4, { lead: 1 });t.sub(2, 1, 1, m('c2') + 1.6, 1.4, { lead: 1.2 });- const tri = path(p, `M${t.cx(0) - 40} ${t.ry(0) - 44}L${t.cx(2) + 40} ${t.ry(0) - 44}L${t.cx(2) + 40} ${t.ry(2) + 20}Z`, { fill: COL.chalk, 'fill-opacity': .1, stroke: COL.chalk, 'stroke-width': 2 }, { o: 0 });+ const L_ = j => t.cx(j) - 44, R_ = j => t.cx(j) + 44, T_ = i => t.ry(i) - 48, B_ = i => t.ry(i) + 20;+ const tri = path(p, `M${L_(0)} ${T_(0)}H${R_(2)}V${B_(2)}H${L_(2)}V${B_(1)}H${L_(1)}V${B_(0)}H${L_(0)}Z`, { fill: COL.chalk, 'fill-opacity': .1, stroke: COL.chalk, 'stroke-width': 2 }, { o: 0 });show(tri, m('tri') + .3, .5); hide(tri, m('up'), .4);text(p, 'down: zeros below the pivots ✓', 160, 560, m('tri') + 1, { size: 28, weight: 600 });t.sub(1, 2, 1, m('up') + 1.8, 1.2, { lead: .9 });diff --git a/site/linear-algebra/ch28/audio/en/find.mp3 b/site/linear-algebra/ch28/audio/en/find.mp3index 0d0e231..5ce6ba8 100644Binary files a/site/linear-algebra/ch28/audio/en/find.mp3 and b/site/linear-algebra/ch28/audio/en/find.mp3 differdiff --git a/site/linear-algebra/ch28/audio/en/timings.js b/site/linear-algebra/ch28/audio/en/timings.jsindex 3addad6..ff64f8c 100644--- a/site/linear-algebra/ch28/audio/en/timings.js+++ b/site/linear-algebra/ch28/audio/en/timings.js@@ -262,16 +262,16 @@ window.TIMINGS = {]},"find": {- "dur": 55.032,+ "dur": 55.296,"marks": {- "look": 1.745,- "mix": 11.211,- "x": 15.781,- "chk": 18.685,- "ex2": 26.979,- "x2": 37.344,- "chk2": 43.216,- "any": 50.052+ "look": 1.81,+ "mix": 10.885,+ "x": 15.508,+ "chk": 18.529,+ "ex2": 27.148,+ "x2": 37.448,+ "chk2": 43.477,+ "any": 50.078},"cues": [[@@ -279,51 +279,51 @@ window.TIMINGS = {"How do you find such an x?"],[- 1.745,+ 1.81,"Compare the columns."],[- 3.216,+ 3.281,"In A equals two, four in the first row, and one, two in the second, column two is two times column one."],[- 11.211,+ 10.885,"So two of column one, minus one of column two, is zero."],[- 15.781,+ 15.508,"That's x equals two, minus one."],[- 18.685,+ 18.529,"Check by rows: two times two, minus four, is zero."],[- 23.32,+ 23.398,"And one times two, minus two, is zero."],[- 26.979,+ 27.148,"Another one: three, minus six in the first row, and one, minus two in the second."],[- 33.724,+ 33.893,"Column two is minus two times column one."],[- 37.344,- "So x is minus two, minus one."+ 37.448,+ "So two of column one, plus one of column two, is zero."],[- 40.143,- "Or, turning both signs around, two, one."+ 41.55,+ "That's x equals two, one."],[- 43.216,+ 43.477,"Check: three times two, minus six, is zero, and two minus two is zero."],[- 50.052,+ 50.078,"And any multiple of x works too: the whole line through it is lost."]]diff --git a/site/linear-algebra/ch28/index.html b/site/linear-algebra/ch28/index.htmlindex 4293ee8..84e038a 100644--- a/site/linear-algebra/ch28/index.html+++ b/site/linear-algebra/ch28/index.html@@ -41,7 +41,7 @@ const dotAt = (P2, [x, y], into, t0, { r = 9, color = COL.chalk, label = null, dshow(d, t0, .3); return d;};// a dot that starts at p and slides to where A sends it-const land = (P2, A, p, into, t0, t1, opts = {}) => { const d = dotAt(P2, p, into, t0, opts); const [X, Y] = ivMul(A, [[p[0]], [p[1]]]).map(r => r[0]); tw(d, { x: P2.PX(X), y: P2.PY(Y) }, t1, 1.4); if (opts.label) hide(d.lastChild, t1 + 1.8, .3); return d; }; // its label goes once it has landed+const land = (P2, A, p, into, t0, t1, opts = {}) => { const d = dotAt(P2, p, into, t0, opts); const [X, Y] = ivMul(A, [[p[0]], [p[1]]]).map(r => r[0]); tw(d, { x: P2.PX(X), y: P2.PY(Y) }, t1, 1.4); if (opts.label) hide(d.lastChild, t1 - .1, .3); return d; }; // its label (x's name) goes as it leaves for Axconst ringAt = (P2, [x, y], color, into, t0, label, { dx = 20, dy = -18, anchor = 'start' } = {}) => {const g = G(into, { x: P2.PX(x), y: P2.PY(y), o: 0 });mk('circle', { r: 17, fill: 'none', stroke: color, 'stroke-width': 3, 'stroke-dasharray': '5 5' }, g);@@ -170,7 +170,7 @@ const BEATS = [['many', 'Many points, one landing spot', (m) => {const p = panel(0);title(p, 'A folds whole lines onto points');- const g = S.g = grid2(p, { A: A2, mat: null, shape: false, lost: true });+ const g = S.g = grid2(p, { A: A2, mat: null, shape: false, units: false, lost: true });g.labels(['col 1', 'col 2']);mat(p, A2, 90, 250, .3);const { PX, PY } = g.P;@@ -178,7 +178,7 @@ const BEATS = [draw(ln, m('slide'), 1.2);const pts = [[1, 0], [2, 1], [3, 2]];const ds = pts.map((q, k) => dotAt(g.P, q, p, k ? m('slide') + 1 + k * 1.2 : m('pt') + .3, { label: `(${q.map(num).join(', ')})`, dx: 12, dy: -14 }));- ringAt(g.P, [2, -1], COL.chalk, p, m('pt') + 1.6, '(2, −1)', { dx: 14, dy: 30 });+ ringAt(g.P, [2, -1], COL.chalk, p, m('pt') + 1.6, '(2, −1)', { dx: -22, dy: 36, anchor: 'end' });say(p, ['A·(1, 0) = (2, −1)'], 90, 450, m('pt') + 1.6, { size: 30 });say(p, ['A·(2, 1) = (4 − 2, −2 + 1) = (2, −1)'], 90, 510, m('same') + .3, { size: 30 });ds.forEach((d, k) => { hide(d.lastChild, m('same') + 1.3, .2); tw(d, { x: PX(2), y: PY(-1) }, m('same') + 1.5 + k * .4, 1.4); });@@ -214,19 +214,23 @@ const BEATS = [const F1 = [[2, 4], [1, 2]], F2 = [[3, -6], [1, -2]];const m1 = mat(p, F1, 90, 250, m('look') + .3);g.to(keysOf(F1), m('look') + .8, 2);- say(p, ['column 2 = 2 × column 1'], 90, 440, m('look') + 3, { size: 30 });- say(p, ['2·(2, 1) − 1·(4, 2) = (0, 0)'], 90, 500, m('mix') + .3, { size: 30 });- land(g.P, F1, [2, -1], p, m('x') + .2, m('chk') + .4, { label: 'x = (2, −1)', dx: 14, dy: 28 });- say(p, ['rows: 2·2 − 4 = 0, 1·2 − 2 = 0'], 90, 560, m('chk') + .6, { size: 28, fill: COL.good });- hide(m1.g, m('ex2') - .2, .3);+ // example 1, then example 2 in the same places (the first clears away)+ const e1 = G(p, {});+ say(e1, ['column 2 = 2 × column 1'], 90, 440, m('look') + 3, { size: 30 });+ say(e1, ['2·(2, 1) − 1·(4, 2) = (0, 0)'], 90, 500, m('mix') + .3, { size: 30 });+ say(e1, ['x = (2, −1)'], 90, 560, m('x') + .3, { size: 30 });+ land(g.P, F1, [2, -1], e1, m('x') + .2, m('chk') + .4, { label: 'x = (2, −1)', dx: 14, dy: 28 });+ say(e1, ['rows: 2·2 − 4 = 0, 1·2 − 2 = 0'], 90, 620, m('chk') + .6, { size: 28, fill: COL.good });+ hide(m1.g, m('ex2') - .2, .3); hide(e1, m('ex2') - .2, .3);mat(p, F2, 90, 250, m('ex2') + .2);g.to(keysOf(F2), m('ex2') + .8, 2);- say(p, ['column 2 = −2 × column 1'], 90, 640, m('ex2') + 4, { size: 30 });- say(p, ['x = (−2, −1) or (2, 1)'], 90, 700, m('x2') + .4, { size: 30 });- land(g.P, F2, [2, 1], p, m('x2') + 3.4, m('chk2') + .3, { label: '(2, 1)', dx: 14, dy: -14 });- say(p, ['rows: 3·2 − 6 = 0, 2 − 2 = 0'], 90, 760, m('chk2') + .5, { size: 28, fill: COL.good });+ say(p, ['column 2 = −2 × column 1'], 90, 440, m('ex2') + 4, { size: 30 });+ say(p, ['2·(3, 1) + 1·(−6, −2) = (0, 0)'], 90, 500, m('x2') + .3, { size: 30 });+ say(p, ['x = (2, 1)'], 90, 560, m('x2') + 4, { size: 30 });+ land(g.P, F2, [2, 1], p, m('x2') + 4, m('chk2') + .3, { label: 'x = (2, 1)', dx: 14, dy: -14 });+ say(p, ['rows: 3·2 − 6 = 0, 2 − 2 = 0'], 90, 620, m('chk2') + .5, { size: 28, fill: COL.good });show(g.parts.lost, m('any') + .3, .5);- text(p, 'any multiple: the whole red line is lost', 90, 830, m('any') + .8, { size: 28, fill: COL.bad, weight: 600 });+ text(p, 'any multiple: the whole red line is lost', 90, 700, m('any') + .8, { size: 28, fill: COL.bad, weight: 600 });}],['q1', 'Quick check', () => {@@ -265,7 +269,7 @@ const BEATS = [t.block(0, m('stuck') + 1, m('three'), COL.bad);say(p, ['1. ad − bc = 6 − 6 = 0'], 90, 600, m('three') + 1.5, { size: 30 });say(p, ['2. A·(3, −1) = (0, 0)'], 90, 655, m('t2') + .2, { size: 30 });- say(p, ['3. a zero row'], 90, 710, m('t3') + .2, { size: 30 });+ say(p, ['3. elimination: zero row'], 90, 710, m('t3') + .2, { size: 30 });}],['three', 'Three by three', (m) => {@@ -387,10 +391,10 @@ const BEATS = [k.turn(90, 0, m('w4') + 3, 1); k.to({ p01: 0 }, m('w4') + 4.2, 1);}],- ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{- id: 'p-which', prompt: ['Which matrices have an inverse? Use any test.'],- build: grid(WHICHQ.map(q => ({ parts: [matEl(q.A)], ans: q.ans, why: q.why })), YESNO, { multi: false, text: true }),- }], done, 'Chapter practice · set 1 of 4') }],+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [0, 1].map(k => ({ // two cards of three: six matrices do not fit one+ id: k ? 'p-which2' : 'p-which', prompt: ['Which matrices have an inverse? Use any test.'],+ build: grid(WHICHQ.slice(3 * k, 3 * k + 3).map(q => ({ parts: [matEl(q.A)], ans: q.ans, why: q.why })), YESNO, { multi: false, text: true }),+ })), done, 'Chapter practice · set 1 of 4') }],['final2', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, LOSTQ.map((q, k) => ({id: `p-lost${k + 1}`, prompt: ['Find an ', $m('x ≠ 0'), ' with ', $m('A x = 0'), ' for ', $m('A'), ' = ', matEl(q.A), '. (Any multiple is fine.)'],build: blanks([{diff --git a/site/linear-algebra/index.html b/site/linear-algebra/index.htmlindex 7cff5f7..8da57a7 100644--- a/site/linear-algebra/index.html+++ b/site/linear-algebra/index.html@@ -74,7 +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]]],+ ['Multiplication and Inverse Matrices', [['Matrix Times Matrix', 10], ['Four Ways to Multiply', 10], ['Rules for Matrix Arithmetic', 10], ['The Inverse: Undoing a Matrix', 12], ['Finding the Inverse: Gauss–Jordan', 11], ['Matrices with No Inverse', 11]]],],hues: ['#f4a48c', '#86c9e8', '#f3c95c', '#e8a0c8', '#8fd6b0', '#bba8ee', '#f0b45a'], // one colour per unit, cycling});diff --git a/site/linear-algebra/lib/grid2.js b/site/linear-algebra/lib/grid2.jsindex 095b195..016aa58 100644--- a/site/linear-algebra/lib/grid2.js+++ b/site/linear-algebra/lib/grid2.js@@ -20,7 +20,16 @@// each number's column colour, so the swap of a and d and the sign change of b and c are visible.// g.det(), g.inverseOf() (null when ad − bc = 0), g.total() (the plane's matrix A·pre), g.turn(d0, d1, at, dur, ease, 'p')// turns pre instead of A.+// Labels on the plane (chapters 23–25 asked for these; all optional):+// names: { x: 'column 2 of B', ax: 'column 2 of AB' }, or a function of the state v returning that object: what the+// x and Ax labels call their points ("x = (…)", "Ax = (…)" by default). g.names(n) changes it later.+// avoid: [[x, y], …] in plane units, or a function of v returning them: extra dots the chapter draws (mm's numbered+// dots) that the labels keep clear of, like the tips. g.avoid(a) changes it later.+// Labels never pile up at one spot: a column label hides while its tip is at the origin, the x label hides while x is+// at the origin or on Ax while Ax's label shows (it names the spot), and the Ax label hides while both are at the origin. Hiding uses+// the display attribute, so a chapter's own opacity or visibility on these labels is untouched.// Exact fractions: g2frac(v) → [n, d] or null; g2parts(v) → math parts (whole, F(n, d), or one decimal while moving).+// g2mid(e): e scales and turns about its own middle (pulse it without it sliding); numbers (g2val, the scrubbable ones) have it.const G2_COLS = [COL.irr, COL.real], G2_AX = COL.task;// A small flag: a pole and a pennant pointing right, so a flip or a turn shows at once.// It stands beside the unit square (x 1.4 … 2.3), not on it, so the square and the flag never hide each other.@@ -36,14 +45,17 @@ const g2parts = v => {};const g2key = ps => ps.map(q => typeof q === 'string' ? q : q.f.join('/')).join('');// A number drawn as math parts, rebuilt only when what it shows changes.+// Scale and turn an element about the middle of its own box (pulse, flash), not about the stage's corner.+const g2mid = e => { e.style.transformBox = 'fill-box'; e.style.transformOrigin = 'center'; return e; };function g2val(parent, { x = 0, y = 0, size = 40, fill = COL.chalk, anchor = 'middle' } = {}) {- const g = G(parent, {});+ const g = g2mid(G(parent, {}));let key = null;return { g, set(v, color = fill, parts = g2parts(v)) { const k = g2key(parts) + color; if (k === key) return; key = k; g.replaceChildren(); M(g, parts, { x, y, size, fill: color, anchor }); } };}function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54, plane: po = {}, grid = true, square = true, shape = false,- units = true, pts = [], t0 = .1, hidePlane = false, result = true, showMat = true, brackets = false, pre = null, fracs = false, name = 'A', lost = false } = {}) {+ units = true, pts = [], t0 = .1, hidePlane = false, result = true, showMat = true, brackets = false, pre = null, fracs = false, name = 'A', lost = false,+ names = null, avoid = null } = {}) {const Pm = pre || [[1, 0], [0, 1]];const v = { a00: A[0][0], a01: A[0][1], a10: A[1][0], a11: A[1][1], x0: x ? x[0] : 0, x1: x ? x[1] : 0, p00: Pm[0][0], p01: Pm[0][1], p10: Pm[1][0], p11: Pm[1][1] };const RANGE = { a00: 9, a01: 9, a10: 9, a11: 9, x0: 9, x1: 9 }, K = 14; // grid lines k = −K … K@@ -64,7 +76,7 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,/* ---------- numbers you can scrub ---------- */function slot(g, key, x, y, fill) {const bx = mk('rect', { x: x - 44, y: y - size * .85, width: 88, height: size * 1.1, rx: 10, fill: 'transparent' }, g);- const t = T(g, '', { x, y, size, fill, font: MATH, anchor: 'middle' });+ const t = g2mid(T(g, '', { x, y, size, fill, font: MATH, anchor: 'middle' }));t.style.pointerEvents = 'none';bx.setAttribute('aria-label', key);const fv = fracs ? g2val(g, { x, y, size: size * .8, fill }) : null;@@ -220,13 +232,15 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,if (x) { const m1 = [v.x0 * c0[0], v.x0 * c0[1]]; seg([0, 0], m1); seg(m1, ax); seg([0, 0], ax); }if (shape) { const F = G2_FLAG.map(tmap); F.forEach((q, i) => seg(q, F[(i + 1) % F.length], 1.5)); seg(F[1], F[3], 1.5); seg(F[0], F[5], 1.5); } // the flag, outline and body// the dots and handles themselves weigh most- for (const q of x ? [c0, c1, ax, [v.x0, v.x1]] : [c0, c1]) for (const [ox, oy] of [[0, 0], [-12, 0], [12, 0], [0, -12], [0, 12]]) pts.push([PX(q[0]) + ox, PY(q[1]) + oy, 4]);+ const extra = (typeof avoid === 'function' ? avoid(v) : avoid) || [];+ for (const q of [...(x ? [c0, c1, ax, [v.x0, v.x1]] : [c0, c1]), ...extra]) for (const [ox, oy] of [[0, 0], [-12, 0], [12, 0], [0, -12], [0, 12]]) pts.push([PX(q[0]) + ox, PY(q[1]) + oy, 4]);const placed = [...unitBoxes.map(b => [...b, 120]), ...tickBoxes.map(b => [...b, 120])];const over = (a, b) => Math.max(0, Math.min(a[0] + a[2], b[0] + b[2]) - Math.max(a[0], b[0])) * Math.max(0, Math.min(a[1] + a[3], b[1] + b[3]) - Math.max(a[1], b[1]));const place = (e, tip, dir, w, hh, baseline) => {const [X, Y] = [PX(tip[0]), PY(tip[1])], gp = 14, n = Math.hypot(...dir) || 1, d = [dir[0] / n, -dir[1] / n];const near = [[gp, -hh - 4], [gp, 6], [-w - gp, -hh - 4], [-w - gp, 6], [-w / 2, -hh - gp - 4], [-w / 2, gp + 6], [gp + 6, -hh / 2], [-w - gp - 6, -hh / 2]];- const cands = [...near.map(c => [...c, 0]), ...near.map(([dx, dy]) => [dx + (dx > 0 ? 26 : dx < -w / 2 ? -26 : 0), dy + (dy > 0 ? 22 : -22), 1.5])]; // a farther ring, a little dearer+ const ring = (k, cost) => near.map(([dx, dy]) => [dx + (dx > 0 ? 26 * k : dx < -w / 2 ? -26 * k : 0), dy + (dy > 0 ? 22 * k : -22 * k), cost]);+ const cands = [...near.map(c => [...c, 0]), ...ring(1, 1.5), ...ring(2.2, 4)]; // farther rings, a little dearer: a crowded spot sends a label outlet best = null;for (const [dx, dy, extra] of cands) {const b = [X + dx, Y + dy, w, hh], cx = dx + w / 2, cy = dy + hh / 2, cn = Math.hypot(cx, cy) || 1;@@ -239,17 +253,22 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,placed.push(best[1]);put(e, { x: best[1][0], y: best[1][1] + baseline });};- [c0, c1].forEach((c, j) => { const L = tipLabels[j]; if (L.firstChild) place(L, c, c, widthOf(L, 5, 28), 32, 23); });+ // one label per spot: a zero column, x = 0, or x sitting on Ax leave their names to what is already there+ const near0 = q => Math.hypot(q[0], q[1]) < .12, same = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]) < .3;+ const shown = (e, on) => { if (on) e.removeAttribute('display'); else { e.setAttribute('display', 'none'); put(e, { x: 0, y: 0 }); } return on; }; // hidden: an attribute and no place of its own, so a replay leaves the same markup+ [c0, c1].forEach((c, j) => { const L = tipLabels[j]; if (shown(L, !near0(c)) && L.firstChild) place(L, c, c, widthOf(L, 5, 28), 32, 23); });if (x) {- place(axLab, ax, ax, widthOf(axLab, axLab.textContent.length, 26), 30, 22);- place(xLab, [v.x0, v.x1], [v.x0, v.x1], widthOf(xLab, xLab.textContent.length, 24), 28, 21);+ const xv = [v.x0, v.x1];+ if (shown(axLab, !(near0(ax) && near0(xv)))) place(axLab, ax, ax, widthOf(axLab, axLab.textContent.length, 26), 30, 22);+ const axSeen = axLab.getAttribute('display') !== 'none' && axLab.style.visibility !== 'hidden'; // x hands its name to Ax's label unless a chapter hid it (not its fading: that would make the frame depend on the path)+ if (shown(xLab, !near0(xv) && !(axSeen && same(xv, ax)))) place(xLab, xv, xv, widthOf(xLab, xLab.textContent.length, 24), 28, 21);}}/* ---------- the inverse, live: ad − bc and A⁻¹ = 1/(ad − bc) · [d −b; −c a] ---------- */let inv = null;function inverse({ at: [ix, iy] = [90, 520], size: s = 40 } = {}) {const root = G(p, {}), part = () => G(root, {});- const det = part(), lhs = part(), scale = part(), adj = part(), eq = part(), res = part(), none = part();+ const det = part(), lhs = part(), scale = part(), adj = part(), eq = part(), res = part(), none = g2mid(part());const rh = s * 1.6, mid = iy + s * 2.4 + rh / 2; // matrices: rows at mid ± rh/2const xL = ix, xS = xL + s * 3.1, xA = xS + s * 1.9, cwA = s * 2, xE = xA + cwA * 2 + 36, xR = xE + s * 1.3, cwR = s * 2.1;const brk = (g, x0, w) => { const top = mid - rh / 2 - s * .95, bot = mid + rh / 2 + s * .45; path(g, `M${x0 + 12} ${top}H${x0}V${bot}H${x0 + 12}M${x0 + w - 12} ${top}H${x0 + w}V${bot}H${x0 + w - 12}`, { stroke: COL.chalk, 'stroke-width': 2.5, fill: 'none' }); };@@ -318,9 +337,10 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,setD(axArrow, arrowD([0, 0], ax));put(xRing, { x: PX(v.x0), y: PY(v.x1) });const br = brackets ? ['[', ']'] : ['(', ')']; // brackets: x and Ax read as vectors, else as points- setText(xLab, `x = ${br[0]}${fmt(v.x0)}, ${fmt(v.x1)}${br[1]}`);+ const nm = { x: 'x', ax: 'Ax', ...(typeof names === 'function' ? names(v) : names) };+ setText(xLab, `${nm.x} = ${br[0]}${fmt(v.x0)}, ${fmt(v.x1)}${br[1]}`);put(axDot, { x: PX(ax[0]), y: PY(ax[1]) });- setText(axLab, `Ax = ${br[0]}${fmt(ax[0])}, ${fmt(ax[1])}${br[1]}`);+ setText(axLab, `${nm.ax} = ${br[0]}${fmt(ax[0])}, ${fmt(ax[1])}${br[1]}`);}placeLabels(c0, c1, ax);listeners.forEach(f => f(v));@@ -379,6 +399,8 @@ function grid2(p, { A = [[1, 0], [0, 1]], x = null, mat = [90, 300], size = 54,map,labels(names) { names.forEach((n, i) => { tipLabels[i].replaceChildren(); M(tipLabels[i], [n], { size: 28, fill: G2_COLS[i], anchor: 'start' }); }); draw(); },tipLabels, // the groups that hold the column names (to show or hide one on its own)+ names(n) { names = n; draw(); }, // what the x and Ax labels call their points (see the header)+ avoid(a) { avoid = a; draw(); }, // extra dots the labels keep clear of (see the header)};return api;}diff --git a/site/linear-algebra/lib/inv.js b/site/linear-algebra/lib/inv.jsindex f1edbcb..d134163 100644--- a/site/linear-algebra/lib/inv.js+++ b/site/linear-algebra/lib/inv.js@@ -19,11 +19,11 @@ const IV_ROW = [COL.whole, COL.nat, COL.int], IV_COL = [COL.irr, COL.real, COL.rconst ivParts = v => typeof v === 'number' ? g2parts(v) : [].concat(v); // a number, or math parts (letters)function ivMat(p, rows, { x = 0, y = 0, size = 40, cw = size * 1.9, rh = size * 1.5, fill = () => COL.chalk, name = null, o = 1 } = {}) {- const n = rows.length, m = rows[0].length, g = G(p, { o });+ const n = rows.length, m = rows[0].length, g = g2mid(G(p, { o }));const w = cw * m + 20, top = y - size * .95, bot = y + (n - 1) * rh + size * .45;path(g, `M${x + 12} ${top}H${x}V${bot}H${x + 12}M${x + w - 12} ${top}H${x + w}V${bot}H${x + w - 12}`, { stroke: COL.chalk, 'stroke-width': 2.5, fill: 'none' });const cx = j => x + 10 + cw * (j + .5), ry = i => y + i * rh;- const cells = rows.map((r, i) => r.map((v, j) => { const c = g2val(G(g, {}), { x: cx(j), y: ry(i), size, fill: fill(i, j) }); c.set(0, fill(i, j), ivParts(v)); return c; }));+ const cells = rows.map((r, i) => r.map((v, j) => { const c = g2val(g2mid(G(g, {})), { x: cx(j), y: ry(i), size, fill: fill(i, j) }); c.set(0, fill(i, j), ivParts(v)); return c; }));let lab = null;if (name) lab = M(g, [].concat(name), { x: x + w / 2, y: bot + size * .95, size: size * .75, fill: COL.dim, anchor: 'middle' });return { g, cells, w, cw, cx, ry, top, bot, x, y, n, m, lab, set(r2) { r2.forEach((r, i) => r.forEach((v, j) => cells[i][j].set(0, fill(i, j), ivParts(v)))); } };@@ -56,7 +56,7 @@ function ivProd(p, L, R, { at: [x, y] = [90, 260], size = 40, names = ['A', 'B',show(wl, t + .3, .3); hide(wl, t + dur, .3);} else {const lhs = [];- L[i].forEach((a, k) => { if (k) lhs.push(' + '); lhs.push(...g2parts(a), '·', ...ivPP(R[k][j])); });+ L[i].forEach((a, k) => { if (k) lhs.push(' + '); lhs.push(...(k ? ivPP(a) : g2parts(a)), '·', ...ivPP(R[k][j])); }); // 1·7 + (−1)·1const wl = M(g, lhs, { x: wx, y: wy, size: workSize, anchor: 'start', o: 0 });const wr = M(g, [' = ', ...g2parts(C[i][j])], { x: wx + wl._w, y: wy, size: workSize, anchor: 'start', o: 0 });show(wl, t + .3, .3); hide(wl, t + dur, .3); show(wr, tr, .3); hide(wr, t + dur, .3);@@ -87,7 +87,7 @@ function gj(p, A, { at: [x0, y0] = [110, 300], size = 42, cw = size * 2.05, rh =const divider = right ? path(g, `M${x0 + cw * n + 14} ${top + 6}V${bot - 6}`, { stroke: COL.dim, 'stroke-width': 2.5, 'stroke-dasharray': '6 6', fill: 'none' }) : null;const bars = I.map(i => mk('rect', { x: x0 - 52, y: ry(i) - size * .7, width: 8, height: size * .8, rx: 4, fill: IV_ROW[i] }, g));const fillOf = j => j < n ? COL.chalk : COL.task;- const cells = I.map(i => J.map(j => g2val(G(g, {}), { x: cx(j), y: ry(i), size, fill: fillOf(j) })));+ const cells = I.map(i => J.map(j => g2val(g2mid(G(g, {})), { x: cx(j), y: ry(i), size, fill: fillOf(j) })));const nameG = [G(g, {}), G(g, {})];const setNames = (ns) => ns.forEach((s, k) => { if (k && !right) return; nameG[k].replaceChildren(); M(nameG[k], [].concat(s), { x: k ? (cx(n) + cx(mcols - 1)) / 2 : (cx(0) + cx(n - 1)) / 2, y: top - 18, size: size * .7, fill: k ? COL.task : COL.dim, anchor: 'middle' }); });setNames(nm);@@ -188,7 +188,10 @@ function gj(p, A, { at: [x0, y0] = [110, 300], size = 42, cw = size * 2.05, rh =g, v, n, cells, cx, ry, top, bot, W, bars, divider, nameG,get plan() { return plan; },sub, div, ring, flash, block, label,- names(ns, t) { const old = nameG.map(e => e.cloneNode(true)); old.forEach((e, k) => { nameG[k].parentNode.append(e); hide(e, t, .3); }); nameG.forEach(e => put(e, { o: 0 })); setNames(ns); nameG.forEach(e => show(e, t + .2, .4)); },+ names(ns, t) { // the old names keep their own timeline (a reveal set on them still runs) and fade at t; new ones take their place+ nameG.forEach((e, k) => { hide(e, t, .3); nameG[k] = G(g, { o: 0 }); show(nameG[k], t + .2, .4); });+ setNames(ns);+ },done(t) { if (open) hide(open, t, .3); },to(next, t, dur = 1.2) { const from = { ...plan }; plan = { ...plan, ...next }; prog(lerp(from, plan), t, dur); },open: openNow, commit, load,