An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
polish(linear-algebra): Unit 1 polish pass
yzr4506a7df68bf
diff --git a/site/linear-algebra/ch01/index.html b/site/linear-algebra/ch01/index.htmlindex 220edcd..e71256c 100644--- a/site/linear-algebra/ch01/index.html+++ b/site/linear-algebra/ch01/index.html@@ -142,14 +142,14 @@ const BEATS = [tw(f, { x: 1040 + dx * .65, y: 353 }, m('pair1'), .9); // into the chip (1, 3)hide(f, m('pair1') + .9, .2);});- const order = text(p, 'x first, then y', 1040, 404, m('pair1') + 9.8, { size: 28, fill: COL.task, anchor: 'middle', weight: 600 });+ const order = text(p, 'x first, then y', 1040, 404, m('pair1') + 9.8, { size: 28, fill: COL.chalk, anchor: 'middle', weight: 600 });hide(order, m('r2') + .5, .4);const extra = [[0, 4], [3, 1], [6, -2], [0.5, 3.5], [-3, 7], [10, -6]].map(([x, y], i) => {const c = chip(p, [pairStr(x, y)], COL.dim, { x: 980 + (i % 3) * 180, y: 520 + Math.floor(i / 3) * 70, size: 28 });put(c, { o: 0, s: .5 }); tw(c, { o: .8, s: 1 }, m('many') + 1 + i * .55, .4, back);return c;});- const more = text(p, '… and endlessly many more', 1160, 690, m('many') + 4.6, { size: 30, fill: COL.task, anchor: 'middle', weight: 600 });+ const more = text(p, '… and endlessly many more', 1160, 690, m('many') + 4.6, { size: 30, fill: COL.chalk, anchor: 'middle', weight: 600 });pulse(S.chips[0], m('pair1') + 7.4, 1.3); // "We write it as a pair"S.unk = [lab, more, ...extra];}],@@ -161,12 +161,12 @@ const BEATS = [S.chips.forEach((c, i) => tw(c, { x: 680, y: 384 + i * 64, s: .8 }, .3, .8));show(sys.stage, m('axes') - .4, .6);// the origin, and where x and y are negative- const o = drop(sys, 0, 0, m('mid') + 1.6, COL.task, '(0, 0)', -82, -14);+ const o = drop(sys, 0, 0, m('mid') + 1.6, COL.chalk, '(0, 0)', -82, -14);const negX = G(p, { o: 0 }), negY = G(p, { o: 0 });- path(negX, `M${PX(0)} ${PY(0)}H${PX(-6)}`, { stroke: COL.task, 'stroke-width': 6 });- T(negX, 'x negative', { x: PX(-3.5), y: PY(0) - 16, size: 26, fill: COL.task, anchor: 'middle', weight: 600 });- path(negY, `M${PX(0)} ${PY(0)}V${PY(-6)}`, { stroke: COL.task, 'stroke-width': 6 });- T(negY, 'y negative', { x: PX(0) + 18, y: PY(-3.5), size: 26, fill: COL.task, weight: 600 });+ path(negX, `M${PX(0)} ${PY(0)}H${PX(-6)}`, { stroke: COL.chalk, 'stroke-width': 6 });+ T(negX, 'x negative', { x: PX(-3.5), y: PY(0) - 16, size: 26, fill: COL.chalk, anchor: 'middle', weight: 600 });+ path(negY, `M${PX(0)} ${PY(0)}V${PY(-6)}`, { stroke: COL.chalk, 'stroke-width': 6 });+ T(negY, 'y negative', { x: PX(0) + 18, y: PY(-3.5), size: 26, fill: COL.chalk, weight: 600 });show(negX, m('neg') + .2, .5); show(negY, m('neg') + 2.5, .5);[negX, negY, o].forEach(e => hide(e, m('p1') - .4, .4));// each pair flies to its place; the walk from the origin follows the words ("one step right, then three steps up")@@ -179,12 +179,12 @@ const BEATS = [});hide(W, m('look'), .6);show(sys.lines[0].l, m('line'), 1);- drop(sys, 1.5, 2.5, m('halfp'), COL.task, '');+ drop(sys, 1.5, 2.5, m('halfp'), COL.chalk, '');// the numbers of the point the voice names, and then of a point running along the line, under the table- const hl = say(p, ['(1.5, 2.5): 1.5 + 2.5 = 4'], 90, 750, m('half') + 1.8, { size: 34, fill: COL.task });+ const hl = say(p, ['(1.5, 2.5): 1.5 + 2.5 = 4'], 90, 750, m('half') + 1.8, { size: 34, fill: COL.chalk });hide(hl, m('rule') - .3, .3);- const probe = G(p, { o: 0 }), pr = mk('circle', { r: 12, fill: COL.task, stroke: COL.board, 'stroke-width': 3 }, probe);- const pt = T(p, '', { x: 90, y: 750, size: 34, fill: COL.task, font: MATH, o: 0 });+ const probe = G(p, { o: 0 }), pr = mk('circle', { r: 12, fill: COL.chalk, stroke: COL.board, 'stroke-width': 3 }, probe);+ const pt = T(p, '', { x: 90, y: 750, size: 34, fill: COL.chalk, font: MATH, o: 0 });show(probe, m('rule') - .2, .3); show(pt, m('rule'), .3);prog(q => {const x = -1.5 + q * 7, y = 4 - x;@@ -236,17 +236,17 @@ const BEATS = [const keep = (c, t) => { const l = sys.P.line(0, c, 1, c - 1, LINE, t, { into: ghost, dash: '10 10', w: 3 }); tw(l, { o: .35 }, t + .6, .4); };keep(4, m('six'));sys.to({ b0: 6 }, m('six'), 1.4); flash(sys, 'b0', m('six'));- const six = [drop(sys, 2, 4, m('up') + 1.4, COL.task, '(2, 4)', 16, -16), say(p, ['2 + 4 = 6'], 90, 330, m('up') + 1.6, { size: 38, fill: COL.task })];+ const six = [drop(sys, 2, 4, m('up') + 1.4, COL.chalk, '(2, 4)', 16, -16), say(p, ['2 + 4 = 6'], 90, 330, m('up') + 1.6, { size: 38, fill: COL.chalk })];six.forEach(e => hide(e, m('zero') - .3, .3));keep(6, m('zero'));sys.to({ b0: 0 }, m('zero'), 1.6); flash(sys, 'b0', m('zero'));- const zero = [drop(sys, 0, 0, m('origin') + 1.2, COL.task, '(0, 0)', 16, -16), say(p, ['0 + 0 = 0'], 90, 330, m('origin') + 4.4, { size: 38, fill: COL.task })];+ const zero = [drop(sys, 0, 0, m('origin') + 1.2, COL.chalk, '(0, 0)', 16, -16), say(p, ['0 + 0 = 0'], 90, 330, m('origin') + 4.4, { size: 38, fill: COL.chalk })];zero.forEach(e => hide(e, m('neg') - .3, .3));keep(0, m('neg'));sys.to({ b0: -3 }, m('neg'), 1.4); flash(sys, 'b0', m('neg'));const n = G(p, { o: 0 });T(n, 'right side changes:', { x: 90, y: 460, size: 32, fill: COL.dim });- T(n, 'the line slides, never turns', { x: 90, y: 510, size: 36, weight: 600, fill: COL.task });+ T(n, 'the line slides, never turns', { x: 90, y: 510, size: 36, weight: 600, fill: COL.chalk });show(n, m('par'));S.slideNote = n;}],@@ -262,21 +262,21 @@ const BEATS = [say(work, ['on the x-axis, y = 0:'], 90, 330, m('why'), { size: 32, fill: COL.dim });const w1 = say(work, ['2x = 4, x = 2'], 90, 385, m('xa'), { size: 40 });const g1 = guides(sys, 2, 0, m('cross'), p);- const c2 = drop(sys, 2, 0, m('cross'), COL.task, '(2, 0)', 44, 56);+ const c2 = drop(sys, 2, 0, m('cross'), COL.chalk, '(2, 0)', 44, 56);const was = drop(sys, 4, 0, m('cross') + .8, COL.faint, '', 10, 36);say(work, ['on the y-axis, x = 0:'], 90, 460, m('ya'), { size: 32, fill: COL.dim });say(work, ['y = 4'], 90, 515, m('ya') + 1.2, { size: 40 });- const same = drop(sys, 0, 4, m('four'), COL.task, '(0, 4) same', 16, -10);+ const same = drop(sys, 0, 4, m('four'), COL.chalk, '(0, 4) same', 16, -10);hide(same, m('minus') - .3, .4);[g1, was, c2].forEach(e => hide(e, m('three') - .3, .3));sys.to({ a00: 4 }, m('three'), 1.4); flash(sys, 'a00', m('three'));hide(w1, m('three') - .3, .3);say(work, ['4x = 4, x = 1'], 90, 385, m('three') + 4.7, { size: 40 });- const c1 = drop(sys, 1, 0, m('three') + 5.6, COL.task, '(1, 0)', 44, 56);+ const c1 = drop(sys, 1, 0, m('three') + 5.6, COL.chalk, '(1, 0)', 44, 56);hide(work, m('minus') - .3, .4); hide(c1, m('minus') - .3, .4);sys.to({ a00: -1 }, m('minus'), 1.8); flash(sys, 'a00', m('minus'));const n = G(p, { o: 0 });- T(n, 'right side: slides the line', { x: 90, y: 630, size: 34, weight: 600, fill: COL.task });+ T(n, 'right side: slides the line', { x: 90, y: 630, size: 34, weight: 600, fill: COL.chalk });T(n, 'numbers in front of x, y: turn it', { x: 90, y: 682, size: 34, weight: 600, fill: COL.whole });show(n, m('sum'));}],@@ -290,11 +290,11 @@ const BEATS = [say(steps, ['x = 0:'], 90, 330, m('x0'), { size: 32, fill: COL.dim });say(steps, ['3y = 6,'], 220, 330, m('x0') + 2.3, { size: 38 });say(steps, ['y = 2'], 360, 330, m('y2'), { size: 38 });- drop(sys, 0, 2, m('p1'), COL.task, '(0, 2)', 16, -16, steps);+ drop(sys, 0, 2, m('p1'), COL.chalk, '(0, 2)', 16, -16, steps);say(steps, ['y = 0:'], 90, 400, m('y0'), { size: 32, fill: COL.dim });say(steps, ['2x = 6,'], 220, 400, m('y0') + 2.3, { size: 38 });say(steps, ['x = 3'], 360, 400, m('x3'), { size: 38 });- drop(sys, 3, 0, m('p2'), COL.task, '(3, 0)', -14, 56, steps, 'end');+ drop(sys, 3, 0, m('p2'), COL.chalk, '(3, 0)', -14, 56, steps, 'end');show(l, m('line'), .9);say(steps, ['check (6, −2):'], 90, 480, m('check'), { size: 32, fill: COL.dim });say(steps, ['2·6'], 90, 535, m('check') + 3, { size: 36 });@@ -310,10 +310,10 @@ const BEATS = [say(s2, ['x = 0:'], 90, 330, m('a'), { size: 32, fill: COL.dim });say(s2, ['−2y = 4,'], 220, 330, m('a') + .9, { size: 38 });say(s2, ['y = −2'], 385, 330, m('a') + 3.5, { size: 38 });- drop(sys, 0, -2, m('a') + 4, COL.task, '(0, −2)', 16, 34, s2);+ drop(sys, 0, -2, m('a') + 4, COL.chalk, '(0, −2)', 16, 34, s2);say(s2, ['y = 0:'], 90, 400, m('b'), { size: 32, fill: COL.dim });say(s2, ['x = 4'], 220, 400, m('b') + 1.4, { size: 38 });- drop(sys, 4, 0, m('b') + 2, COL.task, '(4, 0)', 14, 56, s2);+ drop(sys, 4, 0, m('b') + 2, COL.chalk, '(4, 0)', 14, 56, s2);show(l, m('line2'), .9);}],@@ -340,15 +340,15 @@ const BEATS = [say(p, ['−y = 0, y = 0'], 220, 330, m('x0') + 1, { size: 38 });say(p, ['y = 0:'], 90, 400, m('y0'), { size: 32, fill: COL.dim });say(p, ['2x = 0, x = 0'], 220, 400, m('y0') + 1, { size: 38 });- const o = drop(sys, 0, 0, m('x0') + 2, COL.task, '(0, 0)', -82, -14).firstChild;+ const o = drop(sys, 0, 0, m('x0') + 2, COL.chalk, '(0, 0)', -82, -14).firstChild;pulse(o, m('same')); pulse(o, m('same') + 1.2);text(p, 'the same point twice: not enough for a line', 90, 470, m('same') + .6, { size: 30, fill: COL.bad, weight: 600 });say(p, ['x = 1:'], 90, 550, m('x1'), { size: 32, fill: COL.dim });say(p, ['2 − y = 0, y = 2'], 220, 550, m('x1') + 2, { size: 38 });- drop(sys, 1, 2, m('p'), COL.task, '(1, 2)', 18, 10);+ drop(sys, 1, 2, m('p'), COL.chalk, '(1, 2)', 18, 10);show(sys.lines[0].l, m('line'), .9);const n = G(p, { o: 0 });- T(n, 'right side 0 → the line passes through (0, 0)', { x: 90, y: 650, size: 32, weight: 600, fill: COL.task });+ T(n, 'right side 0 → the line passes through (0, 0)', { x: 90, y: 650, size: 32, weight: 600, fill: COL.chalk });show(n, m('note'));}],@@ -361,8 +361,8 @@ const BEATS = [const l = sys.lines[0].l;// "x can be anything, and y must be two": points at height 2, then the line through all of themconst hd = G(p, {});- [-3, 0, 3].forEach((x, i) => drop(sys, x, 2, m('zero') + 3 + i * .35, COL.task, '', 0, 0, hd));- const fr = text(p, 'x is free, y must be 2', 90, 400, m('zero') + 3, { size: 32, fill: COL.task, weight: 600 });+ [-3, 0, 3].forEach((x, i) => drop(sys, x, 2, m('zero') + 3 + i * .35, COL.chalk, '', 0, 0, hd));+ const fr = text(p, 'x is free, y must be 2', 90, 400, m('zero') + 3, { size: 32, fill: COL.chalk, weight: 600 });show(l, m('h') + .6, .9);[big, hd, fr, l].forEach(e => hide(e, m('eq2') - .3, .3));// x = 3: a new equation, not a turn of the old line, so it is set while the line is away@@ -370,8 +370,8 @@ const BEATS = [sys.to({ a00: 1, a01: 0, b0: 3 }, m('eq2') + 1.4, .05);flash(sys, 'a01', m('eq2') + 2.6);const vd = G(p, {});- [-3, 0, 3].forEach((y, i) => drop(sys, 3, y, m('v') + .1 + i * .35, COL.task, '', 0, 0, vd));- text(p, 'y is free, x must be 3', 90, 400, m('v') + .1, { size: 32, fill: COL.task, weight: 600 });+ [-3, 0, 3].forEach((y, i) => drop(sys, 3, y, m('v') + .1 + i * .35, COL.chalk, '', 0, 0, vd));+ text(p, 'y is free, x must be 3', 90, 400, m('v') + .1, { size: 32, fill: COL.chalk, weight: 600 });show(l, m('v') + 2.7, .9);text(p, '0 in front of a letter = that letter is free', 90, 690, m('sum'), { size: 32, weight: 600 });}],@@ -394,7 +394,7 @@ const BEATS = [[['An equation in x and y has many solutions: pairs (x, y).', 'w1'], ['Drawn as points, the solutions make a straight line.', 'w2'],['The right side slides the line; the numbers in front of x and y turn it.', 'w3'], ['To draw it: set x = 0, then y = 0, and connect the points.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 36, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);@@ -413,7 +413,7 @@ const BEATS = [build: blanks(CROSSQ),}, {id: 'p-turn', prompt: ['Does the change slide the line or turn it?'],- build: grid(TURNQ, [['s', 'Slides', COL.task, 'S'], ['t', 'Turns', COL.whole, 'T']], { multi: false, text: true }),+ build: grid(TURNQ, [['s', 'Slides', COL.chalk, 'S'], ['t', 'Turns', COL.whole, 'T']], { multi: false, text: true }),}], done, 'Chapter practice · set 3 of 4') }],['final4', 'Chapter practice', () => {const p = panel(0);diff --git a/site/linear-algebra/ch02/index.html b/site/linear-algebra/ch02/index.htmlindex b09b03e..a991f18 100644--- a/site/linear-algebra/ch02/index.html+++ b/site/linear-algebra/ch02/index.html@@ -34,36 +34,8 @@ const twoLines = (p, A, b, { t0 = .1, lines = true, meet = true, readout = true,if (!lines) sys.lines.forEach(({ l }) => put(l, { o: 0 }));if (!meet) put(sys.meetBox, { o: 0 });if (!readout) put(sys.readout, { o: 0 });- placeMeet(sys);return sys;};-// The meeting point's label goes where the two lines and the axes leave it most room (the library always puts it up-// and right, where a rising line runs through it). Each spot's text box is tested against both lines and both axes.-const placeMeet = sys => {- const lab = sys.meet.lastChild, { PX, PY } = sys.P;- const spots = [[18, -16, 1], [18, 40, 1], [-18, -16, -1], [-18, 40, -1], [24, -4, 1], [-24, -4, -1], [24, 30, 1], [-24, 30, -1], [0, 72, 0], [0, -50, 0]]; // x, baseline, side (0: centred under or over the point)- const f = (v, s) => {- if (s.x === undefined) return;- const w = lab.textContent.length * 14 + 4, ox = PX(0) - PX(s.x), oy = PY(0) - PY(s.y);- const ds = [0, 1].map(i => [v[`a${i}1`], v[`a${i}0`]]).filter(([a, b]) => a || b).map(([a, b]) => [a / Math.hypot(a, b), b / Math.hypot(a, b)]); // each line's direction on screen- let best = spots[0], far = -1;- for (const sp of spots) {- let d = Infinity;- const x0 = sp[2] ? Math.min(sp[0], sp[0] + sp[2] * w) : -w / 2, x1 = sp[2] ? Math.max(sp[0], sp[0] + sp[2] * w) : w / 2, y0 = sp[1] - 22, y1 = sp[1];- ds.forEach(([ux, uy]) => { // a line through the point: 0 if it cuts the text box, else its distance from the nearest corner- const c = [[x0, y0], [x1, y0], [x0, y1], [x1, y1]].map(([x, y]) => x * uy - y * ux);- d = Math.min(d, Math.min(...c) < 0 && Math.max(...c) > 0 ? 0 : Math.min(...c.map(Math.abs)));- });- // an axis under the text is less bad than a line through it, but still to be avoided- const gap = (a0, a1, b0, b1) => Math.max(0, b0 - a1, a0 - b1); // between two ranges, 0 when they overlap- const ax = Math.min(gap(x0, x1, ox - 34, ox + 4), gap(y0, y1, oy - 4, oy + 30)); // each axis with its numbers (left of y, under x)- d = Math.min(d, ax + 8) + ax / 100; // between equals, the spot farther from the axes- if (d > far + 1e-6) { best = sp; far = d; }- }- put(lab, { x: best[0], y: best[1] }); lab.setAttribute('text-anchor', best[2] > 0 ? 'start' : best[2] < 0 ? 'end' : 'middle');- };- sys.onChange(f); f(sys.v, sys.solve());-};// A dashed guide from a point straight down (or across) to an axis.const guide = (sys, x, y, toAxis, t0, into) => {const { PX, PY } = sys.P, d = toAxis === 'x' ? `M${PX(x)} ${PY(y)}V${PY(0)}` : `M${PX(x)} ${PY(y)}H${PX(0)}`;@@ -159,11 +131,11 @@ const BEATS = [const sys = twoLines(p, [[1, 1], [1, -1]], [5, 1], { t0: m('name') - .3, readout: false, hidePlane: true });put(sys.eqRows[1].g, { o: 0 }); show(sys.eqRows[1].g, m('and'));// the brace: one system, both rows- const br = path(p, 'M48 140Q30 140 30 160V205Q30 222 16 222Q30 222 30 239V284Q30 304 48 304', { stroke: COL.task, 'stroke-width': 3.5, fill: 'none' }, { d: 0 });+ const br = path(p, 'M48 140Q30 140 30 160V205Q30 222 16 222Q30 222 30 239V284Q30 304 48 304', { stroke: COL.chalk, 'stroke-width': 3.5, fill: 'none' }, { d: 0 });draw(br, m('both'), .6);hide(r1, m('both'), .4); hide(r2, m('both'), .4);- text(p, 'a system of equations:', 90, 470, m('both') + .5, { size: 32, fill: COL.task, weight: 600 });- text(p, 'both must be true at once', 90, 520, m('both') + .9, { size: 32, fill: COL.task, weight: 600 });+ text(p, 'a system of equations:', 90, 470, m('both') + .5, { size: 32, fill: COL.chalk, weight: 600 });+ text(p, 'both must be true at once', 90, 520, m('both') + .9, { size: 32, fill: COL.chalk, weight: 600 });// the hunt: pairs that add to 5, each tested in the second equationconst cx = [890, 1110, 1390], hy = 220, rh = 82;const head = G(p, { o: 0 });@@ -229,7 +201,7 @@ const BEATS = [const n2 = text(p, 'not 0', cx[1] + 165, hy + 80 + rh + 40, m('b1') + 1.6, { size: 22, fill: COL.bad, anchor: 'middle' });S.chk = [n1, n2];const rule = G(p, { o: 0 });- T(rule, 'a solution of the system passes every equation', { x: 90, y: 790, size: 32, weight: 600, fill: COL.task });+ T(rule, 'a solution of the system passes every equation', { x: 90, y: 790, size: 32, weight: 600, fill: COL.chalk });show(rule, m('cok') + 1.4);}],@@ -287,7 +259,7 @@ const BEATS = [text(p, 'the same pair as in the table', 330, 396, m('same') + .2, { size: 26, fill: COL.dim });sys.focus(0, m('name') + 2.5); sys.focus(1, m('name') + 4.5); sys.focus(null, m('name') + 6.5);const n = G(p, { o: 0 });- T(n, 'the crossing is on both lines: it solves both equations', { x: 90, y: 760, size: 30, weight: 600, fill: COL.task });+ T(n, 'the crossing is on both lines: it solves both equations', { x: 90, y: 760, size: 30, weight: 600, fill: COL.chalk });show(n, m('on') + .3);}],@@ -314,7 +286,7 @@ const BEATS = [tw(sys.lines[1].l, { 'a_stroke-width': 9 }, m('off'), .3); tw(sys.lines[1].l, { 'a_stroke-width': 5 }, m('off') + 1, .5);say(p, ['(1, 4): 1 − 4 = −3, (2, 3): −1, (4, 1): 3'], 90, 680, m('off') + .3, { size: 28, fill: COL.dim });text(p, 'none of them is 1: off the coral line', 90, 725, m('off') + 1.4, { size: 28, fill: CORAL, weight: 600 });- text(p, 'only the crossing (3, 2) is on both', 90, 790, m('sum'), { size: 32, fill: COL.task, weight: 600 });+ text(p, 'only the crossing (3, 2) is on both', 90, 790, m('sum'), { size: 32, fill: COL.chalk, weight: 600 });}],['q2', 'Quick check', () => {@@ -352,8 +324,8 @@ const BEATS = [okMark(p, true, 470, 670, m('c2') + 3);show(sys.readout, m('ok'));const n = G(p, { o: 0 });- T(n, 'the picture says where to look;', { x: 90, y: 760, size: 30, weight: 600, fill: COL.task });- T(n, 'putting the numbers back in proves it', { x: 90, y: 802, size: 30, weight: 600, fill: COL.task });+ T(n, 'the picture says where to look;', { x: 90, y: 760, size: 30, weight: 600, fill: COL.chalk });+ T(n, 'putting the numbers back in proves it', { x: 90, y: 802, size: 30, weight: 600, fill: COL.chalk });show(n, m('lesson'));}],@@ -427,8 +399,8 @@ const BEATS = [say(p, ['−3 + 2·3 = 3 ✓'], 90, 525, m('chk') + 2, { size: 34, fill: CORAL });sys.focus(null, m('rule'));const n = G(p, { o: 0 });- T(n, 'one right side changes: that line slides,', { x: 90, y: 720, size: 30, weight: 600, fill: COL.task });- T(n, 'and the meeting point slides along the other line', { x: 90, y: 762, size: 30, weight: 600, fill: COL.task });+ T(n, 'one right side changes: that line slides,', { x: 90, y: 720, size: 30, weight: 600, fill: COL.chalk });+ T(n, 'and the meeting point slides along the other line', { x: 90, y: 762, size: 30, weight: 600, fill: COL.chalk });show(n, m('rule'));S.g2 = g2;}],@@ -460,8 +432,8 @@ const BEATS = [say(p, ['2 + 3 = 5 ✓, 2·2 − 3 = 1 ✓'], 90, 470, m('chk2'), { size: 32 });sys.focus(null, m('rule'));const n = G(p, { o: 0 });- T(n, 'a line moves: the meeting point', { x: 90, y: 720, size: 30, weight: 600, fill: COL.task });- T(n, 'stays on the line that does not', { x: 90, y: 762, size: 30, weight: 600, fill: COL.task });+ T(n, 'a line moves: the meeting point', { x: 90, y: 720, size: 30, weight: 600, fill: COL.chalk });+ T(n, 'stays on the line that does not', { x: 90, y: 762, size: 30, weight: 600, fill: COL.chalk });show(n, m('rule'));S.t2 = t2;}],@@ -484,7 +456,7 @@ const BEATS = [[['A system: equations that must all be true at once.', 'w1'], ['A pair solves the system only if it passes every equation.', 'w2'],['Row picture: each equation is a line; the solution is where they cross.', 'w3'], ['The picture shows where to look; putting the numbers back in proves it.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 36, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/ch03/index.html b/site/linear-algebra/ch03/index.htmlindex 57ab2b9..d6e5bae 100644--- a/site/linear-algebra/ch03/index.html+++ b/site/linear-algebra/ch03/index.html@@ -35,8 +35,8 @@ const eqStr = (a, bb, c) => {};// Two equations in the top left, the plane on the right. When the two lines are one line, the coral one is drawn// dashed so the blue one shows through it. When the lines meet off the picture, an arrow at the edge points there.-const twoLines = (p, A, b, { t0 = .1, lines = true, meet = true, readout = true, hidePlane = false, offMark = false } = {}) => {- const sys = linsys(p, { A, b, eq: [90, 200], mat: null, t0, hidePlane });+const twoLines = (p, A, b, { t0 = .1, lines = true, meet = true, readout = true, hidePlane = false, offMark = false, exact = true } = {}) => {+ const sys = linsys(p, { A, b, eq: [90, 200], mat: null, t0, hidePlane, exact });if (!lines) sys.lines.forEach(({ l }) => put(l, { o: 0 }));if (!meet) put(sys.meetBox, { o: 0 });if (!readout) put(sys.readout, { o: 0 });@@ -64,49 +64,21 @@ const twoLines = (p, A, b, { t0 = .1, lines = true, meet = true, readout = true,const ux = (s.x - ex) / best, uy = (s.y - ey) / best;const a = [PX(ex - ux * 1.1), PY(ey - uy * 1.1)], c = [PX(ex), PY(ey)];arr.setAttribute('d', `M${a[0]} ${a[1]}L${c[0]} ${c[1]}M${c[0] - 16 * ux - 9 * uy} ${c[1] + 16 * uy - 9 * ux}L${c[0]} ${c[1]}L${c[0] - 16 * ux + 9 * uy} ${c[1] + 16 * uy + 9 * ux}Z`);- lab.textContent = `meets at (${fmt1(s.x)}, ${fmt1(s.y)})`;+ lab.textContent = Math.max(Math.abs(s.x), Math.abs(s.y)) > 99 ? 'meets very far away' : `meets at (${fmt1(s.x)}, ${fmt1(s.y)})`; // no five-digit numbers flashing by on the way to parallelput(lab, { x: c[0] + (ux > 0 ? -30 : 30), y: c[1] + (uy < 0 ? 44 : -26) }); // beside the arrow's tip, outside the grid's numberslab.setAttribute('text-anchor', ux > 0 ? 'end' : 'start');};sys.onChange(onChange);onChange(sys.v, sys.solve());- placeMeet(sys);return sys;};-// The meeting point's label goes where the two lines and the axes leave it most room (the library always puts it up-// and right, where a rising line runs through it). Each spot's text box is tested against both lines and both axes.-const placeMeet = sys => {- const lab = sys.meet.lastChild, { PX, PY } = sys.P;- const spots = [[18, -16, 1], [18, 40, 1], [-18, -16, -1], [-18, 40, -1], [24, -4, 1], [-24, -4, -1], [24, 30, 1], [-24, 30, -1], [0, 72, 0], [0, -50, 0]]; // x, baseline, side (0: centred under or over the point)- const f = (v, s) => {- if (s.x === undefined) return;- const w = lab.textContent.length * 14 + 4, ox = PX(0) - PX(s.x), oy = PY(0) - PY(s.y);- const ds = [0, 1].map(i => [v[`a${i}1`], v[`a${i}0`]]).filter(([a, b]) => a || b).map(([a, b]) => [a / Math.hypot(a, b), b / Math.hypot(a, b)]); // each line's direction on screen- let best = spots[0], far = -1;- for (const sp of spots) {- let d = Infinity;- const x0 = sp[2] ? Math.min(sp[0], sp[0] + sp[2] * w) : -w / 2, x1 = sp[2] ? Math.max(sp[0], sp[0] + sp[2] * w) : w / 2, y0 = sp[1] - 22, y1 = sp[1];- ds.forEach(([ux, uy]) => { // a line through the point: 0 if it cuts the text box, else its distance from the nearest corner- const c = [[x0, y0], [x1, y0], [x0, y1], [x1, y1]].map(([x, y]) => x * uy - y * ux);- d = Math.min(d, Math.min(...c) < 0 && Math.max(...c) > 0 ? 0 : Math.min(...c.map(Math.abs)));- });- // an axis under the text is less bad than a line through it, but still to be avoided- const gap = (a0, a1, b0, b1) => Math.max(0, b0 - a1, a0 - b1); // between two ranges, 0 when they overlap- const ax = Math.min(gap(x0, x1, ox - 34, ox + 4), gap(y0, y1, oy - 4, oy + 30)); // each axis with its numbers (left of y, under x)- d = Math.min(d, ax + 8) + ax / 100; // between equals, the spot farther from the axes- if (d > far + 1e-6) { best = sp; far = d; }- }- put(lab, { x: best[0], y: best[1] }); lab.setAttribute('text-anchor', best[2] > 0 ? 'start' : best[2] < 0 ? 'end' : 'middle');- };- sys.onChange(f); f(sys.v, sys.solve());-};// A small framed picture of two lines, for comparing the three cases side by side.const mini = (p, cx, cy, l1, l2, t0, caption, sub, tPlane = t0) => {const P = plane(p, { cx, cy, u: 30, x0: -5, x1: 5, y0: -5, y1: 5, labels: false, t0: tPlane });P.line(...l1, BLUE, t0 + .4, { w: 5 });P.line(...l2, CORAL, t0 + .8, { w: 5, dash: l2.dash });text(p, caption, cx, cy + 225, t0 + .6, { size: 32, weight: 600, anchor: 'middle' });- return { P, sub: sub ? T(p, sub, { x: cx, y: cy + 270, size: 28, fill: COL.task, weight: 600, anchor: 'middle', o: 0 }) : null };+ return { P, sub: sub ? T(p, sub, { x: cx, y: cy + 270, size: 28, fill: COL.chalk, weight: 600, anchor: 'middle', o: 0 }) : null };};/* ---------- practice data ---------- */@@ -198,7 +170,7 @@ const BEATS = [const gap = G(p, {}), { PX, PY } = b.P;path(gap, `M${PX(0)} ${PY(-1)}V${PY(2)}`, { stroke: COL.dim, 'stroke-width': 2.5, 'stroke-dasharray': '5 6' }, { o: 0 });show(gap.firstChild, m('par') + 1.6, .4);- [-3, 0, 3].forEach((x, i) => c.P.dot(x, -x, COL.task, m('same') + 1.5 + i * .3, { r: 8 }));+ [-3, 0, 3].forEach((x, i) => c.P.dot(x, -x, COL.chalk, m('same') + 1.5 + i * .3, { r: 8 }));}],['parallel', 'Lines that never meet', (m) => {@@ -208,7 +180,7 @@ const BEATS = [say(p, ['x + y = 2 and x + y = 5 ?'], 90, 470, m('ask'), { size: 38 });say(p, ['1 + 1 = 2'], 90, 545, m('try'), { size: 36, fill: BLUE });say(p, ['1 + 1 ≠ 5'], 90, 600, m('sum'), { size: 36, fill: CORAL });- text(p, 'x + y is one number: it cannot be 2 and 5 at once', 90, 670, m('never'), { size: 28, fill: COL.task, weight: 600 });+ text(p, 'x + y is one number: it cannot be 2 and 5 at once', 90, 670, m('never'), { size: 28, fill: COL.chalk, weight: 600 });const { PX, PY } = sys.P;show(sys.lines[0].l, m('l1'), .9); show(sys.lines[1].l, m('l2'), .9);// a probe walks along each line: its sum never changes@@ -235,7 +207,7 @@ const BEATS = [put(gaps, { o: 1 });[[-2.5, 4.5, -1, 6], [-1, 3, .5, 4.5], [.5, 1.5, 2, 3], [2, 0, 3.5, 1.5], [3.5, -1.5, 5, 0]].forEach(([x1, y1, x2, y2], i) =>draw(path(gaps, `M${PX(x1)} ${PY(y1)}L${PX(x2)} ${PY(y2)}`, { stroke: COL.dim, 'stroke-width': 3 }, { d: 0 }), m('tilt') + .5 + i * .5, .4));- text(p, 'always the same gap', PX(-5.6), PY(-3), m('gap'), { size: 26, fill: COL.dim });+ text(p, 'always the same gap', PX(-5.8), PY(-4.4), m('gap'), { size: 26, fill: COL.dim });show(sys.readout, m('none'));}],@@ -283,13 +255,13 @@ const BEATS = [show(sys.lines[0].l, m('draw') - .6, .6); show(sys.lines[1].l, m('draw') + .4, .9);hide(w, m('p1') - .3, .3);sys.to({ a10: 2, a11: 4, b1: 6 }, m('p1') + .3, 1.2); ['a10', 'a11', 'b1'].forEach(k => flash(sys, k, m('p1') + .3)); // check in the equations as first written- drop(sys, 3, 0, m('p1a'), COL.task, '(3, 0)', 12, -18);+ drop(sys, 3, 0, m('p1a'), COL.chalk, '(3, 0)', 12, -18);say(p, ['3 + 2·0 = 3'], 90, 470, m('p1a') + .4, { size: 34, fill: BLUE }); okMark(p, true, 310, 470, m('p1a') + 1.6);say(p, ['2·3 + 4·0 = 6'], 370, 470, m('p1b'), { size: 34, fill: CORAL }); okMark(p, true, 620, 470, m('p1b') + 2.5);- drop(sys, 1, 1, m('p2'), COL.task, '(1, 1)');+ drop(sys, 1, 1, m('p2'), COL.chalk, '(1, 1)');say(p, ['1 + 2·1 = 3'], 90, 535, m('p2') + .6, { size: 34, fill: BLUE }); okMark(p, true, 310, 535, m('p2') + 2);say(p, ['2·1 + 4·1 = 6'], 370, 535, m('p2b'), { size: 34, fill: CORAL }); okMark(p, true, 620, 535, m('p2b') + 1);- [-5, -3, 5].forEach((x, i) => drop(sys, x, (3 - x) / 2, m('all') + i * .4, COL.task, ''));+ [-5, -3, 5].forEach((x, i) => drop(sys, x, (3 - x) / 2, m('all') + i * .4, COL.chalk, ''));show(sys.readout, m('inf'));}],@@ -308,8 +280,8 @@ const BEATS = [okMark(p, true, 450, 540, m('match') + .5);show(sys.readout, m('inf'));const n = G(p, { o: 0 });- T(n, 'both sides times the same number (not 0):', { x: 90, y: 720, size: 30, weight: 600, fill: COL.task });- T(n, 'the line does not move', { x: 90, y: 762, size: 30, weight: 600, fill: COL.task });+ T(n, 'both sides times the same number (not 0):', { x: 90, y: 720, size: 30, weight: 600, fill: COL.chalk });+ T(n, 'the line does not move', { x: 90, y: 762, size: 30, weight: 600, fill: COL.chalk });show(n, m('say'));sys.focus(0, m('say') + 2);sys.to({ a00: 3, a01: -3, b0: 3 }, m('say') + 2.5, 2.5); ['a00', 'a01', 'b0'].forEach(k => flash(sys, k, m('say') + 2.5));@@ -345,7 +317,7 @@ const BEATS = [const ex1 = say(p, ['2x + 3y → ×2 → 4x + 6y'], 150, 620, m('s1') + 5, { size: 34, fill: COL.dim });hide(ex1, m('s2') - .3, .3);tw(F0, { y: 250 }, m('ex') - .2, .8); // the steps move down under the equations- const hl = (e, t, t2) => { tw(e, { c_fill: COL.task }, t, .3); tw(e, { c_fill: COL.dim }, t2, .3); };+ const hl = (e, t, t2) => { tw(e, { c_fill: COL.chalk }, t, .3); tw(e, { c_fill: COL.dim }, t2, .3); };// example 1: times 3 on both sidesconst l1 = say(p, ['left: 1·3 = 3, 2·3 = 6: times 3'], 90, 395, m('e1a'), { size: 30, fill: CORAL });[['a00', 'a10', 1.2], ['a01', 'a11', 3.4]].forEach(([k1, k2, d]) => { flash(sys, k1, m('e1a') + d); flash(sys, k2, m('e1a') + d + .6); });@@ -363,7 +335,7 @@ const BEATS = [say(p, ['left: 1·3 = 3, but 2·3 = 6, not 5'], 90, 395, m('e3a'), { size: 30, fill: COL.bad });flash(sys, 'a01', m('e3a') + 2); flash(sys, 'a11', m('e3a') + 3.6);tw(sys.lines[1].l, { 'a_stroke-width': 9 }, m('e3a') + 4, .3); tw(sys.lines[1].l, { 'a_stroke-width': 5 }, m('e3b'), .5);- tw(no1, { c_fill: COL.task }, m('e3c'), .3);+ tw(no1, { c_fill: COL.chalk }, m('e3c'), .3);pulse(sys.meet, m('e3c') + .6); pulse(sys.meet, m('e3c') + 1.8);void q1; void q2;}],@@ -371,13 +343,15 @@ const BEATS = [['runaway', 'On the way to parallel', (m) => {const p = panel(0);text(p, 'Turning toward parallel', 60, 110, .2, { size: 40, weight: 600 });- const sys = S.sys = twoLines(p, [[1, 1], [2, 1]], [2, 5], { t0: m('eq') - .3, offMark: true });+ const sys = S.sys = twoLines(p, [[1, 1], [2, 1]], [2, 5], { t0: m('eq') - .3, offMark: true, exact: false }); // the voice and the table say 1.5, 1.2, 1.1pulse(sys.meet, m('meet'));sys.focus(1, m('turn'));const steps = [['six', 1.5], ['off', 1.2], ['far', 1.1], ['gone', 1]];const trails = [sys.to({ a10: 1.5 }, m('six') - 1.2, 1.4, io, { trail: true })];steps.slice(1).forEach(([mk_, a]) => sys.to({ a10: a }, m(mk_) - .6, 1.2));steps.forEach(([mk_]) => flash(sys, 'a10', m(mk_) - .6));+ tw(sys.readout, { o: 0 }, m('gone') - .7, .2); tw(sys.readout, { o: 1 }, m('gone') + .7, .3);+ tw(sys.readout, { o: 0 }, m('back') - .2, .15); tw(sys.readout, { o: 1 }, m('back') + .6, .3); // the readout's runaway numbers stay out of sightsys.focus(null, m('run') - .5);// where they meet, step by step, under the readouttext(p, 'x number', 90, 470, m('meet'), { size: 26, fill: COL.dim }); text(p, 'they meet at', 260, 470, m('meet'), { size: 26, fill: COL.dim });@@ -418,7 +392,7 @@ const BEATS = [['Multiples: compare the right sides. Same multiple: one line. Not: parallel.', 'w3'],['Both sides times the same number (not 0): the line stays put.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 32, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/ch04/index.html b/site/linear-algebra/ch04/index.htmlindex b162e95..16b2d2d 100644--- a/site/linear-algebra/ch04/index.html+++ b/site/linear-algebra/ch04/index.html@@ -141,7 +141,7 @@ const BEATS = [const w = sz * 1.9, x0 = 300 - w / 2, t = mid - sz * 1.32, b = mid + sz * 1.32;const br = path(p, `M${x0 + 16} ${t}H${x0}V${b}H${x0 + 16}M${x0 + w - 16} ${t}H${x0 + w}V${b}H${x0 + w - 16}`, { stroke: COL.chalk, 'stroke-width': 3.5, fill: 'none' }, { d: 0 });draw(br, m('br'), .8);- text(p, 'a vector', 300, b + 52, m('name'), { size: 32, fill: COL.task, anchor: 'middle', weight: 600 });+ text(p, 'a vector', 300, b + 52, m('name'), { size: 32, fill: COL.chalk, anchor: 'middle', weight: 600 });say(p, ['v'], 170, y, m('v'), { size: sz, fill: GREEN, anchor: 'end' });say(p, ['='], 232, y, m('v') + .1, { size: sz, anchor: 'end' });[three, two].forEach(e => tw(e, { c_color: GREEN }, m('v') + .3, .6));@@ -210,12 +210,12 @@ const BEATS = [countWalk(vs.P, [0, 0], [3, 0], GREEN, m('right') + .8, 2.4, wv);countWalk(vs.P, [3, 0], [3, 2], GREEN, m('up') + .8, 1.6, wv);const trav = G(p, { o: 0 });- mk('circle', { r: 9, fill: COL.task }, trav);+ mk('circle', { r: 9, fill: COL.chalk }, trav);show(trav, m('tip') + 1.2, .3);prog(q => put(trav, { x: vs.P.PX(3 * q), y: vs.P.PY(2 * q) }), m('tip') + 1.6, 3.2, io);hide(trav, m('same') - .2, .3);vs.flash('v0', m('right')); vs.flash('v1', m('up') - .4);- vs.P.dot(0, 0, COL.task, m('tip'), { r: 8, label: '(0, 0)', dx: -84, dy: -14 });+ vs.P.dot(0, 0, COL.chalk, m('tip'), { r: 8, label: '(0, 0)', dx: -84, dy: -14 });vs.show('v', m('tip') + 4.4, .6);const pd = G(p, {}); vs.P.dot(3, 2, COL.chalk, m('same'), { r: 8, label: '(3, 2)', dx: 16, dy: 36, into: pd });const note = G(p, { o: 0 });@@ -274,8 +274,8 @@ const BEATS = [text(p, '−2: 2 down', 330, 632, m('ld') + 1.2, { size: 28, fill: COL.dim });hide(wu, m('sum') - .2, .4);const s = G(p, { o: 0 });- T(s, 'top number: − left, + right', { x: 90, y: 740, size: 30, weight: 600, fill: COL.task });- T(s, 'bottom number: − down, + up', { x: 90, y: 790, size: 30, weight: 600, fill: COL.task });+ T(s, 'top number: − left, + right', { x: 90, y: 740, size: 30, weight: 600, fill: COL.chalk });+ T(s, 'bottom number: − down, + up', { x: 90, y: 790, size: 30, weight: 600, fill: COL.chalk });show(s, m('sum'));['v0', 'w0', 'u0'].forEach((k, i) => vs.flash(k, m('sum') + 2.2 + i * .35));['v1', 'w1', 'u1'].forEach((k, i) => vs.flash(k, m('sum') + 4.8 + i * .35));@@ -318,11 +318,11 @@ const BEATS = [const vs = vecs(p, { vecs: { v: [-5, 2] }, show: [] });vs.label('v', []);const P2 = vs.P;- P2.dot(-5, 2, COL.task, m('pts'), { r: 10, label: '(−5, 2)', dx: -40, dy: -24 });+ P2.dot(-5, 2, COL.chalk, m('pts'), { r: 10, label: '(−5, 2)', dx: -40, dy: -24 });vs.show('v', m('vec'), .6);const ex = G(p, { o: 0 });- M(ex, ['(−5, 2)'], { x: 90, y: 330, size: 44, anchor: 'start', fill: COL.task });- M(ex, ['↔'], { x: 290, y: 330, size: 44, fill: COL.task, anchor: 'middle' });+ M(ex, ['(−5, 2)'], { x: 90, y: 330, size: 44, anchor: 'start', fill: COL.chalk });+ M(ex, ['↔'], { x: 290, y: 330, size: 44, fill: COL.chalk, anchor: 'middle' });colm(ex, -5, 2, 400, 330, { fill: GREEN });show(ex, m('vec') + .6, .6); hide(ex, m('so') - .3, .4);// "same numbers": the trip to (−5, 2) counted, 5 left and 2 up@@ -338,11 +338,11 @@ const BEATS = [P2.arrow(0, 0, x, y, COL.dim, t + .1, { into: fan });});const tips = G(p, { o: 0 });- fanPts.forEach(([x, y]) => mk('circle', { cx: P2.PX(x), cy: P2.PY(y), r: 9, fill: COL.task }, tips));+ fanPts.forEach(([x, y]) => mk('circle', { cx: P2.PX(x), cy: P2.PY(y), r: 9, fill: COL.chalk }, tips));show(tips, m('back'), .4); hide(tips, m('so'), .6);const eq = G(p, { o: 0 });M(eq, ['point (x, y)'], { x: 90, y: 330, size: 44, anchor: 'start' });- M(eq, ['↔'], { x: 400, y: 330, size: 44, fill: COL.task, anchor: 'middle' });+ M(eq, ['↔'], { x: 400, y: 330, size: 44, fill: COL.chalk, anchor: 'middle' });M(eq, ['vector'], { x: 460, y: 330, size: 44, anchor: 'start' });colm(eq, 'x', 'y', 660, 330, { fill: GREEN });show(eq, m('so'), .6);@@ -351,7 +351,7 @@ const BEATS = [T(d2, 'a vector: the trip from the origin to that place', { x: 90, y: 575, size: 32, weight: 600, fill: GREEN });show(d2, m('diff'), .6);const trav = G(p, { o: 0 });- mk('circle', { r: 10, fill: COL.task }, trav);+ mk('circle', { r: 10, fill: COL.chalk }, trav);show(trav, m('diff') + 2.4, .3);prog(q => put(trav, { x: P2.PX(-5 * q), y: P2.PY(2 * q) }), m('diff') + 2.6, 3, io);}],@@ -370,7 +370,7 @@ const BEATS = [text(p, '4 steps left → −4', 260, 300, m('top1') + .4, { size: 28, fill: COL.dim });show(c1.bot, m('bot1')); lightUp(c1.bot, m('bot1') + .2, GREEN);text(p, '1 step up → 1', 260, 380, m('bot1'), { size: 28, fill: COL.dim });- const b1 = G(p, {}); mk('rect', { x: 94, y: 244, width: 112, height: 144, rx: 12, fill: 'none', stroke: COL.task, 'stroke-width': 3 }, b1);+ const b1 = G(p, {}); mk('rect', { x: 94, y: 244, width: 112, height: 144, rx: 12, fill: 'none', stroke: COL.chalk, 'stroke-width': 3 }, b1);put(b1, { o: 0 }); show(b1, m('col1'), .4); hide(b1, m('a2'), .4);hide(w1, m('a2'), .4);vs.to({ v0: 2, v1: -5 }, m('a2') + .2, 1.4);@@ -383,7 +383,7 @@ const BEATS = [text(p, '2 steps right → 2', 260, 590, m('count3') + 1, { size: 28, fill: COL.dim });show(c2.bot, m('bot2')); lightUp(c2.bot, m('bot2') + .2, GREEN);text(p, '5 steps down → −5', 260, 670, m('bot2'), { size: 28, fill: COL.dim });- const b2 = G(p, {}); mk('rect', { x: 94, y: 534, width: 112, height: 144, rx: 12, fill: 'none', stroke: COL.task, 'stroke-width': 3 }, b2);+ const b2 = G(p, {}); mk('rect', { x: 94, y: 534, width: 112, height: 144, rx: 12, fill: 'none', stroke: COL.chalk, 'stroke-width': 3 }, b2);put(b2, { o: 0 }); show(b2, m('col2'), .4);tw(vs.A.v.path, { 'a_stroke-width': 9 }, m('col2'), .3); tw(vs.A.v.path, { 'a_stroke-width': 5 }, m('col2') + .8, .5);}],@@ -413,7 +413,7 @@ const BEATS = [stepTo(vs, 'v', [5, 2], [5, -1], m('minus') + .9, .5); vs.flash('v1', m('minus') + .9);// a hand takes the tip and pulls it; the tip jumps from grid point to grid point, as it does for the readerconst hand = G(p, { o: 0 }), { PX, PY } = vs.P;- mk('circle', { r: 20, fill: COL.task, 'fill-opacity': .25, stroke: COL.task, 'stroke-width': 3 }, hand);+ mk('circle', { r: 20, fill: COL.chalk, 'fill-opacity': .25, stroke: COL.chalk, 'stroke-width': 3 }, hand);put(hand, { x: PX(5), y: PY(-1) });show(hand, m('drag') + 1, .4);const t0 = m('pull'), dur = 2.4;@@ -433,7 +433,7 @@ const BEATS = [hide(hand, m('again') + 2.8, .4);vs.flash('v0', m('again2')); vs.flash('v1', m('again2'));const n = G(p, { o: 0 });- T(n, 'change a number → the arrow moves', { x: 90, y: 450, size: 32, weight: 600, fill: COL.task });+ T(n, 'change a number → the arrow moves', { x: 90, y: 450, size: 32, weight: 600, fill: COL.chalk });T(n, 'move the arrow → the numbers change', { x: 90, y: 505, size: 32, weight: 600, fill: GREEN });show(n, m('always'));}],@@ -460,7 +460,7 @@ const BEATS = [showRow(r, m(n)); vs.show(n, m(n) + .3, .6);});const e = G(p, { o: 0 });- T(e, 'equal: top = top and bottom = bottom', { x: 90, y: 760, size: 30, weight: 600, fill: COL.task });+ T(e, 'equal: top = top and bottom = bottom', { x: 90, y: 760, size: 30, weight: 600, fill: COL.chalk });show(e, m('eq'));['v', 'w', 'u'].forEach((id, i) => [2, 3.6].forEach(dt => { tw(vs.A[id].path, { 'a_stroke-width': 9 }, m('eq') + dt + i * .15, .3); tw(vs.A[id].path, { 'a_stroke-width': 5 }, m('eq') + dt + i * .15 + .6, .4); }));['v0', 'w0', 'u0'].forEach(k => vs.flash(k, m('eq') + 2));@@ -491,7 +491,7 @@ const BEATS = [['Negative numbers point left or down; zero on top and below is the zero vector, a dot.', 'w3'], ['Change the numbers, the arrow moves; move the arrow, the numbers change.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });const dg = G(g, { x: 150, y: -12 });- mk('circle', { r: 26, fill: COL.task }, dg);+ mk('circle', { r: 26, fill: COL.chalk }, dg);T(dg, String(i + 1), { x: 0, y: 11, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 34, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/ch05/index.html b/site/linear-algebra/ch05/index.htmlindex eed914e..8b89f0b 100644--- a/site/linear-algebra/ch05/index.html+++ b/site/linear-algebra/ch05/index.html@@ -33,7 +33,7 @@ const slideIn = (vs, id, tail, t0, dur = 1.6) => {show(a.lab, t0 + .4 + dur, .4);};// A dot that makes a trip along a list of plane points, one leg after another.-const travel = (p, P, pts, t0, leg = 1.4, color = COL.task) => {+const travel = (p, P, pts, t0, leg = 1.4, color = COL.chalk) => {const d = G(p, { o: 0 });mk('circle', { r: 10, fill: color, stroke: COL.board, 'stroke-width': 2 }, d);put(d, { x: P.PX(pts[0][0]), y: P.PY(pts[0][1]) });@@ -69,14 +69,14 @@ const ringAt = (P, x, y, t0, into) => { // the amber target of a taskconst lightUp = (e, t0, base = COL.chalk) => { tw(e, { c_color: COL.task }, t0, .25); tw(e, { c_color: base }, t0 + 1.2, .6); };// A curved arrow from one number to another, arched over (up) or under the row: "this one goes there".const centre = e => { const b = e.getBBox(); return [b.x + b.width / 2, b.y + b.height / 2, b.height]; };-const curve = (p, a, b, t0, { color = COL.task, up = true, dur = .7 } = {}) => {+const curve = (p, a, b, t0, { color = COL.chalk, up = true, dur = .7 } = {}) => {const [ax, ay, ah] = centre(a), [bx, by, bh] = centre(b), sy = up ? -1 : 1;const y0 = ay + sy * ah * .6, y1 = by + sy * bh * .6, top = (up ? Math.min(y0, y1) : Math.max(y0, y1)) + sy * 36;const e = path(p, `M${ax} ${y0}C${ax} ${top} ${bx} ${top} ${bx} ${y1}`, { stroke: color, 'stroke-width': 3, fill: 'none', 'stroke-linecap': 'round', 'stroke-dasharray': '2 0' }, { d: 0 });draw(e, t0, dur);return e;};-const boxAround = (p, els, t0, color = COL.task) => {+const boxAround = (p, els, t0, color = COL.chalk) => {const bs = els.map(e => e.getBBox()), x = Math.min(...bs.map(b => b.x)) - 10, y = Math.min(...bs.map(b => b.y)) - 6;const w = Math.max(...bs.map(b => b.x + b.width)) + 10 - x, hh = Math.max(...bs.map(b => b.y + b.height)) + 6 - y;const r = path(p, `M${x + 10} ${y}H${x + w - 10}Q${x + w} ${y} ${x + w} ${y + 10}V${y + hh - 10}Q${x + w} ${y + hh} ${x + w - 10} ${y + hh}H${x + 10}Q${x} ${y + hh} ${x} ${y + hh - 10}V${y + 10}Q${x} ${y} ${x + 10} ${y}Z`, { stroke: color, 'stroke-width': 3, fill: 'none' }, { d: 0 });@@ -123,12 +123,16 @@ const BEATS = [const r = text(scene, 'v + w, and c times v: with the numbers and with the arrows', 800, 510, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });// a small tip-to-tail sum, drawn as the narration says "picture"const pic = G(scene, { o: 0 }), o = [690, 780];- const ar = (d, c, t0) => draw(path(pic, d, { stroke: c, 'stroke-width': 6, 'stroke-linecap': 'round', fill: 'none' }, { d: 0 }), t0, .7);- ar(`M${o[0]} ${o[1]}l120 -30`, GREEN, m('both') + .2);- ar(`M${o[0] + 120} ${o[1] - 30}l40 -80`, VIOLET, m('both') + .9);- ar(`M${o[0]} ${o[1]}l160 -110`, COL.task, m('both') + 1.6);- ar(`M${o[0] + 260} ${o[1]}l90 -45`, GREEN, m('both') + 2.2);- ar(`M${o[0] + 260} ${o[1]}l180 -90`, GREEN, m('both') + 2.8);+ const ar = (x, y, dx, dy, c, t0) => { // a line from (x, y) by (dx, dy), then its head+ const L = Math.hypot(dx, dy), ux = dx / L, uy = dy / L, tx = x + dx, ty = y + dy;+ const d = `M${x} ${y}L${tx} ${ty}M${tx - 16 * ux + 9 * uy} ${ty - 16 * uy - 9 * ux}L${tx} ${ty}L${tx - 16 * ux - 9 * uy} ${ty - 16 * uy + 9 * ux}`;+ draw(path(pic, d, { stroke: c, 'stroke-width': 6, 'stroke-linecap': 'round', 'stroke-linejoin': 'round', fill: 'none' }, { d: 0 }), t0, .7);+ };+ ar(o[0], o[1], 120, -30, GREEN, m('both') + .2);+ ar(o[0] + 120, o[1] - 30, 40, -80, VIOLET, m('both') + .9);+ ar(o[0], o[1], 160, -110, COL.task, m('both') + 1.6);+ ar(o[0] + 260, o[1], 180, -90, GREEN, m('both') + 2.8);+ ar(o[0] + 260, o[1], 90, -45, GREEN, m('both') + 2.2);show(pic, m('both'), .3);tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(pic, D - .9, .8);}],@@ -150,7 +154,7 @@ const BEATS = [boxAround(lk, [st0, st1], m('res') + .2);hide(lk, m('ex2') - .3, .4);const n = G(p, { o: 0 });- T(n, 'tops add to tops, bottoms add to bottoms: they never mix', { x: 90, y: 480, size: 30, weight: 600, fill: COL.task });+ T(n, 'tops add to tops, bottoms add to bottoms: they never mix', { x: 90, y: 480, size: 30, weight: 600, fill: COL.chalk });show(n, m('never'));lightUp(ft, m('never') + 2.4); lightUp(st0, m('never') + 2.4, COL.task); lightUp(fb, m('never') + 4.6); lightUp(st1, m('never') + 4.6, COL.task);showRow(rb, m('ex2'), 0, 7);@@ -183,6 +187,7 @@ const BEATS = [vs.legs(['v', 'dw'], m('match') - .2, false); vs.legs('sum', m('match'));vs.legs('sum', m('ex2') - .3, false); hide(end, m('ex2') - .3, .3); hide(vs.A.w.g, m('ex2') - .3, .3); // the faded first w would ride along as a stray arrowvs.flash('sum0', m('match')); vs.flash('sum1', m('match'));+ prog(q => { vs.A.dw.nudge = [34 * q, 0]; }, m('ex2') + .9, 2.4); // w's label off the y-axis: its middle ends at (0, ½)vs.to({ v0: 2, v1: -1, w0: -4, w1: 3 }, m('ex2') + .9, 2.4);thick(vs, 'dw', m('follow') + .3); thick(vs, 'sum', m('follow') + 1.3, 6);vs.flash('sum0', m('read') + .4); vs.flash('sum1', m('read') + .4);@@ -194,7 +199,7 @@ const BEATS = [const vs = vecs(p, { vecs: { v: [3, 1], w: [1, 2] }, show: ['v', 'dw', 'sum'], plane: ZOOM.order });vs.label('sum', ['v + w']);const { PX, PY } = vs.P;- const par = path(p, `M${PX(0)} ${PY(0)}L${PX(3)} ${PY(1)}L${PX(4)} ${PY(3)}L${PX(1)} ${PY(2)}Z`, { fill: COL.task, stroke: 'none' }, { o: 0 });+ const par = path(p, `M${PX(0)} ${PY(0)}L${PX(3)} ${PY(1)}L${PX(4)} ${PY(3)}L${PX(1)} ${PY(2)}Z`, { fill: COL.chalk, stroke: 'none' }, { o: 0 });vs.P.g.insertBefore(par, vs.P.g.lastChild);tw(par, { o: .14 }, m('para'), .8);vs.show('dw0', m('wv'), .6);@@ -210,7 +215,7 @@ const BEATS = [const bx = G(p, {});boxAround(bx, [a0], m('nums') + .6); boxAround(bx, [b0], m('nums') + 1.4);boxAround(bx, [a1], m('nums') + 4.2, VIOLET); boxAround(bx, [b1], m('nums') + 5, VIOLET);- say(p, ['v + w = w + v'], 90, 730, m('rule'), { size: 54, fill: COL.task });+ say(p, ['v + w = w + v'], 90, 730, m('rule'), { size: 54, fill: COL.chalk });}],['q1', 'Quick check', () => {@@ -232,7 +237,7 @@ const BEATS = [vRow(vs, 'v', GREEN, 250, 1); vRow(vs, 'w', VIOLET, 430, 1);vs.row([{ t: 'v', fill: GREEN }, '+', { t: 'w', fill: VIOLET }, '=', { fn: v => [`${vs.fmt(v.v0)} + ${vs.paren(v.w0)}`, `${vs.fmt(v.v1)} + ${vs.paren(v.w1)}`], w: 46 * 4.2 }, '=', { col: 'sum' }], { x: 90, y: 610 });const { PX, PY } = vs.P, hand = G(p, { o: 0 });- mk('circle', { r: 20, fill: COL.task, 'fill-opacity': .25, stroke: COL.task, 'stroke-width': 3 }, hand);+ mk('circle', { r: 20, fill: COL.chalk, 'fill-opacity': .25, stroke: COL.chalk, 'stroke-width': 3 }, hand);put(hand, { x: PX(4), y: PY(3) });show(hand, m('grab') + .6, .4);prog(q => { // the tip of w snaps from grid point to grid point, as it does for the reader@@ -243,9 +248,9 @@ const BEATS = [hide(hand, m('rule'), .4);vs.flash('w0', m('pull') + .5); vs.flash('w1', m('pull') + .5); vs.flash('sum0', m('sum')); vs.flash('sum1', m('sum'));const ce = G(p, { x: PX(5), y: PY(-1), o: 0 });- mk('circle', { r: 18, fill: 'none', stroke: COL.task, 'stroke-width': 4 }, ce);+ mk('circle', { r: 18, fill: 'none', stroke: COL.chalk, 'stroke-width': 4 }, ce);show(ce, m('rule'), .3); pulse(ce, m('rule') + .6, 1.4); pulse(ce, m('rule') + 2, 1.4); hide(ce, m('scrub'), .3);- text(p, 'v + w ends where w ends', 90, 770, m('rule'), { size: 28, fill: COL.task, weight: 600 });+ text(p, 'v + w ends where w ends', 90, 770, m('rule'), { size: 28, fill: COL.chalk, weight: 600 });vs.to({ v0: 3, v1: 1, w0: 2, w1: -2 }, m('rule') - .1, .01); // the plan catches up with the handvs.to({ v0: 1 }, m('move'), 1.6); vs.flash('v0', m('scrub') + 1.6);vs.flash('sum0', m('sum2') + .3);@@ -286,7 +291,7 @@ const BEATS = [vs.flash('v0', m('rule') + 2); vs.flash('cv0', m('rule') + 2.6); vs.flash('v1', m('rule') + 3.8); vs.flash('cv1', m('rule') + 4.4); // "two times two is four, two times one is two"vs.legs('cv', m('t3') + .4); vs.legs('cv', m('long3') + 2, false);const cr2 = vs.row([{ t: 'c' }, '=', { key: 'c' }], { x: 90, y: 600, size: 40, o: 0 }); showRow(cr2, m('name') + .4); // the number's name, live- text(p, 'the number in front: a scalar (it scales v)', 290, 590, m('name') + .4, { size: 30, fill: COL.task, weight: 600 });+ text(p, 'the number in front: a scalar (it scales v)', 290, 590, m('name') + .4, { size: 30, fill: COL.chalk, weight: 600 });vs.to({ c: 3 }, m('three') + .2, 1.4); vs.flash('c', m('three') + .2);vs.flash('cv0', m('t3') + .2); vs.flash('cv1', m('t3') + 1.8);thick(vs, 'cv', m('long3'));@@ -297,8 +302,8 @@ const BEATS = [text(p, 'Shrink, flip, vanish', 60, 110, .2, { size: 40, weight: 600 });const vs = vecs(p, { vecs: { v: [2, 1] }, c: 3, show: ['v', 'cv'] });vs.dim('v', .3, .35);- vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, '=', { key: 'c' }, { col: 'v', fixed: true }, '=', { fn: v => [`${vs.fmt(v.c)}·${vs.paren(v.v0)}`, `${vs.fmt(v.c)}·${vs.paren(v.v1)}`], w: 150 }, '=', { col: 'cv' }], { x: 90, y: 250 });- const note = (str, y, t0, fill = COL.task) => text(p, str, 90, y, t0, { size: 30, fill, weight: 600 });+ vs.row([{ key: 'c', one: true }, { t: 'v', fill: GREEN }, '=', { key: 'c', one: true }, { col: 'v', fixed: true }, '=', { fn: v => [`${vs.fmt(v.c)}·${vs.paren(v.v0)}`, `${vs.fmt(v.c)}·${vs.paren(v.v1)}`], w: 150 }, '=', { col: 'cv' }], { x: 90, y: 250 }); // c = −1 is said and flashed: written −1+ const note = (str, y, t0, fill = COL.chalk) => text(p, str, 90, y, t0, { size: 30, fill, weight: 600 });vs.to({ c: .5 }, m('half') + .2, 1.4); vs.flash('c', m('half') + .2);vs.flash('cv0', m('th') + .2); vs.flash('cv1', m('th') + 1.5);note('c = ½: half as long', 420, m('short'));@@ -313,11 +318,11 @@ const BEATS = [const trail = G(p, {});[-3, -2, -1, 0, 1, 2, 3].forEach(k => {const t = m('line') + .6 + (k + 3) / 6 * 4;- vs.P.dot(2 * k, k, COL.task, t, { r: 6, into: trail, label: k >= -1 && k !== 2 && k !== -1 ? undefined : k === -1 ? "−v" : `${num(k)}v`, dx: 12, dy: 26 });+ vs.P.dot(2 * k, k, COL.chalk, t, { r: 6, into: trail, label: k >= -1 && k !== 2 && k !== -1 ? undefined : k === -1 ? "−v" : `${num(k)}v`, dx: 12, dy: 26 });});vs.to({ c: -3 }, m('line'), .6);vs.to({ c: 3 }, m('line') + .6, 4, lin);- vs.P.line(-6, -3, 6, 3, COL.task, m('all'), { dash: '10 10', w: 3, into: trail });+ vs.P.line(-6, -3, 6, 3, COL.chalk, m('all'), { dash: '10 10', w: 3, into: trail });note('every multiple of v: on the line through v', 670, m('all') + .4, COL.chalk);}],@@ -336,7 +341,7 @@ const BEATS = [vs.dim('v', m('bt'), .4); vs.show('cv', m('bt') + .1, .6);vs.flash('cv0', m('bt') + .6); vs.flash('cv1', m('bt') + 2.8);vs.legs('cv', m('bt') + .4); vs.legs('cv', m('br') + 3, false);- text(p, '(−) × (−) = (+)', 90, 520, m('sign'), { size: 34, fill: COL.task, weight: 600 });+ text(p, '(−) × (−) = (+)', 90, 520, m('sign'), { size: 34, fill: COL.chalk, weight: 600 });thick(vs, 'cv', m('br') + .6); thick(vs, 'v', m('br') + 2.4);text(p, 'twice as long, the opposite way', 90, 580, m('br') + 1, { size: 30, fill: COL.dim });}],@@ -381,7 +386,7 @@ const BEATS = [vs.show('sum', m('end'), .6);const gap = G(p, {});vs.P.arrow(1, 2, 3, 1, COL.task, m('gap') + .6, { into: gap });- text(p, 'from the tip of w to the tip of v', 90, 600, m('gap') + .6, { size: 28, fill: COL.task, weight: 600 });+ text(p, 'from the tip of w to the tip of v', 90, 600, m('gap') + .6, { size: 28, fill: COL.chalk, weight: 600 });travel(p, vs.P, [[0, 0], [1, 2], [3, 1]], m('why') + .4, 1.3);say(p, ['w + (v − w) = v'], 90, 680, m('why') + 1, { size: 40 });}],@@ -412,7 +417,7 @@ const BEATS = [show(legs, m('steps') + .2, .5); hide(legs, m('slide') - .2, .3);tw(gap, { x: -4 * u, y: 1 * u }, m('slide') + .4, 2);vs.show('sum', m('same'), .4); hide(gap, m('same') + .4, .3); thick(vs, 'sum', m('same') + .5, 6);- text(p, 'moved without turning: still the same vector', 90, 440, m('same') + .3, { size: 28, fill: COL.task, weight: 600 });+ text(p, 'moved without turning: still the same vector', 90, 440, m('same') + .3, { size: 28, fill: COL.chalk, weight: 600 });// check: w, then v − w placed at its tip, ends on vconst back = G(p, { o: 0 });vs.P.arrow(4, 1, 2, 3, COL.task, 0, { into: back });@@ -439,12 +444,12 @@ const BEATS = [['c·v: multiply both numbers by c (stretch, shrink, flip, vanish).', 'w3'], ['v − w = v + (−1)·w.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });const dg = G(g, { x: 150, y: -12 });- mk('circle', { r: 26, fill: COL.task }, dg);+ mk('circle', { r: 26, fill: COL.chalk }, dg);T(dg, String(i + 1), { x: 0, y: 11, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });const tl = T(g, str, { x: 210, size: 36, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);pulse(dg, m('end') + i * .3, 1.25);- const next = ['w2', 'w3', 'w4', 'end'][i], ul = path(g, `M210 16H${210 + tl.getComputedTextLength()}`, { stroke: COL.task, 'stroke-width': 3, 'stroke-opacity': .6 }, { d: 0 });+ const next = ['w2', 'w3', 'w4', 'end'][i], ul = path(g, `M210 16H${210 + tl.getComputedTextLength()}`, { stroke: COL.chalk, 'stroke-width': 3, 'stroke-opacity': .6 }, { d: 0 });draw(ul, m(mark) + .5, Math.max(1, m(next) - m(mark) - 1), lin);});}],diff --git a/site/linear-algebra/ch06/index.html b/site/linear-algebra/ch06/index.htmlindex 626d897..a8790bf 100644--- a/site/linear-algebra/ch06/index.html+++ b/site/linear-algebra/ch06/index.html@@ -29,14 +29,14 @@ const thick = (vs, id, t0, w = 5) => { tw(vs.A[id].path, { 'a_stroke-width': w +const pairStr = (x, y) => `(${num(x)}, ${num(y)})`;// A curved arrow from one number to another, arched over (up) or under the row: "this one goes there".const centre = e => { const b = e.getBBox(); return [b.x + b.width / 2, b.y + b.height / 2, b.height]; };-const curve = (p, a, b, t0, { color = COL.task, up = true, dur = .7 } = {}) => {+const curve = (p, a, b, t0, { color = COL.chalk, up = true, dur = .7 } = {}) => {const [ax, ay, ah] = centre(a), [bx, by, bh] = centre(b), sy = up ? -1 : 1;const y0 = ay + sy * ah * .6, y1 = by + sy * bh * .6, top = (up ? Math.min(y0, y1) : Math.max(y0, y1)) + sy * 36;const e = path(p, `M${ax} ${y0}C${ax} ${top} ${bx} ${top} ${bx} ${y1}`, { stroke: color, 'stroke-width': 3, fill: 'none', 'stroke-linecap': 'round' }, { d: 0 });draw(e, t0, dur);return e;};-const boxAround = (p, els, t0, color = COL.task) => {+const boxAround = (p, els, t0, color = COL.chalk) => {const bs = els.map(e => e.getBBox()), x = Math.min(...bs.map(b => b.x)) - 10, y = Math.min(...bs.map(b => b.y)) - 6;const w = Math.max(...bs.map(b => b.x + b.width)) + 10 - x, hh = Math.max(...bs.map(b => b.y + b.height)) + 6 - y;const r = path(p, `M${x + 10} ${y}H${x + w - 10}Q${x + w} ${y} ${x + w} ${y + 10}V${y + hh - 10}Q${x + w} ${y + hh} ${x + w - 10} ${y + hh}H${x + 10}Q${x} ${y + hh} ${x} ${y + hh - 10}V${y + 10}Q${x} ${y} ${x + 10} ${y}Z`, { stroke: color, 'stroke-width': 3, fill: 'none' }, { d: 0 });@@ -61,7 +61,8 @@ const comboLabel = vs => v => {return [`${term(v.c, 'v')} ${v.d < 0 ? '−' : '+'} ${term(Math.abs(v.d), 'w')}`];};// c v + d w = c [v] + d [w] (first line), and = [c v] + [d w] = [sum] or = [c·v0 + d·w0, …] = [sum] (second line).-const line1 = (vs, y, o = 0, size = 42) => vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { key: 'c' }, { col: 'v', fixed: true }, { key: 'd', signed: true }, { col: 'w', fixed: true }], { x: 70, y, size, o });+// c and d are what this chapter looks for: a 1 is written ("one v plus two w"), except where one = false (special: "v + w")+const line1 = (vs, y, o = 0, size = 42, one = true) => vs.row([{ key: 'c', one }, { t: 'v', fill: GREEN }, { key: 'd', signed: true, one }, { t: 'w', fill: VIOLET }, '=', { key: 'c', one }, { col: 'v', fixed: true }, { key: 'd', signed: true, one }, { col: 'w', fixed: true }], { x: 70, y, size, o });const line2 = (vs, y, o = 0, size = 42) => vs.row(['=', { col: 'cv', fixed: true }, '+', { col: 'dw', fixed: true }, '=', { col: 'sum', fixed: true }], { x: 160, y, size, o });const line2x = (vs, y, o = 0, size = 42) => vs.row(['=', { fn: v => [`${vs.fmt(v.c)}·${vs.paren(v.v0)} + ${vs.fmt(v.d)}·${vs.paren(v.w0)}`, `${vs.fmt(v.c)}·${vs.paren(v.v1)} + ${vs.fmt(v.d)}·${vs.paren(v.w1)}`], w: 360 }, '=', { col: 'sum', fixed: true }], { x: 160, y, size, o });const lecture = (p, o = {}) => { const vs = vecs(p, { vecs: { v: LV, w: LW }, ...o }); vs.label('sum', comboLabel(vs)); return vs; };@@ -83,7 +84,7 @@ const ringAt = (P, x, y, t0, into, color = COL.task, left = false) => { // lef// c and d are found at each one, as they are for the reader.const handPath = (p, vs, pts, t0, leg = 1.6) => {const { PX, PY } = vs.P, hand = G(p, { o: 0 });- mk('circle', { r: 20, fill: COL.task, 'fill-opacity': .25, stroke: COL.task, 'stroke-width': 3 }, hand);+ mk('circle', { r: 20, fill: COL.chalk, 'fill-opacity': .25, stroke: COL.chalk, 'stroke-width': 3 }, hand);put(hand, { x: PX(pts[0][0]), y: PY(pts[0][1]) });show(hand, t0 - .4, .3);pts.slice(1).forEach((b, i) => {@@ -133,8 +134,12 @@ const BEATS = [tw(g, { o: 1, y: 0 }, .2, 1.1, out);const r = text(scene, 'c v + d w: stretch two vectors, then add', 800, 510, m('sub'), { size: 36, fill: COL.dim, anchor: 'middle' });const pic = G(scene, { o: 0 }), o = [740, 790];- const ar = (d, c, t0) => draw(path(pic, d, { stroke: c, 'stroke-width': 6, 'stroke-linecap': 'round', fill: 'none' }, { d: 0 }), t0, .7);- ar(`M${o[0]} ${o[1]}l80 40`, GREEN, m('sub') + 1.2); ar(`M${o[0] + 80} ${o[1] + 40}l-80 -160`, VIOLET, m('sub') + 1.9); ar(`M${o[0]} ${o[1]}l0 -120`, COL.task, m('sub') + 2.6);+ const ar = (x, y, dx, dy, c, t0) => { // a line from (x, y) by (dx, dy), then its head+ const L = Math.hypot(dx, dy), ux = dx / L, uy = dy / L, tx = x + dx, ty = y + dy;+ const d = `M${x} ${y}L${tx} ${ty}M${tx - 16 * ux + 9 * uy} ${ty - 16 * uy - 9 * ux}L${tx} ${ty}L${tx - 16 * ux - 9 * uy} ${ty - 16 * uy + 9 * ux}`;+ draw(path(pic, d, { stroke: c, 'stroke-width': 6, 'stroke-linecap': 'round', 'stroke-linejoin': 'round', fill: 'none' }, { d: 0 }), t0, .7);+ };+ ar(o[0], o[1], 80, 40, GREEN, m('sub') + 1.2); ar(o[0] + 80, o[1] + 40, -80, -160, VIOLET, m('sub') + 1.9); ar(o[0], o[1], 0, -120, COL.task, m('sub') + 2.6);show(pic, m('sub') + 1, .3);tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(pic, D - .9, .8);}],@@ -169,7 +174,7 @@ const BEATS = [vs.dim(['v', 'w'], m('pic'), .25); hide(vs.A.v.lab, m('pic'), .3); hide(vs.A.w.lab, m('pic'), .3);thick(vs, 'cv', m('pic') + .3);// a traveller makes the trip: along 1v, then along 2w, and stops at (0, 3)- const trip = G(vs.P.g, { o: 0 }); mk('circle', { r: 10, fill: COL.task, stroke: COL.board, 'stroke-width': 2 }, trip);+ const trip = G(vs.P.g, { o: 0 }); mk('circle', { r: 10, fill: COL.chalk, stroke: COL.board, 'stroke-width': 2 }, trip);put(trip, { x: vs.P.PX(0), y: vs.P.PY(0) }); show(trip, m('pic') + .3, .3);prog(q => put(trip, { x: vs.P.PX(2 * q), y: vs.P.PY(-q) }), m('pic') + .6, 1.4);prog(q => put(trip, { x: vs.P.PX(2 - 2 * q), y: vs.P.PY(-1 + 4 * q) }), m('end') - .5, 1.2);@@ -180,7 +185,7 @@ const BEATS = [vs.show('sum', m('end') + .7, .6);vs.P.dot(0, 3, COL.task, m('end') + .7, { r: 9, label: '(0, 3)', dx: -80, dy: 8 });const nm = G(p, { o: 0 });- T(nm, 'c v + d w: a linear combination of v and w', { x: 70, y: 600, size: 32, weight: 600, fill: COL.task });+ T(nm, 'c v + d w: a linear combination of v and w', { x: 70, y: 600, size: 32, weight: 600, fill: COL.chalk });show(nm, m('name'));text(p, 'keep in mind: v = [2, −1], w = [−1, 2], 1v + 2w = [0, 3]', 70, 660, m('keep'), { size: 26, fill: COL.dim });void s0;@@ -219,8 +224,8 @@ const BEATS = [const p = panel(0);text(p, 'Old friends are combinations too', 60, 110, .2, { size: 40, weight: 600 });const vs = lecture(p, { c: -1, d: 1, show: ['cv', 'dw', 'sum'] });- line1(vs, 240, 1);- const note = (str, y, t0) => text(p, str, 70, y, t0, { size: 32, fill: COL.task, weight: 600 });+ line1(vs, 240, 1, 42, false); // c = 1, d = 1 reads v + w+ const note = (str, y, t0) => text(p, str, 70, y, t0, { size: 32, fill: COL.chalk, weight: 600 });vs.to({ c: 1, d: 1 }, m('sum'), 1.2); note('c = 1, d = 1: v + w', 400, m('sum') + .6);vs.to({ c: 1, d: -1 }, m('diff'), 1.2); note('c = 1, d = −1: v − w', 460, m('diff') + .6);vs.to({ c: 2, d: 0 }, m('onlyv'), 1.2); note('d = 0: just c v', 520, m('onlyv') + .6);@@ -259,7 +264,7 @@ const BEATS = [text(p, 'd changes: the tip slides along w', 70, 475, m('dpath'), { size: 30, fill: VIOLET, weight: 600 });hide(tr, m('both') + .2, .4);vs.to({ c: 2, d: -1 }, m('both') + .4, 1.4); vs.to({ c: 0, d: 1 }, m('both') + 1.9, 1.4); // a wander first- text(p, 'both: anywhere you steer', 70, 530, m('both') + .3, { size: 30, fill: COL.task, weight: 600 });+ text(p, 'both: anywhere you steer', 70, 530, m('both') + .3, { size: 30, fill: COL.chalk, weight: 600 });// two worked steers, each written out and its landing point markedconst sumRow = vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { col: 'sum', fixed: true }], { x: 70, y: 680, size: 42, o: 0 });[['s1', 2, 3, 1, 4], ['s2', -1, -2, 0, -3]].forEach(([k, c, d, x, y]) => {@@ -281,7 +286,7 @@ const BEATS = [const ring = ringAt(vs.P, 0, 3, m('target'), p, COL.task, true);pulse(ring, m('ask') + .3, 1.6); pulse(ring, m('ask') + 1.4, 1.6);['c', 'd'].forEach(k => vs.flash(k, m('ask') + .8));- const o = vs.P.dot(0, 0, COL.task, m('start'), { r: 8 }); pulse(o, m('start') + .6, 1.8);+ const o = vs.P.dot(0, 0, COL.chalk, m('start'), { r: 8 }); pulse(o, m('start') + .6, 1.8);vs.to({ c: .5 }, m('start') + 1.6, .8); vs.to({ c: 0 }, m('start') + 2.6, .8); // a first nudge: c moves the tip along vvs.to({ c: 1 }, m('up'), 1.2); vs.flash('c', m('up'));vs.to({ d: 1 }, m('d1'), 1); vs.flash('d', m('d1'));@@ -299,7 +304,7 @@ const BEATS = [vs.flash('c', m('p11') + .6); vs.flash('d', m('p11') + .6);handPath(p, vs, [[1, 1], [1, 0]], m('p10') - .4, 1.2);vs.flash('c', m('p10') + 2); vs.flash('d', m('p10') + 3.6);- text(p, 'c and d can be fractions', 70, 600, m('frac'), { size: 30, fill: COL.task, weight: 600 });+ text(p, 'c and d can be fractions', 70, 600, m('frac'), { size: 30, fill: COL.chalk, weight: 600 });}],['q2', 'Your turn', () => {@@ -327,7 +332,7 @@ const BEATS = [// values in passing are thirds here: only whole c and d get names on the arrowsconst whole = v => Number.isInteger(v.c) && Number.isInteger(v.d), lab = comboLabel(vs);vs.label('cv', v => whole(v) ? (v.c === 1 ? ['v'] : [vs.fmt(v.c) + 'v']) : []); vs.label('dw', v => whole(v) ? (v.d === 1 ? ['w'] : [vs.fmt(v.d) + 'w']) : []);- vs.label('sum', v => whole(v) ? lab(v) : []);+ vs.label('sum', []); // the hand sits on its tip: the row above names the combinationconst ax = G(p, {});vs.P.line(0, 0, 2, -1, GREEN, m('grid') + .3, { w: 4, into: ax });vs.P.line(0, 0, -1, 2, VIOLET, m('grid') + 1.3, { w: 4, into: ax });@@ -348,7 +353,7 @@ const BEATS = [const all = path(p, `M${vs.P.PX(-6)} ${vs.P.PY(6)}H${vs.P.PX(6)}V${vs.P.PY(-6)}H${vs.P.PX(-6)}Z`, { fill: COL.task, stroke: 'none' }, { o: 0 });vs.P.g.insertBefore(all, vs.P.g.lastChild);tw(all, { o: .12 }, m('plane'), 1);- text(p, 'c v + d w reaches every point of the plane', 70, 420, m('plane'), { size: 30, fill: COL.task, weight: 600 });+ text(p, 'c v + d w reaches every point of the plane', 70, 420, m('plane'), { size: 30, fill: COL.chalk, weight: 600 });}],['count', 'Reading c and d off the grid', (m) => {@@ -384,10 +389,16 @@ const BEATS = [const vs = lecture(p, { c: 1, d: 1, show: ['v', 'w'] });vs.row([{ t: 'v', fill: GREEN }, '=', { col: 'v', fixed: true }, ' ', { t: 'w', fill: VIOLET }, '=', { col: 'w', fixed: true }], { x: 70, y: 240, size: 42 });vs.lattice(.3, true, .6);+ // lines closer than a few px shimmer (moiré): the grid fades out as it squashes, leaving the line (span)+ vs.onChange(v => {+ const det = Math.abs(v.v0 * v.w1 - v.v1 * v.w0), gap = det / Math.max(Math.hypot(v.v0, v.v1), Math.hypot(v.w0, v.w1), 1e-9) * vs.P.u;+ const o = String(Math.max(0, Math.min(1, (gap - 12) / 20)));+ [...vs.latticeG.children].slice(0, 3).forEach(e => { if (e.style.opacity !== o) e.style.opacity = o; });+ });vs.to({ w0: 4, w1: -2 }, m('turn') + .3, m('par') - m('turn') - .3, lin);const w2 = say(p, ['w = 2v'], 70, 420, m('par'), { size: 44, fill: VIOLET }); hide(w2, m('ex2'), .3);const n1 = text(p, 'the grid squashes flat', 70, 480, m('squash'), { size: 28, fill: COL.dim });- const n2 = text(p, 'every combination: on one line', 70, 530, m('line'), { size: 30, fill: COL.task, weight: 600 });+ const n2 = text(p, 'every combination: on one line', 70, 530, m('line'), { size: 30, fill: COL.chalk, weight: 600 });// steering on the line: whatever c and d are, the tip stays on itvs.show('sum', m('try'), .4); // only the combination: its two parts lie on the same line and would hide each othervs.to({ c: 2, d: -1 }, m('try') + .5, 1.2); vs.to({ c: -1, d: -1 }, m('try') + 1.9, 1.4); vs.to({ c: 1, d: -1 }, m('try') + 3.5, 1.4);@@ -399,11 +410,12 @@ const BEATS = [// a second pair on one linevs.hide('sum', m('ex2') - .2, .3);[n1, n2].forEach(e => hide(e, m('ex2'), .3));+ tw(vs.latticeG, { o: 0 }, m('ex2'), .2); tw(vs.latticeG, { o: 1 }, m('ex2') + 1.9, .4); // no grid flashing up between the two pairsvs.to({ v0: 1, v1: 1, w0: -2, w1: -2, c: 1, d: 1 }, m('ex2') + .2, 1.6);vs.flash('v0', m('ex2') + 1.6); vs.flash('v1', m('ex2') + 1.6); vs.flash('w0', m('ex2') + 3.6); vs.flash('w1', m('ex2') + 3.6);hide(say(p, ['w = −2v'], 70, 420, m('x2'), { size: 44, fill: VIOLET }), m('rule'), .3);thick(vs, 'v', m('x2') + .4); thick(vs, 'w', m('x2') + 1.4); thick(vs, 'v', m('x2') + 2.8); thick(vs, 'w', m('x2') + 3.8);- hide(text(p, 'every combination: on the line through (1, 1)', 70, 530, m('line2'), { size: 30, fill: COL.task, weight: 600 }), m('rule'), .3);+ hide(text(p, 'every combination: on the line through (1, 1)', 70, 530, m('line2'), { size: 30, fill: COL.chalk, weight: 600 }), m('rule'), .3);vs.show('sum', m('line2') + .2, .4);vs.to({ c: 3, d: 2 }, m('line2') + .4, 1); vs.to({ c: -2, d: -2 }, m('line2') + 1.5, 1); // the tip runs along the line y = xvs.hide('sum', m('rule') - .2, .3);@@ -432,12 +444,12 @@ const BEATS = [['Two vectors in different directions reach every point.', 'w3'], ['Two vectors on one line reach only that line.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });const dg = G(g, { x: 150, y: -12 });- mk('circle', { r: 26, fill: COL.task }, dg);+ mk('circle', { r: 26, fill: COL.chalk }, dg);T(dg, String(i + 1), { x: 0, y: 11, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });const tl = T(g, str, { x: 210, size: 36, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);pulse(dg, m('end') + i * .3, 1.25);- const next = ['w2', 'w3', 'w4', 'end'][i], ul = path(g, `M210 16H${210 + tl.getComputedTextLength()}`, { stroke: COL.task, 'stroke-width': 3, 'stroke-opacity': .6 }, { d: 0 });+ const next = ['w2', 'w3', 'w4', 'end'][i], ul = path(g, `M210 16H${210 + tl.getComputedTextLength()}`, { stroke: COL.chalk, 'stroke-width': 3, 'stroke-opacity': .6 }, { d: 0 });draw(ul, m(mark) + .5, Math.max(1, m(next) - m(mark) - 1), lin);});}],diff --git a/site/linear-algebra/ch07/index.html b/site/linear-algebra/ch07/index.htmlindex 3e07aa9..2c394d9 100644--- a/site/linear-algebra/ch07/index.html+++ b/site/linear-algebra/ch07/index.html@@ -43,7 +43,7 @@ const colPic = (p, A, opts = {}) => {};// x [col 1] + y [col 2] = [b], and below it the amounts: 1 [col 1] + 2 [col 2] = [b]const colEq = (vs, x, y, size = 40, o = 1) => vs.row([{ t: 'x' }, { col: 'v', fixed: true }, '+', { t: 'y' }, { col: 'w', fixed: true }, '=', { col: 'sum', fixed: true }], { x, y, size, o });-const colAmt = (vs, x, y, size = 40, o = 1) => vs.row([{ key: 'c' }, { col: 'v', fixed: true }, { key: 'd', signed: true }, { col: 'w', fixed: true }, '=', { col: 'sum', fixed: true }], { x, y, size, o });+const colAmt = (vs, x, y, size = 40, o = 1) => vs.row([{ key: 'c', one: true }, { col: 'v', fixed: true }, { key: 'd', signed: true, one: true }, { col: 'w', fixed: true }, '=', { col: 'sum', fixed: true }], { x, y, size, o });// Row picture (linsys, left) and column picture (vecs, right) of one system, linked both ways:// change the system or b on the left and the mix follows on the right; drag b on the right and the lines follow.let twinN = 0;@@ -186,7 +186,7 @@ const BEATS = [show(sys.meetBox, m('meet'), .5); pulse(sys.meet, m('meet') + .5, 1.6);show(sys.readout, m('ans'), .5);const n = G(p, { o: 0 });- T(n, 'row picture: the solution is where the lines meet', { x: 90, y: 560, size: 30, weight: 600, fill: COL.task });+ T(n, 'row picture: the solution is where the lines meet', { x: 90, y: 560, size: 30, weight: 600, fill: COL.chalk });show(n, m('name'));sys.lines.forEach((l, i) => { tw(l.l, { 'a_stroke-width': 9 }, m('name') + .4 + i * .5, .3); tw(l.l, { 'a_stroke-width': 5 }, m('name') + 1.1 + i * .5, .4); });}],@@ -224,13 +224,13 @@ const BEATS = [const eq = vs.row([{ t: 'x' }, { col: 'v', fixed: true }, '+', { t: 'y' }, { col: 'w', fixed: true }, '=', { col: 'sum', fixed: true }], { x: 120, y: 540, size: 54, o: 0 });showRow(eq, m('eq'), 0, 2); showRow(eq, m('eq') + 2.4, 2, 5); showRow(eq, m('eq') + 4.6, 5, 7);const top = [vs.num('v0').pop(), vs.num('w0').pop(), vs.num('sum0').pop()], bot = [vs.num('v1').pop(), vs.num('w1').pop(), vs.num('sum1').pop()];- const hl = (els, t0, dur) => els.forEach(e => { tw(e, { c_color: COL.task }, t0, .3); tw(e, { c_color: e.getAttribute('color') }, t0 + dur, .5); });- hl(top, m('top') + .4, m('bot') - m('top') - .8);- hide(rbox(p, 150, 460, 510, 60, COL.task, m('top') + .3), m('bot') - .2, .4); // read across the top- hide(rbox(p, 150, 530, 510, 60, COL.task, m('bot') + .3), m('same'), .4); // then across the bottom+ const hl = (els, t0, dur, c) => els.forEach(e => { tw(e, { c_color: c }, t0, .3); tw(e, { c_color: e.getAttribute('color') }, t0 + dur, .5); }); // in the row's colour+ hl(top, m('top') + .4, m('bot') - m('top') - .8, BLUE);+ hide(rbox(p, 150, 460, 510, 60, BLUE, m('top') + .3), m('bot') - .2, .4); // read across the top+ hide(rbox(p, 150, 530, 510, 60, CORAL, m('bot') + .3), m('same'), .4); // then across the bottomsay(p, ['x·2 + y·(−1) = 0'], 120, 720, m('top') + .6, { size: 40 });say(p, ['→ 2x − y = 0'], 520, 720, m('top') + 4.2, { size: 40, fill: BLUE });- hl(bot, m('bot') + .4, m('same') - m('bot') - .6);+ hl(bot, m('bot') + .4, m('same') - m('bot') - .6, CORAL);say(p, ['x·(−1) + y·2 = 3'], 120, 790, m('bot') + .6, { size: 40 });say(p, ['→ −x + 2y = 3'], 520, 790, m('bot') + 4.4, { size: 40, fill: CORAL });rbox(p, 100, 670, 820, 150, COL.good, m('same') + .3);@@ -254,7 +254,7 @@ const BEATS = [[0, 2, 3, 5].forEach(i => show(rb.parts[i], m('ch6') + 5)); show(rb.parts[6], m('ch6') + 6.2);say(p, ['c = 1, d = 2'], 70, 570, m('found'), { size: 40, fill: COL.task });// the same equation: dashed links, partner to partner, as the narration pairs them- [[1, .3], [4, 1.1], [0, 2.8], [3, 3.5], [6, 5.6]].forEach(([i, dt]) => draw(path(p, `M${ctr(i)} 296V350`, { stroke: COL.task, 'stroke-width': 3, 'stroke-dasharray': '5 6', fill: 'none' }, { d: 0 }), m('here') + dt, .4));+ [[1, .3], [4, 1.1], [0, 2.8], [3, 3.5], [6, 5.6]].forEach(([i, dt]) => draw(path(p, `M${ctr(i)} 296V350`, { stroke: COL.chalk, 'stroke-width': 3, 'stroke-dasharray': '5 6', fill: 'none' }, { d: 0 }), m('here') + dt, .4));const amt = colAmt(vs, 70, 680, 42, 0);vs.show(['v', 'w'], m('seen'), .6);thick(vs, 'v', m('ch6') + 1.6); thick(vs, 'w', m('ch6') + 3.4);@@ -273,7 +273,7 @@ const BEATS = [tw(vs.A.dw.g, { o: 1 }, m('plus'), .3); tw(vs.A.dw.g, { x: 0, y: 0 }, m('plus') + .4, 1.4);vs.show('sum', m('lands'), .6); thick(vs, 'sum', m('lands') + .6, 6);const nm = G(p, { o: 0 });- T(nm, 'column picture: the solution is the mix that makes b', { x: 70, y: 780, size: 28, weight: 600, fill: COL.task });+ T(nm, 'column picture: the solution is the mix that makes b', { x: 70, y: 780, size: 28, weight: 600, fill: COL.chalk });show(nm, m('name'));}],@@ -303,15 +303,15 @@ const BEATS = [const ea = va.row([{ t: 'x' }, { col: 'v', fixed: true }, '+', { t: 'y' }, { col: 'w', fixed: true }, '=', { col: 'sum', fixed: true }], { x: 560, y: 250, size: 42, o: 0 });showRow(ea, m('ax') + 1, 0, 2); showRow(ea, m('ay') + 1, 2, 5); showRow(ea, m('ab') + .8, 5, 7);// 1·[1, 3] + 2·[4, −1] = [1, 3] + [8, −2] = [1 + 8, 3 − 2] = [9, 1]: every step on the board- const ca = va.row([{ key: 'c' }, { col: 'v', fixed: true }, { key: 'd', signed: true }, { col: 'w', fixed: true }, '=', { fn: () => ['1', '3'], w: 56, fill: GREEN }, '+', { fn: () => ['8', '−2'], w: 66, fill: VIOLET },+ const ca = va.row([{ key: 'c', one: true }, { col: 'v', fixed: true }, { key: 'd', signed: true, one: true }, { col: 'w', fixed: true }, '=', { fn: () => ['1', '3'], w: 56, fill: GREEN }, '+', { fn: () => ['8', '−2'], w: 66, fill: VIOLET },'=', { fn: () => ['1 + 8', '3 − 2'], w: 130 }, '=', { col: 'sum', fixed: true }], { x: 560, y: 400, size: 38, o: 0 });showRow(ca, m('acheck'), 0, 4); showRow(ca, m('acheck') + 3.4, 4, 6); showRow(ca, m('acheck') + 4.8, 6, 8);const fns = va.num('fn'), [ft, fb] = fns.slice(4); put(fb, { o: 0 }); showRow(ca, m('acheck') + 6.4, 8, 10); show(fb, m('acheck2'));showRow(ca, m('acheck2') + 1.6, 10, 12); [ft, fb].forEach(e => lightUp(e, m('acheck2') + 1.8));const sb = sysText(p, [['', '', 'y', '2'], ['x', '−', '3y', '0']], 120, 600, { size: 46, gap: 70, o: 0 });show(sb, m('b'));- say(p, ['0x'], 120 + 100 * .92, 600, m('bx') + .6, { size: 46, fill: COL.task, anchor: 'end' });- say(p, ['+'], 120 + 162 * .92, 600, m('bx') + .6, { size: 46, fill: COL.task, anchor: 'middle' });+ say(p, ['0x'], 120 + 100 * .92, 600, m('bx') + .6, { size: 46, fill: COL.chalk, anchor: 'end' });+ say(p, ['+'], 120 + 162 * .92, 600, m('bx') + .6, { size: 46, fill: COL.chalk, anchor: 'middle' });boxCol(p, sb, 0, GREEN, m('bx') + 1.2); boxCol(p, sb, 1, VIOLET, m('by')); boxCol(p, sb, 2, COL.task, m('bb'));const vb = colPic(p, [[0, 1], [1, -3]], { c: 6, d: 2, hidePlane: true, show: [] });const eb = vb.row([{ t: 'x' }, { col: 'v', fixed: true }, '+', { t: 'y' }, { col: 'w', fixed: true }, '=', { col: 'sum', fixed: true }], { x: 560, y: 640, size: 42, o: 0 });@@ -336,6 +336,11 @@ const BEATS = [const p = panel(0);text(p, 'Change b: both pictures follow', 60, 110, .2, { size: 40, weight: 600 });const { sys, vs } = twin(p, LA, LB);+ // with b up and left (−3, 3), col 2's label would sit on b's arrow: it goes right of the y-axis, level with its tip+ vs.onChange((v, k) => {+ const n = k.sum[0] < -1.5 && k.sum[1] > 1.5 ? [92, 14] : [-14, 0];+ if (vs.A.w.nudge?.[0] !== n[0]) { vs.A.w.nudge = n; vs.redraw(); }+ });flashLs(sys, 'b0', m('change')); flashLs(sys, 'b1', m('change')); vs.flash('sum0', m('change')); vs.flash('sum1', m('change'));sys.to({ b0: 3, b1: 0 }, m('to30') + .2, 1.8);pulse(sys.meet, m('rows') + 1.6, 1.6);@@ -345,7 +350,7 @@ const BEATS = [pulse(sys.meet, m('ag2') + .4, 1.6); vs.flash('c', m('ag2') + 1.6); vs.flash('d', m('ag2') + 1.6);// a hand drags b in the column picture; the tip snaps to grid points, x and y are found at eachconst { PX, PY } = vs.P, hand = G(p, { o: 0 });- mk('circle', { r: 18, fill: COL.task, 'fill-opacity': .25, stroke: COL.task, 'stroke-width': 3 }, hand);+ mk('circle', { r: 18, fill: COL.chalk, 'fill-opacity': .25, stroke: COL.chalk, 'stroke-width': 3 }, hand);put(hand, { x: PX(1), y: PY(1) });show(hand, m('drag') + .4, .3);prog(q => {@@ -426,7 +431,7 @@ const BEATS = [show(ring, m('miss') + 1, .3); pulse(ring, m('miss') + 1.4, 1.6);text(p, 'no mix of the columns reaches b', 860, 318, m('miss') + 1.6, { size: 26, fill: COL.bad, weight: 600 });sys.lines.forEach((l, i) => { tw(l.l, { 'a_stroke-width': 9 }, m('rowp') + .8 + i * .5, .3); tw(l.l, { 'a_stroke-width': 5 }, m('rowp') + 1.5 + i * .5, .4); });- text(p, 'no solution, seen two ways', 800, 886, m('both'), { size: 30, fill: COL.task, weight: 600, anchor: 'middle' });+ text(p, 'no solution, seen two ways', 800, 886, m('both'), { size: 30, fill: COL.chalk, weight: 600, anchor: 'middle' });}],['q3', 'Quick check', () => {@@ -439,7 +444,7 @@ const BEATS = [}, { ask: done => quiz(CARD, [{id: 'c-mix', prompt: ['How much of each column makes ', $m('b'), '?'],build: blanks([{ parts: ['x = ', { box: '2' }, ' y = ', { box: '1' }], why: '2·[2, 1] + 1·[1, 3] = [4 + 1, 2 + 3] = [5, 5].',- hint: 'Top: 2x + y must be 5. Bottom: x + 3y must be 5. Try small whole numbers.',+ hint: 'Top: 2x + y = 5. Bottom: x + 3y = 5. Try y = 1: the top needs 2x = 4.',fx: () => ['cv', 'dw'].forEach((id, i) => fx(S.vs.A[id].g, { o: 1 }, i * .5, .5)) }]),}], done) }],@@ -449,12 +454,12 @@ const BEATS = [['Column picture: the solution is the mix of columns that makes b.', 'w3'], ['Both pictures always give the same answer.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });const dg = G(g, { x: 150, y: -12 });- mk('circle', { r: 26, fill: COL.task }, dg);+ mk('circle', { r: 26, fill: COL.chalk }, dg);T(dg, String(i + 1), { x: 0, y: 11, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });const tl = T(g, str, { x: 210, size: 34, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);pulse(dg, m('end') + i * .3, 1.25);- const next = ['w2', 'w3', 'w4', 'end'][i], ul = path(g, `M210 16H${210 + tl.getComputedTextLength()}`, { stroke: COL.task, 'stroke-width': 3, 'stroke-opacity': .6 }, { d: 0 });+ const next = ['w2', 'w3', 'w4', 'end'][i], ul = path(g, `M210 16H${210 + tl.getComputedTextLength()}`, { stroke: COL.chalk, 'stroke-width': 3, 'stroke-opacity': .6 }, { d: 0 });draw(ul, m(mark) + .5, Math.max(1, m(next) - m(mark) - 1), lin);});}],@@ -488,10 +493,10 @@ const BEATS = [['play', 'Playground', (m) => {const p = panel(0);text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });- S.T2 = twin(p, LA, LB, { rows: false });+ S.T2 = twin(p, LA, LB, { eqAt: null, amtAt: m('go') }); // the amounts row under the card: it follows b, and scrubbing it moves btext(p, 'try: make the two lines parallel', 420, 846, m('go'), { size: 24, fill: COL.dim, anchor: 'middle' });text(p, 'try: line the columns up, or put b on col 1', 1180, 846, m('go') + .6, { size: 24, fill: COL.dim, anchor: 'middle' });- }, { ask: playAsk(() => twinPlay(S.T2), { pos: { x: 640, y: 24, w: 930, cls: 'side' }, tip: 'Change any number on the left; drag col 1, col 2 or b on the right. Nothing is marked.' }) }],+ }, { ask: playAsk(() => twinPlay(S.T2), { pos: { x: 640, y: 24, w: 930, cls: 'side' }, tip: 'Change any number on the left, or drag col 1, col 2 or b on the right.' }) }],['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));diff --git a/site/linear-algebra/ch08/index.html b/site/linear-algebra/ch08/index.htmlindex 7115709..bdca176 100644--- a/site/linear-algebra/ch08/index.html+++ b/site/linear-algebra/ch08/index.html@@ -79,8 +79,6 @@ function pick(group, test) {[...group.children].filter(c => c !== sub && test(...(() => { const [x, y, w, hh] = boxOf(c); return [x + w / 2, y + hh / 2, c]; })())).forEach(c => sub.append(c));return sub;}-// The equations of a linsys, one group per row (so a beat can bring them in one at a time).-const eqRowGroups = sys => [pick(sys.E, (x, y) => y < EQ[1] + 46 - 20), pick(sys.E, (x, y) => y >= EQ[1] + 26)];// The pieces of the matrix form: A's bracket and label, the x column, '=', b's bracket and label (entries stay put).function matParts(sys) {const entries = new Set(['a00', 'a01', 'a10', 'a11', 'b0', 'b1'].map(k => matText(sys, k)));@@ -211,7 +209,7 @@ const BEATS = [frame(p, 80, 572, 134, 96, COLC[0], m('c1'), m('c2')); thick(sys.cols[0], m('c1') + .3);frame(p, 214, 572, 168, 96, COLC[1], m('c2'), m('c3')); thick(sys.cols[1], m('c2') + .3);frame(p, 428, 572, 98, 96, COL.task, m('c3'), m('mix')); thick(sys.bArrow, m('c3') + .3);- say(p, ['1·col 1 + 2·col 2 = b'], 90, 760, m('mix') + .3, { size: 34, fill: COL.task });+ say(p, ['1·col 1 + 2·col 2 = b'], 90, 760, m('mix') + .3, { size: 34, fill: COL.chalk });sys.combo.forEach((c, i) => { put(c, { o: 0 }); show(c, m('mix') + .4 + i * 1.2, .5); }); // tip to tail on "one of the first … two of the second"thick(sys.bArrow, m('mix') + 2.6);// the letters, again and again; then only the numbers matter@@ -235,12 +233,13 @@ const BEATS = [tw(matText(sys, key), { o: 1 }, t0 + 1.15, .25);};const mid = (k) => { const [x, , w] = termBox(sys, k); return x + w / 2; };+ Object.values(parts).forEach(g => tw(g, { o: .3 }, m('r1'), .4)); // the empty table is there, faint, before the numbers land in itfly('a00', '2', [mid('a00') - 10, EQ[1]], m('r1') + .4, COLC[0]);- text(p, '−y = −1·y', 590, EQ[1], m('one') + .2, { size: 30, fill: COL.task, weight: 600 });- frame(p, ...(([x, y, w, hh]) => [x - 8, y - 6, w + 16, hh + 12])(termBox(sys, 'a01')), COL.task, m('one'), m('r2'));+ text(p, '−y = −1·y', 590, EQ[1], m('one') + .2, { size: 30, fill: COL.chalk, weight: 600 });+ frame(p, ...(([x, y, w, hh]) => [x - 8, y - 6, w + 16, hh + 12])(termBox(sys, 'a01')), COL.chalk, m('one'), m('r2'));fly('a01', '−1', [mid('a01'), EQ[1]], m('one') + 2.6, COLC[1]);- text(p, '−x = −1·x', 590, EQ[1] + 92, m('r2') + .4, { size: 30, fill: COL.task, weight: 600 });- frame(p, ...(([x, y, w, hh]) => [x - 8, y - 6, w + 16, hh + 12])(termBox(sys, 'a10')), COL.task, m('r2'), m('r2') + 2.6);+ text(p, '−x = −1·x', 590, EQ[1] + 92, m('r2') + .4, { size: 30, fill: COL.chalk, weight: 600 });+ frame(p, ...(([x, y, w, hh]) => [x - 8, y - 6, w + 16, hh + 12])(termBox(sys, 'a10')), COL.chalk, m('r2'), m('r2') + 2.6);fly('a10', '−1', [mid('a10'), EQ[1] + 92], m('r2') + 2, COLC[0]);fly('a11', '2', [mid('a11') - 10, EQ[1] + 92], m('r2') + 4.2, COLC[1]);show(parts.A, m('box'), .5);@@ -281,9 +280,9 @@ const BEATS = [tw(sys.lines[i].l, { 'a_stroke-width': 10 }, t + 3, .35); tw(sys.lines[i].l, { 'a_stroke-width': 5 }, t + 4.2, .6);});text(p, 'how A times x works: chapter 9', 90, 760, m('next') + .5, { size: 28, fill: COL.dim });- frame(p, EQ[0] - 50, EQ[1] - 56, 540, 160, COL.task, m('short') + .6);- frame(p, MAT[0] - 14, MAT[1] - 64, 500, 244, COL.task, m('short') + 1.6);- text(p, 'the same system', 330, 338, m('short') + 2.4, { size: 28, fill: COL.task, anchor: 'middle', weight: 600 });+ frame(p, EQ[0] - 50, EQ[1] - 56, 540, 160, COL.chalk, m('short') + .6);+ frame(p, MAT[0] - 14, MAT[1] - 64, 500, 244, COL.chalk, m('short') + 1.6);+ text(p, 'the same system', 330, 338, m('short') + 2.4, { size: 28, fill: COL.chalk, anchor: 'middle', weight: 600 });['a00', 'a01', 'a10', 'a11', 'b0', 'b1'].forEach((k, i) => flash(sys, k, m('short') + 2.2 + i * .2));}],@@ -307,10 +306,10 @@ const BEATS = [tw(sys.cols[1], { 'a_stroke-width': 10 }, m('arrows') + 5.4, .3); tw(sys.cols[1], { 'a_stroke-width': 5 }, m('arrows') + 6.8, .5);text(p, 'one column = one unknown = one arrow', 90, 730, m('arrows') + .3, { size: 30, weight: 600, fill: COLC[0] });const sz = G(p, { o: 0 });- M(sz, ['2 by 2'], { x: 90, y: 810, size: 44, fill: COL.task, anchor: 'start' });+ M(sz, ['2 by 2'], { x: 90, y: 810, size: 44, fill: COL.chalk, anchor: 'start' });T(sz, '2 rows, 2 columns', { x: 260, y: 808, size: 28, fill: COL.dim });show(sz, m('size') + .4);- text(p, 'rows first', 520, 808, m('first') + .2, { size: 28, fill: COL.task, weight: 600 });+ text(p, 'rows first', 520, 808, m('first') + .2, { size: 28, fill: COL.chalk, weight: 600 });}],['entry', 'Every number has an address', (m) => {@@ -321,8 +320,8 @@ const BEATS = [[0, 1].forEach(i => text(p, `row ${i + 1}`, MAT[0] - 46, MX.row[i] - 6, 1.2 + i * .4, { size: 24, fill: ROWC[i], anchor: 'end', weight: 600 }));[0, 1].forEach(j => text(p, `column ${j + 1}`, MX.col[j] + (j ? 22 : -6), MX.row[0] - 88, 2.6 + j * .4, { size: 22, fill: COLC[j], anchor: 'middle', weight: 600 }));const rm = G(p, { o: 0, x: MAT[0] - 28, y: MX.row[0] - 16 }), cm = G(p, { o: 0, x: MX.col[0], y: MX.row[0] - 68 });- path(rm, 'M-12 -10L4 0L-12 10Z', { fill: COL.task });- path(cm, 'M-10 -12L0 4L10 -12Z', { fill: COL.task });+ path(rm, 'M-12 -10L4 0L-12 10Z', { fill: COL.chalk });+ path(cm, 'M-10 -12L0 4L10 -12Z', { fill: COL.chalk });const go = (i, j, t) => { tw(rm, { y: MX.row[i] - 16 }, t, .7); tw(cm, { x: MX.col[j] }, t + .8, .7); };show(rm, m('a21') + .6, .3); show(cm, m('a21') + .6, .3);go(1, 0, m('a21') + 1.4);@@ -345,11 +344,11 @@ const BEATS = [rowBand(p, 1, m('rule') + .3, m('rule') + 3);colBand(p, 0, m('rule') + 2.2, m('sub'));const sub = G(p, { o: 0 });- M(sub, ['a₂₁ = −1'], { x: 90, y: 815, size: 40, fill: COL.task, anchor: 'start' });+ M(sub, ['a₂₁ = −1'], { x: 90, y: 815, size: 40, fill: COL.chalk, anchor: 'start' });T(sub, 'row 2, column 1', { x: 290, y: 812, size: 28, fill: COL.dim });show(sub, m('sub') + 1);rings(sys, 'a10', p, m('sub') + 1, m('try'));- text(p, 'point at any number', 520, 690, m('try') + .3, { size: 28, fill: COL.task, weight: 600 });+ text(p, 'point at any number', 520, 690, m('try') + .3, { size: 28, fill: COL.chalk, weight: 600 });text(p, 'in the matrix or the equations', 520, 730, m('try') + .6, { size: 24, fill: COL.dim });// a pointer that visits two numbers, the way the reader canconst ptr = G(p, { o: 0 });@@ -385,11 +384,12 @@ const BEATS = [text(p, 'One number, two places', 60, 110, .2, { size: 40, weight: 600 });const sys = S.sys = sysOf(p, [[2, -1], [-1, 2]], [0, 3], { view: 'both' });sys.labels(['col 1', 'col 2', 'b']);+ ['a00', 'a01', 'a10', 'a11', 'b0', 'b1'].forEach((k, i) => rings(sys, k, p, .8 + i * .9, 1.6 + i * .9, { tag: false })); // "the same numbers": each pair in turnrings(sys, 'a10', p, m('pick'), m('turn') + 2);const ghost = sys.P.line(0, 1.5, 3, 3, LS_ROW[1], m('flip'), { dash: '10 10', w: 3, into: p }); tw(ghost, { o: .35 }, m('flip') + .6, .4);sys.to({ a10: 1 }, m('flip'), 1.2);flash(sys, 'a10', m('both'));- const bx_ = text(p, '−x becomes +x', 90, EQ[1] + 150, m('both') + .4, { size: 30, fill: COL.task, weight: 600 }); hide(bx_, m('b'), .3);+ const bx_ = text(p, '−x becomes +x', 90, EQ[1] + 150, m('both') + .4, { size: 30, fill: COL.chalk, weight: 600 }); hide(bx_, m('b'), .3);{ const gh = sys.P.arrow(0, 0, 2, -1, LS_COLS[0], m('col'), { into: p }); gh.setAttribute('stroke-dasharray', '8 8'); tw(gh, { o: .5 }, m('col') + .5, .3); hide(gh, m('b'), .4); }tw(sys.lines[1].l, { 'a_stroke-width': 10 }, m('turn') + .3, .35); tw(sys.lines[1].l, { 'a_stroke-width': 5 }, m('turn') + 1.5, .6);tw(sys.cols[0], { 'a_stroke-width': 10 }, m('col') + .4, .35); tw(sys.cols[0], { 'a_stroke-width': 5 }, m('col') + 1.8, .6);@@ -435,7 +435,7 @@ const BEATS = [show(A.g, m('rows3'));[0, 1, 2].forEach(i => { band(A1, 156, 440 + i * 62 - 42, 156, 58, ROWC[i], m('rows3') + .2 + i * .4, m('cols2')); band(A1, 70, 190 + i * 70 - 44, 340, 60, ROWC[i], m('rows3') + .2 + i * .4, m('cols2')); });[0, 1].forEach(j => band(A1, 160 + 78 * j + 3, 395, 72, 186, COLC[j], m('cols2') + .2 + j * .4, m('lines3')));- const sz = G(A1, { o: 0 }); M(sz, ['3 by 2'], { x: 150, y: 640, size: 40, fill: COL.task, anchor: 'start' }); T(sz, '3 rows, 2 columns', { x: 150, y: 690, size: 26, fill: COL.dim }); show(sz, m('cols2') + 1.5);+ const sz = G(A1, { o: 0 }); M(sz, ['3 by 2'], { x: 150, y: 640, size: 40, fill: COL.chalk, anchor: 'start' }); T(sz, '3 rows, 2 columns', { x: 150, y: 690, size: 26, fill: COL.dim }); show(sz, m('cols2') + 1.5);const xv = mtx(A1, [['x'], ['y']], 350, 471, { o: 0 }), eqs = M(A1, ['='], { x: 488, y: 516, size: 42, o: 0 }), bv = mtx(A1, [[3], [1], [5]], 520, 440, { o: 0 });bv.cells.flat().forEach(c => c.setAttribute('fill', COL.task));show(xv.g, m('xb') + .2); show(eqs, m('xb') + .2); show(bv.g, m('xb') + 1.6);@@ -454,11 +454,24 @@ const BEATS = [show(B.g, m('A23'));[0, 1].forEach(i => band(A2, 156, 440 + i * 62 - 42, 234, 58, ROWC[i], m('A23') + .2 + i * .4, m('A23') + 3));[0, 1, 2].forEach(j => band(A2, 160 + 78 * j + 3, 395, 72, 124, COLC[j], m('A23') + 3 + j * .4, m('x3')));- const sz2 = G(A2, { o: 0 }); M(sz2, ['2 by 3'], { x: 150, y: 640, size: 40, fill: COL.task, anchor: 'start' }); T(sz2, '2 rows, 3 columns', { x: 150, y: 690, size: 26, fill: COL.dim }); show(sz2, m('A23') + 4);+ const sz2 = G(A2, { o: 0 }); M(sz2, ['2 by 3'], { x: 150, y: 640, size: 40, fill: COL.chalk, anchor: 'start' }); T(sz2, '2 rows, 3 columns', { x: 150, y: 690, size: 26, fill: COL.dim }); show(sz2, m('A23') + 4);const xv2 = mtx(A2, [['x'], ['y'], ['z']], 430, 409, { o: 0 }), eq2 = M(A2, ['='], { x: 568, y: 485, size: 42, o: 0 }), bv2 = mtx(A2, [[4], [1]], 600, 440, { o: 0 });bv2.cells.flat().forEach(c => c.setAttribute('fill', COL.task));show(xv2.g, m('x3')); show(eq2, m('x3')); show(bv2.g, m('x3') + 1.5);- text(A2, 'three unknowns live in space: chapter 11', 1160, 450, m('two3') + 2, { size: 28, fill: COL.dim, anchor: 'middle' });+ text(A2, 'three unknowns live in space: chapter 11', 1160, 790, m('two3') + 2, { size: 28, fill: COL.dim, anchor: 'middle' });+ // the two shapes side by side on the right, as grids of boxes: rows light up for the equations, columns for the unknowns+ const shape = (x0, y0, R, C, label, xs, t0, tRows, tCols) => {+ const g = G(A2, { o: 0 }), c = 64;+ for (let i = 0; i < R; i++) for (let j = 0; j < C; j++) mk('rect', { x: x0 + j * c, y: y0 + i * c, width: c - 8, height: c - 8, rx: 8, fill: 'none', stroke: COL.chalk, 'stroke-width': 2.5 }, g);+ M(g, [label], { x: x0 + C * c / 2 - 4, y: y0 + R * c + 52, size: 38, fill: COL.chalk });+ T(g, xs, { x: x0 + C * c / 2 - 4, y: y0 + R * c + 96, size: 24, fill: COL.dim, anchor: 'middle' });+ show(g, t0, .5);+ if (tRows !== undefined) for (let i = 0; i < R; i++) band(A2, x0 - 6, y0 + i * c - 6, C * c + 4, c + 4, ROWC[i], tRows + i * .4, tCols, .28);+ if (tCols !== undefined) for (let j = 0; j < C; j++) band(A2, x0 + j * c - 6, y0 - 6, c + 4, R * c + 4, COLC[j], tCols + j * .4, m('rule') + 2, .28);+ return g;+ };+ shape(930, 260, 3, 2, '3 by 2', '3 equations, 2 unknowns', m('two3') + .3);+ shape(1230, 260, 2, 3, '2 by 3', '2 equations, 3 unknowns', m('A23') - .2, m('A23') + .2, m('A23') + 2.2);const rule = G(A2, { o: 0 });T(rule, 'one row for each equation,', { x: 90, y: 770, size: 30, weight: 600, fill: ROWC[0] });T(rule, 'one column for each unknown', { x: 90, y: 815, size: 30, weight: 600, fill: COLC[0] });@@ -486,8 +499,8 @@ const BEATS = [['back', 'From the matrix to the equations', (m) => {const p = panel(0);text(p, 'From A, x, b back to the equations', 60, 110, .2, { size: 40, weight: 600 });- const sys = S.sys = sysOf(p, [[1, 4], [2, 0]], [9, 2], { t0: m('given') - .4 });- const [g0, g1] = eqRowGroups(sys);+ const sys = S.sys = sysOf(p, [[1, 4], [2, 0]], [9, 2], { t0: m('given') - .4, hideEq: true });+ const [g0, g1] = sys.eqRows.map(r => r.g); // each row waits for its wordsput(sys.ROWV, { o: 0 });// row 1 read with x and y, written out in full firstrowBand(p, 0, m('r1'), m('r2'), { eq: false, b: true });@@ -511,9 +524,9 @@ const BEATS = [frame(p, MX.xcol - 50, MAT[1] - 60, 100, 236, COL.chalk, m('r2') + 1, m('lines'));const full2 = G(p, {}); readRow(1, [2, 0, 2], [m('r2') + 1.4, m('r2') + 1.8, m('r2') + 2.8, m('r2') + 3.2, m('r2') + 4.2]).forEach(e => full2.append(e));hide(full2, m('zero') - .2, .4); show(g1, m('zero'));- text(p, '0y is nothing: 2x = 2', 90, EQ[1] + 150, m('zero') + 1.4, { size: 28, fill: COL.task, weight: 600 });+ text(p, '0y is nothing: 2x = 2', 90, EQ[1] + 150, m('zero') + 1.4, { size: 28, fill: COL.chalk, weight: 600 });rings(sys, 'a11', p, m('zero') + .3, m('zero') + 3, { tag: false });- { const [x, y, w, hh] = termBox(sys, 'a11'); const k = path(p, `M${x - 6} ${y + hh * .55}L${x + w + 6} ${y + hh * .45}`, { stroke: COL.task, 'stroke-width': 4 }, { d: 0 }); tw(k, { d: 1 }, m('zero') + 3.4, .5); }+ { const [x, y, w, hh] = termBox(sys, 'a11'); const k = path(p, `M${x - 6} ${y + hh * .55}L${x + w + 6} ${y + hh * .45}`, { stroke: COL.chalk, 'stroke-width': 4 }, { d: 0 }); tw(k, { d: 1 }, m('zero') + 3.4, .5); }show(sys.ROWV, m('lines'), .8);tw(sys.lines[1].l, { 'a_stroke-width': 10 }, m('lines') + 2.2, .35); tw(sys.lines[1].l, { 'a_stroke-width': 5 }, m('lines') + 3.6, .6);say(p, ['x = 1'], 1160 + 52 + 12, 450 + 52 * 5, m('lines') + 2.6, { size: 30, fill: LS_ROW[1] });@@ -574,7 +587,7 @@ const BEATS = [[['Ax = b is the system: A the numbers, x the unknowns, b the right sides.', 'w1'], ['Each row of A is one equation; each column belongs to one unknown.', 'w2'],['Size: rows first, then columns. 2 rows, 2 columns: 2 by 2.', 'w3'], ['Row 2, column 1: the second equation, in front of x. One number, two places.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 150 + i * 105, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 34, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);@@ -591,7 +604,7 @@ const BEATS = [fr(810, 590, 188, 170, COL.chalk, m('w1') + 2, m('w1') + 4); fr(1000, 590, 90, 170, COL.chalk, m('w1') + 4, m('w1') + 6); fr(1140, 590, 100, 170, COL.task, m('w1') + 6, m('w2'));[0, 1].forEach(i => { band(pic, 816, 640 + 70 * i - 44, 176, 62, ROWC[i], m('w2') + .5 + i * 1.2, m('w2') + 4); band(pic, 330, 640 + 70 * i - 44, 260, 62, ROWC[i], m('w2') + .5 + i * 1.2, m('w2') + 4); });[0, 1].forEach(j => band(pic, 830 + 74 * j, 590, 66, 170, COLC[j], m('w3') - 1.6 + j * .8, m('w3')));- const sz = text(pic, '2 by 2', 1300, 690, m('w3') + 1.5, { size: 40, fill: COL.task, weight: 600 }); hide(sz, m('w4'), .3);+ const sz = text(pic, '2 by 2', 1300, 690, m('w3') + 1.5, { size: 40, fill: COL.chalk, weight: 600 }); hide(sz, m('w4'), .3);fr(816, 670, 70, 60, COLC[0], m('w4') + .6, m('end'));fr(460 - eqs[1]._w / 2 - 10, 664, 62, 64, COLC[0], m('w4') + 1.6, m('end'));// change it in one place: both places changediff --git a/site/linear-algebra/ch09/index.html b/site/linear-algebra/ch09/index.htmlindex 837679d..3dc5b73 100644--- a/site/linear-algebra/ch09/index.html+++ b/site/linear-algebra/ch09/index.html@@ -196,7 +196,7 @@ const BEATS = [pulseAll(['a00', 'a01', 'a10', 'a11'].map(k => g.num(k)[0]), m('A') + .6, .9);pulseAll(['x0', 'x1'].map(k => g.num(k)[0]), m('x') + .4, .8);q.forEach((e, i) => { show(e, m('q') + .3 + i * .3, .3); pulse(e, m('q') + 1.6 + i * .3); });- text(p, 'two numbers to find', g.lay.r, 430, m('q') + 1, { size: 26, fill: COL.task, anchor: 'middle', weight: 600 });+ text(p, 'two numbers to find', g.lay.r, 430, m('q') + 1, { size: 26, fill: COL.chalk, anchor: 'middle', weight: 600 });const plan = G(p, { o: 0 });T(plan, '1. by columns', { x: 90, y: 560, size: 34, weight: 600, fill: COLC[0] });T(plan, '2. by rows', { x: 90, y: 615, size: 34, weight: 600, fill: ROWC[0] });@@ -295,7 +295,7 @@ const BEATS = [[g.axArrow, g.axDot, g.axLab].forEach(e => show(e, m('same') + .4, .5));pulse(g.axDot, m('same') + 1);const dot = G(p, { o: 0 });- T(dot, 'dot product', { x: 90, y: 700, size: 32, weight: 600, fill: COL.task });+ T(dot, 'dot product', { x: 90, y: 700, size: 32, weight: 600, fill: COL.chalk });T(dot, 'a row times a column: multiply, then add', { x: 90, y: 745, size: 28, fill: COL.dim });show(dot, m('dot') + 1);say(p, ['[2, 5] · [1, 2] = 12'], 90, 800, m('dot') + 5, { size: 34, fill: ROWC[0] });@@ -343,6 +343,14 @@ const BEATS = [frame(p, cx[1] - 130, cy[0] - 58, 260, 190, COLC[1], m('colway') + 1.5, m('rowway'));const cw = lineUp(p, [{ v: [2, 1], fill: COLC[0] }, '+', { v: [10, 6], fill: COLC[1] }, '=', { v: [12, 7], fill: COL.task }], 820, 610, { size: 42 });cw.forEach((r, k) => show(r.e, m('colway') + 3 + k * .5, .4));+ // each product's result flies to where it is used: into its column's stack, then into its row's sum+ const PR = [[2, 10], [1, 6]], resAt = (i, j) => [cx[j] + cells[i * 2 + j]._w / 2 - 13 * String(PR[i][j]).length, cy[i]];+ const feed = (i, j, to, t) => {+ const [x, y] = resAt(i, j), f = M(p, [String(PR[i][j])], { x, y, size: 46, anchor: 'middle', fill: COLC[j], o: 0 });+ show(f, t, .15); tw(f, { x: to[0], y: to[1], s: .9 }, t + .15, .7, io); hide(f, t + .8, .2);+ };+ [0, 1].forEach(j => [0, 1].forEach(i => feed(i, j, cw[j * 2].m.at(i, 0), m('colway') + 2.3 + j + i * .2)));+ [0, 1].forEach(i => [0, 1].forEach(j => feed(i, j, [1342 + j * 66 + (i && j ? -12 : 0), cy[i]], m('rowway') + .1 + i * 1.6 + j * .2)));text(p, 'columns, then add', 1420, 600, m('colway') + 5, { size: 26, fill: COLC[0], weight: 600, anchor: 'middle' });[0, 1].forEach(i => {frame(p, cx[0] - 130, cy[i] - 50, 520, 70, ROWC[i], m('rowway') + i * 1.6, m('same') + 2);@@ -377,8 +385,8 @@ const BEATS = [lineRow(0, [2, -1], 470, m('r1') + .2, '2x − y');lineRow(1, [-1, 2], 545, m('r2') + .2, '−x + 2y');// the rows: our two lines (linsys draws the equations and the row picture), then the columns- const sys = S.sys = linsys(p, { eq: [90, 636], mat: null, size: 44, sol: false, t0: m('A') + .5 }); // the plane from the start- const eg = G(p, { o: 0 }); eg.append(sys.E); show(eg, m('b') + 1, .5); // the equations wait for their words (linsys shows E at t0)+ const sys = S.sys = linsys(p, { eq: [90, 636], mat: null, size: 44, sol: false, hideEq: true, t0: m('A') + .5 }); // the plane from the start+ sys.eqRows.forEach(r => show(r.g, m('b') + 1, .5)); // the equations wait for their wordssys.lines.forEach((l, i) => { tw(l.l, { 'a_stroke-width': 9 }, m('b') + 1.4 + i * 3.4, .3); tw(l.l, { 'a_stroke-width': 5 }, m('b') + 2.8 + i * 3.4, .5); });sys.view('both', m('c') + .5, .8);sys.labels(['col 1', 'col 2', 'b']);@@ -406,8 +414,8 @@ const BEATS = [[0, 1].forEach(i => band(p, 96, A.at(i, 0)[1] - 50, 196, 68, ROWC[i], m('r') + .3 + i * 3, m('r') + 3 + i * 3));say(p, ['row 1: x + y = 5'], 70, 470, m('r') + .6, { size: 38, fill: ROWC[0] });say(p, ['row 2: x − y = 1'], 70, 530, m('r') + 3.6, { size: 38, fill: ROWC[1] });- const sys = S.sys = linsys(p, { A: [[1, 1], [1, -1]], b: [5, 1], eq: [90, 636], mat: null, size: 44, sol: false, t0: m('A') + .5 });- const eg = G(p, { o: 0 }); eg.append(sys.E); show(eg, m('r') + 6, .5);+ const sys = S.sys = linsys(p, { A: [[1, 1], [1, -1]], b: [5, 1], eq: [90, 636], mat: null, size: 44, sol: false, hideEq: true, t0: m('A') + .5 });+ sys.eqRows.forEach(r => show(r.g, m('r') + 6, .5));pulse(sys.meet, m('lines') + .6); pulse(sys.meet, m('lines') + 1.8);text(p, 'they meet at (3, 2)', 560, 670, m('lines') + .6, { size: 26, fill: ROWC[0], weight: 600 });// by columns: 3 of column 1, 2 of column 2@@ -582,7 +590,7 @@ const BEATS = [[['By columns: Ax = (first number of x)·column 1 + (second)·column 2 + …', 'w1'], ['By rows: each number of Ax is a row of A times x (a dot product).', 'w2'],['Both ways use the same products, so they always agree.', 'w3'], ['x: one number per column of A. Ax: one number per row.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 160 + i * 105, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 34, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);@@ -597,7 +605,7 @@ const BEATS = [[0, 1].forEach(i => band(p, 306, 660 + 56 * i - 38, 136, 52, ROWC[i], m('w2') + .6 + i * .7, m('w3')));say(p, ['1·[2, 1] + 2·[5, 3] = [12, 7]'], 800, 680, m('w1') + 2.5, { size: 34, fill: COLC[0] });say(p, ['2·1 + 5·2 = 12, 1·1 + 3·2 = 7'], 800, 740, m('w2') + 1.5, { size: 34, fill: ROWC[0] });- frame(p, 780, 630, 560, 140, COL.task, m('w3') + .5, m('w4'));+ frame(p, 780, 630, 560, 140, COL.chalk, m('w3') + .5, m('w4'));[0, 1].forEach(j => band(p, 300 + 10 + 66 * j + 3, 616, 60, 112, COLC[j], m('w4') + .5, m('w4') + 2.5)); band(p, 462, 616, 72, 112, COLC[0], m('w4') + 1, m('w4') + 2.5, .15);[0, 1].forEach(i => band(p, 306, 660 + 56 * i - 38, 136, 52, ROWC[i], m('w4') + 2.8 + i * .3, m('end'))); band(p, 610, 616, 80, 112, ROWC[0], m('w4') + 3.4, m('end'), .15);}],diff --git a/site/linear-algebra/ch10/index.html b/site/linear-algebra/ch10/index.htmlindex 985d4e3..e40d350 100644--- a/site/linear-algebra/ch10/index.html+++ b/site/linear-algebra/ch10/index.html@@ -80,7 +80,7 @@ const LANDQ = [{ A: [[1, 1], [0, 1]], pts: [[1, 2], [-1, 1], [3, -1]] },{ A: [[0, -1], [1, 0]], pts: [[1, 0], [2, 1], [-1, 3]] },];-const KINDS = [['st', 'Stretch', COL.irr, 'S'], ['fl', 'Flip', COL.nat, 'F'], ['sh', 'Shear', COL.real, 'H'], ['tu', 'Turn', COL.whole, 'T'], ['sq', 'Squash', COL.task, 'Q']];+const KINDS = [['st', 'Stretch', COL.irr, 'S'], ['fl', 'Flip', COL.nat, 'F'], ['sh', 'Shear', COL.real, 'H'], ['tu', 'Turn', COL.whole, 'T'], ['sq', 'Squash', COL.rat, 'Q']];const KINDQ = [{ A: [[3, 0], [0, 1]], ans: ['st'], why: '(1, 0) goes 3 times as far, (0, 1) stays: 3 times as wide.' },{ A: [[1, 0], [0, -1]], ans: ['fl'], why: '(0, 1) lands on (0, −1): a mirror image, upside down.' },@@ -138,13 +138,13 @@ const BEATS = [pts.forEach((q, i) => {const special = (q[0] === 1 && q[1] === 1) || (q[0] === 2 && q[1] === 0);mk('circle', { cx: g.P.PX(q[0]), cy: g.P.PY(q[1]), r: 6, fill: 'none', stroke: COL.chalk, 'stroke-opacity': .45, 'stroke-width': 2 }, ghosts);- const d = carry(g, q, dots, m('many') + .3 + i * .08, { color: special ? COL.task : COL.chalk, dur: 2.4, r: special ? 10 : 7, move: m('go') + .2 });+ const d = carry(g, q, dots, m('many') + .3 + i * .08, { color: special ? COL.chalk : COL.chalk, dur: 2.4, r: special ? 10 : 7, move: m('go') + .2 });if (special) pulse(d, m('check') + (q[0] === 1 ? .3 : 2.2), 1.5);});show(ghosts, m('go') + .2, .4);text(p, 'rings: where the dots started', 90, 760, m('go') + 1.4, { size: 26, fill: COL.dim });- text(p, '(1, 1) → (1, 2)', 90, 640, m('check') + .3, { size: 32, fill: COL.task, weight: 600 });- text(p, '(2, 0) → (4, 2)', 90, 690, m('check') + 2.2, { size: 32, fill: COL.task, weight: 600 });+ text(p, '(1, 1) → (1, 2)', 90, 640, m('check') + .3, { size: 32, fill: COL.chalk, weight: 600 });+ text(p, '(2, 0) → (4, 2)', 90, 690, m('check') + 2.2, { size: 32, fill: COL.chalk, weight: 600 });}],['grid', 'The grid moves', (m) => {@@ -157,9 +157,9 @@ const BEATS = [const L = G(g.P.g, {});[1, 2, 3].forEach((k, i) => { const l = g.P.line(...mul(A1, [0, k]), ...mul(A1, [1, k]), COL.chalk, (i ? m('par') : m('straight')) + .3 + Math.max(0, i - 1) * .6, { into: L }); hide(l, m('faint'), .4); });const gp = g.P.g.querySelector('path'); tw(gp, { 'a_stroke-opacity': .45 }, m('faint') + .3, .4); tw(gp, { 'a_stroke-opacity': .1 }, m('faint') + 2.6, .6);- text(p, 'straight lines stay straight', 90, 480, m('straight') + .4, { size: 30, weight: 600, fill: COL.task });- text(p, 'parallel lines stay parallel,', 90, 530, m('par') + .4, { size: 30, weight: 600, fill: COL.task });- text(p, 'equally spaced', 90, 575, m('par') + 1.6, { size: 30, weight: 600, fill: COL.task });+ text(p, 'straight lines stay straight', 90, 480, m('straight') + .4, { size: 30, weight: 600, fill: COL.chalk });+ text(p, 'parallel lines stay parallel,', 90, 530, m('par') + .4, { size: 30, weight: 600, fill: COL.chalk });+ text(p, 'equally spaced', 90, 575, m('par') + 1.6, { size: 30, weight: 600, fill: COL.chalk });text(p, 'faint: the plane before A', 90, 640, m('faint') + .4, { size: 28, fill: COL.dim });const sqe = g.parts.square.firstChild; tw(sqe, { 'a_fill-opacity': .4 }, m('sq') + .3, .4); tw(sqe, { 'a_fill-opacity': .12 }, m('sq') + 2.5, .6);text(p, 'the unit square → a slanted box', 90, 700, m('sq') + .4, { size: 28, fill: COL.chalk, weight: 600 });@@ -183,7 +183,7 @@ const BEATS = [show(g.cols[1], m('e2') + 1.8, .4);colFrame(p, g, 1, m('e2') + 1.8, m('why'));say(p, ['(1, 0) → 1·col 1 + 0·col 2'], 90, 610, m('why') + 2.5, { size: 32 });- say(p, ['(x, y) → x·col 1 + y·col 2'], 90, 680, m('all') + 4, { size: 36, fill: COL.task });+ say(p, ['(x, y) → x·col 1 + y·col 2'], 90, 680, m('all') + 4, { size: 36, fill: COL.chalk });const st1 = G(p, {});[[0, 0, 1, 0], [1, 0, 2, 0], [2, 0, 2, 1]].forEach(([a, b, c, d], i) => g.P.arrow(a, b, c, d, COL.chalk, m('all') + 1 + i * .6, { into: st1 }).setAttribute('stroke-width', 6));tw(g.parts.square, { o: .25 }, m('all') + .6, .4); tw(g.parts.square, { o: 1 }, m('read'), .4); // the slanted box steps back while the steps are walked@@ -223,9 +223,9 @@ const BEATS = [say(w2, ['−1·(2, 1) = (−2, −1)'], 250, 480, m('t1') + .4, { size: 36, fill: COLC[0] });P2.arrow(-2, -1, -3, 0, COLC[1], m('t2') + .3, { into: w2 }); P2.arrow(-3, 0, -4, 1, COLC[1], m('t2') + 1, { into: w2 });say(w2, ['+ 2·(−1, 1) = (−2, 2)'], 250, 535, m('t2') + .4, { size: 36, fill: COLC[1] });- P2.dot(-4, 1, COL.task, m('land2') + .3, { label: '(−4, 1)', dx: -10, dy: -18, anchor: 'end', into: w2 });- say(w2, ['= (−4, 1)'], 250, 590, m('land2') + .5, { size: 36, fill: COL.task });- carry(g, [-1, 2], w2, m('back') + .2, { color: COL.task, dur: 1.6, r: 9 });+ P2.dot(-4, 1, COL.chalk, m('land2') + .3, { label: '(−4, 1)', dx: -10, dy: -18, anchor: 'end', into: w2 });+ say(w2, ['= (−4, 1)'], 250, 590, m('land2') + .5, { size: 36, fill: COL.chalk });+ carry(g, [-1, 2], w2, m('back') + .2, { color: COL.chalk, dur: 1.6, r: 9 });}],['drag', 'Move a column, move the matrix', (m) => {@@ -248,8 +248,8 @@ const BEATS = [g.to({ a00: 1 }, m('scrubn') - 1.2, 1.6, lin);thick(g.cols[0], m('same') + .4); thick(g.cols[1], m('same') + .4);flash(g, 'a00', m('same') + .4); flash(g, 'a10', m('same') + .7); flash(g, 'a01', m('same') + 1); flash(g, 'a11', m('same') + 1.3);- text(p, 'move the arrows: the numbers move', 90, 480, m('same') + .6, { size: 30, weight: 600, fill: COL.task });- text(p, 'move the numbers: the arrows move', 90, 530, m('same') + 2, { size: 30, weight: 600, fill: COL.task });+ text(p, 'move the arrows: the numbers move', 90, 480, m('same') + .6, { size: 30, weight: 600, fill: COL.chalk });+ text(p, 'move the numbers: the arrows move', 90, 530, m('same') + 2, { size: 30, weight: 600, fill: COL.chalk });}],['q1', 'Your turn', () => {@@ -274,11 +274,11 @@ const BEATS = [colFrame(p, g, 0, m('c'), m('c') + 4); thick(g.cols[0], m('c') + .3);colFrame(p, g, 1, m('c') + 4, m('see')); thick(g.cols[1], m('c') + 4.3);g.to({ a00: 1 }, m('see'), .7); g.to({ a00: 2 }, m('see') + 1, 2); // once more, slowly, as it is described- text(p, 'twice as wide, same height', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.task });+ text(p, 'twice as wide, same height', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.chalk });tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .45 }, m('flag') + 3.4, .5);g.to({ a00: 1 }, m('flag') + .2, .6); g.to({ a00: 2 }, m('flag') + 1, 1.6); // the flag widens while it is watchedg.to({ a11: 2 }, m('both') + 1, 1.4);- text(p, '2, 0 and 0, 2: twice as big', 90, 540, m('both') + 1.4, { size: 30, weight: 600, fill: COL.task });+ text(p, '2, 0 and 0, 2: twice as big', 90, 540, m('both') + 1.4, { size: 30, weight: 600, fill: COL.chalk });}],['flip', 'Flip', (m) => {@@ -291,9 +291,9 @@ const BEATS = [const mir = path(p, `M${g.P.PX(0)} ${g.P.PY(5.4)}V${g.P.PY(-5.4)}`, { stroke: COL.chalk, 'stroke-width': 3, 'stroke-dasharray': '8 8' }, { o: 0 });show(mir, m('see') + .2, .4); hide(mir, m('flip2'), .3);g.to({ a00: 1 }, m('see') + .3, .8); g.to({ a00: -1 }, m('see') + 1.4, 2.2); // over the mirror line, slowly, as it is said- const cap1 = [text(p, 'a mirror image across the y-axis', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.task })];+ const cap1 = [text(p, 'a mirror image across the y-axis', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.chalk })];tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .45 }, m('flag') + 2, .5);- cap1.push(text(p, 'the flag points left', 90, 540, m('flag') + .4, { size: 30, fill: COL.task }));+ cap1.push(text(p, 'the flag points left', 90, 540, m('flag') + .4, { size: 30, fill: COL.chalk }));cap1.forEach(e => hide(e, m('flip2'), .3));// the second flip: upside down (back through the plain plane, not through the zero matrix)g.to({ a00: 1 }, m('flip2') + .2, .9);@@ -302,7 +302,7 @@ const BEATS = [const mir2 = path(p, `M${g.P.PX(-5.4)} ${g.P.PY(0)}H${g.P.PX(5.4)}`, { stroke: COL.chalk, 'stroke-width': 3, 'stroke-dasharray': '8 8' }, { o: 0 });show(mir2, m('see2') + .2, .4);g.to({ a11: 1 }, m('see2') + .3, .8); g.to({ a11: -1 }, m('see2') + 1.4, 2.2);- text(p, 'upside down: a mirror across the x-axis', 90, 480, m('see2') + .4, { size: 30, weight: 600, fill: COL.task });+ text(p, 'upside down: a mirror across the x-axis', 90, 480, m('see2') + .4, { size: 30, weight: 600, fill: COL.chalk });}],['shear', 'Shear', (m) => {@@ -317,7 +317,7 @@ const BEATS = [const sl = G(p, {});[1, 2, 3].forEach((k, i) => { g.P.arrow(-4, k, -4 + k, k, COL.chalk, m('see') + 2.4 + i * .6, { into: sl }); });hide(sl, m('up'), .3);- hide(text(p, 'higher lines slide further', 90, 480, m('see') + 1, { size: 30, weight: 600, fill: COL.task }), m('up'), .3);+ hide(text(p, 'higher lines slide further', 90, 480, m('see') + 1, { size: 30, weight: 600, fill: COL.chalk }), m('up'), .3);tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .45 }, m('flag') + 2, .5);// the other shear: upright lines slide upg.to({ a01: 0 }, m('up') + .2, .9);@@ -326,7 +326,7 @@ const BEATS = [g.to({ a10: 0 }, m('see2'), .7); g.to({ a10: 1 }, m('see2') + 1, 2.2);const su = G(p, {});[1, 2, 3].forEach((k, i) => { g.P.arrow(k, -4, k, -4 + k, COL.chalk, m('see2') + 2.4 + i * .6, { into: su }); });- text(p, 'further right, further up', 90, 480, m('see2') + 1, { size: 30, weight: 600, fill: COL.task });+ text(p, 'further right, further up', 90, 480, m('see2') + 1, { size: 30, weight: 600, fill: COL.chalk });}],['turn', 'Turn', (m) => {@@ -337,28 +337,28 @@ const BEATS = [g.turn(0, 90, m('A') + .3, 2.2);colFrame(p, g, 0, m('c'), m('c') + 4); thick(g.cols[0], m('c') + .3);colFrame(p, g, 1, m('c') + 4, m('see')); thick(g.cols[1], m('c') + 4.3);- text(p, 'a quarter turn, counterclockwise', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.task });+ text(p, 'a quarter turn, counterclockwise', 90, 480, m('see') + .4, { size: 30, weight: 600, fill: COL.chalk });const { PX, PY } = g.P, R = 3.4 * g.P.u;// the arc grows with the turn, and its head shows which wayconst arc = G(p, { o: 0 });const ap = path(arc, `M${PX(3.4)} ${PY(0)}A${R} ${R} 0 0 0 ${PX(0)} ${PY(3.4)}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' }, { d: 0 });- path(arc, `M${PX(0) + 14} ${PY(3.4) - 9}L${PX(0)} ${PY(3.4)}L${PX(0) + 14} ${PY(3.4) + 9}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });+ show(path(arc, `M${PX(0) + 14} ${PY(3.4) - 9}L${PX(0)} ${PY(3.4)}L${PX(0) + 14} ${PY(3.4) + 9}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' }, { o: 0 }), m('see') + 3, .2); // the head comes when the arc reaches itg.turn(90, 0, m('see'), .7); g.turn(0, 90, m('see') + 1, 2.2);show(arc, m('see') + 1, .2); tw(ap, { d: 1 }, m('see') + 1, 2.2, io);hide(arc, m('half'), .3);tw(g.parts.shape.firstChild, { 'a_fill-opacity': .9 }, m('flag'), .3); tw(g.parts.shape.firstChild, { 'a_fill-opacity': .45 }, m('flag') + 2, .5);g.turn(90, 180, m('half') + 1.5, 2.2);- text(p, 'half turn: rows −1, 0 and 0, −1', 90, 540, m('half') + 2, { size: 28, weight: 600, fill: COL.task });+ text(p, 'half turn: rows −1, 0 and 0, −1', 90, 540, m('half') + 2, { size: 28, weight: 600, fill: COL.chalk });// the other way: a quarter turn clockwise- g.turn(180, 360, m('cw') + .2, .8); // on round to the start (never backwards through the quarter turn)+ g.turn(180, 0, m('cw') + .2, .8); // back to the start the way it came: on round would pass the clockwise pose before it is showng.turn(0, -90, m('cw') + 2, 2.4);colFrame(p, g, 0, m('cw') + 2.8, m('cwm')); colFrame(p, g, 1, m('cw') + 4.6, m('cwm'));const arc2 = G(p, { o: 0 });const ap2 = path(arc2, `M${PX(3.4)} ${PY(0)}A${R} ${R} 0 0 1 ${PX(0)} ${PY(-3.4)}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' }, { d: 0 });- path(arc2, `M${PX(0) + 14} ${PY(-3.4) - 9}L${PX(0)} ${PY(-3.4)}L${PX(0) + 14} ${PY(-3.4) + 9}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });+ show(path(arc2, `M${PX(0) + 14} ${PY(-3.4) - 9}L${PX(0)} ${PY(-3.4)}L${PX(0) + 14} ${PY(-3.4) + 9}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' }, { o: 0 }), m('cw') + 4.2, .2);show(arc2, m('cw') + 2, .2); tw(ap2, { d: 1 }, m('cw') + 2, 2.4, io);['a00', 'a01', 'a10', 'a11'].forEach((k, i) => flash(g, k, m('cwm') + .4 + i * .5));- text(p, 'clockwise: rows 0, 1 and −1, 0', 90, 600, m('cwm') + .4, { size: 28, weight: 600, fill: COL.task });+ text(p, 'clockwise: rows 0, 1 and −1, 0', 90, 600, m('cwm') + .4, { size: 28, weight: 600, fill: COL.chalk });}],['readit', 'Read the matrix off', (m) => {@@ -397,7 +397,7 @@ const BEATS = [show(q2, m('two') - .2, .3); hide(q2, m('show2'), .3); tw(g.M, { o: 1 }, m('show2') + .2, .5);thick(g.cols[0], m('two') + 1.6); thick(g.cols[1], m('two') + 3.4);say(p, ['column 1 = (0, 2), column 2 = (−2, 0)'], 90, 480, m('two') + 2, { size: 32 });- text(p, 'a quarter turn, twice as big', 90, 540, m('show2') + 4.6, { size: 30, weight: 600, fill: COL.task });+ text(p, 'a quarter turn, twice as big', 90, 540, m('show2') + 4.6, { size: 30, weight: 600, fill: COL.chalk });g.to({ a00: 1, a01: 0, a10: 0, a11: 1 }, m('show2') + 4.4, .6); g.to({ a00: 0, a01: -2, a10: 2, a11: 0 }, m('show2') + 5.2, 2.4); // once more from the plain plane: it turns and grows}],@@ -435,15 +435,15 @@ const BEATS = [text(p, 'the line through (1, 2)', 90, 580, m('see') + 4, { size: 26, fill: COL.dim });colFrame(p, g, 0, m('c'), m('c') + 3.5); colFrame(p, g, 1, m('c') + 3.5, m('see'));text(p, 'column 2 = 2 × column 1', 90, 480, m('c') + 4.5, { size: 30, weight: 600, fill: COLC[1] });- text(p, 'everything lands on one line', 90, 530, m('see') + 1, { size: 30, weight: 600, fill: COL.task });+ text(p, 'everything lands on one line', 90, 530, m('see') + 1, { size: 30, weight: 600, fill: COL.chalk });const { PX, PY } = g.P;const d = G(p, { x: PX(2), y: PY(-1), o: 0 });- mk('circle', { r: 9, fill: COL.task, stroke: COL.board, 'stroke-width': 2 }, d);- const dl = T(d, '(2, −1)', { x: 14, y: 24, size: 22, fill: COL.task, font: MATH });+ mk('circle', { r: 9, fill: COL.chalk, stroke: COL.board, 'stroke-width': 2 }, d);+ const dl = T(d, '(2, −1)', { x: 14, y: 24, size: 22, fill: COL.chalk, font: MATH });show(d, m('lost') + 2.2, .3); hide(dl, m('lost') + 5.6, .3); tw(d, { x: PX(0), y: PY(0) }, m('lost') + 5.6, 1.2);say(p, ['(2, −1) → (2 − 2, 4 − 4) = (0, 0)'], 90, 620, m('lost') + 3.2, { size: 30 });[[-2, 1], [4, -2]].forEach(([a, b], i) => {- const e = G(p, { x: QX(a), y: QY(b), o: 0 }); mk('circle', { r: 9, fill: COL.task, stroke: COL.board, 'stroke-width': 2 }, e);+ const e = G(p, { x: QX(a), y: QY(b), o: 0 }); mk('circle', { r: 9, fill: COL.chalk, stroke: COL.board, 'stroke-width': 2 }, e);show(e, m('lost2') + .3 + i * .5, .3); tw(e, { x: QX(0), y: QY(0) }, m('lost2') + 2, 1.4);});ring(g.P, [1, 0], COL.bad, p, m('miss') + .5, '(1, 0): never reached');@@ -452,7 +452,7 @@ const BEATS = [text(p, 'every b? chapter 14', 90, 725, m('miss') + 8.5, { size: 28, fill: COL.dim });g.to({ a00: 0, a01: 0, a10: 0, a11: 0 }, m('zero') + 1, 1.8);hide(g.parts.cols, m('zero') + 2.4, .4);- text(p, 'all zeros: one single point', 90, 790, m('zero') + 1.4, { size: 30, weight: 600, fill: COL.task });+ text(p, 'all zeros: one single point', 90, 790, m('zero') + 1.4, { size: 30, weight: 600, fill: COL.chalk });}],['solve', 'Solving Ax = b', (m) => {@@ -498,7 +498,7 @@ const BEATS = [[['A moves every point: x goes to Ax.', 'w1'], ['Straight lines stay straight; parallel lines stay parallel, evenly spaced.', 'w2'],['Column 1 is where (1, 0) lands, column 2 where (0, 1) lands.', 'w3'], ['Stretch, flip, shear, turn, squash. Ax = b: find the x that lands on b.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 150 + i * 95, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 32, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/ch11/index.html b/site/linear-algebra/ch11/index.htmlindex 1d840ff..1b9a19e 100644--- a/site/linear-algebra/ch11/index.html+++ b/site/linear-algebra/ch11/index.html@@ -31,10 +31,10 @@ const tri = q => `(${q.map(c => num(r1(c))).join(', ')})`;const onePlane = (p, a, b, c, d, { t0 = .1, view = VIEW } = {}) => lin3(p, { rows: 1, A: [[a, b, c], [0, 0, 0], [0, 0, 0]], b: [d, 0, 0], eq: [90, 200], size: 50, space: { ...view }, t0 });const flash = (sys, key, t0) => sys.num(key).forEach(e => { tw(e, { c_fill: COL.task }, t0, .25); tw(e, { c_fill: COL.chalk }, t0 + 1.2, .6); });const glowPl = (pl, t0) => { prog(q => pl.width(3 + 5 * Math.sin(Math.PI * q)), t0, 1.2, lin); };-// Amber dots where the plane crosses the three axes, following the numbers; labels keep tick numbers away.+// Chalk dots where the plane crosses the three axes, following the numbers; labels keep tick numbers away.const crossings = (sys, t0 = 0, { labels = true } = {}) => {const V = sys.space, g = G(V.content, { o: 0 });- const dots = [0, 1, 2].map(() => V.point(null, { color: COL.task, r: 8, size: 24, into: g }));+ const dots = [0, 1, 2].map(() => V.point(null, { color: COL.chalk, r: 8, size: 24, into: g }));sys.onChange(v => [0, 1, 2].forEach(j => {const a = v[`a0${j}`], c = Math.abs(a) > 1e-6 ? v.b0 / a : null, ok = c !== null && Math.abs(c) <= V.R + 1e-6, q = [0, 0, 0];if (ok) q[j] = c;@@ -140,6 +140,12 @@ const BEATS = [if (!i) { const w = say(p, ['1 + 1 + z = 3'], tx[3], yy, m('x1') + 3.2, { size: 32, anchor: 'middle', fill: COL.dim }); hide(w, at[0][3] - .2, .2); }text(p, '✓', 640, yy, at[i][3] + .3, { size: 34, fill: COL.good, anchor: 'middle', weight: 700 });});+ // while the first row is worked out, its triple builds large on the right: x, then y, then the z it forces+ const big = G(p, {}), bigX = [1035, 1085, 1120, 1170, 1205, 1255, 1295];+ ['(', '1', ',', '1', ',', '', ')'].forEach((c, k) => { if (c) say(big, [c], bigX[k], 420, k === 1 ? m('x1') : k === 3 ? m('x1') + .8 : m('x1'), { size: 72, fill: k % 2 ? AXC[(k - 1) / 2] : COL.chalk, anchor: 'middle' }); });+ const zq = say(big, ['?'], bigX[5], 420, m('x1') + 1.2, { size: 72, fill: COL.dim, anchor: 'middle' }); hide(zq, m('z1') + .2, .3);+ say(big, ['1'], bigX[5], 420, m('z1') + .3, { size: 72, fill: AXC[2], anchor: 'middle' });+ hide(big, m('tri') - .4, .4);text(p, 'solutions: triples', 1160, 250, m('tri') - .3, { size: 30, fill: COL.dim, anchor: 'middle' });// each row's numbers fly into its chip as the row is checkedrows.forEach((r, i) => r.forEach((c, j) => {@@ -153,13 +159,13 @@ const BEATS = [tw(c, { o: 1, s: 1 }, (i ? at[i][3] + .2 : m('tri')) + 1.1, .5, back);});text(p, 'x first, then y, then z', 1160, 486, m('tri') + 3, { size: 24, fill: COL.dim, anchor: 'middle' });- const tl = text(p, 'a triple', 1030, 400, m('r2') - 2.2, { size: 26, fill: COL.task, anchor: 'middle', weight: 600 });+ const tl = text(p, 'a triple', 1030, 400, m('r2') - 2.2, { size: 26, fill: COL.chalk, anchor: 'middle', weight: 600 });hide(tl, m('r2') + 1.5, .4);[[0, 0, 1], [1, 0, 2], [3, 1, -1], [5, -1, -1], [-1, 2, 2], [4, -2, 1]].forEach((r, i) => {const c = chip(p, [tri(r)], COL.dim, { x: 990 + (i % 3) * 190, y: 580 + Math.floor(i / 3) * 66, size: 26 });put(c, { o: 0, s: .5 }); tw(c, { o: .8, s: 1 }, m('many') + .6 + i * .45, .4, back);});- text(p, '… and endlessly many more', 1180, 730, m('many') + 3.6, { size: 30, fill: COL.task, anchor: 'middle', weight: 600 });+ text(p, '… and endlessly many more', 1180, 730, m('many') + 3.6, { size: 30, fill: COL.chalk, anchor: 'middle', weight: 600 });text(p, 'a pair is a point on a flat plane. A triple?', 1180, 805, m('many') + 7, { size: 30, fill: COL.chalk, anchor: 'middle', weight: 600 });}],@@ -169,11 +175,11 @@ const BEATS = [const V = S.V = space3(p, { yaw: 0, pitch: 90, t0: .1 });put(V.axes[2], { o: 0 }); put(V.cube, { o: 0 });V.poly([[-4, -4, 0], [4, -4, 0], [4, 4, 0], [-4, 4, 0]], { color: COL.chalk, fo: .06, w: 0 }); // the sheet of paper that is laid down- const pt = V.point([2, 1, 0], { color: COL.task, label: '(2, 1)' });+ const pt = V.point([2, 1, 0], { color: COL.chalk, label: '(2, 1)' });// the walk of chapter 1, on the flat plane seen from aboveV.walk([2, 1, 0], m('pt'), { dur: 1.4, dot: false, w: 4 });- const p2 = say(p, ['(2, 1)'], 90, 210, m('pt') + .6, { size: 46, fill: COL.task });- hide(p2, m('floor') + .3, .3); say(p, ['(2, 1, 0)'], 90, 210, m('floor') + .5, { size: 46, fill: COL.task });+ const p2 = say(p, ['(2, 1)'], 90, 210, m('pt') + .6, { size: 46, fill: COL.chalk });+ hide(p2, m('floor') + .3, .3); say(p, ['(2, 1, 0)'], 90, 210, m('floor') + .5, { size: 46, fill: COL.chalk });put(pt.e, { o: 0 }); show(pt.e, m('pt') + 1.3, .3);[[0, 'xr'], [1, 'yu']].forEach(([j, mk_]) => {const a = V.line(null, null, { color: AXC[j], w: 7, into: V.content, head: true }), e = [0, 0, 0];@@ -205,10 +211,10 @@ const BEATS = [text(p, 'A point in space: three numbers', 60, 110, .2, { size: 40, weight: 600 });const V = space3(p, { ...VIEW, t0: .1 });V.sway(5, 11);- say(p, ['(2, 1, 3)'], 90, 210, .4, { size: 54, fill: COL.task });+ const c1 = say(p, ['(2, 1, 3)'], 90, 210, .4, { size: 54, fill: COL.chalk });const O = V.point(null, { color: COL.chalk, r: 7 });prog(() => O.set([0, 0, 0]), m('o'), 0, lin); pulse(O.e, m('o'));- const w1 = V.walk([2, 1, 3], 0, { at: [m('x'), m('y'), m('z')], dur: 3, label: '(2, 1, 3)', w: 8 });+ const w1 = V.walk([2, 1, 3], 0, { at: [m('x'), m('y'), m('z')], dur: 3, label: '(2, 1, 3)', color: COL.chalk, w: 8 });const steps = [['2', 'steps along x'], ['1', 'step along y, away'], ['3', 'steps up']];const st1 = G(p, {});steps.forEach(([n, s], j) => { say(st1, [n], 110, 300 + j * 56, m(['x', 'y', 'z'][j]), { size: 40, fill: AXC[j], anchor: 'middle' }); text(st1, s, 150, 300 + j * 56, m(['x', 'y', 'z'][j]) + .2, { size: 28, fill: COL.dim }); });@@ -219,13 +225,13 @@ const BEATS = [V.turn({ yaw: VIEW.yaw + 55, pitch: 12 }, m('turn'), 3);V.turn({ yaw: VIEW.yaw - 10, pitch: VIEW.pitch }, m('ex2') - .2, 2.2);[st1, sn].forEach(e => hide(e, m('ex2') - .4, .4));- tw(w1.dot.e, { o: .5 }, m('ex2'), .4);- say(p, ['(−1, 2, −2)'], 360, 210, m('ex2'), { size: 54, fill: COL.int });- const w2 = V.walk([-1, 2, -2], 0, { at: [m('x2'), m('y2'), m('z2')], dur: 3, label: '(−1, 2, −2)', color: COL.int, w: 8 });+ tw(w1.dot.e, { o: .5 }, m('ex2'), .4); tw(c1, { o: .5 }, m('ex2'), .4); // the first point steps back for the second+ say(p, ['(−1, 2, −2)'], 360, 210, m('ex2'), { size: 54, fill: COL.chalk });+ const w2 = V.walk([-1, 2, -2], 0, { at: [m('x2'), m('y2'), m('z2')], dur: 3, label: '(−1, 2, −2)', color: COL.chalk, w: 8 });const steps2 = [['−1', 'step along x: to the left'], ['2', 'steps along y, away'], ['−2', 'steps: down, below the floor']];steps2.forEach(([n, s], j) => { say(p, [n], 110, 300 + j * 56, m(['x2', 'y2', 'z2'][j]), { size: 40, fill: AXC[j], anchor: 'middle' }); text(p, s, 150, 300 + j * 56, m(['x2', 'y2', 'z2'][j]) + .2, { size: 28, fill: COL.dim }); });pulse(w2.dot.e, m('here2'));- text(p, 'one triple = one point in space', 90, 560, m('here2'), { size: 34, weight: 600, fill: COL.task });+ text(p, 'one triple = one point in space', 90, 560, m('here2'), { size: 34, weight: 600, fill: COL.chalk });V.sway(8, 12, m('here2'));}],@@ -238,15 +244,15 @@ const BEATS = [pl.fade(0, 0, 0); pl.fade(1, m('plane') + .3, 1.2);const cl = G(V.content, {});const sols = [[1, 1, 1, 'p1'], [3, 0, 0, 'p2'], [0, 2, 1, 'p3'], [2, 2, -1, 'p4']];- sols.forEach(([x, y, z, mk_]) => { const d = V.point(null, { color: COL.task, label: tri([x, y, z]), size: 24, into: cl }); prog(() => d.set([x, y, z]), m(mk_), 0, lin); pulse(d.e, m(mk_)); hide(d.t, m('more'), .5); });+ sols.forEach(([x, y, z, mk_]) => { const d = V.point(null, { color: COL.chalk, label: tri([x, y, z]), size: 24, into: cl }); prog(() => d.set([x, y, z]), m(mk_), 0, lin); pulse(d.e, m(mk_)); hide(d.t, m('more'), .5); });[[0, 3, 0], [0, 0, 3], [2, 1, 0], [1, 0, 2], [0, 1, 2], [2, 0, 1], [1, 2, 0], [-1, 2, 2], [3, 1, -1], [1, -1, 3], [2, -1, 2], [-1, 1, 3], [4, 0, -1], [0, 4, -1]].forEach((q, i) => {- const d = V.point(null, { color: COL.task, r: 7, into: cl });+ const d = V.point(null, { color: COL.chalk, r: 7, into: cl });prog(() => d.set(q), m('more') + i * .12, 0, lin);});// edge-on: the view direction (sin yaw, cos yaw, −tan pitch) lies in the plane when tan pitch = sin yaw + cos yawconst edge = Math.atan(Math.sin(VIEW.yaw * Math.PI / 180) + Math.cos(VIEW.yaw * Math.PI / 180)) * 180 / Math.PI;V.turn({ pitch: edge }, m('edge'), 2.4);- const ln = text(p, 'all in one line: a flat sheet seen edge-on', 90, 330, m('line'), { size: 30, fill: COL.task, weight: 600 });+ const ln = text(p, 'all in one line: a flat sheet seen edge-on', 90, 330, m('line'), { size: 30, fill: COL.chalk, weight: 600 });hide(ln, m('plane'), .4);V.turn({ pitch: VIEW.pitch }, m('plane'), 2.4);tw(cl, { o: .55 }, m('rule') - .5, .5);@@ -319,15 +325,15 @@ const BEATS = [const cr = (lab, res, y, t, q, mk_) => {say(steps, [lab], 90, y, t, { size: 30, fill: COL.dim });say(steps, [res], 470, y, t + 1.2, { size: 36 });- const d = V.point(null, { color: COL.task, label: tri(q), size: 24, into: steps });+ const d = V.point(null, { color: COL.chalk, label: tri(q), size: 24, into: steps });prog(() => d.set(q), m(mk_), 0, lin); pulse(d.e, m(mk_));};cr('on the x-axis, y = z = 0:', 'x = 3', 330, m('xa'), [3, 0, 0], 'px');cr('on the y-axis, x = z = 0:', 'y = 3', 390, m('ya'), [0, 3, 0], 'py');cr('on the z-axis, x = y = 0:', 'z = 3', 450, m('za'), [0, 0, 3], 'pz');- const t1 = V.poly([[3, 0, 0], [0, 3, 0], [0, 0, 3]], { color: COL.task, fo: .28, w: 4, into: steps });+ const t1 = V.poly([[3, 0, 0], [0, 3, 0], [0, 0, 3]], { color: COL.chalk, fo: .28, w: 4, into: steps });tw(t1.e, { o: 0 }, 0, 0); show(t1.e, m('tri'), .8);- text(steps, 'the corner where x, y, z are all positive', 90, 520, m('tri') + 1.5, { size: 26, fill: COL.task });+ text(steps, 'the corner where x, y, z are all positive', 90, 520, m('tri') + 1.5, { size: 26, fill: COL.chalk });pl.fade(.9, m('tri') + 3, 1.2);hide(steps, m('ex2') - .5, .4);pl.fade(.25, m('ex2') - .5, .4);@@ -354,7 +360,7 @@ const BEATS = [const sys = S.sys = onePlane(p, 1, 1, 1, 3);const V = sys.space;crossings(sys, m('three'), { labels: false });- const rd = G(p, { o: 0 }), rdT = T(rd, '', { x: 90, y: 400, size: 34, fill: COL.task, font: MATH });+ const rd = G(p, { o: 0 }), rdT = T(rd, '', { x: 90, y: 400, size: 34, fill: COL.chalk, font: MATH });T(rd, 'where it crosses the axes:', { x: 90, y: 350, size: 28, fill: COL.dim });sys.onChange(v => { const c = r1(v.b0); const s = `(${num(c)}, 0, 0), (0, ${num(c)}, 0), (0, 0, ${num(c)})`; if (rdT.textContent !== s) rdT.textContent = s; });show(rd, m('three'));@@ -365,12 +371,12 @@ const BEATS = [sys.to({ b0: 1 }, m('one'), 1.6); flash(sys, 'b0', m('one'));keep(1, m('zero'));sys.to({ b0: 0 }, m('zero'), 1.4); flash(sys, 'b0', m('zero'));- const zz = say(p, ['0 + 0 + 0 = 0'], 90, 460, m('origin'), { size: 38, fill: COL.task }); hide(zz, m('neg'), .3);+ const zz = say(p, ['0 + 0 + 0 = 0'], 90, 460, m('origin'), { size: 38, fill: COL.chalk }); hide(zz, m('neg'), .3);keep(0, m('neg'));sys.to({ b0: -2 }, m('neg'), 1.4); flash(sys, 'b0', m('neg'));const n = G(p, { o: 0 });T(n, 'right side changes:', { x: 90, y: 500, size: 32, fill: COL.dim });- T(n, 'the plane slides, never tilts', { x: 90, y: 550, size: 36, weight: 600, fill: COL.task });+ T(n, 'the plane slides, never tilts', { x: 90, y: 550, size: 36, weight: 600, fill: COL.chalk });show(n, m('par'));V.sway(10, 14, 0);}],@@ -387,9 +393,9 @@ const BEATS = [const w = G(p, {});say(w, ['on the x-axis, y = z = 0:'], 90, 330, m('why'), { size: 30, fill: COL.dim });say(w, ['3x = 3, x = 1'], 90, 385, m('xa'), { size: 40 });- const hinge = V.line(null, null, { color: COL.task, w: 5, into: V.content });+ const hinge = V.line(null, null, { color: COL.chalk, w: 5, into: V.content });prog(() => hinge.set([0, 3, 0], [0, 0, 3]), m('same'), 0, lin);- text(w, 'y and z crossings stay: the hinge', 90, 450, m('same') + .5, { size: 28, fill: COL.task, weight: 600 });+ text(w, 'y and z crossings stay: the hinge', 90, 450, m('same') + .5, { size: 28, fill: COL.chalk, weight: 600 });hide(w, m('zc') - .3, .3); hide(hinge.e, m('zc') - .3, .3);sys.to({ a00: 1, a02: 3 }, m('zc'), 1.8); flash(sys, 'a00', m('zc')); flash(sys, 'a02', m('zc'));const w2 = say(p, ['on the z-axis: 3z = 3, z = 1'], 90, 385, m('zt'), { size: 36 });@@ -397,7 +403,7 @@ const BEATS = [sys.to({ a00: -1, a02: 1 }, m('minus'), 1.8); flash(sys, 'a00', m('minus')); flash(sys, 'a02', m('minus'));say(p, ['on the x-axis: −x = 3, x = −3'], 90, 385, m('neg'), { size: 36 });const n = G(p, { o: 0 });- T(n, 'right side: slides the plane', { x: 90, y: 630, size: 34, weight: 600, fill: COL.task });+ T(n, 'right side: slides the plane', { x: 90, y: 630, size: 34, weight: 600, fill: COL.chalk });T(n, 'numbers in front of x, y, z: tilt it', { x: 90, y: 682, size: 34, weight: 600, fill: BLUE });show(n, m('sum'));V.turn({ pitch: 50 }, m('zc'), 2); // x + y + 3z = 3 is edge-on at pitch 24@@ -431,14 +437,14 @@ const BEATS = [V.sway(6, 13);pl.fade(0, 0, 0); pl.fade(1, m('floor'), 1);['a00', 'a01'].forEach(k => flash(sys, k, m('zero') + .4));- const f1 = text(p, 'x and y free, z must be 2', 90, 300, m('zero') + 1.5, { size: 32, fill: COL.task, weight: 600 });+ const f1 = text(p, 'x and y free, z must be 2', 90, 300, m('zero') + 1.5, { size: 32, fill: COL.chalk, weight: 600 });const fl = G(V.content, {});- [[-3, -2], [0, 0], [3, 1], [-1, 3]].forEach(([x, y], i) => { const d = V.point(null, { color: COL.task, r: 7, into: fl, stem: true }); prog(() => d.set([x, y, 2]), m('floor') + .5 + i * .25, 0, lin); });+ [[-3, -2], [0, 0], [3, 1], [-1, 3]].forEach(([x, y], i) => { const d = V.point(null, { color: COL.chalk, r: 7, into: fl, stem: true }); prog(() => d.set([x, y, 2]), m('floor') + .5 + i * .25, 0, lin); });V.turn({ pitch: 8 }, m('floor') + .4, 2); V.turn({ pitch: VIEW.pitch }, m('eq2') - .5, 1.5);[f1, fl].forEach(e => hide(e, m('eq2') - .4, .3));sys.to({ a00: 1, a02: 0, b0: 1 }, m('eq2'), 1.8);['a00', 'a02', 'b0'].forEach(k => flash(sys, k, m('eq2') + .8));- const f2 = text(p, 'y and z free, x must be 1', 90, 300, m('wall') - .4, { size: 32, fill: COL.task, weight: 600 });+ const f2 = text(p, 'y and z free, x must be 1', 90, 300, m('wall') - .4, { size: 32, fill: COL.chalk, weight: 600 });V.turn({ yaw: VIEW.yaw + 40 }, m('wall'), 2.4); // nearer face-on to the wall x = 1hide(f2, m('eq3') - .4, .3);// x + y = 2: first the line on the floor, then the wall that rises from it@@ -449,10 +455,10 @@ const BEATS = [const ln = V.line(null, null, { color: BLUE, w: 6, into: V.content });prog(q => ln.set([4, -2, 0], [4 - 6 * q, -2 + 6 * q, 0]), m('line'), 1.2, io);text(p, 'on the floor: the line x + y = 2', 90, 300, m('line'), { size: 30, fill: BLUE, weight: 600 });- text(p, 'z is free: up and down', 90, 350, m('free'), { size: 30, fill: COL.task, weight: 600 });+ text(p, 'z is free: up and down', 90, 350, m('free'), { size: 30, fill: COL.chalk, weight: 600 });const wl = V.poly(null, { color: BLUE, fo: .22, w: 3, into: V.polys });prog(q => { const h = V.R * q; wl.set(q ? [[4, -2, -h], [-2, 4, -h], [-2, 4, h], [4, -2, h]] : null); }, m('rise'), 2.2, io);- [-1, 1, 3].forEach((x, i) => { const d = V.point(null, { color: COL.task, r: 7, into: V.content }); prog(() => d.set([x, 2 - x, [3, -2, 1.5][i]]), m('free') + 1 + i * .3, 0, lin); });+ [-1, 1, 3].forEach((x, i) => { const d = V.point(null, { color: COL.chalk, r: 7, into: V.content }); prog(() => d.set([x, 2 - x, [3, -2, 1.5][i]]), m('free') + 1 + i * .3, 0, lin); });V.turn({ yaw: -15, pitch: 18 }, m('rise'), 3); // the wall x + y = 2 from 60° off face-on: it reads as standingtext(p, 'a missing letter = a free letter', 90, 690, m('sum'), { size: 32, weight: 600 });}],@@ -477,7 +483,7 @@ const BEATS = [[['A point in space is a triple (x, y, z): along x, back along y, up z.', 'w1'], ['The solutions of one equation in x, y, z make a flat plane.', 'w2'],['Where it crosses the three axes: three points pin it down.', 'w3'], ['Right side slides it; the numbers tilt it; a missing letter is free.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 34, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/ch12/index.html b/site/linear-algebra/ch12/index.htmlindex 9da0a5a..c1a3ab0 100644--- a/site/linear-algebra/ch12/index.html+++ b/site/linear-algebra/ch12/index.html@@ -57,7 +57,7 @@ const rise = (sys, i, a, b, t, dur = 1.6) => {prog(q => { const h = R * q; wl.set(q ? [[a[0], a[1], -h], [b[0], b[1], -h], [b[0], b[1], h], [a[0], a[1], h]] : null); }, t, dur, io);reveal(sys, i, t + dur, .3); hide(wl.e, t + dur + .2, .3);};-const tickCross = (V, pts, t, color = COL.task, into) => pts.map(([q, lab, dx, dy], k) => {+const tickCross = (V, pts, t, color = COL.chalk, into) => pts.map(([q, lab, dx, dy], k) => {const d = V.point(null, { color, r: 8, label: lab || tri(q), size: 24, dx, dy, into });prog(() => d.set(q), t[k], 0, lin); pulse(d.e, t[k]);return d;@@ -130,7 +130,7 @@ const BEATS = [put(sys.E, { o: 0 });sys.rows.forEach((g, i) => { put(g, { o: 0 }); show(g, m('eq') + [0, 3.2, 8.4][i], .5); });flash(sys, 'a02', m('zero')); flash(sys, 'a20', m('zero') + 2.2);- text(p, 'all three true at once', 90, 420, m('all'), { size: 30, fill: COL.task, weight: 600 });+ text(p, 'all three true at once', 90, 420, m('all'), { size: 30, fill: COL.chalk, weight: 600 });const V = sys.space;V.sway(6, 14);// two tries, side by side@@ -138,12 +138,12 @@ const BEATS = [prog(() => P1.set([0, 0, 1]), m('try'), 0, lin); pulse(P1.e, m('try'));prog(() => P2.set([1, 2, 4]), m('try2'), 0, lin); pulse(P2.e, m('try2'));S.P1 = P1; S.P2 = P2;- say(p, ['(0, 0, 1)'], 90, 490, m('try'), { size: 34, fill: COL.task });+ say(p, ['(0, 0, 1)'], 90, 490, m('try'), { size: 34, fill: COL.chalk });chk(p, '2·0 − 0 = 0', true, 90, 545, m('c1'));chk(p, '−0 + 2·0 − 1 = −1', true, 90, 595, m('c2'));chk(p, '−3·0 + 4·1 = 4', true, 90, 645, m('c3'));text(p, 'a solution', 90, 705, m('yes'), { size: 30, fill: COL.good, weight: 600 });- say(p, ['(1, 2, 4)'], 450, 490, m('try2'), { size: 34, fill: COL.task });+ say(p, ['(1, 2, 4)'], 450, 490, m('try2'), { size: 34, fill: COL.chalk });chk(p, '2 − 2 = 0', true, 450, 545, m('d1'));chk(p, '−1 + 4 − 4 = −1', true, 450, 595, m('d2'));chk(p, '−6 + 16 = 10', false, 450, 645, m('d3'));@@ -157,7 +157,7 @@ const BEATS = [[...p.children].filter(e => e !== sys.E && e !== V.g && !e.textContent.startsWith('Three equations')).forEach(e => hide(e, .1, .4));lit(sys, 0, .2);const w = G(p, {});- text(w, 'z is missing: z is free', 90, 460, m('free'), { size: 30, fill: COL.task, weight: 600 });+ text(w, 'z is missing: z is free', 90, 460, m('free'), { size: 30, fill: COL.chalk, weight: 600 });text(w, 'on the floor: the line 2x − y = 0', 90, 510, m('floor'), { size: 30, fill: S3_ROW[0], weight: 600 });text(w, 'stood up: a wall', 90, 560, m('rise'), { size: 30, fill: S3_ROW[0], weight: 600 });S.w = w;@@ -175,7 +175,7 @@ const BEATS = [hide(S.w, .1, .4);lit(sys, 1, m('eq2') - .3);const w = S.w = G(p, {});- const cr = tickCross(V, [[[1, 0, 0], '', 12, 30], [[0, -.5, 0], '(0, −½, 0)', -120, 4], [[0, 0, 1], ' ', -100, -14]], [m('cx') + 2.5, m('cy') + 2.8, m('cz') + 2.4], COL.task, w);+ const cr = tickCross(V, [[[1, 0, 0], '', 12, 30], [[0, -.5, 0], '(0, −½, 0)', -120, 4], [[0, 0, 1], ' ', -100, -14]], [m('cx') + 2.5, m('cy') + 2.8, m('cz') + 2.4], COL.chalk, w);say(w, ['x-axis: −x = −1, x = 1'], 90, 460, m('cx') + 1, { size: 30 });say(w, ['y-axis: 2y = −1, y = −', F(1, 2)], 90, 510, m('cy') + 1, { size: 30 });say(w, ['z-axis: −z = −1, z = 1'], 90, 560, m('cz') + 1, { size: 30 });@@ -187,11 +187,11 @@ const BEATS = [const w2 = G(p, {});text(w2, 'on the dashed line: both equations true', 90, 460, m('line'), { size: 30, fill: COL.chalk, weight: 600 });// a probe runs along the meeting line (t, 2t, 1 + 3t)- const pr = V.point(null, { color: COL.task, r: 9 });+ const pr = V.point(null, { color: COL.chalk, r: 9 });prog(q => { const t = -1 + 1.8 * (1 - Math.cos(2 * Math.PI * q)) / 2; pr.set([t, 2 * t, 1 + 3 * t]); }, m('line') + .3, m('both') - m('line') - .4, lin);hide(pr.e, m('both'), .3);pulse(S.P1.e, m('both') + .5); pulse(S.P2.e, m('both') + 1.2);- text(w2, 'two equations: a whole line of solutions', 90, 520, m('many'), { size: 30, fill: COL.task, weight: 600 });+ text(w2, 'two equations: a whole line of solutions', 90, 520, m('many'), { size: 30, fill: COL.chalk, weight: 600 });S.w = w2;V.turn({ yaw: VIEW.yaw + 20 }, m('meet'), 3); // not past −15: y would run up the z axis V.turn({ yaw: VIEW.yaw }, m('many'), 2.5);}],@@ -202,10 +202,10 @@ const BEATS = [hide(S.w, .1, .4);lit(sys, 2, m('eq3') - .3);const w = S.w = G(p, {});- text(w, 'x is missing: it runs along x', 90, 460, m('nox'), { size: 30, fill: COL.task, weight: 600 });+ text(w, 'x is missing: it runs along x', 90, 460, m('nox'), { size: 30, fill: COL.chalk, weight: 600 });say(w, ['z-axis: 4z = 4, z = 1'], 90, 515, m('cz'), { size: 30 });say(w, ['y-axis: −3y = 4, y = −', F(4, 3)], 90, 570, m('cy'), { size: 30 });- const cr = tickCross(V, [[[0, 0, 1], ' ', -100, -14], [[0, -4 / 3, 0], '(0, −4/3, 0)', -150, 4]], [m('cz') + .4, m('cy') + .6], COL.task, w);+ const cr = tickCross(V, [[[0, 0, 1], ' ', -100, -14], [[0, -4 / 3, 0], '(0, −4/3, 0)', -150, 4]], [m('cz') + .4, m('cy') + .6], COL.chalk, w);reveal(sys, 2, m('show'), 1);cr.forEach(d => hide(d.e, m('cut'), .4));lit(sys, [0, 1], m('cut') - .2); // the line of the first two, bright; the third plane dim while we look at the line@@ -231,13 +231,14 @@ const BEATS = [V.turn({ yaw: -25, pitch: 24 }, m('f2'), 1.4); // plane 2 face-onV.turn({ yaw: 5, pitch: 36 }, m('f3'), 1.3); // plane 3 face-onV.turn({ yaw: -50, pitch: 28 }, m('lines'), 3); // all three well apart+ V.turn({ yaw: 310, pitch: 28 }, m('ans') + .4, 9.5); // then once all the way round: from all sidessys.focus(0, m('f1')); sys.focus(1, m('f2')); sys.focus(2, m('f3')); sys.focus(null, m('lines'));[m('f1'), m('f2'), m('f3')].forEach(t => pulse(sys.meet.e, t + .4));[0, 1, 2].forEach(i => prog(q => sys.lines[i].e.setAttribute('stroke-width', 2.5 + 3.5 * Math.sin(Math.PI * q)), m('lines') + i * .5, 1.2, lin));pulse(sys.meet.e, m('thru') + .5);tw(sys.sol, { s: 1.08 }, m('ans'), .3); tw(sys.sol, { s: 1 }, m('ans') + .5, .4);const n = G(S.p, { o: 0 });- T(n, 'three planes meet → the solution', { x: 90, y: 610, size: 34, weight: 600, fill: COL.task });+ T(n, 'three planes meet → the solution', { x: 90, y: 610, size: 34, weight: 600, fill: COL.chalk });show(n, m('name'));V.sway(5, 12, m('ans'));}],@@ -273,7 +274,7 @@ const BEATS = [// the corner's three edges, from the point, along the three axes' directionsconst e = [0, 1, 2].map(j => V.line(null, null, { color: COL.chalk, w: 3, dash: '2 6', into: V.content }));prog(() => { e[0].set([1, 2, 3], [-4, 2, 3]); e[1].set([1, 2, 3], [1, -4, 3]); e[2].set([1, 2, 3], [1, 2, -4]); }, m('pt') + .6, 0, lin);- text(p, 'one letter per equation: read it off', 90, 480, m('read'), { size: 30, fill: COL.task, weight: 600 });+ text(p, 'one letter per equation: read it off', 90, 480, m('read'), { size: 30, fill: COL.chalk, weight: 600 });}],['solve', 'A little more work', (m) => {@@ -289,10 +290,12 @@ const BEATS = [say(w, ['x + x + 1 = 3'], 90, 580, m('s1'), { size: 34, fill: S3_ROW[0] });say(w, ['2x = 2, x = 1'], 90, 635, m('s1b'), { size: 34 });say(w, ['y = x = 1'], 90, 690, m('sy'), { size: 34 });- lit(sys, 2, m('s3') - .2); lit(sys, 1, m('s2') - .2); lit(sys, 0, m('s1') - .2); lit(sys, null, m('pt') - .2);+ lit(sys, 2, m('s3') - .2); lit(sys, 1, m('s2') - .2); lit(sys, 0, m('s1') - .2); lit(sys, null, m('pt') - .2); // before the reveals: rows onlyshow(sys.sol, m('pt') + .4);- reveal(sys, 0, m('see')); reveal(sys, 1, m('w')); reveal(sys, 2, m('f'));- show(sys.meet.e, m('f') + .6, .3); pulse(sys.meet.e, m('f') + .8);+ // each plane comes in as its equation is used, so the picture keeps pace with the algebra; named again on see / w / f+ reveal(sys, 2, m('s3') + .3); reveal(sys, 1, m('s2') + .3); reveal(sys, 0, m('s1') + .3);+ glowPl(sys.planes[0], m('see')); glowPl(sys.planes[1], m('w')); glowPl(sys.planes[2], m('f'));+ show(sys.meet.e, m('pt') + .4, .3); pulse(sys.meet.e, m('pt') + .6); pulse(sys.meet.e, m('f') + .8);tw(w, { o: .25 }, m('see'), .4);V.turn({ yaw: 60, pitch: 26 }, m('see'), 4);const c = G(p, {});@@ -367,7 +370,7 @@ const BEATS = [const V = sys.space;tw(sys.sol, { o: 0 }, 0, 0); show(sys.sol, m('many'), .4);V.sway(6, 12);- const sp = V.line(null, null, { color: COL.task, w: 6, into: V.content });+ const sp = V.line(null, null, { color: COL.chalk, w: 6, into: V.content });prog(q => sp.set([-4, -4, -4], [-4 + 8 * q, -4 + 8 * q, -4 + 8 * q]), m('spine'), 1.4, io);// look down the spine, like looking at a book from its endV.turn({ yaw: -135, pitch: 35.3 }, m('spine') + 1.2, 3); V.turn({ yaw: -60, pitch: 15 }, m('pts') - .2, 2.6);@@ -379,7 +382,7 @@ const BEATS = [say(p, ['1 − 1 = 0, 1 − 1 = 0, 1 − 1 = 0 ✓'], 90, 480, m('pts') + .4, { size: 28, fill: COL.good });tw(sys.sol, { s: 1.06 }, m('many'), .3); tw(sys.sol, { s: 1 }, m('many') + .5, .4);const n = G(p, { o: 0 });- T(n, 'one point · no point · a whole line', { x: 90, y: 600, size: 34, weight: 600, fill: COL.task });+ T(n, 'one point · no point · a whole line', { x: 90, y: 600, size: 34, weight: 600, fill: COL.chalk });show(n, m('sum'));}],@@ -404,7 +407,7 @@ const BEATS = [[['Three equations, three unknowns: one triple must make all three true.', 'w1'], ['Each equation is a plane; two planes usually meet in a line.', 'w2'],['The third plane cuts that line at one point: the solution. Check it in each.', 'w3'], ['Three planes can also meet nowhere, or along a whole line.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 34, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/ch13/index.html b/site/linear-algebra/ch13/index.htmlindex 46c9f71..d176e06 100644--- a/site/linear-algebra/ch13/index.html+++ b/site/linear-algebra/ch13/index.html@@ -33,6 +33,16 @@ const tri = q => `(${q.map(c => num(r1(c))).join(', ')})`;const colSys = (p, { b = LEC.b, A = LEC.A, t0 = .1, view = 'col', eq = [90, 180], mat = null, mix = [90, CF_Y], mixAt, space = VIEW } = {}) => {const sys = lin3(p, { A, b, eq, mat, mix, mixAt, view, sol: false, space: { ...space }, t0 });sys.labels(['col 1', 'col 2', 'col 3', 'b']);+ // b on column 3 (the lecture's b is column 3): one label, "col 3 = b", instead of two crowding the one tip+ const [l3, lb] = [sys.tipLabels[2], sys.tipLabels[3]];+ sys.space.on(() => {+ const v = sys.v, same = lb.textContent === 'b' && l3.textContent.startsWith('col 3') && st(lb).o > .5 && [0, 1, 2].every(i => Math.abs(v[`a${i}2`] - v[`b${i}`]) < 1e-6);+ if (l3.textContent !== (same ? 'col 3 = b' : 'col 3')) {+ l3.replaceChildren('col 3');+ if (same) [' = ', 'b'].forEach(str => { const ts = document.createElementNS(NS, 'tspan'); ts.setAttribute('fill', COL.task); if (str === 'b') ts.setAttribute('font-style', 'italic'); ts.textContent = str; l3.append(ts); });+ }+ lb.style.visibility = same ? 'hidden' : '';+ });return sys;};const inCF = (sys, e) => sys.CF.contains(e);@@ -202,7 +212,7 @@ const BEATS = [V.turn({ yaw: VIEW.yaw - 25 }, m('w2'), 2.5); V.turn({ yaw: VIEW.yaw - 10, pitch: 26 }, m('w3'), 2.5);showArrow(sys, 3, m('bb'));prog(q => sys.bArrow.e.setAttribute('stroke-width', 9 + 5 * Math.sin(Math.PI * q)), m('same'), 1.2, lin);- S.bcol = text(S.p, 'b is column 3!', 90, 680, m('same') + .3, { size: 34, fill: COL.task, weight: 600 });+ S.bcol = text(S.p, 'b is column 3!', 90, 680, m('same') + .3, { size: 34, fill: COL.chalk, weight: 600 });}],['mix', 'The mix that reaches b', (m) => {@@ -220,7 +230,7 @@ const BEATS = [const s = text(p, 'the planes meet at (0, 0, 1): the same answer', 90, 680, m('same') + .3, { size: 30, fill: COL.chalk, weight: 600 });sys.view('col', m('easy') + 4, .6);hide(s, m('easy') + 4, .4);- text(p, 'b is a column: the answer at a glance', 90, 730, m('easy') + 4.3, { size: 30, fill: COL.task, weight: 600 });+ text(p, 'b is a column: the answer at a glance', 90, 730, m('easy') + 4.3, { size: 30, fill: COL.chalk, weight: 600 });}],['combo', 'Adding arrows tip to tail', (m) => {@@ -336,7 +346,7 @@ const BEATS = [const lg = G(V.content, {}); legs(sys, [1, 1, 0], [m('path'), m('path') + .7, m('path') + 1.4], lg); hide(lg, m('back'), .4);sys.view('row', m('back'), .6);show(sys.meet.e, m('back') + .3, .3); pulse(sys.meet.e, m('back') + .8);- text(p, 'planes meet at (1, 1, 0) · mix 1, 1, 0', 90, 750, m('agree'), { size: 30, fill: COL.task, weight: 600 });+ text(p, 'planes meet at (1, 1, 0) · mix 1, 1, 0', 90, 750, m('agree'), { size: 30, fill: COL.chalk, weight: 600 });V.turn(ROWV3, m('newb'), 2); V.turn(VIEW, m('col'), 2); V.turn(ROWV3, m('back'), 1.6);}],@@ -354,7 +364,7 @@ const BEATS = [box(p, 90 + 174 * j - 8, 560 - 44, 148, 162, S3_COLS[j], m(k), until);prog(q => sys.cols[j].e.setAttribute('stroke-width', 5 + 5 * Math.sin(Math.PI * q)), m(k), 1.2, lin);});- say(p, ['A x = x·col 1 + y·col 2 + z·col 3'], 90, 740, m('same'), { size: 36, fill: COL.task });+ say(p, ['A x = x·col 1 + y·col 2 + z·col 3'], 90, 740, m('same'), { size: 36, fill: COL.chalk });box(p, 360, 180, 76, 172, COL.chalk, m('x'), m('x') + 3);text(p, 'the x in A x: the mix', 90, 800, m('x') + .3, { size: 30, fill: COL.chalk, weight: 600 });}],@@ -392,7 +402,7 @@ const BEATS = [[['Read down the columns: x·col 1 + y·col 2 + z·col 3 = b.', 'w1'], ['Each column is an arrow in space; b is the target.', 'w2'],['Add arrows tip to tail: tops, middles, bottoms.', 'w3'], ['The solution is the mix that lands on b: where the planes meet.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 36, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/ch14/index.html b/site/linear-algebra/ch14/index.htmlindex 0a20c3a..4bc3022 100644--- a/site/linear-algebra/ch14/index.html+++ b/site/linear-algebra/ch14/index.html@@ -244,7 +244,7 @@ const BEATS = [thick(sys.combo[0], m('mix') + 1.5, 4); thick(sys.combo[1], m('mix') + 2.3, 4);// "until now": one b at a time; "now": every point of the planeconst one = text(p, 'until now: one b → find its mix', 90, 650, m('flip'), { size: 30, fill: COL.dim });- const all = text(p, 'now: every b → is there always a mix?', 90, 700, m('big'), { size: 32, fill: COL.task, weight: 600 });+ const all = text(p, 'now: every b → is there always a mix?', 90, 700, m('big'), { size: 32, fill: COL.chalk, weight: 600 });const { PX, PY } = sys.P, qs = G(p, {});[[-4, 3], [3, 4], [5, -2], [-2, -5], [1, -1], [-5, 0], [4, 1], [-1, 5], [2, -4]].forEach(([x, y], i) => {const d = G(qs, { x: PX(x), y: PY(y), o: 0, s: .4 });@@ -320,7 +320,7 @@ const BEATS = [const why = G(p, {});say(why, ['top: x + 2y'], 90, 615, m('top'), { size: 36, fill: COL.chalk });say(why, ['bottom: 2x + 4y = 2·(x + 2y)'], 90, 665, m('bot'), { size: 36, fill: COL.chalk });- const rule = S.rule = text(p, 'bottom = 2 × top, whatever the mix', 90, 720, m('rule'), { size: 32, fill: COL.task, weight: 600 });+ const rule = S.rule = text(p, 'bottom = 2 × top, whatever the mix', 90, 720, m('rule'), { size: 32, fill: COL.chalk, weight: 600 });box(p, 114, 366, 124, 140, LS_COLS[0], m('why'), m('why') + 3); box(p, 306, 366, 124, 140, LS_COLS[1], m('why') + .4, m('why') + 3.4);// b = (3, 5): off the lineshow(sys.bArrow, m('b'), .3);@@ -358,11 +358,11 @@ const BEATS = [});hide(S.rule, .1, .3);sys.view('row', m('rowp')); hide(lat.g, m('rowp'), .4); hide(trips, m('rowp'), .4);- const sameT = text(p, 'the same line: every point on it solves both', 90, 830, m('same'), { size: 28, fill: COL.task, weight: 600 });+ const sameT = text(p, 'the same line: every point on it solves both', 90, 830, m('same'), { size: 28, fill: COL.chalk, weight: 600 });hide(onT, m('sum') - .3, .3);const sum = G(p, { o: 0 });T(sum, 'columns on one line:', { x: 90, y: 790, size: 28, fill: COL.dim });- T(sum, 'b off the line → no mix; b on the line → endlessly many', { x: 90, y: 835, size: 28, fill: COL.task, weight: 600 });+ T(sum, 'b off the line → no mix; b on the line → endlessly many', { x: 90, y: 835, size: 28, fill: COL.chalk, weight: 600 });show(sum, m('sum'), .5); hide(sameT, m('sum'), .3);sys.view('col', m('sum')); show(lat.g, m('sum'), .4);sys.to({ b0: 3, b1: 1 }, m('sum') + 1.4, 1.1); sys.to({ b0: 2, b1: 4 }, m('sum') + 5.4, 1.1);@@ -391,7 +391,7 @@ const BEATS = [text(p, 'Three columns in space', 60, 110, .2, { size: 40, weight: 600 });const sys = S.sys = sys3(p, LEC3, [0, -1, 4], { t0: m('sys') - .3, mixAt: false }), V = sys.space;V.sway(5, 16);- const ask = text(p, 'every b in space?', 90, 680, m('ask'), { size: 32, fill: COL.task, weight: 600 });+ const ask = text(p, 'every b in space?', 90, 680, m('ask'), { size: 32, fill: COL.chalk, weight: 600 });hide(ask, m('s12') - .3, .3);// b and column 3 wait; the sheet of col 1 and col 2 first[sys.bArrow.e, sys.tipLabels[3], ...sys.combo.map(c => c.e)].forEach(e => put(e, { o: 0 }));@@ -399,13 +399,13 @@ const BEATS = [const sh = S.sheet = sheet(V, 0);put(sh.e, { o: 0 }); show(sh.e, m('s12'), .8);thick(sys.cols[0].e, m('s12') + 1.5); thick(sys.cols[1].e, m('s12') + 2.3);- const n1 = text(p, 'mixes of col 1 and col 2: a flat sheet', 90, 680, m('s12') + 1, { size: 30, fill: COL.task, weight: 600 });+ const n1 = text(p, 'mixes of col 1 and col 2: a flat sheet', 90, 680, m('s12') + 1, { size: 30, fill: COL.chalk, weight: 600 });tw(sys.cols[2].e, { o: 1 }, m('c3'), .4); tw(sys.tipLabels[2], { o: 1 }, m('c3'), .4); thick(sys.cols[2].e, m('c3') + .3);hide(n1, m('z1') - .2, .3);// z lifts the sheet: it passes through b = z·col 3 (the mix 0, 0, z)show(sys.CF, m('z1'), .5); show(sys.bArrow.e, m('z1') + .2, .4); show(sys.tipLabels[3], m('z1') + .4, .4);prog(q => sh.at(2 * q), m('z1') + .2, 1.4);- const zT = T(p, '', { x: 90, y: 680, size: 32, fill: COL.task, font: MATH, weight: 600, o: 0 });+ const zT = T(p, '', { x: 90, y: 680, size: 32, fill: COL.chalk, font: MATH, weight: 600, o: 0 });const zSet = z => { const s = `z = ${fmt1(z)}: the sheet moves to z·col 3`; if (zT.textContent !== s) zT.textContent = s; };prog(q => zSet(q), m('z1') + .2, 1.4); show(zT, m('z1') + .2, .3);sys.to({ x2: -1 }, m('zneg'), 1.4); prog(q => { sh.at(2 - 4 * q); zSet(1 - 2 * q); }, m('zneg'), 1.4);@@ -436,7 +436,7 @@ const BEATS = [sys.to({ a02: 1, a12: 1, a22: -3 }, m('fall'), 2.2);flash(['a02', 'a12', 'a22'].flatMap(k => sys.num(k)), m('now'));const sum = say(p, ['col 3 = (2, −1, 0) + (−1, 2, −3) = (1, 1, −3)'], 90, 660, m('sum'), { size: 32, fill: S3_COLS[2] });- const stuck = text(p, 'every mix stays in the sheet', 90, 710, m('stuck'), { size: 30, fill: COL.task, weight: 600 });+ const stuck = text(p, 'every mix stays in the sheet', 90, 710, m('stuck'), { size: 30, fill: COL.chalk, weight: 600 });hide(sum, m('test') - .3, .3); hide(stuck, m('test') - .3, .3);// the test: top + 2·middle + bottom of A x, liveconst tg = G(p, { o: 0 });@@ -493,7 +493,7 @@ const BEATS = [['3 columns not in one plane: all of space. In one plane: only that plane.', 'w3'],['Columns that lie flat: some b have no mix, the others endlessly many.', 'w4']].forEach(([str, mark], i) => {const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });- mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.task }, g);+ mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });T(g, str, { x: 210, size: 34, weight: 600 });tw(g, { o: 1, x: 0 }, m(mark), .6);diff --git a/site/linear-algebra/lib/linsys.js b/site/linear-algebra/lib/linsys.jsindex 2286ce9..4bc870c 100644--- a/site/linear-algebra/lib/linsys.js+++ b/site/linear-algebra/lib/linsys.js@@ -2,10 +2,12 @@// Every number on screen is the same value: scrub one (drag sideways, or focus it and press ↑/↓) and the lines,// the columns and the other copy follow; drag a line or an arrow tip in the plane and the numbers follow.// The beat moves it with sys.to(); a question turns the reader's hands on with sys.live(true).+// hidePlane / hideEq keep the plane / the equation rows hidden until the beat shows sys.stage / sys.eqRows[i].g.+// The meeting point's label places itself clear of both lines and the axes on every change.// Loads after engine.js and math.js (it uses plane()).const LS_ROW = [COL.whole, COL.nat], LS_COLS = [COL.irr, COL.real], LS_B = COL.task;-function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [90, 560], size = 54, plane: po = {}, view = 'row', rows = 2, hidePlane = false, sol: readout = rows === 2, t0 = .1 } = {}) {+function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [90, 560], size = 54, plane: po = {}, view = 'row', rows = 2, hidePlane = false, hideEq = false, exact = true, sol: readout = rows === 2, t0 = .1 } = {}) {const RI = rows === 2 ? [0, 1] : [0];if (rows === 1) mat = null;const v = { a00: A[0][0], a01: A[0][1], a10: A[1][0], a11: A[1][1], b0: b[0], b1: b[1] };@@ -24,6 +26,14 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [return (r < 0 ? '−' : '') + (one && Math.abs(r) === 1 ? '' : s);};const setText = (e, s) => { if (e.textContent !== s) e.textContent = s; };+ // A value at rest that is a fraction with a small denominator, as [numerator, denominator], else null: 2.5 is 5/2.+ // A value passing between them while it moves is not one, and shows one decimal. exact: false keeps decimals (1.5).+ let moving = false;+ const niceFrac = (n, maxQ = 12) => {+ if (!exact || moving || Math.abs(n - Math.round(n)) < 5e-6) return null; // a whole number, or as good as+ for (let q = 2; q <= maxQ; q++) { const k = Math.round(n * q); if (Math.abs(n * q - k) < 5e-6) return [k, q]; }+ return null;+ };const pt = e => { const q = svg.createSVGPoint(); q.x = e.clientX; q.y = e.clientY; const w = q.matrixTransform(P2.g.getScreenCTM().inverse()); return [(w.x - P2.cx) / P2.u, (P2.cy - w.y) / P2.u]; };const clamp = (k, n) => Math.max(-RANGE[k], Math.min(RANGE[k], n));@@ -36,12 +46,23 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [l?.setAttribute('font-style', 'italic');t.style.pointerEvents = 'none'; if (l) l.style.pointerEvents = 'none'; // the box under them takes the drag// A number with a letter after it keeps its hit box tight around what shows: a hidden 1 leaves just the letter.+ // A fraction at rest is drawn stacked in its own group beside the (then empty) text.+ const fg = G(g, {}); fg.style.pointerEvents = 'none'; fg.classList.add('ls-frac');+ let fkey = '';+ const width = () => fkey ? fg._fw : t.textContent ? t.getComputedTextLength() : 0;+ const show = (n, one1) => {+ const q = niceFrac(n), k = q ? q.join('/') + (t.getAttribute('font-size') || size) : '';+ if (!q) setText(t, fmt(n, one1) || (one1 ? '' : '0')); else setText(t, '');+ if (k === fkey) return;+ fkey = k; fg.replaceChildren();+ if (q) fg._fw = M(fg, [q[0] < 0 ? '−' : '', F(Math.abs(q[0]), q[1])], { x, y, size: +(t.getAttribute('font-size') || size), fill, anchor })._w; // its own colour, not a flash passing over the text+ };const fit = () => {if (!letter || anchor !== 'end') return;- const tw0 = t.textContent ? t.getComputedTextLength() : 0, lw = l.getComputedTextLength() || size * .5, bx0 = x - tw0 - 10;+ const tw0 = width(), lw = l.getComputedTextLength() || size * .5, bx0 = x - tw0 - 10;if (+box.getAttribute('x') !== bx0) { box.setAttribute('x', bx0); box.setAttribute('width', tw0 + lw + 23); }};- const s = { key, t, l, box, one, fit, set: () => { setText(t, fmt(v[key], one) || (one ? '' : '0')); fit(); } };+ const s = { key, t, l, box, one, fit, show, width, frac: fg, set: () => { show(v[key], one); fit(); } };box.setAttribute('aria-label', key);let drag = null;box.addEventListener('pointerdown', e => {@@ -81,6 +102,7 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [T(g, '=', { x: x + 338, y, size, fill: COL.chalk, font: MATH, anchor: 'middle' });const c = slot(g, `b${i}`, x + 376, y, { anchor: 'start' });eqRows.push({ g, bar, a, sign, bb, c });+ if (hideEq) put(g, { o: 0 }); // hideEq: each row waits for its words; the beat shows sys.eqRows[i].g});// The second term shows its size; the sign between carries its sign and sits halfway between the two terms,// so "x + y", "2x + 3y" and "2.5x − 2.5y" are evenly spaced.@@ -88,9 +110,9 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [const right = eq[0] + 270, xEnd = eq[0] + 113 + (r.a.l.getComputedTextLength() || size * .5);r.bb.set = () => {setText(r.sign, v[`a${i}1`] < 0 ? '−' : '+');- setText(r.bb.t, fmt(Math.abs(v[`a${i}1`]), true));+ r.bb.show(Math.abs(v[`a${i}1`]), true);r.bb.fit();- const x = Math.round((xEnd + right - (r.bb.t.textContent ? r.bb.t.getComputedTextLength() : 0)) / 2);+ const x = Math.round((xEnd + right - r.bb.width()) / 2);if (st(r.sign).x !== x) put(r.sign, { x });};});@@ -151,6 +173,34 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [meetBox.style.pointerEvents = trailG.style.pointerEvents = 'none'; // a drag at the crossing reaches the lines under itmk('circle', { r: 11, fill: COL.chalk, stroke: COL.board, 'stroke-width': 3 }, meet);const meetT = T(meet, '', { x: 18, y: -16, size: 30, fill: COL.chalk, font: MATH, weight: 600 });+ // The meeting point's label goes where the two lines and the axes leave it most room (up and right, the old fixed+ // spot, has a rising line through it). Each spot's text box is tested against both lines and both axes.+ const SPOTS = [[18, -16, 1], [18, 40, 1], [-18, -16, -1], [-18, 40, -1], [24, -4, 1], [-24, -4, -1], [24, 30, 1], [-24, 30, -1], [0, 72, 0], [0, -50, 0],+ [0, -96, 0], [0, 118, 0], [64, 44, 1], [-64, 44, -1], [64, -30, 1], [-64, -30, -1]]; // x, baseline, side (0: centred under or over the point); the last six, farther out, for two lines crossing near the point+ const placeMeet = s => {+ if (!s) { if (st(meetT).x !== 18 || st(meetT).y !== -16) put(meetT, { x: 18, y: -16 }); if (meetT.getAttribute('text-anchor') !== 'start') meetT.setAttribute('text-anchor', 'start'); return; }+ const w = meetT.textContent.length * 14 + 4, ox = PX(0) - PX(s.x), oy = PY(0) - PY(s.y);+ const ds = RI.map(i => [v[`a${i}1`], v[`a${i}0`]]).filter(([a, b2]) => a || b2).map(([a, b2]) => [a / Math.hypot(a, b2), b2 / Math.hypot(a, b2)]); // each line's direction on screen+ const gap = (a0, a1, b0, b1) => Math.max(0, b0 - a1, a0 - b1); // between two ranges, 0 when they overlap+ let best = SPOTS[0], far = -Infinity;+ SPOTS.forEach((sp, k) => {+ let d = Infinity;+ const x0 = sp[2] ? Math.min(sp[0], sp[0] + sp[2] * w) : -w / 2, x1 = sp[2] ? Math.max(sp[0], sp[0] + sp[2] * w) : w / 2, y0 = sp[1] - 22, y1 = sp[1];+ ds.forEach(([ux, uy]) => { // a line through the point: 0 if it cuts the text box, else its distance from the nearest corner+ const c = [[x0, y0], [x1, y0], [x0, y1], [x1, y1]].map(([x, y]) => x * uy - y * ux);+ d = Math.min(d, Math.min(...c) < 0 && Math.max(...c) > 0 ? 0 : Math.min(...c.map(Math.abs)));+ });+ // an axis under the text is less bad than a line through it, but still to be avoided+ const ax = Math.min(gap(x0, x1, ox - 34, ox + 4), gap(y0, y1, oy - 4, oy + 30)); // each axis with its numbers (left of y, under x)+ // 14 px of room is room enough: the nearer spot (earlier in the list) wins; between equals, the one farther from the axes+ d = Math.min(d, 14, ax + 8) + Math.min(ax, 100) / 100;+ if (k >= 10) d -= 12; // a far spot only when every near one touches a line+ if (d > far + 1e-6) { best = sp; far = d; }+ });+ if (st(meetT).x !== best[0] || st(meetT).y !== best[1]) put(meetT, { x: best[0], y: best[1] });+ const anchor = best[2] > 0 ? 'start' : best[2] < 0 ? 'end' : 'middle';+ if (meetT.getAttribute('text-anchor') !== anchor) meetT.setAttribute('text-anchor', anchor);+ };const arrowD = (xa, ya, xb, yb) => {const a = [PX(xa), PY(ya)], c = [PX(xb), PY(yb)], L = Math.hypot(c[0] - a[0], c[1] - a[1]);@@ -198,7 +248,7 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [};const frac = n => { // exact when the numbers are whole: a fraction in lowest terms, else one decimalconst det = Math.round(v.a00 * v.a11 - v.a01 * v.a10), num = Math.round(n * det);- if (!Object.values(v).every(Number.isInteger) || !det) return [fmt(n)];+ if (!Object.values(v).every(Number.isInteger) || !det) { const q = niceFrac(n, 99); return q ? [q[0] < 0 ? '−' : '', F(Math.abs(q[0]), q[1])] : [fmt(n)]; } // numbers at rest like 5/2: still exactconst g = gcd(Math.abs(num), Math.abs(det)) || 1, nn = num / g * Math.sign(det), dd = Math.abs(det) / g;return dd === 1 ? [fmt(nn)] : [nn < 0 ? '−' : '', F(Math.abs(nn), dd)];};@@ -216,6 +266,7 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [const s = solve(), inGrid = s.x !== undefined && s.x >= bx[0] && s.x <= bx[1] && s.y >= by[0] && s.y <= by[1];put(meet, { x: inGrid ? PX(s.x) : 0, y: inGrid ? PY(s.y) : 0, o: inGrid ? 1 : 0 });setText(meetT, inGrid ? `(${fracText(s.x)}, ${fracText(s.y)})` : ''); // cleared off the grid, so a seek and a play leave the same page+ placeMeet(inGrid ? s : null); // off the grid it goes back to the first spot, so a seek and a play leave the same pageconst c0 = [v.a00, v.a10], c1 = [v.a01, v.a11], bb = [v.b0, v.b1];[[cols[0], c0], [cols[1], c1], [bArrow, bb]].forEach(([e, [x, y]], i) => {e.setAttribute('d', arrowD(0, 0, x, y));@@ -270,7 +321,7 @@ function linsys(p, { A = [[2, -1], [-1, 2]], b = [0, 3], eq = [90, 250], mat = [const goal = { ...plan };const tr = trail ? path(trailG, '', { ...trailAttrs }) : null;prog(q => {- edit(lsMix(from, goal, q));+ moving = q < 1; edit(lsMix(from, goal, q)); moving = false; // numbers on the way show one decimalif (!tr) return;const pts = [], n = Math.ceil(60 * q);for (let i = 0; i <= n; i++) { const p = meetOf(lsMix(from, goal, n ? q * i / n : 0)); if (p) pts.push(p); }diff --git a/site/linear-algebra/lib/play.js b/site/linear-algebra/lib/play.jsindex 57b1f61..06dfd14 100644--- a/site/linear-algebra/lib/play.js+++ b/site/linear-algebra/lib/play.js@@ -3,6 +3,14 @@// Use it as a beat's ask: ['play', 'Playground', m => { … build S.sys … }, { ask: playAsk(() => S.sys, { tip }) }]// Works with any component that has .live(on), .v and .set(values) (linsys, lin3, vecs, grid2).const PLAY_INK = [COL.chalk, COL.task, COL.whole, COL.nat];+let playKeys = null;+// A beat opened with ?beat=N is not started until the reader plays, and until then the engine keeps every key but Space+// and Enter for the cover. The playground's keys work at once, as its buttons do: the first one starts the lesson.+document.addEventListener('keydown', e => {+ if (P.started || !playKeys || P.keys !== playKeys || e.altKey || e.metaKey || e.ctrlKey || e.shiftKey) return;+ if (e.target.matches?.('input') || e.target.closest?.('button') || !$('help').hidden) return;+ if (playKeys(e)) { e.preventDefault(); e.stopImmediatePropagation(); hideCover(); }+}, true);function playAsk(getSys, { pos = { x: 40, y: 430, w: 720, cls: 'side' }, tip = 'Change anything you like and watch what moves with it.', live } = {}) {return done => {@@ -54,7 +62,7 @@ function playAsk(getSys, { pos = { x: 40, y: 430, w: 720, cls: 'side' }, tip = 'c.replaceChildren(h('div', 'head', [h('p', 'kicker', 'Playground · no score'), h('p', 'prompt', [rich([tip], 24)]),h('p', 'keys', ['Drag numbers sideways or use ', kbd('Tab'), kbd('↑'), kbd('↓'), '; drag lines and arrows; ', kbd('D'), ' to draw on the board.'])]), acts);paint();- P.keys = e => {+ P.keys = playKeys = e => {if (P.gen !== gen) return false;if (e.key === 'Enter') { bOn.click(); return true; }if (isShortcut(e, 'd')) { bDraw.click(); return true; }diff --git a/site/linear-algebra/lib/space3.js b/site/linear-algebra/lib/space3.jsindex 2dfbf7b..1b5b9e0 100644--- a/site/linear-algebra/lib/space3.js+++ b/site/linear-algebra/lib/space3.js@@ -234,13 +234,15 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, p/* ---------- things in space: they re-project with the camera; set() moves them ---------- */// A dot with a label; stem: true adds its shadow on the floor and a dashed line down to it, so its height reads.// Without dx/dy the label finds a free spot round the dot by itself.- function point(pos, { color = COL.chalk, r = 10, label = '', size: ls = 28, into = content, stem = false, dx, dy } = {}) {+ // halo: a dark rim round the label's letters, so it stays readable over a plane's edge or an axis.+ function point(pos, { color = COL.chalk, r = 10, label = '', size: ls = 28, into = content, stem = false, dx, dy, halo = false } = {}) {const e = G(into, {});const st_ = stem ? path(into, '', { stroke: color, 'stroke-width': 2, 'stroke-dasharray': '5 6', 'stroke-opacity': .7, fill: 'none' }) : null;const sh = stem ? mk('ellipse', { rx: 7, ry: 3.5, fill: color, 'fill-opacity': .45 }, into) : null;if (st_) into.insertBefore(st_, e), into.insertBefore(sh, e);mk('circle', { r, fill: color, stroke: COL.board, 'stroke-width': 3 }, e);const t = T(e, label, { x: dx ?? r + 8, y: dy ?? -r - 6, size: ls, fill: color, font: MATH, weight: 600 });+ if (halo) for (const [k, v] of Object.entries({ stroke: COL.board, 'stroke-width': 6, 'stroke-linejoin': 'round', 'paint-order': 'stroke' })) t.setAttribute(k, v);const it = { e, pos, t, stemEl: st_, set(q) { it.pos = q; dirty(); }, label(s) { if (t.textContent !== s) { t.textContent = s; dirty(); } } };Object.assign(it, { r, ls, auto: dx === undefined && dy === undefined, off: [dx ?? r + 8, dy ?? -r - 6] });pts.push(it);@@ -436,7 +438,7 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, p// x·[col 1] + y·[col 2] + z·[col 3] = [b] there, with x, y, z (keys x0, x1, x2) scrubbable: changing them (or A) moves// b to A times the mix; changing b solves for the mix again. mixAt: when the column form fades in (false: never by// itself).-function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eq = [90, 180], mat = [100, 490], size = 46, space: so = {}, view = 'row', sol: readout = true, rows = 3, mix = null, mixAt, t0 = .1 } = {}) {+function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eq = [90, 180], mat = [100, 490], size = 46, space: so = {}, view = 'row', sol: readout = true, rows = 3, mix = null, mixAt, focusDim = .18, t0 = .1 } = {}) {const I = [0, 1, 2], RI = I.slice(0, rows), v = {}, RANGE = {};I.forEach(i => { I.forEach(j => { v[`a${i}${j}`] = A[i][j]; RANGE[`a${i}${j}`] = 9; }); v[`b${i}`] = b[i]; RANGE[`b${i}`] = 30; });if (rows < 3) { mat = null; readout = false; }@@ -448,6 +450,13 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqreturn (r < 0 ? '−' : '') + (one && Math.abs(r) === 1 ? '' : s);};const setText = (e, s) => { if (e.textContent !== s) e.textContent = s; };+ let moving = false;+ // A value at rest that is a fraction with a small denominator, as [numerator, denominator], else null: 2.5 is 5/2.+ const niceFrac = (n, maxQ = 12) => {+ if (moving || Math.abs(n - Math.round(n)) < 5e-6) return null; // a whole number, or as good as+ for (let q = 2; q <= maxQ; q++) { const k = Math.round(n * q); if (Math.abs(n * q - k) < 5e-6) return [k, q]; }+ return null;+ };const clamp = (key, n) => Math.max(-RANGE[key], Math.min(RANGE[key], n));const Am = (s = v) => I.map(i => I.map(j => s[`a${i}${j}`]));const col = j => [v[`a0${j}`], v[`a1${j}`], v[`a2${j}`]], bv = () => [v.b0, v.b1, v.b2];@@ -477,7 +486,17 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eql?.setAttribute('font-style', 'italic');t.style.pointerEvents = 'none'; // Firefox hit-tests the text over the box: the box must get the pointerif (l) l.style.pointerEvents = 'none';- const s = { key, t, l, box, one, set: () => setText(t, fmt(v[key], one) || (one ? '' : '0')) };+ // A fraction at rest is drawn stacked in its own group beside the (then empty) text; a value moving shows one decimal.+ const fg = G(g, {}); fg.style.pointerEvents = 'none'; fg.classList.add('ls-frac');+ let fkey = '';+ const show = (n, one1) => {+ const q = niceFrac(n), k = q ? q.join('/') + (t.getAttribute('font-size') || fs) : '';+ setText(t, q ? '' : fmt(n, one1) || (one1 ? '' : '0'));+ if (k === fkey) return;+ fkey = k; fg.replaceChildren();+ if (q) M(fg, [q[0] < 0 ? '−' : '', F(Math.abs(q[0]), q[1])], { x, y, size: +(t.getAttribute('font-size') || fs), fill, anchor });+ };+ const s = { key, t, l, box, one, show, frac: fg, set: () => show(v[key], one) };box.setAttribute('aria-label', key);let drag = null;box.addEventListener('pointerdown', e => {@@ -518,9 +537,10 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqterms.forEach(({ s, sign }, j) => {const key = `a${i}${j}`;s.set = () => {- const n = Math.round(v[key]), zero = n === 0, o = zero ? '.35' : ''; // whole numbers only: a passing 2.5 would run into the sign+ // whole numbers while moving (a passing 2.3 would run into the sign); a fraction at rest exactly (5/2)+ const n = niceFrac(v[key]) ? v[key] : Math.round(v[key]), zero = n === 0, o = zero ? '.35' : '';if (sign) { setText(sign, n < 0 ? '−' : '+'); sign.style.opacity = o; }- setText(s.t, zero ? '0' : fmt(sign ? Math.abs(n) : n, true));+ s.show(sign ? Math.abs(n) : n, true);s.t.style.opacity = o; s.l.style.opacity = o;};});@@ -578,7 +598,7 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqplanes.forEach((pl, i) => { pl.visible = i < rows; });const lines = I.map(() => V.seg(null, null, { color: COL.chalk, w: 2.5, dash: '7 7', into: ROWV }));lines.forEach(l => l.e.setAttribute('stroke-opacity', .75));- const meet = V.point(null, { color: COL.chalk, r: 11, into: ROWV });+ const meet = V.point(null, { color: COL.chalk, r: 11, into: ROWV, halo: true });// A plane is dragged by its edge: a wide, invisible copy of its outline.const hits = planes.map(pl => {const h = path(ROWV, '', { stroke: 'transparent', 'stroke-width': 26, fill: 'none' });@@ -699,7 +719,7 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqconst solve = () => solveOf(v);const exact = n => { // a fraction in lowest terms when the numbers are whole, else one decimalconst det = Math.round(S3_det(Am())), num = Math.round(n * det);- if (!Object.values(v).every(Number.isInteger) || !det) return [fmt(n)];+ if (!Object.values(v).every(Number.isInteger) || !det) { const q = niceFrac(n, 99); return q ? [q[0] < 0 ? '−' : '', F(Math.abs(q[0]), q[1])] : [fmt(n)]; } // numbers at rest like 5/2: still exactconst g = gcd(Math.abs(num), Math.abs(det)) || 1, nn = num / g * Math.sign(det), dd = Math.abs(det) / g;return dd === 1 ? [fmt(nn)] : [nn < 0 ? '−' : '', F(Math.abs(nn), dd)];};@@ -713,14 +733,14 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqconst s = solve(), one = s.x !== undefined, X = mix ? [v.x0, v.x1, v.x2] : one ? [s.x, s.y, s.z] : null;const inCube = rows === 3 && one && [s.x, s.y, s.z].every(c => Math.abs(c) <= R + 1e-9);meet.set(inCube ? [s.x, s.y, s.z] : null);- if (inCube) meet.label(`(${[s.x, s.y, s.z].map(c => fmt(c)).join(', ')})`);+ const txt = parts => parts.map(q => typeof q === 'string' ? q : q.f.join('/')).join(''); // a fraction part is { f: [n, d] }, not text+ if (inCube) meet.label(`(${[s.x, s.y, s.z].map(c => txt(exact(c))).join(', ')})`); // exact, as the readout: (4/3, 1, 0)const O = [0, 0, 0], bb = bv();I.forEach(j => cols[j].set(O, col(j)));bArrow.set(O, bb);const reach = X && X.every(c => Math.abs(c) <= 12);let at = O;I.forEach(j => { const nxt = j === 2 && !mix ? bb : at.map((c, l) => c + X?.[j] * col(j)[l]); combo[j].set(reach ? at : null, reach ? nxt : null); at = reach ? nxt : O; });- const txt = parts => parts.map(q => typeof q === 'string' ? q : q.f.join('/')).join(''); // a fraction part is { f: [n, d] }, not textconst key = one ? [s.x, s.y, s.z].map(c => txt(exact(c))).join('|') : s.none ? 'none' : 'many' + s.rank;if (readout && key !== solKey) {solKey = key;@@ -750,7 +770,7 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqplan = { ...plan, ...next };derive(plan, Object.keys(next));const goal = { ...plan }, keys = Object.keys(next);- prog(q => edit(Object.fromEntries(keys.map(key => [key, from[key] + (goal[key] - from[key]) * q]))), at, dur, ease);+ prog(q => { moving = q < 1; edit(Object.fromEntries(keys.map(key => [key, from[key] + (goal[key] - from[key]) * q]))); moving = false; }, at, dur, ease); // numbers on the way: whole or one decimal},// Show the row picture, the column picture, or both; only what shows can be dragged.view(which, at, dur = .6) {@@ -759,10 +779,11 @@ function lin3(p, { A = [[2, -1, 0], [-1, 2, -1], [0, -3, 4]], b = [0, -1, 4], eqprog(() => { usable(ROWV, which !== 'col'); usable(COLV, which !== 'row'); V.redraw(); }, at, 0, lin);},// Light some planes (an index, a list, or null for all) and dim the rest, with their equations.- focus(which, at, dur = .6) {+ // { dim } is how much of the other planes is left (default lin3's focusDim, .18); steep planes that crowd want .06.+ focus(which, at, dur = .6, { dim = focusDim } = {}) {const on = which === null || which === undefined ? I : [].concat(which);I.forEach(i => {- planes[i].fade(on.includes(i) ? 1 : .18, at, dur);+ planes[i].fade(on.includes(i) ? 1 : dim, at, dur);if (rowG[i]) tw(rowG[i], { o: on.includes(i) ? 1 : .35 }, at, dur);});},diff --git a/site/linear-algebra/lib/vecs.js b/site/linear-algebra/lib/vecs.jsindex c5b147a..276bde4 100644--- a/site/linear-algebra/lib/vecs.js+++ b/site/linear-algebra/lib/vecs.js@@ -73,15 +73,18 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna/* ---------- numbers you can scrub ---------- */// A slot shows one value; its ink is redrawn when the value's text changes and keeps its colour in `color`,// so a flash (c_color) survives the redraw. The box under it takes the drag; the text never does.- function slot(g, key, x, y, { w = size * 1.7, sz = size, fill = COL.chalk, anchor = 'middle', scrub = true, pf } = {}) {+ // coef: a number written in front of a letter or a column; a 1 there is not written (−1 is "−") unless the reader can scrub it.+ function slot(g, key, x, y, { w = size * 1.7, sz = size, fill = COL.chalk, anchor = 'middle', scrub = true, pf, coef = false } = {}) {const bx = anchor === 'middle' ? x - w / 2 : anchor === 'end' ? x - w : x;const box = scrub ? mk('rect', { x: bx, y: y - sz * .95, width: w, height: sz * 1.3, rx: 10, fill: 'transparent' }, g) : null;const ink = G(g, {}); ink.setAttribute('color', fill); ink.style.pointerEvents = 'none';let shownKey = '';const s = {- key, box, ink, fill,+ key, box, ink, fill, coef, held: false,set() {- const pp = pf ? pf(v) : parts(get(key)), k = JSON.stringify(pp);+ let pp = pf ? pf(v) : parts(get(key));+ if (coef && !s.held && pp.length === 1 && /^−?1$/.test(pp[0])) pp = [pp[0].slice(0, -1)];+ const k = JSON.stringify(pp);if (k === shownKey) return;shownKey = k; ink.replaceChildren();const long = pp.some(q => typeof q === 'string' && q.includes(DECIMAL_SIGN)); // a value passing between whole numbers@@ -128,6 +131,8 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna// { fn: v => [top, bottom], w, fill } a column of computed math parts, e.g. ['3 + 1'] (see vs.paren)// { key: 'c' } one scrubbable number (a scalar), chalk// { key: 'd', signed: true } the same, with its sign drawn as the + or − before it (for a second term: c v − 2w)+ // A scalar in front of a letter or a column is a coefficient: a 1 is not written (−1 shows as −) unless the reader+ // can scrub it; { key: 'c', one: true } writes it anyway (a beat whose voice reads "one times v").// Each item is its own group in .parts, so a beat can reveal them one by one; o: 0 starts them all hidden.function row(items, { x = 90, y = 250, size: sz = size, o = 1, gap = sz * .28 } = {}) {const g = G(p, {}), out = [], mid = y - sz * .32, rh = sz * 1.3;@@ -156,9 +161,9 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snaslot(part, 'sign', cx + sz * .3, y, { sz, scrub: false, pf: vv => [vv[it.key] < -1e-9 ? '−' : '+'] });cx += sz * .45 + gap * .5;}- const w = sz * 1.15, k = it.key;- slot(part, k, cx + w, y, { sz, fill: it.fill ?? COL.chalk, w, anchor: 'end', pf: it.signed ? vv => parts(Math.abs(vv[k])) : undefined });- cx += w + gap * .5; // clear of a bracket after it+ const w = sz * 1.15, k = it.key, nx = items[items.indexOf(it) + 1], coef = !it.one && !!nx && typeof nx === 'object' && (nx.t !== undefined || !!nx.col || !!nx.fn);+ slot(part, k, cx + w, y, { sz, fill: it.fill ?? COL.chalk, w, anchor: 'end', coef, pf: it.signed ? vv => parts(Math.abs(vv[k])) : undefined });+ cx += w + gap * .5 + (nx?.col || nx?.fn ? sz * .14 : 0); // clear of a bracket after it: "1[" must not touch}out.push(part);}@@ -363,6 +368,7 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snas.box.setAttribute('stroke', ok ? COL.faint : 'none');s.box.setAttribute('stroke-dasharray', '4 6');if (ok) s.box.setAttribute('tabindex', 0); else s.box.removeAttribute('tabindex');+ if (s.coef && s.held !== ok) { s.held = ok; s.set(); } // a 1 the reader can grab is written}for (const id of ids) {const a = A[id], can = on && (id === 'sum' ? solving : id in onDrag) && (dragSet ? dragSet.includes(id) : st(a.g).o > .3);