Skip to content

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

feat(linear-algebra): Unit 5 reviewed; the book's 40 chapters on the contents

yzra49d2bdc5a99
diff --git a/site/linear-algebra/ch35/index.html b/site/linear-algebra/ch35/index.html
index 53a9688..800696d 100644
--- a/site/linear-algebra/ch35/index.html
+++ b/site/linear-algebra/ch35/index.html
@@ -30,6 +30,15 @@ const CARD = { x: 40, y: 450, w: 740, cls: 'side' };
const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
const title = (p, str) => text(p, str, 60, 110, .2, { size: 40, weight: 600 });
+// A beat that carries on the last beat's panel names itself: the old title fades, the new one comes in.
+const retitle = str => { hide(S.title, .1, .3); S.title = text(S.p, str, 60, 110, .35, { size: 40, weight: 600 }); };
+// A copy of A's number (i, j) flies on an arc to its place in Aᵀ, row j, column i, and fades there.
+const ghost = (p, T_, i, j, t0, { size = 54, dur = 1.3, lift = 90 } = {}) => {
+ const { a, t } = T_.L, x1 = a.cx(j), y1 = a.ry(i), x2 = t.cx(i), y2 = t.ry(j);
+ const e = M(p, [num(T_.v[`a${i}${j}`])], { x: x1, y: y1, size, fill: MMT_ROW[i], o: 0 });
+ prog(q => put(e, { x: x1 + (x2 - x1) * q, y: y1 + (y2 - y1) * q - lift * Math.sin(Math.PI * q), o: q <= 0 || q >= 1 ? 0 : Math.min(1, q / .08, (1 - q) / .12) }), t0, dur, io);
+ return e;
+};
// A chalk ring around a box, drawn on at t0.
const ring = (p, x, y, w, h, t0, color = COL.chalk) => { const r = path(p, `M${x + 14} ${y}H${x + w - 14}Q${x + w} ${y} ${x + w} ${y + 14}V${y + h - 14}Q${x + w} ${y + h} ${x + w - 14} ${y + h}H${x + 14}Q${x} ${y + h} ${x} ${y + h - 14}V${y + 14}Q${x} ${y} ${x + 14} ${y}Z`, { stroke: color, 'stroke-width': 3, fill: 'none' }, { d: 0 }); draw(r, t0, .6); return r; };
// A curved arrow from (x1, y1) to (x2, y2), bulging by `bend`, drawn on at t0.
@@ -38,7 +47,8 @@ const bow = (p, x1, y1, x2, y2, t0, { bend = -60, color = COL.chalk, w = 3 } = {
const cx = mx + nx * bend, cy = my + ny * bend, tx = x2 - cx, ty = y2 - cy, tl = Math.hypot(tx, ty), ux = tx / tl, uy = ty / tl;
const g = G(p, {});
draw(path(g, `M${x1} ${y1}Q${cx} ${cy} ${x2} ${y2}`, { stroke: color, 'stroke-width': w, fill: 'none' }, { d: 0 }), t0, .6);
- const hd = path(g, `M${x2 - 14 * ux - 8 * uy} ${y2 - 14 * uy + 8 * ux}L${x2} ${y2}L${x2 - 14 * ux + 8 * uy} ${y2 - 14 * uy - 8 * ux}`, { stroke: color, 'stroke-width': w, fill: 'none', o: 0 });
+ const hd = path(g, `M${x2 - 14 * ux - 8 * uy} ${y2 - 14 * uy + 8 * ux}L${x2} ${y2}L${x2 - 14 * ux + 8 * uy} ${y2 - 14 * uy - 8 * ux}`, { stroke: color, 'stroke-width': w, fill: 'none' });
+ put(hd, { o: 0 });
show(hd, t0 + .5, .2);
return g;
};
@@ -64,6 +74,22 @@ const target = (P2, [x, y], into, t0 = .3) => {
return g;
};
const matEl = rows => mmEl(rows, { size: 22 });
+// blanks() writes a row's parts as math text and drops a drawn matrix (mmEl), so a row that shows one becomes its own
+// question with the matrix in its prompt; rows without a matrix stay together in one question.
+const blankQs = (id, prompt, rows) => {
+ const qs = [], plain = [];
+ const flush = () => { if (plain.length) qs.push({ id: `${id}${qs.length + 1}`, prompt: [prompt], build: blanks(plain.splice(0)) }); };
+ rows.forEach(r => {
+ const k = r.parts.findLastIndex(p => p instanceof Element);
+ if (k < 0) { plain.push(r); return; }
+ flush();
+ const head = r.parts.slice(0, k + 1), rest = r.parts.slice(k + 1);
+ if (typeof rest[0] === 'string') rest[0] = rest[0].replace(/^[\s.,]+/, '');
+ qs.push({ id: `${id}${qs.length + 1}`, prompt: [prompt + ' ', ...(head[0] instanceof Element ? ['A = '] : []), ...head], build: blanks([{ ...r, parts: rest }]) });
+ });
+ flush();
+ return qs;
+};
/* ---------- practice data (every answer read off twice: by rows of A and by columns of Aᵀ) ---------- */
const TRQ = [
@@ -100,7 +126,7 @@ const PRODQ = [
why: 'AB is 2 × 5, so (AB)ᵀ is 5 × 2. Bᵀ is 5 × 3, and BᵀAᵀ = (5 × 3)(3 × 2) = 5 × 2 agrees.', hint: 'Find the size of AB first (outside numbers), then swap. For Bᵀ, swap B’s size.' },
];
const HANDQ = [
- { id: 'p-hand1', start: { mA: 2, nA: 2, a00: 0, a01: 0, a10: 0, a11: 0 }, prompt: ['Change A until Aᵀ = ', matEl([[1, 4], [-2, 0]]), '.'],
+ { id: 'p-hand1', start: { mA: 2, nA: 2, a00: 1, a01: 0, a10: 0, a11: 1 }, prompt: ['Change A until Aᵀ = ', matEl([[1, 4], [-2, 0]]), '.'],
test: (v, T_) => v.mA === 2 && v.nA === 2 && T_.T(0, 0) === 1 && T_.T(0, 1) === 4 && T_.T(1, 0) === -2 && T_.T(1, 1) === 0,
why: 'A = (1, −2), (4, 0): its columns (1, 4) and (−2, 0) are the rows of Aᵀ.', hint: 'Row 1 of Aᵀ, (1, 4), must be column 1 of A. You can also type straight into Aᵀ.',
ans: { a00: 1, a01: -2, a10: 4, a11: 0 } },
@@ -108,7 +134,7 @@ const HANDQ = [
test: v => v.mA === 2 && v.nA === 2 && v.a10 === -3 && v.a11 === 2,
why: 'Column 2 of Aᵀ is row 2 of A: (−3, 2) across the bottom of A.', hint: v => v.a01 === -3 && v.a11 === 2 ? 'That moved the violet arrow, column 2 of A. The coral dashed one is row 2 of A: the bottom row.' : 'The coral dashed arrow is row 2 of A. Its numbers are the bottom row of A.',
ans: { a10: -3, a11: 2 } },
- { id: 'p-hand3', start: { mA: 2, nA: 2, a00: 0, a01: 0, a10: 0, a11: 0 }, prompt: ['Change the size and the numbers of A so that Aᵀ is the row (1, 2, 3).'],
+ { id: 'p-hand3', start: { mA: 2, nA: 2, a00: 1, a01: 0, a10: 0, a11: 1 }, prompt: ['Change the size and the numbers of A so that Aᵀ is the row (1, 2, 3).'],
test: v => v.mA === 3 && v.nA === 1 && v.a00 === 1 && v.a10 === 2 && v.a20 === 3,
why: 'A must be the column (1, 2, 3): 3 × 1. Its transpose lies down as a row.', hint: v => v.mA === 1 && v.nA === 3 ? 'A is a row now, so Aᵀ is a column. Make A the column: 3 rows, 1 column.' : 'Aᵀ is 1 × 3, so A must be 3 × 1: three rows, one column. Change the size numbers under A.',
ans: { mA: 3, nA: 1, a00: 1, a10: 2, a20: 3 } },
@@ -133,7 +159,7 @@ const BEATS = [
['recall', 'Rows and columns', (m) => {
const p = S.p = panel(0);
- title(p, 'Rows and columns, again');
+ S.title = title(p, 'Rows and columns, again');
const T_ = S.T = mmT(p, { A: A1, at: AT, size: 54, cw: 86, rh: 76, gap: 200, hideT: true, t0: m('A') - .4 });
put(T_.L.t.g, { o: 0 });
const a = T_.L.a;
@@ -144,7 +170,7 @@ const BEATS = [
const n = S.note = G(p, {});
hide(sizeRing(p, a, T_.L.bottom - 12, m('size')), m('last') - .3, .3);
const s1 = G(n, { o: 0 });
- M(s1, ['2 × 3'], { x: 900, y: 300, size: 44, fill: COL.chalk });
+ M(s1, ['2 × 3'], { x: 900, y: 300, size: 44, fill: COL.chalk, anchor: 'start' });
T(s1, '2 rows, 3 columns: rows first', { x: 900, y: 350, size: 28, fill: COL.dim, weight: 600 });
show(s1, m('size') + .3, .4); hide(s1, m('last') - .3, .3);
// chapter 34: the permutation P and its flip
@@ -160,7 +186,7 @@ const BEATS = [
['flip', 'Rows stand up as columns', (m) => {
const p = S.p, T_ = S.T, { a, t } = T_.L;
- hide(S.note, .1, .4);
+ hide(S.note, .1, .4); retitle('Rows stand up as columns');
show(t.g, m('r1') + .3, .4);
T_.show('row', 0, m('r1')); T_.show('row', 1, m('r2'));
T_.fly(m('c1'), { by: (i, j) => (i ? m('c2') - m('c1') : 0) + j * .2, dur: 1.1 });
@@ -168,19 +194,19 @@ const BEATS = [
T_.show(null, null, m('name'));
const n = S.note = G(p, {});
const nm = G(n, { o: 0 });
- M(nm, ['Aᵀ'], { x: 900, y: 320, size: 54 });
+ M(nm, ['Aᵀ'], { x: 900, y: 320, size: 54, anchor: 'start' });
T(nm, 'say: “A transpose”', { x: 900, y: 372, size: 28, fill: COL.dim, weight: 600 });
show(nm, m('name') + .2, .4);
sizeRing(p, a, T_.L.bottom - 12, m('size')); sizeRing(p, t, T_.L.bottom - 12, m('size') + .5);
const sz = G(n, { o: 0 });
- M(sz, ['2 × 3 → 3 × 2'], { x: 900, y: 560, size: 40 });
+ M(sz, ['2 × 3 → 3 × 2'], { x: 900, y: 560, size: 40, anchor: 'start' });
T(sz, 'the size numbers swap too', { x: 900, y: 606, size: 28, fill: COL.dim, weight: 600 });
show(sz, m('size') + 1, .4);
}],
['cols', 'Columns lie down as rows', (m) => {
const p = S.p, T_ = S.T, { t } = T_.L;
- hide(S.note, .1, .4);
+ hide(S.note, .1, .4); retitle('Columns lie down as rows');
[0, 1, 2].forEach(j => {
T_.show('col', j, m(`col${j + 1}`), { side: 'a' });
T_.show('col', j, m(`row${j + 1}`));
@@ -194,24 +220,24 @@ const BEATS = [
}],
['entry', 'One number at a time', (m) => {
- const p = S.p, T_ = S.T, { a, t } = T_.L;
- hide(S.note, .1, .4);
+ const p = S.p, T_ = S.T;
+ hide(S.note, .1, .4); retitle('One number at a time');
const n = S.note = G(p, {});
T_.show('cell', [1, 0], m('pick'), { side: 't' }); T_.show('cell', [1, 0], m('from'));
say(n, ['row 1, column 2 of Aᵀ: 4'], 960, 300, m('pick') + .3, { size: 32 });
say(n, ['= row 2, column 1 of A'], 960, 350, m('from') + .3, { size: 32 });
- bow(n, a.cx(0) + 20, a.ry(1) + 20, t.cx(1) - 10, t.ry(0) + 22, m('from'), { bend: 90 });
+ ghost(n, T_, 1, 0, m('from') + .3);
T_.show('cell', [0, 2], m('two'), { side: 't' }); T_.show('cell', [0, 2], m('from2'));
say(n, ['row 3, column 1 of Aᵀ: 3'], 960, 440, m('two') + .3, { size: 32 });
say(n, ['= row 1, column 3 of A'], 960, 490, m('from2') + .3, { size: 32 });
- bow(n, a.cx(2), a.ry(0) - 50, t.cx(0) - 20, t.ry(2) - 40, m('from2'), { bend: -70 });
+ ghost(n, T_, 0, 2, m('from2') + .3);
T_.show(null, null, m('rule'));
const r = G(n, { o: 0 });
- M(r, ['row i, column j of Aᵀ'], { x: 960, y: 610, size: 34, fill: COL.chalk });
- M(r, ['= row j, column i of A'], { x: 960, y: 660, size: 34, fill: COL.chalk });
+ M(r, ['row i, column j of Aᵀ'], { x: 960, y: 610, size: 34, fill: COL.chalk, anchor: 'start' });
+ M(r, ['= row j, column i of A'], { x: 960, y: 660, size: 34, fill: COL.chalk, anchor: 'start' });
show(r, m('rule') + .2, .5);
text(n, 'swap the address', 960, 730, m('swap'), { size: 30, weight: 600 });
- [[0, 1], [2, 1], [1, 1], [0, 0]].forEach(([i, j], k) => T_.show('cell', [i, j], m('rule') + 1 + k * 1.4));
+ [[0, 1], [1, 2], [1, 1], [0, 0]].forEach(([i, j], k) => { T_.show('cell', [i, j], m('rule') + 1 + k * 1.4); ghost(n, T_, i, j, m('rule') + 1.1 + k * 1.4, { dur: 1.1, lift: 60 }); });
T_.show(null, null, m('rule') + 6.6);
}],
@@ -261,7 +287,7 @@ const BEATS = [
bow(p, T1.L.a.x + T1.L.a.W + 14, T1.L.midY, T1.L.t.x - 14, T1.L.midY, m('again') + 1, { bend: -40 });
bow(p, T2.L.a.x + T2.L.a.W + 14, T2.L.midY, T2.L.t.x - 14, T2.L.midY, m('back') - .3, { bend: -40 });
const r = G(p, { o: 0 });
- M(r, ['(Aᵀ)ᵀ = A'], { x: 1100, y: 330, size: 54 });
+ M(r, ['(Aᵀ)ᵀ = A'], { x: 1100, y: 330, size: 54, anchor: 'start' });
T(r, 'two flips undo each other', { x: 1100, y: 380, size: 28, fill: COL.dim, weight: 600 });
show(r, m('rule'), .5);
T1.flash('a', 'all', m('rule') + .3); T2.flash('t', 'all', m('rule') + .9);
@@ -271,7 +297,7 @@ const BEATS = [
X.fly(m('row'), { by: 'cells', step: .3, dur: .9 });
X.show('col', 0, m('col'), { side: 'a' }); X.show(null, null, m('row'));
const nm = G(p, { o: 0 });
- M(nm, ['xᵀ = a row'], { x: 1100, y: 640, size: 44 });
+ M(nm, ['xᵀ = a row'], { x: 1100, y: 640, size: 44, anchor: 'start' });
T(nm, 'a column (3 × 1) lies down: 1 × 3', { x: 1100, y: 690, size: 28, fill: COL.dim, weight: 600 });
show(nm, m('name'), .5);
}],
@@ -356,7 +382,7 @@ const BEATS = [
verdict();
show(v3, m('wrong') + 1.5, .4); show(v2, m('match'), .4);
const r = S.rule = G(p, { o: 0 });
- M(r, ['(AB)ᵀ = BᵀAᵀ'], { x: 1080, y: 300, size: 54 });
+ M(r, ['(AB)ᵀ = BᵀAᵀ'], { x: 1080, y: 300, size: 54, anchor: 'start' });
T(r, 'flip each one, and reverse the order', { x: 1080, y: 350, size: 28, fill: COL.dim, weight: 600 });
show(r, m('rule'), .5);
P2.flash('a', 'all', m('rule') + 2.6); P2.flash('b', 'all', m('rule') + 3.2); TT.flash('t', 'all', m('rule') + 4.2); P2.flash('c', 'all', m('rule') + 4.2);
@@ -439,21 +465,12 @@ const BEATS = [
tw(g, { o: 1, x: 0 }, m(mark), .6);
});
}],
- ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{
- id: 'p-tr', prompt: ['Write the rows of Aᵀ. (Row k of Aᵀ is column k of A.)'],
- build: blanks(TRQ),
- }], done, 'Chapter practice · set 1 of 4') }],
- ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
- id: 'p-size', prompt: ['Sizes and addresses.'],
- build: blanks(SIZEQ),
- }, {
+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, blankQs('p-tr', 'Write the rows of Aᵀ. (Row k of Aᵀ is column k of A.)', TRQ), done, 'Chapter practice · set 1 of 4') }],
+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [...blankQs('p-size', 'Sizes and addresses.', SIZEQ), {
id: 'p-tf', prompt: ['True or false?'],
build: grid(TFQ, [['t', 'True', COL.good, 'T'], ['f', 'False', COL.bad, 'F']], { multi: false, text: true }),
}], done, 'Chapter practice · set 2 of 4') }],
- ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
- id: 'p-prod', prompt: ['Transposes of products.'],
- build: blanks(PRODQ),
- }, {
+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [...blankQs('p-prod', 'Transposes of products.', PRODQ), {
id: 'p-abc', prompt: ['Three matrices: (ABC)ᵀ = (AB · C)ᵀ. Use the rule twice. Which is it?'],
build: choice(['AᵀBᵀCᵀ', 'CᵀBᵀAᵀ', 'CᵀAᵀBᵀ', 'CBA'], 1,
'(AB · C)ᵀ = Cᵀ(AB)ᵀ = CᵀBᵀAᵀ: flip each, and the whole order turns around.',
@@ -462,7 +479,7 @@ const BEATS = [
['final4', 'Chapter practice', () => {
const p = panel(0);
title(p, 'Build it');
- S.T = mmT(p, { A: [[0, 0], [0, 0]], at: [90, 270], size: 44, cw: 70, rh: 62, gap: 130, plane: { cx: 1190, cy: 470, u: 44 } });
+ S.T = mmT(p, { A: [[1, 0], [0, 1]], at: [90, 270], size: 44, cw: 70, rh: 62, gap: 130, plane: { cx: 1190, cy: 470, u: 44 } });
}, { ask: done => quiz({ x: 40, y: 500, w: 740, cls: 'side' }, HANDQ.map(q => ({
id: q.id, prompt: q.prompt,
build: (body, api) => { S.T.set(q.start); return mmTTask(S.T, q.test, q.why, q.hint, () => S.T.set(q.ans), { sizes: q.id === 'p-hand3' })(body, api); },
diff --git a/site/linear-algebra/ch36/audio/en/rtr.mp3 b/site/linear-algebra/ch36/audio/en/rtr.mp3
index 7579f88..c6d54cf 100644
Binary files a/site/linear-algebra/ch36/audio/en/rtr.mp3 and b/site/linear-algebra/ch36/audio/en/rtr.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/rtr2.mp3 b/site/linear-algebra/ch36/audio/en/rtr2.mp3
index 5e4c3df..56d9a44 100644
Binary files a/site/linear-algebra/ch36/audio/en/rtr2.mp3 and b/site/linear-algebra/ch36/audio/en/rtr2.mp3 differ
diff --git a/site/linear-algebra/ch36/audio/en/timings.js b/site/linear-algebra/ch36/audio/en/timings.js
index 0fb6895..4d9a227 100644
--- a/site/linear-algebra/ch36/audio/en/timings.js
+++ b/site/linear-algebra/ch36/audio/en/timings.js
@@ -350,18 +350,22 @@ window.TIMINGS = {
]
},
"rtr": {
- "dur": 34.512,
+ "dur": 73.056,
"marks": {
- "R": 3.255,
- "rt": 13.333,
- "mult": 17.617,
- "size": 20.365,
- "work": 24.557,
- "c11": 25.482,
- "c12": 26.393,
- "c21": 27.266,
- "c22": 27.982,
- "sym": 29.023
+ "R": 3.789,
+ "rt": 14.206,
+ "mult": 18.49,
+ "size": 21.094,
+ "work": 27.474,
+ "c11": 29.648,
+ "s11": 38.984,
+ "c12": 41.953,
+ "s12": 49.635,
+ "c21": 52.344,
+ "s21": 60.312,
+ "c22": 61.523,
+ "s22": 64.805,
+ "sym": 67.695
},
"cues": [
[
@@ -369,50 +373,78 @@ window.TIMINGS = {
"Here is where symmetric matrices come from."
],
[
- 3.255,
+ 3.789,
"Take any matrix R, even one that is not square."
],
[
- 6.875,
+ 7.826,
"This R is three by two: one, three; two, three; four, one."
],
[
- 13.333,
+ 14.206,
"Its transpose, R transpose, is two by three."
],
[
- 17.617,
+ 18.49,
"Multiply R transpose times R."
],
[
- 20.365,
- "Two by three times three by two: the answer is two by two."
+ 21.094,
+ "Two by three times three by two: the inside threes match, and the answer is two by two."
+ ],
+ [
+ 27.474,
+ "Work it out, one number at a time."
+ ],
+ [
+ 29.648,
+ "Top left: row one of R transpose, times column one of R."
+ ],
+ [
+ 34.258,
+ "One times one, plus two times two, plus four times four: one plus four plus sixteen, twenty-one."
+ ],
+ [
+ 41.953,
+ "Top right: row one times column two."
+ ],
+ [
+ 44.857,
+ "One times three, plus two times three, plus four times one: three plus six plus four, thirteen."
+ ],
+ [
+ 52.344,
+ "Bottom left: row two times column one."
],
[
- 24.557,
- "Work it out."
+ 55.638,
+ "Three times one, plus three times two, plus one times four: thirteen again."
],
[
- 25.482,
- "Twenty-one, thirteen, thirteen, nineteen."
+ 61.523,
+ "Bottom right: row two times column two: nine plus nine plus one, nineteen."
],
[
- 29.023,
+ 67.695,
"Look at the two thirteens, in mirror spots."
],
[
- 32.266,
+ 70.703,
"R transpose R is symmetric."
]
]
},
"rtr2": {
- "dur": 21.6,
+ "dur": 40.608,
"marks": {
- "R": 2.096,
- "prod": 5.0,
- "sym": 9.323,
- "other": 13.268
+ "R": 1.966,
+ "prod": 4.753,
+ "sym": 9.076,
+ "other": 13.242,
+ "o11": 20.0,
+ "o12": 25.677,
+ "o22": 31.055,
+ "o2": 32.93
},
"cues": [
[
@@ -420,24 +452,44 @@ window.TIMINGS = {
"Another one, to be sure."
],
[
- 2.096,
+ 1.966,
"R is one, two; zero, one."
],
[
- 5.0,
+ 4.753,
"R transpose R is one, two; two, five."
],
[
- 9.323,
+ 9.076,
"The two twos sit in mirror spots: symmetric again."
],
[
- 13.268,
- "And the other order, R times R transpose, is five, two; two, one."
+ 13.242,
+ "Now the other order, R times R transpose."
+ ],
+ [
+ 16.458,
+ "Here each number is a row of R times a row of R."
+ ],
+ [
+ 20.0,
+ "Row one with itself: one times one plus two times two, five."
+ ],
+ [
+ 25.677,
+ "Row one with row two: one times zero plus two times one, two."
+ ],
+ [
+ 31.055,
+ "Row two with itself: one."
+ ],
+ [
+ 32.93,
+ "So R R transpose is five, two; two, one."
],
[
- 18.997,
- "A different matrix, but symmetric too."
+ 36.836,
+ "A different matrix from R transpose R, but symmetric too."
]
]
},
diff --git a/site/linear-algebra/ch36/index.html b/site/linear-algebra/ch36/index.html
index 4c12e8c..0823890 100644
--- a/site/linear-algebra/ch36/index.html
+++ b/site/linear-algebra/ch36/index.html
@@ -29,12 +29,14 @@ const CARD = { x: 40, y: 450, w: 740, cls: 'side' };
const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
const title = (p, str) => text(p, str, 60, 110, .2, { size: 40, weight: 600 });
+// A beat that carries on the last beat's panel names itself: the old title fades, the new one comes in.
+const retitle = str => { hide(S.title, .1, .3); S.title = text(S.p, str, 60, 110, .35, { size: 40, weight: 600 }); };
const thick = (tp, t0) => { const w = tp.dash ? 4 : 6; tw(tp.shaft, { 'a_stroke-width': w + 5 }, t0, .3); tw(tp.shaft, { 'a_stroke-width': w }, t0 + 1.2, .6); };
const hideArrows = T_ => [...T_.arrows.cols, ...T_.arrows.rows].forEach(tp => put(tp.ag, { o: 0 }));
// One mirror pair of a matrix laid out by mmT or mm (cx, ry): two rings and a bow between them, drawn at t0.
const pairRing = (into, Mx, i, j, t0, color, size) => {
const g = G(into, { o: 0 }), c = (r, k) => [Mx.cx(k), Mx.ry(r) - size * .3];
- [c(i, j), c(j, i)].forEach(([x, y]) => mk('circle', { cx: x, cy: y, r: size * .62, fill: 'none', stroke: color, 'stroke-width': 3 }, g));
+ [c(i, j), c(j, i)].forEach(([x, y]) => mk('ellipse', { cx: x, cy: y, rx: size * .74, ry: size * .62, fill: 'none', stroke: color, 'stroke-width': 3 }, g));
const [x1, y1] = c(i, j), [x2, y2] = c(j, i), bend = 18 + 10 * (j - i);
path(g, `M${x1 - size * .5} ${y1 + size * .4}Q${(x1 + x2) / 2 + bend} ${(y1 + y2) / 2 + bend} ${x2 + size * .5} ${y2 - size * .4}`, { stroke: color, 'stroke-width': 2.5, fill: 'none', 'stroke-opacity': .8 });
show(g, t0, .4);
@@ -49,7 +51,7 @@ const symRings = (into, P_, size, t0) => {
if (!C || C.length !== C[0].length) return;
for (let i = 0; i < C.length; i++) for (let j = i + 1; j < C.length; j++) {
const ok = Math.abs(C[i][j] - C[j][i]) < 1e-9, col = ok ? COL.good : COL.bad;
- [[i, j], [j, i]].forEach(([r, k]) => mk('circle', { cx: c.cx(k), cy: c.ry(r) - size * .3, r: size * .66, fill: 'none', stroke: col, 'stroke-width': 3 }, g));
+ [[i, j], [j, i]].forEach(([r, k]) => mk('ellipse', { cx: c.cx(k), cy: c.ry(r) - size * .3, rx: Math.min(size * .8, c.c / 2 - 2), ry: size * .64, fill: 'none', stroke: col, 'stroke-width': 3 }, g));
}
};
P_.onChange(redraw); redraw();
@@ -68,6 +70,22 @@ const rtrLink = P_ => {
});
};
const matEl = rows => mmEl(rows, { size: 22 });
+// blanks() writes a row's parts as math text and drops a drawn matrix (mmEl), so a row that shows one becomes its own
+// question with the matrix in its prompt; rows without a matrix stay together in one question.
+const blankQs = (id, prompt, rows) => {
+ const qs = [], plain = [];
+ const flush = () => { if (plain.length) qs.push({ id: `${id}${qs.length + 1}`, prompt: [prompt], build: blanks(plain.splice(0)) }); };
+ rows.forEach(r => {
+ const k = r.parts.findLastIndex(p => p instanceof Element);
+ if (k < 0) { plain.push(r); return; }
+ flush();
+ const head = r.parts.slice(0, k + 1), rest = r.parts.slice(k + 1);
+ if (typeof rest[0] === 'string') rest[0] = rest[0].replace(/^[\s.,]+/, '');
+ qs.push({ id: `${id}${qs.length + 1}`, prompt: [prompt + ' ', ...(head[0] instanceof Element ? ['A = '] : []), ...head], build: blanks([{ ...r, parts: rest }]) });
+ });
+ flush();
+ return qs;
+};
/* ---------- practice data (every matrix checked pair by pair, every product by columns of R) ---------- */
const YN = [['y', 'Symmetric', COL.good, 'Y'], ['n', 'Not', COL.bad, 'N']];
@@ -88,7 +106,7 @@ const SYMQ = [
];
const FILLQ = [
{ parts: [matEl([[4, 0], [-3, 1]]), ' row 1, column 2 must be ', { box: '-3' }], why: 'Its mirror, row 2, column 1, is −3.', hint: 'Look across the diagonal: the mirror number is in row 2, column 1.' },
- { parts: [matEl([[0, 2, 0], [0, 5, 6], [7, 0, 1]]), ' (zeros show the gaps) row 1, column 3 = ', { box: '7' }, ', row 2, column 1 = ', { box: '2' }, ', row 3, column 2 = ', { box: '6' }],
+ { parts: [matEl([[3, 2, 0], [0, 5, 6], [7, 0, 1]]), ' (the zeros off the diagonal are gaps) row 1, column 3 = ', { box: '7' }, ', row 2, column 1 = ', { box: '2' }, ', row 3, column 2 = ', { box: '6' }],
why: 'Each gap copies its mirror: 7 from row 3, column 1; 2 from row 1, column 2; 6 from row 2, column 3.', hint: 'Swap the address of each gap and copy the number you find there.' },
{ parts: ['Pairs 1, 2, 3 given; the diagonal is yours: ', matEl([[0, 1, 2], [1, 0, 3], [2, 3, 0]]), ' diagonal = (', { box: '0' }, ', ', { box: '0' }, ', ', { box: '0' }, ')'],
test: () => true, why: 'Any numbers work: the diagonal never moves in a flip, so it is free.', hint: 'The diagonal stays in place when you flip. Does it have to match anything?' },
@@ -107,7 +125,7 @@ const RTRQ = [
const HANDQ = [
{ id: 'p-sym1', start: { a00: 2, a01: 3, a10: -1, a11: 1 }, only: ['a10', 't01'], prompt: ['Make A symmetric by changing only the number in row 2, column 1.'],
why: 'Row 2, column 1 must copy its mirror, 3. Now column 1 is (2, 3) = row 1.', hint: 'Its mirror is row 1, column 2. Copy that number.', ans: { a10: 3 } },
- { id: 'p-sym2', start: { a00: 0, a01: 0, a10: 0, a11: 0 }, only: null, prompt: ['Make A symmetric with column 1 equal to (1, 4). Then the blue dashed arrow must lie on the green one.'],
+ { id: 'p-sym2', start: { a00: 1, a01: 0, a10: 0, a11: 1 }, only: null, prompt: ['Make A symmetric with column 1 equal to (1, 4). Then the blue dashed arrow must lie on the green one.'],
why: 'Column 1 = (1, 4), so row 2, column 1 is 4; symmetric, so row 1, column 2 is 4 too. Row 2, column 2 is free.', hint: v => v.a00 === 1 && v.a10 === 4 ? 'Column 1 is right. Now its mirror: row 1 must be (1, 4) as well.' : 'Column 1 is the left column of A: 1 on top, 4 under it.',
test: (v, T_) => v.a00 === 1 && v.a10 === 4 && T_.sym(), ans: { a00: 1, a10: 4, a01: 4 } },
];
@@ -139,15 +157,15 @@ const BEATS = [
T_.flash('a', [[0, 1], [1, 0]], m('diff')); T_.flash('t', [[0, 1], [1, 0]], m('diff') + .3);
pairRing(T_.front, T_.L.a, 0, 1, m('diff') + .2, COL.bad, 54);
const n = G(p, { o: 0 });
- M(n, ['Aᵀ ≠ A'], { x: 980, y: 330, size: 54, fill: COL.bad });
+ M(n, ['Aᵀ ≠ A'], { x: 980, y: 330, size: 54, fill: COL.bad, anchor: 'start' });
T(n, 'the 2 and the 3 traded places', { x: 980, y: 380, size: 28, fill: COL.dim, weight: 600 });
show(n, m('diff') + 1, .5);
text(p, 'most matrices change', 980, 470, m('most'), { size: 30, weight: 600 });
}],
['sym', 'When the flip changes nothing', (m) => {
- const p = panel(0);
- title(p, 'When the flip changes nothing');
+ const p = S.p = panel(0);
+ S.title = title(p, 'When the flip changes nothing');
const T_ = S.T = mmT(p, { A: S2, at: AT, size: 54, cw: 86, rh: 76, gap: 200, names: ['S', 'Sᵀ'], hideT: true, t0: m('S') - .4 });
put(T_.L.t.g, { o: 0 }); show(T_.L.t.g, m('flip') - .2, .4);
T_.show('row', 0, m('flip') + .3); T_.show('row', 1, m('flip') + 3.6); T_.show(null, null, m('same'));
@@ -163,7 +181,7 @@ const BEATS = [
['pairs', 'Mirror pairs', (m) => {
const T_ = S.T;
- hide(S.note, .1, .4);
+ hide(S.note, .1, .4); retitle('Mirror pairs');
T_.diag(m('diag')); T_.show('diag', null, m('diag'));
T_.show(null, null, m('pair'));
T_.flash('a', [[0, 1], [1, 0]], m('pair')); T_.flash('t', [[0, 1], [1, 0]], m('pair'));
@@ -179,15 +197,16 @@ const BEATS = [
['ex3', 'Three by three', (m) => {
const p = panel(0);
title(p, 'Three by three: check the pairs');
- const T_ = mmT(p, { A: S3, at: [140, 290], size: 54, cw: 86, rh: 76, gap: 200, names: ['S', 'Sᵀ'], hideT: true, t0: m('S') - .4 });
+ const T_ = mmT(p, { A: S3, at: [140, 300], size: 56, cw: 108, rh: 92, gap: 200, names: ['S', 'Sᵀ'], hideT: true, t0: m('S') - .4 }); // room for a ring round each number
put(T_.L.t.g, { o: 0 }); show(T_.L.t.g, m('flip') - .2, .4);
[0, 1, 2].forEach(k => T_.show('row', k, m('S') + .8 + k * 2.4, { side: 'a' }));
T_.diag(m('diag')); T_.show('diag', null, m('diag'), { side: 'a' }); T_.show(null, null, m('p1'));
- [['p1', 0, 1], ['p2', 0, 2], ['p3', 1, 2]].forEach(([k, i, j]) => { T_.flash('a', [[i, j]], m(k) + .2); T_.flash('a', [[j, i]], m(k) + 2.2); pairRing(T_.front, T_.L.a, i, j, m(k) + 3, COL.good, 54); });
+ const rings = [['p1', 0, 1], ['p2', 0, 2], ['p3', 1, 2]].map(([k, i, j]) => { T_.flash('a', [[i, j]], m(k) + .2); T_.flash('a', [[j, i]], m(k) + 2.2); return pairRing(T_.front, T_.L.a, i, j, m(k) + 3, COL.good, 56); });
+ rings.slice(0, 2).forEach((g, n) => tw(g, { o: .35 }, m(['p2', 'p3'][n]), .4)); // a checked pair steps back while the next is read
T_.fly(m('flip') + .4, { by: 'rows', step: .7, dur: 1 });
const n = G(p, { o: 0 });
- T(n, '3 pairs, all equal:', { x: 1040, y: 330, size: 32, weight: 600 });
- T(n, 'symmetric', { x: 1040, y: 380, size: 40, weight: 700 });
+ T(n, '3 pairs, all equal:', { x: 1120, y: 340, size: 32, weight: 600 });
+ T(n, 'symmetric', { x: 1120, y: 390, size: 40, weight: 700 });
show(n, m('yes'), .5);
}],
@@ -255,14 +274,19 @@ const BEATS = [
[0, 1, 2].forEach(i => P_.flash('b', { row: i }, m('R') + 5.2 + i * 1.3));
P_.flash('a', { row: 0 }, m('rt') + .6); P_.flash('a', { row: 1 }, m('rt') + 1.4);
P_.inner(m('size') + .4); P_.outer(m('size') + 2.6);
- [['c11', [0, 0]], ['c12', [0, 1]], ['c21', [1, 0]], ['c22', [1, 1]]].forEach(([k, ij], n) => {
- P_.show('entry', ij, m(k) - (n ? .2 : 1.2), { times: [m(k) - (n ? .2 : 1.2)] });
- P_.reveal({ cell: ij }, m(k) + .1);
+ const ks = ['11', '12', '21', '22'];
+ ks.forEach((k, n) => {
+ const c = m('c' + k), s_ = m('s' + k), done = Math.min(s_ + 1.4, n < 3 ? m('c' + ks[n + 1]) - .3 : 1e9); // the sum lands before the next entry's working starts
+ const ij = [+k[0] - 1, +k[1] - 1];
+ P_.show('entry', ij, c, { times: [c + .3, Math.max(c + 1.5, s_ - .2), done] });
+ P_.reveal({ cell: ij }, done);
+ // while the products are read aloud, each pair that is multiplied lights up: one number of Rᵀ's row, one of R's column
+ if (k !== '22') [0, 1, 2].forEach(q => { const t = s_ - 4.8 + q * 1.6; P_.flash('a', { cell: [ij[0], q] }, t); P_.flash('b', { cell: [q, ij[1]] }, t); });
});
P_.show(null, null, m('sym'));
symRings(p, P_, 40, m('sym') + .4);
const n = G(p, { o: 0 });
- M(n, ['RᵀR is symmetric'], { x: 1000, y: 330, size: 40 });
+ M(n, ['RᵀR is symmetric'], { x: 1000, y: 330, size: 40, anchor: 'start' });
T(n, '13 and 13 in mirror spots', { x: 1000, y: 380, size: 28, fill: COL.dim, weight: 600 });
show(n, m('sym') + 1.4, .5);
}],
@@ -274,10 +298,16 @@ const BEATS = [
const P1 = mm(p, { A: tr(R2), B: R2, at: [70, 260], names: ['Rᵀ', 'R', 'RᵀR'], tintB: 'cols', ...o, t0: m('R') - .4 });
P1.reveal('all', m('prod') + .3);
symRings(p, P1, 40, m('sym') + .3);
- const P2 = mm(p, { A: R2, B: tr(R2), at: [70, 580], names: ['R', 'Rᵀ', 'RRᵀ'], tintA: 'cols', ...o, t0: m('other') - .3 });
- P2.reveal('all', m('other') + 2.4);
- symRings(p, P2, 40, m('other') + 4.4);
- text(p, 'RᵀR ≠ RRᵀ, but both are symmetric', 860, 470, m('other') + 4.8, { size: 30, weight: 600 });
+ const P2 = mm(p, { A: R2, B: tr(R2), at: [70, 520], names: ['R', 'Rᵀ', 'RRᵀ'], tintA: 'cols', work: [90, 770], wsize: 30, ...o, t0: m('other') - .3 });
+ P2.flash('a', { row: 0 }, m('other') + 3.4); P2.flash('a', { row: 1 }, m('other') + 4.2);
+ [['o11', [0, 0], [[0, 0]]], ['o12', [0, 1], [[0, 1], [1, 0]]], ['o22', [1, 1], [[1, 1]]]].forEach(([k, ij, cells]) => {
+ const tt = k === 'o22' ? [m(k) + .1, m(k) + .6, m(k) + 1.2] : [m(k) + .2, m(k) + 1.6, m(k) + 2.6]; // "Row two with itself: one" is short
+ P2.show('entry', ij, m(k), { times: tt });
+ cells.forEach(cell => P2.reveal({ cell }, tt[2]));
+ });
+ P2.show(null, null, m('o2'));
+ symRings(p, P2, 40, m('o2') + 2.6);
+ text(p, 'RᵀR ≠ RRᵀ, but both are symmetric', 860, 470, m('o2') + 3.4, { size: 30, weight: 600 });
}],
['why', 'Why: columns times columns', (m) => {
@@ -291,11 +321,11 @@ const BEATS = [
const G1 = MM_COL[0], V1 = MM_COL[1];
say(p, ['row 1, column 2:'], 90, 600, m('pairs'), { size: 32, fill: COL.dim });
say(p, ['1·3 + 2·3 + 4·1'], 380, 600, m('pairs') + 3.4, { size: 36 });
- say(p, ['= 13'], 680, 600, m('pairs') + 8.6, { size: 36 });
+ say(p, ['= 13'], 380 + mathW(['1·3 + 2·3 + 4·1'], 36) + 8, 600, m('pairs') + 8.6, { size: 36 });
P_.show('entry', [1, 0], m('mirror'));
say(p, ['row 2, column 1:'], 90, 680, m('mirror') + .3, { size: 32, fill: COL.dim });
say(p, ['3·1 + 3·2 + 1·4'], 380, 680, m('same') + 1.6, { size: 36 });
- say(p, ['= 13'], 680, 680, m('same') + 7, { size: 36 });
+ say(p, ['= 13'], 380 + mathW(['3·1 + 3·2 + 1·4'], 36) + 8, 680, m('same') + 7, { size: 36 });
// the two columns of R, side by side: their numbers pair up the same way either way round
const cg = G(p, { o: 0 });
T(cg, 'column 1', { x: 1050, y: 470, size: 26, fill: G1, weight: 600, anchor: 'middle' });
@@ -332,7 +362,7 @@ const BEATS = [
say(p, ['= RᵀR'], X, Y[2], m('back') + 1, { size: 56 });
text(p, '(Rᵀ)ᵀ = R: two flips undo each other', 720, Y[2] - 10, m('back'), { size: 28, fill: COL.dim, weight: 600 });
const e = G(p, { o: 0 });
- M(e, ['(RᵀR)ᵀ = RᵀR'], { x: X, y: 720, size: 56 });
+ M(e, ['(RᵀR)ᵀ = RᵀR'], { x: X, y: 720, size: 56, anchor: 'start' });
T(e, 'symmetric, for every R', { x: X + 440, y: 712, size: 34, fill: COL.good, weight: 700 });
show(e, m('end') + .5, .5);
draw(path(p, `M${X} 742H${X + 410}`, { stroke: COL.good, 'stroke-width': 4 }, { d: 0 }), m('end') + 3, .8);
@@ -383,17 +413,14 @@ const BEATS = [
});
}],
['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{
- id: 'p-sym', prompt: ['Symmetric or not?'],
- build: grid(SYMQ, YN, { multi: false, text: true }),
- }], done, 'Chapter practice · set 1 of 4') }],
- ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
- id: 'p-fill', prompt: ['Fill the gaps so that each matrix is symmetric.'],
- build: blanks(FILLQ),
- }], done, 'Chapter practice · set 2 of 4') }],
- ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
- id: 'p-rtr', prompt: ['Work out RᵀR (columns of R times columns of R) or RRᵀ (rows times rows).'],
- build: blanks(RTRQ),
+ id: 'p-sym1', prompt: ['Symmetric or not? Check each pair across the diagonal.'],
+ build: grid(SYMQ.slice(0, 4), YN, { multi: false, text: true }),
}, {
+ id: 'p-sym2', prompt: ['Symmetric or not? Three more.'],
+ build: grid(SYMQ.slice(4), YN, { multi: false, text: true }),
+ }], done, 'Chapter practice · set 1 of 4') }],
+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, blankQs('p-fill', 'Fill the gaps so that the matrix is symmetric.', FILLQ), done, 'Chapter practice · set 2 of 4') }],
+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [...blankQs('p-rtr', 'RᵀR: columns of R times columns of R. RRᵀ: rows times rows.', RTRQ), {
id: 'p-square', prompt: ['R is 4 × 2. What is RᵀR?'],
build: choice(['2 × 2 and symmetric', '4 × 4 and symmetric', '2 × 2, symmetric only by luck', 'it does not fit'], 0,
'Rᵀ is 2 × 4, so RᵀR = (2 × 4)(4 × 2) = 2 × 2; and RᵀR is always symmetric.',
diff --git a/site/linear-algebra/ch37/audio/en/combos.mp3 b/site/linear-algebra/ch37/audio/en/combos.mp3
index afd72c9..10cc584 100644
Binary files a/site/linear-algebra/ch37/audio/en/combos.mp3 and b/site/linear-algebra/ch37/audio/en/combos.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/dots.mp3 b/site/linear-algebra/ch37/audio/en/dots.mp3
index e79551e..790415c 100644
Binary files a/site/linear-algebra/ch37/audio/en/dots.mp3 and b/site/linear-algebra/ch37/audio/en/dots.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/more.mp3 b/site/linear-algebra/ch37/audio/en/more.mp3
new file mode 100644
index 0000000..5630fbf
Binary files /dev/null and b/site/linear-algebra/ch37/audio/en/more.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/quad.mp3 b/site/linear-algebra/ch37/audio/en/quad.mp3
index 0f6b94f..9dccd50 100644
Binary files a/site/linear-algebra/ch37/audio/en/quad.mp3 and b/site/linear-algebra/ch37/audio/en/quad.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/r3.mp3 b/site/linear-algebra/ch37/audio/en/r3.mp3
index 7dd9cf2..5249dc3 100644
Binary files a/site/linear-algebra/ch37/audio/en/r3.mp3 and b/site/linear-algebra/ch37/audio/en/r3.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/recall.mp3 b/site/linear-algebra/ch37/audio/en/recall.mp3
index d3c5884..8dd9a3c 100644
Binary files a/site/linear-algebra/ch37/audio/en/recall.mp3 and b/site/linear-algebra/ch37/audio/en/recall.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/rn.mp3 b/site/linear-algebra/ch37/audio/en/rn.mp3
index d09fb0c..cad0659 100644
Binary files a/site/linear-algebra/ch37/audio/en/rn.mp3 and b/site/linear-algebra/ch37/audio/en/rn.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/space.mp3 b/site/linear-algebra/ch37/audio/en/space.mp3
index 0a5dd1f..3ea76f8 100644
Binary files a/site/linear-algebra/ch37/audio/en/space.mp3 and b/site/linear-algebra/ch37/audio/en/space.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/timings.js b/site/linear-algebra/ch37/audio/en/timings.js
index 8a599c9..38620e7 100644
--- a/site/linear-algebra/ch37/audio/en/timings.js
+++ b/site/linear-algebra/ch37/audio/en/timings.js
@@ -21,14 +21,17 @@ window.TIMINGS = {
]
},
"recall": {
- "dur": 29.832,
+ "dur": 51.576,
"marks": {
- "v": 2.161,
- "w": 9.062,
- "add": 11.966,
- "sum": 15.013,
- "stretch": 17.682,
- "mix": 20.924
+ "v": 2.175,
+ "w": 9.036,
+ "add": 11.888,
+ "sum": 14.818,
+ "stretch": 17.461,
+ "mix": 20.612,
+ "mix1": 26.237,
+ "mix2": 32.656,
+ "mix3": 41.042
},
"cues": [
[
@@ -36,48 +39,60 @@ window.TIMINGS = {
"First, what we already know."
],
[
- 2.161,
+ 2.175,
"Chapter four: a vector is an arrow, and a column of numbers."
],
[
- 7.148,
+ 7.188,
"Here v is two, one."
],
[
- 9.062,
+ 9.036,
"And w is minus one, two."
],
[
- 11.966,
+ 11.888,
"Chapter five added them, tip to tail: v plus w is one, three."
],
[
- 17.682,
+ 17.461,
"And stretched them: two v is four, two."
],
[
- 20.924,
+ 20.612,
"Chapter six mixed both at once: c times v, plus d times w."
],
[
- 26.641,
+ 26.237,
+ "Two v plus w: four, two, plus minus one, two, makes three, four."
+ ],
+ [
+ 32.656,
+ "Minus v plus two w: minus two, minus one, plus minus two, four, makes minus four, three."
+ ],
+ [
+ 41.042,
+ "And v minus w: two, one, plus one, minus two, makes three, minus one."
+ ],
+ [
+ 48.281,
"Every pair c, d gives a new arrow."
]
]
},
"space": {
- "dur": 51.936,
+ "dur": 56.064,
"marks": {
"word": 1.237,
- "rule1": 5.755,
- "rule2": 12.253,
- "plane": 18.841,
- "add": 29.01,
- "in1": 31.914,
- "scale": 34.531,
- "in2": 38.138,
- "neg": 39.349,
- "so": 45.065
+ "rule1": 5.482,
+ "rule2": 11.719,
+ "plane": 18.034,
+ "add": 28.242,
+ "in1": 35.925,
+ "scale": 38.503,
+ "in2": 42.24,
+ "neg": 43.398,
+ "so": 49.245
},
"cues": [
[
@@ -89,62 +104,70 @@ window.TIMINGS = {
"A vector space is a collection of vectors that obeys two rules."
],
[
- 5.755,
+ 5.482,
"Rule one: add any two vectors of the collection, and the answer is in the collection too."
],
[
- 12.253,
+ 11.719,
"Rule two: multiply any one of them by any number, and the answer is in the collection too."
],
[
- 18.841,
+ 18.034,
"Our first example is the whole plane: every pair of numbers x, y."
],
[
- 24.453,
+ 23.542,
"Its name is R two: R for the real numbers, two for two of them."
],
[
- 29.01,
- "Add v and w: one, three."
+ 28.242,
+ "Add v and w: two plus minus one is one, one plus two is three."
],
[
- 31.914,
+ 34.844,
+ "One, three."
+ ],
+ [
+ 35.925,
"Two numbers, so it is in R two."
],
[
- 34.531,
+ 38.503,
"Multiply v by three: six, three."
],
[
- 38.138,
+ 42.24,
"Two numbers again."
],
[
- 39.349,
+ 43.398,
"Multiply by minus one: minus two, minus one."
],
[
- 43.477,
+ 47.721,
"Still two numbers."
],
[
- 45.065,
+ 49.245,
"Whatever we do, we get a pair, and every pair is in R two."
],
[
- 49.544,
+ 53.737,
"So R two is a vector space."
]
]
},
"zero": {
- "dur": 23.016,
+ "dur": 41.928,
"marks": {
- "zero": 3.294,
- "shrink": 5.391,
- "must": 11.081,
- "also": 17.982
+ "zero": 2.943,
+ "half": 6.406,
+ "zero2": 9.414,
+ "shrink": 15.469,
+ "must": 21.198,
+ "also": 28.802,
+ "neg": 30.13,
+ "back": 33.633
},
"cues": [
[
@@ -152,54 +175,96 @@ window.TIMINGS = {
"One thing every vector space must hold."
],
[
- 3.294,
- "Multiply v by zero."
+ 2.943,
+ "Multiply v by smaller and smaller numbers."
],
[
- 5.391,
- "The arrow shrinks to nothing: zero, zero, the point at the origin."
+ 6.406,
+ "One half v is one, one half."
],
[
- 11.081,
- "Rule two allows multiplying by zero, so the zero vector is inside every vector space."
+ 9.414,
+ "Zero v: zero times two is zero, and zero times one is zero."
],
[
- 17.982,
- "Adding gets there too: v plus minus v is zero, zero."
+ 15.469,
+ "The arrow has shrunk to nothing: the point zero, zero, at the origin."
+ ],
+ [
+ 21.198,
+ "Rule two allows every number, zero included."
+ ],
+ [
+ 24.661,
+ "So the zero vector is inside every vector space."
+ ],
+ [
+ 28.802,
+ "Adding gets there too."
+ ],
+ [
+ 30.13,
+ "Minus v is minus two, minus one."
+ ],
+ [
+ 33.633,
+ "Put it on the tip of v: two plus minus two is zero, one plus minus one is zero."
+ ],
+ [
+ 40.677,
+ "Back at the origin."
]
]
},
"combos": {
- "dur": 23.328,
+ "dur": 40.056,
"marks": {
- "cv": 2.135,
- "dw": 4.883,
- "both": 8.021,
- "all": 10.625
+ "cv": 2.175,
+ "dw": 5.534,
+ "both": 8.49,
+ "again": 17.93,
+ "again2": 22.943,
+ "all": 26.94
},
"cues": [
[
- 0.104,
+ 0.091,
"Now put the two rules together."
],
[
- 2.135,
- "c times v is inside, by rule two."
+ 2.175,
+ "Take two v."
+ ],
+ [
+ 3.438,
+ "It is inside, by rule two."
],
[
- 4.883,
- "d times w is inside, by rule two."
+ 5.534,
+ "Take one w."
],
[
- 8.021,
- "And their sum is inside, by rule one."
+ 6.667,
+ "Inside, by rule two."
],
[
- 10.625,
+ 8.49,
+ "Add them: by rule one, two v plus w is inside too."
+ ],
+ [
+ 13.49,
+ "Four, two, plus minus one, two: three, four."
+ ],
+ [
+ 17.93,
+ "Once more: minus v and two w are both inside, by rule two, so their sum, minus four, three, is inside, by rule one."
+ ],
+ [
+ 26.94,
"So every combination of vectors in a vector space stays in the space."
],
[
- 15.26,
+ 32.109,
"Let c and d run through many numbers: the combinations land all over the plane, and none of them leaves it."
]
]
@@ -219,16 +284,17 @@ window.TIMINGS = {
]
},
"r3": {
- "dur": 28.56,
+ "dur": 42.864,
"marks": {
"three": 1.562,
- "v": 9.792,
- "w": 12.461,
- "add": 14.349,
- "in": 18.32,
- "scale": 21.055,
- "in2": 24.987,
- "so": 26.25
+ "v": 9.661,
+ "w": 12.331,
+ "add": 14.128,
+ "in": 22.578,
+ "scale": 27.604,
+ "in2": 31.654,
+ "neg": 32.878,
+ "so": 40.391
},
"cues": [
[
@@ -240,45 +306,54 @@ window.TIMINGS = {
"A list of three numbers is an arrow in space, as in chapter eleven."
],
[
- 6.797,
+ 6.758,
"All of them together are called R three."
],
[
- 9.792,
+ 9.661,
"Take v, one, two, zero, and w, zero, one, two."
],
[
- 14.349,
- "Add them, number by number: one, three, two."
+ 14.128,
+ "Add them, number by number: one plus zero is one, two plus one is three, zero plus two is two."
],
[
- 18.32,
- "Three numbers, so it is in R three."
+ 22.578,
+ "One, three, two: three numbers, so it is in R three."
],
[
- 21.055,
+ 27.604,
"Stretch w by two: zero, two, four."
],
[
- 24.987,
+ 31.654,
"Three numbers again."
],
[
- 26.25,
+ 32.878,
+ "Even minus one times v, minus one, minus two, zero, is a list of three numbers."
+ ],
+ [
+ 40.391,
"R three is a vector space too."
]
]
},
"rn": {
- "dur": 42.816,
+ "dur": 52.824,
"marks": {
- "four": 1.94,
- "v": 7.096,
- "w": 12.904,
- "add": 17.331,
- "sum": 18.763,
- "scale": 25.078,
- "n": 33.099
+ "four": 1.927,
+ "v": 6.901,
+ "w": 12.526,
+ "add": 17.279,
+ "s1": 20.039,
+ "s2": 22.109,
+ "s3": 25.117,
+ "s4": 28.19,
+ "s5": 30.456,
+ "sum": 32.8,
+ "scale": 35.039,
+ "n": 42.93
},
"cues": [
[
@@ -286,47 +361,63 @@ window.TIMINGS = {
"And more numbers than axes?"
],
[
- 1.94,
+ 1.927,
"Chapter fifteen drew those as bars: one bar for each number."
],
[
- 7.096,
+ 6.901,
"Here v has five numbers: one, minus two, zero, three, one."
],
[
- 12.904,
+ 12.526,
"And w: two, one, minus one, zero, two."
],
[
- 17.331,
- "Add them bar by bar."
+ 17.279,
+ "Add them bar by bar, across each row."
+ ],
+ [
+ 20.039,
+ "One plus two is three."
+ ],
+ [
+ 22.109,
+ "Minus two plus one is minus one."
+ ],
+ [
+ 25.117,
+ "Zero plus minus one is minus one."
+ ],
+ [
+ 28.19,
+ "Three plus zero is three."
],
[
- 18.763,
- "Three, minus one, minus one, three, three."
+ 30.456,
+ "One plus two is three."
],
[
- 22.812,
+ 32.8,
"Five numbers: in R five."
],
[
- 25.078,
+ 35.039,
"Stretch v by two: every bar doubles."
],
[
- 28.19,
+ 38.06,
"Two, minus four, zero, six, two."
],
[
- 31.198,
+ 41.133,
"Still five numbers."
],
[
- 33.099,
+ 42.93,
"For any count n, all lists of n numbers form a vector space, called R n."
],
[
- 39.076,
+ 49.18,
"Adding and stretching never change how many numbers there are."
]
]
@@ -346,17 +437,18 @@ window.TIMINGS = {
]
},
"quad": {
- "dur": 37.872,
+ "dur": 52.776,
"marks": {
- "quarter": 1.94,
- "v": 7.435,
- "w": 9.167,
- "add": 12.344,
- "ok": 14.635,
- "scale": 20.026,
- "neg": 24.193,
- "out": 26.693,
- "fail": 31.146
+ "quarter": 1.914,
+ "v": 7.591,
+ "w": 9.648,
+ "add": 12.786,
+ "ok": 17.708,
+ "why": 22.474,
+ "scale": 31.536,
+ "neg": 35.208,
+ "out": 42.396,
+ "fail": 48.477
},
"cues": [
[
@@ -364,63 +456,78 @@ window.TIMINGS = {
"Now a collection that fails."
],
[
- 1.94,
+ 1.914,
"Keep only the arrows that point into the top right quarter: both numbers zero or more."
],
[
- 7.435,
+ 7.591,
"v is two, one, and w is one, three."
],
[
- 11.172,
+ 11.615,
"Both are inside."
],
[
- 12.344,
- "Add them: three, four."
+ 12.786,
+ "Add them: two plus one is three, one plus three is four."
+ ],
+ [
+ 17.708,
+ "Three, four: both numbers are positive, so it is inside."
],
[
- 14.635,
- "Inside."
+ 22.474,
+ "That always happens."
],
[
- 15.638,
- "Adding two arrows of the quarter always stays in the quarter."
+ 23.958,
+ "A number zero or more, plus a number zero or more, is zero or more."
],
[
- 20.026,
- "Now stretch v by two: four, two."
+ 29.609,
+ "Adding never leaves the quarter."
],
[
- 22.943,
+ 31.536,
+ "Stretch v by two: four, two."
+ ],
+ [
+ 33.984,
"Inside too."
],
[
- 24.193,
- "But multiply v by minus one."
+ 35.208,
+ "But rule two says any number, and minus one is a number."
],
[
- 26.693,
- "Minus two, minus one: it points the other way, out of the quarter."
+ 40.039,
+ "Multiply v by minus one."
],
[
- 31.146,
- "Rule two says every number."
+ 42.396,
+ "Minus two, minus one: both numbers negative."
],
[
- 33.607,
+ 45.833,
+ "It points the other way, out of the quarter."
+ ],
+ [
+ 48.477,
"One failure is enough: the quarter is not a vector space."
]
]
},
"dots": {
- "dur": 24.12,
+ "dur": 39.24,
"marks": {
- "dots": 1.927,
- "add": 6.107,
- "scale": 13.594,
- "half": 16.432,
- "fail": 20.326
+ "dots": 1.888,
+ "add": 6.562,
+ "dot": 13.385,
+ "whole": 15.378,
+ "two": 20.898,
+ "scale": 26.289,
+ "half": 31.706,
+ "fail": 35.534
},
"cues": [
[
@@ -428,35 +535,106 @@ window.TIMINGS = {
"Another one that fails."
],
[
- 1.927,
+ 1.888,
"Keep only the points with whole number coordinates, the dots of the grid."
],
[
- 6.107,
- "Add one, two and two, one: three, three."
+ 6.562,
+ "Add one, two and two, one: one plus two is three, two plus one is three."
],
[
- 9.948,
- "A dot."
+ 13.385,
+ "Three, three: a dot."
],
[
- 10.964,
- "Adding whole numbers gives whole numbers."
+ 15.378,
+ "Whole numbers added to whole numbers stay whole, so adding never leaves the dots."
],
[
- 13.594,
- "But multiply one, one by one half."
+ 20.898,
+ "Stretching by a whole number doesn't either: two times one, one is two, two."
],
[
- 16.432,
+ 26.289,
+ "But rule two says any number."
+ ],
+ [
+ 29.049,
+ "Multiply one, one by one half."
+ ],
+ [
+ 31.706,
"One half, one half: it lands between the dots."
],
[
- 20.326,
+ 35.534,
"Not in the collection, so this is not a vector space either."
]
]
},
+ "more": {
+ "dur": 40.104,
+ "marks": {
+ "holey": 3.151,
+ "hv": 7.279,
+ "hz": 10.052,
+ "hf": 15.3,
+ "one": 22.383,
+ "oadd": 27.096,
+ "oout": 32.344,
+ "of": 35.078
+ },
+ "cues": [
+ [
+ 0.104,
+ "Two more that fail, each in its own way."
+ ],
+ [
+ 3.151,
+ "First: the whole plane, with one point cut out, the origin."
+ ],
+ [
+ 7.279,
+ "Take v, two, one."
+ ],
+ [
+ 8.815,
+ "It is inside."
+ ],
+ [
+ 10.052,
+ "Multiply it by zero: zero, zero."
+ ],
+ [
+ 13.333,
+ "That is the one point we cut out."
+ ],
+ [
+ 15.3,
+ "Rule two fails, so this is not a vector space: a vector space must hold the zero vector."
+ ],
+ [
+ 22.383,
+ "Second: a collection with just one arrow in it, one, one."
+ ],
+ [
+ 27.096,
+ "Add it to itself: one plus one is two, one plus one is two."
+ ],
+ [
+ 32.344,
+ "Two, two is not in the collection."
+ ],
+ [
+ 35.078,
+ "This time rule one fails."
+ ],
+ [
+ 37.083,
+ "One arrow alone is not a vector space."
+ ]
+ ]
+ },
"q3": {
"dur": 9.264,
"marks": {},
@@ -472,13 +650,13 @@ window.TIMINGS = {
]
},
"wrap": {
- "dur": 29.928,
+ "dur": 33.288,
"marks": {
- "w1": 1.003,
- "w2": 11.354,
- "w3": 16.953,
- "w4": 23.685,
- "end": 28.646
+ "w1": 1.016,
+ "w2": 11.25,
+ "w3": 16.784,
+ "w4": 23.398,
+ "end": 31.979
},
"cues": [
[
@@ -486,27 +664,27 @@ window.TIMINGS = {
"Let's sum up."
],
[
- 1.003,
+ 1.016,
"A vector space is a collection of vectors closed under two moves: adding any two, and multiplying any one by any number."
],
[
- 9.753,
+ 9.583,
"The answers stay inside."
],
[
- 11.354,
+ 11.25,
"So every combination stays inside, and the zero vector is always there."
],
[
- 16.953,
+ 16.784,
"R two, R three, and R n, all lists of n numbers, are vector spaces."
],
[
- 23.685,
- "The quarter plane and the grid dots are not: a stretch can throw a vector out."
+ 23.398,
+ "The quarter, the grid dots, the plane without its origin, and a single arrow are not: one add or one stretch throws a vector out."
],
[
- 28.646,
+ 31.979,
"Now practice."
]
]
diff --git a/site/linear-algebra/ch37/audio/en/wrap.mp3 b/site/linear-algebra/ch37/audio/en/wrap.mp3
index 7329d96..ede643d 100644
Binary files a/site/linear-algebra/ch37/audio/en/wrap.mp3 and b/site/linear-algebra/ch37/audio/en/wrap.mp3 differ
diff --git a/site/linear-algebra/ch37/audio/en/zero.mp3 b/site/linear-algebra/ch37/audio/en/zero.mp3
index d618140..b6817d1 100644
Binary files a/site/linear-algebra/ch37/audio/en/zero.mp3 and b/site/linear-algebra/ch37/audio/en/zero.mp3 differ
diff --git a/site/linear-algebra/ch37/index.html b/site/linear-algebra/ch37/index.html
index 7d050bb..dad1c2a 100644
--- a/site/linear-algebra/ch37/index.html
+++ b/site/linear-algebra/ch37/index.html
@@ -17,7 +17,7 @@
<script src="audio/en/timings.js"></script>
<script>
'use strict';
-const CHAPTER = { number: 37, title: 'What Is a Vector Space?', minutes: 11, language: 'en', next: '../ch38/' };
+const CHAPTER = { number: 37, title: 'What Is a Vector Space?', minutes: 13, language: 'en', next: '../ch38/' };
/* ---------- chapter helpers ---------- */
const GREEN = VS_COL[0], VIOLET = VS_COL[1];
@@ -29,20 +29,31 @@ const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start'
const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
const title = (p, str) => text(p, str, 60, 110, .2, { size: 40, weight: 600 });
const showRow = (r, t0, dur = .4) => r.parts.forEach(e => show(e, t0, dur));
+// flash the columns of a row as the voice reads them: [[id, at], …] with id 'cv', 'dw', 'sum', 'v', 'w'
+const readCols = (vs, list) => list.forEach(([id, at]) => { vs.flash(id + '0', at); vs.flash(id + '1', at); });
const thick = (vs, id, t0, w = 5) => { tw(vs.A[id].path, { 'a_stroke-width': w + 5 }, t0, .3); tw(vs.A[id].path, { 'a_stroke-width': w }, t0 + 1.2, .6); };
-const pair = (x, y) => `(${num(Math.round(x * 10) / 10)}, ${num(Math.round(y * 10) / 10)})`;
-// "2v − w", "½v", "−v + 3w": the combination's name, as it is written (no 1s, no + −, no 0 terms)
-const comboLabel = (vs, c, d) => {
- const term = (k, n) => Math.abs(k) === 1 ? [n] : [...vs.parts(Math.abs(k)), n];
- const out = [];
- if (Math.abs(c) > 1e-9) out.push(...(c < 0 ? ['−'] : []), ...term(c, 'v'));
- if (Math.abs(d) > 1e-9) out.push(out.length ? (d < 0 ? ' − ' : ' + ') : (d < 0 ? '−' : ''), ...term(d, 'w'));
- return vs.nice(c) && vs.nice(d) ? out : [];
+// a coordinate as the columns write it: whole, a half as ½ or 3/2, else one decimal (a value in passing)
+const coord = x => Math.abs(x - Math.round(x)) < 1e-9 ? num(Math.round(x) || 0) : Math.abs(x * 2 - Math.round(x * 2)) < 1e-9 ? (x < 0 ? '−' : '') + (Math.round(Math.abs(x * 2)) === 1 ? '½' : Math.round(Math.abs(x * 2)) + '/2') : num(Math.round(x * 10) / 10);
+const pair = (x, y) => `(${coord(x)}, ${coord(y)})`;
+// c·v alone and d·w alone, named as written ("2v", "−w"); vs.combo names the whole combination.
+const cvName = vs => s => vs.combo({ c: s.c, d: 0 }), dwName = vs => s => vs.combo({ c: 0, d: s.d });
+const cvOnly = vs => s => Math.abs(s.c - 1) < 1e-9 ? [] : vs.combo({ c: s.c, d: 0 }); // c·v over v: at c = 1 the name is v's own
+// The combination's name, live, right-aligned at x, then "= …columns" (items as in vs.row): "2v + w = [4 2] + [−1 2] = [3 4]".
+// While c or d passes between nice values the name is the general one, idle. Returns the row: .parts[0] is "=", then the items.
+const comboRow = (vs, p, x, y, items, t0, { name = s => vs.combo(s), idle = ['c v + d w'], size = 46 } = {}) => {
+ const g = G(p, { o: 0 }), ink = G(g, {});
+ let key = '';
+ const up = () => { let pp = name(vs.v); if (!pp.length) pp = idle; const k = JSON.stringify(pp); if (k === key) return; key = k; ink.replaceChildren(); if (pp.length) M(ink, pp, { x, y, size, anchor: 'end' }); };
+ vs.onChange(up); up();
+ const r = vs.row(['=', ...items], { x: x + 14, y, size });
+ g.appendChild(r.g);
+ if (t0 != null) show(g, t0, .4);
+ return r;
};
// The plane's vectors: v and w, c·v + d·w drawn tip to tail, the combination as the amber arrow.
-const plane2 = (p, { v, w }, { c = 1, d = 1, show: sh = ['v', 'w'], t0 = .1, steps } = {}) => {
- const vs = vecs(p, { vecs: { v, w }, c, d, show: sh, plane: { cx: 1160, cy: 460, u: 50 }, t0, steps });
- vs.label('sum', v_ => comboLabel(vs, v_.c, v_.d));
+const plane2 = (p, { v, w }, { c = 1, d = 1, show: sh = ['v', 'w'], t0 = .1, steps, colors } = {}) => {
+ const vs = vecs(p, { vecs: { v, w }, c, d, show: sh, plane: { cx: 1160, cy: 460, u: 50 }, t0, steps, colors });
+ vs.label('sum', s => vs.combo(s));
vs.label('cv', ['']); vs.label('dw', ['']);
return vs;
};
@@ -51,7 +62,12 @@ const region = (vs, kind, t0 = .3) => {
const { PX, PY, x0, x1, y0, y1 } = vs.P, g = G(vs.P.g, { o: 0 });
vs.P.g.insertBefore(g, vs.layer);
if (kind === 'dots') { for (let x = x0; x <= x1; x++) for (let y = y0; y <= y1; y++) mk('circle', { cx: PX(x), cy: PY(y), r: 5, fill: COL.chalk, 'fill-opacity': .55 }, g); }
- else {
+ else if (kind === 'holey') { // the whole plane with the origin cut out: a hole with a red rim
+ mk('rect', { x: PX(x0), y: PY(y1), width: PX(x1) - PX(x0), height: PY(y0) - PY(y1), fill: COL.chalk, 'fill-opacity': .1 }, g);
+ mk('circle', { cx: PX(0), cy: PY(0), r: 13, fill: COL.board, stroke: COL.bad, 'stroke-width': 3 }, g);
+ } else if (kind === 'one') { // one arrow, (1, 1), and nothing else
+ mk('circle', { cx: PX(1), cy: PY(1), r: 16, fill: 'none', stroke: COL.chalk, 'stroke-width': 3, 'stroke-dasharray': '5 5' }, g);
+ } else {
const yb = kind === 'half' ? y0 : 0;
mk('rect', { x: PX(kind === 'half' ? x0 : 0), y: PY(y1), width: PX(x1) - PX(kind === 'half' ? x0 : 0), height: PY(yb) - PY(y1), fill: COL.chalk, 'fill-opacity': .1 }, g);
path(g, kind === 'half' ? `M${PX(x0)} ${PY(0)}H${PX(x1)}` : `M${PX(0)} ${PY(y1)}V${PY(0)}H${PX(x1)}`, { stroke: COL.chalk, 'stroke-width': 4, 'stroke-opacity': .6, fill: 'none' });
@@ -61,16 +77,20 @@ const region = (vs, kind, t0 = .3) => {
};
const IN = {
quarter: ([x, y]) => x > -1e-9 && y > -1e-9,
+ holey: ([x, y]) => Math.hypot(x, y) > 1e-9,
+ one: ([x, y]) => Math.abs(x - 1) < 1e-9 && Math.abs(y - 1) < 1e-9,
half: ([x, y]) => y > -1e-9,
dots: ([x, y]) => Math.abs(x - Math.round(x)) < 1e-9 && Math.abs(y - Math.round(y)) < 1e-9,
};
-// A live line under the algebra: the combination's numbers and whether it is inside the region.
-const verdict = (p, vs, kind, x, y, t0, { name = 'the arrow' } = {}) => {
+// A live line under the algebra: where the combination's tip is and whether it is inside the region.
+// While a number passes between nice values the line only follows, dim: no verdict on a value in passing.
+const verdict = (p, vs, kind, x, y, t0) => {
const g = G(p, { o: 0 }), t = T(g, '', { x, y, size: 30, weight: 700 });
const up = () => {
- const s = vs.calc().sum, ok = IN[kind](s), str = `${name} = ${pair(s[0], s[1])}: ${ok ? 'inside ✓' : 'outside ✗'}`;
+ const s = vs.calc().sum, ok = IN[kind](s), still = Object.values(vs.v).every(vs.nice);
+ const str = `tip at ${pair(s[0], s[1])}` + (still ? `: ${ok ? 'inside ✓' : 'outside ✗'}` : '');
if (t.textContent !== str) t.textContent = str;
- t.setAttribute('fill', ok ? COL.good : COL.bad);
+ t.setAttribute('fill', !still ? COL.dim : ok ? COL.good : COL.bad);
};
vs.onChange(up); up();
if (t0 != null) show(g, t0, .4);
@@ -151,7 +171,7 @@ const BEATS = [
const p = panel(0);
title(p, 'Vectors so far: arrows you add and stretch');
const vs = plane2(p, V2, { show: [], t0: m('v') - .4, c: 1, d: 1 });
- vs.label('cv', v_ => comboLabel(vs, v_.c, 0)); vs.label('dw', ['w']);
+ vs.label('cv', cvName(vs)); vs.label('dw', dwName(vs));
vs.row([{ t: 'v', fill: GREEN }, '=', { col: 'v', fixed: true }], { x: 90, y: 250 });
vs.show('v', m('v') + .3);
thick(vs, 'v', m('v') + 2); vs.flash('v0', m('v') + 3.6); vs.flash('v1', m('v') + 3.6);
@@ -166,8 +186,14 @@ const BEATS = [
const r2 = vs.row(['2v', '=', { fn: () => ['2 · 2', '2 · 1'], w: 140 }, '=', { fn: () => ['4', '2'], w: 70, fill: GREEN }], { x: 90, y: 640, o: 0 }); showRow(r2, m('stretch') + .6, .4);
vs.hide('cv', m('mix') - .2); vs.dim('v', m('mix') - .2, 1);
vs.to({ c: 1, d: 1 }, m('mix'), .1);
- vs.show(['cv', 'dw', 'sum'], m('mix') + .3);
- vs.to({ c: 2, d: 1 }, m('mix') + 2.5, 1.2); vs.to({ c: -1, d: 1.5 }, m('mix') + 4.2, 1.4); vs.to({ c: .5, d: -1 }, m('mix') + 6, 1.4);
+ vs.show(['cv', 'dw', 'sum'], m('mix') + .3); vs.dim(['v', 'w'], m('mix') + .3, .25);
+ // the mixes, each read number by number on the row that replaces the two above
+ [rs, r2].forEach(r => hide(r.g, m('mix') + .2, .4));
+ comboRow(vs, p, 250, 520, [{ col: 'cv', fixed: true }, '+', { col: 'dw', fixed: true }, '=', { col: 'sum', fixed: true }], m('mix1') - .3);
+ [['mix1', { c: 2, d: 1 }, [1.6, 2.8, 4.4]], ['mix2', { c: -1, d: 2 }, [2.4, 4.3, 6.4]], ['mix3', { c: 1, d: -1 }, [1.4, 2.6, 4.1]]].forEach(([k, cd, at]) => {
+ vs.to(cd, m(k) - .2, 1); readCols(vs, [['cv', m(k) + at[0]], ['dw', m(k) + at[1]], ['sum', m(k) + at[2]]]);
+ });
+ vs.to({ c: .5, d: 1.5 }, m('mix3') + 6.2, 1.6); vs.to({ c: -2, d: -1 }, m('mix3') + 8.4, 1.6); // "every pair c, d": two more
}],
['space', 'Two rules', (m) => {
@@ -193,8 +219,9 @@ const BEATS = [
hide(dotsG, m('add') - .3, .4);
vs.show(['v', 'w'], m('plane') + 1.5);
vs.show(['cv', 'dw', 'sum'], m('add')); vs.dim(['v', 'w'], m('add'), .25);
- const row = vs.row([{ col: 'sum', fixed: true }], { x: 90, y: 560, o: 0 }); showRow(row, m('add') + .4, .4);
- const ok = (t0, t1) => { const e = text(p, 'two numbers: in R² ✓', 260, 572, t0, { size: 30, fill: COL.good, weight: 700 }); hide(e, t1, .3); };
+ comboRow(vs, p, 250, 560, [{ col: 'sum', fixed: true }], m('add') + .4);
+ vs.flash('sum0', m('add') + 2.4); vs.flash('sum1', m('add') + 4.6);
+ const ok = (t0, t1) => { const e = text(p, 'two numbers: in R² ✓', 420, 572, t0, { size: 30, fill: COL.good, weight: 700 }); hide(e, t1, .3); };
ok(m('in1'), m('scale') - .2);
vs.to({ c: 3, d: 0 }, m('scale'), 1.2); vs.hide('dw', m('scale'), .4); vs.flash('sum0', m('scale') + 1.2); vs.flash('sum1', m('scale') + 1.2);
ok(m('in2'), m('neg') - .2);
@@ -208,40 +235,51 @@ const BEATS = [
const p = panel(0);
title(p, 'Every vector space holds the zero vector');
const vs = plane2(p, { v: V2.v, w: [-2, -1] }, { show: ['cv'], c: 1, d: 0 });
- vs.label('dw', ['−v']); vs.label('sum', ['']);
- vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, '=', { col: 'cv', fixed: true }], { x: 90, y: 280 });
- vs.to({ c: 0 }, m('zero') + .3, 2.4, io); vs.flash('c', m('zero') + .3);
- const o = G(p, { o: 0 }); vs.P.dot(0, 0, COL.chalk, 0, { into: o, label: '(0, 0)', dx: 16, dy: 36 }); show(o, m('shrink') + .4, .4);
- text(p, 'rule 2 with c = 0: 0·v = (0, 0)', 90, 470, m('must'), { size: 32, weight: 600 });
- vs.flash('c', m('must') + .3); vs.flash('cv0', m('must') + 1.6); vs.flash('cv1', m('must') + 1.6);
- text(p, 'so (0, 0) is in every vector space', 90, 520, m('must') + 2.4, { size: 32, weight: 700 });
- // v, then −v from its tip: back to the origin
- vs.to({ c: 1 }, m('also'), 1);
- vs.show('dw', m('also') + 1.2);
- vs.to({ d: 1 }, m('also') + 1.2, 1.4);
- text(p, 'v + (−v) = (0, 0)', 90, 620, m('also') + 1.4, { size: 36, weight: 600 });
+ vs.label('cv', cvName(vs)); vs.label('dw0', ['−v']); vs.label('dw', ['−v'], 'mid', [-18, -30]); vs.label('sum', []);
+ const top = vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, '=', { fn: s_ => [[...vs.parts(s_.c), ' · 2'], [...vs.parts(s_.c), ' · 1']], w: 150 }, '=', { col: 'cv', fixed: true }], { x: 90, y: 280 });
+ hide(top.g, m('also') - .2, .4); // "1 · 2" would follow when v comes back
+ vs.to({ c: .5 }, m('half') - .3, 1.2); vs.flash('c', m('half') + .9);
+ vs.to({ c: 0 }, m('zero2') - .2, 1.4); vs.flash('cv0', m('zero2') + 1.6); vs.flash('cv1', m('zero2') + 3.4);
+ const o = G(p, { o: 0 }); vs.P.dot(0, 0, COL.chalk, 0, { into: o, label: '(0, 0)', dx: -92, dy: -14 }); show(o, m('shrink'), .4);
+ text(p, 'rule 2 with c = 0: 0·v = (0, 0)', 90, 450, m('must'), { size: 32, weight: 600 });
+ vs.flash('c', m('must') + .3);
+ text(p, 'so (0, 0) is in every vector space', 90, 500, m('must') + 2.6, { size: 32, weight: 700 });
+ // −v from the origin, then moved onto the tip of v: back to the origin
+ vs.to({ c: 1, d: 1 }, m('also'), 1);
+ vs.show('dw0', m('neg')); say(p, ['−v = (−2, −1)'], 90, 600, m('neg'), { size: 36, fill: VIOLET });
+ vs.hide('dw0', m('back') - .1, .4); vs.to({ d: 0 }, m('back') - .1, .1); vs.show('dw', m('back')); vs.dim('cv', m('back'), .45);
+ vs.to({ d: 1 }, m('back') + .4, 2.4, lin); // −v grows from the tip of v back to the origin
+ const r = vs.row(['v + (−v)', '=', { fn: () => ['2 + (−2)', '1 + (−1)'], w: 200 }, '=', { fn: () => ['0', '0'], w: 70 }], { x: 90, y: 750, size: 40, o: 0 });
+ showRow(r, m('back') + .3, .4);
}],
['combos', 'Every combination stays in', (m) => {
const p = panel(0);
title(p, 'Both rules together: every combination');
- const vs = plane2(p, V2, { show: ['v', 'w'], c: 2, d: 1 });
- vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { col: 'sum', fixed: true }], { x: 90, y: 300 });
- vs.show('cv', m('cv')); vs.flash('c', m('cv'));
- vs.show('dw', m('dw')); vs.flash('d', m('dw'));
- vs.show('sum', m('both'));
+ const vs = plane2(p, V2, { show: ['v', 'w'], c: 2, d: 0 });
+ vs.label('cv', cvName(vs)); vs.label('dw', dwName(vs), 'mid', [24, -8]);
+ // the row grows with the voice: 2v = [4 2], then + w = [−1 2] (d grows from 0), then = their sum
+ const row = comboRow(vs, p, 250, 300, [{ col: 'cv', fixed: true }, '+', { col: 'dw', fixed: true }, '=', { col: 'sum', fixed: true }], m('cv') - .3);
+ row.parts.slice(2).forEach(e => put(e, { o: 0 }));
+ vs.show('cv', m('cv')); vs.dim('v', m('cv'), .3); vs.flash('cv0', m('cv') + .3); vs.flash('cv1', m('cv') + .3);
+ vs.show('dw', m('dw')); vs.to({ d: 1 }, m('dw'), 1); vs.dim('w', m('dw'), .3); row.parts.slice(2, 4).forEach(e => show(e, m('dw'), .4)); vs.flash('dw0', m('dw') + 1.2); vs.flash('dw1', m('dw') + 1.2);
+ vs.show('sum', m('both')); row.parts.slice(4).forEach(e => show(e, m('both') + 2, .4));
+ readCols(vs, [['cv', m('both') + 4.6], ['dw', m('both') + 5.8], ['sum', m('both') + 7.4]]);
+ readCols(vs, [['cv', m('again') + 1.4], ['dw', m('again') + 3.4]]);
text(p, 'c·v: rule 2 d·w: rule 2 sum: rule 1', 90, 440, m('both') + .4, { size: 28, weight: 600 });
+ vs.to({ c: -1 }, m('again') + .2, 1.2); vs.to({ d: 2 }, m('again') + 2.2, 1.2); // −v, then 2w, as the voice names them vs.flash('sum0', m('again2') + .8); vs.flash('sum1', m('again2') + .8);
// the combination runs through many c and d, and leaves a dot wherever it lands
const trail = G(p, {}), { PX, PY } = vs.P;
const path_ = [[2, 1], [1, 2], [-1, 2], [-2, 0], [-1, -2], [1, -1], [2.5, -.5], [0, 1.5], [-1.5, 1], [.5, -2]];
path_.forEach(([c, d], k) => {
- const t0 = m('all') + 2 + k * .9;
+ const t0 = m('all') + 2.4 + k * 1.05;
vs.to({ c, d }, t0, .7);
const s = [c * 2 - d, c + 2 * d];
const dt = mk('circle', { cx: PX(s[0]), cy: PY(s[1]), r: 7, fill: COL.task, 'fill-opacity': .7 }, trail);
put(dt, { o: 0 }); show(dt, t0 + .7, .2);
});
text(p, 'every combination stays in R²', 90, 520, m('all') + .3, { size: 32, weight: 700 });
+
}],
['q1', 'Quick check', () => {
@@ -256,7 +294,7 @@ const BEATS = [
['r3', 'R³', (m) => {
const p = panel(0);
title(p, 'R³: every list of three numbers');
- const V = space3(p, { cx: 1150, cy: 480, size: 600, range: 4, yaw: -35, pitch: 20, t0: m('three') - .3 });
+ const V = space3(p, { cx: 1170, cy: 490, size: 740, range: 4, yaw: -35, pitch: 20, t0: m('three') - .3 });
V.sway(8, 16);
const O = [0, 0, 0], v = [1, 2, 0], w = [0, 1, 2], s = [1, 3, 2];
const av = V.arrow(O, v, { color: GREEN }), aw = V.arrow(O, w, { color: VIOLET }), aw2 = V.arrow(v, v, { color: VIOLET, dash: '8 6' }), as = V.arrow(O, O, { color: COL.task, w: 6 });
@@ -271,6 +309,7 @@ const BEATS = [
hide(aw2.e, m('scale') - .2, .3);
prog(q => { const k = 1 + q; as.set(O, w.map(x => x * k)); }, m('scale') + .3, 1.4);
prog(q => { if (q > 0) as.set(O, w.map(x => x * 2)); }, m('scale') + 1.7, 0);
+ prog(q => as.set(O, w.map((x, i) => x * 2 * (1 - q) - v[i] * q)), m('neg') + .2, 1.6); // 2w swings round to −v
const L = G(p, {});
say(L, ['v = (1, 2, 0)'], 90, 260, m('v'), { size: 38, fill: GREEN });
say(L, ['w = (0, 1, 2)'], 90, 330, m('w'), { size: 38, fill: VIOLET });
@@ -278,7 +317,9 @@ const BEATS = [
text(L, 'three numbers: in R³ ✓', 90, 480, m('in'), { size: 30, fill: COL.good, weight: 700 });
say(L, ['2w = (0, 2, 4)'], 90, 580, m('scale') + .4, { size: 34 });
text(L, 'three numbers: in R³ ✓', 90, 630, m('in2'), { size: 30, fill: COL.good, weight: 700 });
- text(L, 'R³ is a vector space', 90, 730, m('so'), { size: 36, weight: 700 });
+ say(L, ['−v = (−1, −2, 0)'], 90, 720, m('neg') + .4, { size: 34 });
+ text(L, 'three numbers: in R³ ✓', 400, 720, m('neg') + 3.5, { size: 30, fill: COL.good, weight: 700 });
+ text(L, 'R³ is a vector space', 90, 810, m('so'), { size: 36, weight: 700 });
}],
['rn', 'Rⁿ as bars', (m) => {
@@ -298,6 +339,10 @@ const BEATS = [
hide(rr, m(k) + 1.6 + 5 * .75, .3);
});
show(bs.eqSign, m('add') + .4, .4); show(bs.ax.g, m('add') + .4, .4);
+ const across = mk('rect', { x: cv.x - 10, y: 0, width: bs.ax.x + 150 - cv.x, height: bs.zeroY(1) - bs.zeroY(0) - 6, rx: 10, fill: 'none', stroke: COL.chalk, 'stroke-width': 3 }, p);
+ put(across, { o: 0, y: bs.zeroY(0) - 40 });
+ ['s1', 's2', 's3', 's4', 's5'].forEach((k, i) => { if (i) tw(across, { y: bs.zeroY(i) - 40 }, m(k) - .2, .3); else show(across, m(k) - .2, .3); });
+ hide(across, m('sum'), .3);
bs.to({ x0: 1, x1: 1 }, m('add') + .8, 1.6);
bs.to({ x0: 2, x1: 0 }, m('scale') + .3, 1.6);
bs.to({ x0: 1, x1: -1 }, m('n') + 4, 1.4); bs.to({ x0: -1, x1: 2 }, m('n') + 6, 1.4);
@@ -333,19 +378,22 @@ const BEATS = [
region(vs, 'quarter', m('quarter'));
text(p, 'only arrows with x ≥ 0 and y ≥ 0', 90, 220, m('quarter') + .5, { size: 30, weight: 600 });
vs.show('v', m('v')); vs.show('w', m('w'));
+ comboRow(vs, p, 250, 330, [{ col: 'sum', fixed: true }], m('add') + .3);
vs.show(['cv', 'dw', 'sum'], m('add')); vs.dim(['v', 'w'], m('add'), .25);
- const vd = verdict(p, vs, 'quarter', 90, 400, m('add') + .8, { name: 'c·v + d·w' });
- vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }], { x: 90, y: 320 });
- vs.flash('sum0', m('ok')); vs.flash('sum1', m('ok'));
- vs.to({ v0: 4, v1: .5, w0: .5, w1: 2 }, m('ok') + 2.2, 1.4); vs.to({ v0: 1, v1: 0, w0: 0, w1: 4 }, m('ok') + 3.8, 1.4); vs.to({ v0: 2, v1: 1, w0: 1, w1: 3 }, m('ok') + 5.4, 1.2);
- vs.hide('dw', m('scale') - .2); vs.dim(['v', 'w'], m('scale') - .2, 1); vs.hide('w', m('scale') - .2);
- vs.to({ c: 2, d: 0 }, m('scale'), 1.2); vs.flash('c', m('scale'));
- vs.to({ c: -1 }, m('neg') + .3, 1.8); vs.flash('c', m('neg') + .3);
+ vs.flash('sum0', m('add') + 2.4); vs.flash('sum1', m('add') + 4);
+ verdict(p, vs, 'quarter', 90, 460, m('ok'));
+ // other arrows of the quarter, added: the sum never leaves it
+ const why = G(p, { o: 0 });
+ T(why, '(0 or more) + (0 or more) = 0 or more', { x: 90, y: 530, size: 30, weight: 600 });
+ show(why, m('why') + 2, .4); hide(why, m('scale') - .3, .3);
+ vs.to({ v0: 4, v1: .5, w0: .5, w1: 2 }, m('why') + 1, 1.2); vs.to({ v0: 1, v1: 0, w0: 0, w1: 4 }, m('why') + 3, 1.2); vs.to({ v0: 2, v1: 1, w0: 1, w1: 3 }, m('why') + 5, 1.2);
+ vs.hide(['dw', 'w'], m('scale') - .3); vs.dim('v', m('scale') - .3, 1);
+ vs.to({ c: 2, d: 0 }, m('scale'), 1.2);
+ thick(vs, 'sum', m('neg') + 2.2); vs.to({ c: -1 }, m('neg') + 4, 1.8);
thick(vs, 'sum', m('out') + .4, 6);
const no = G(p, { o: 0 });
- T(no, 'rule 2 broken: not a vector space', { x: 90, y: 520, size: 32, fill: COL.bad, weight: 700 });
+ T(no, 'rule 2 broken: not a vector space', { x: 90, y: 560, size: 32, fill: COL.bad, weight: 700 });
show(no, m('fail') + 1, .5);
- void vd;
}],
['dots', 'The dots fail', (m) => {
@@ -355,35 +403,70 @@ const BEATS = [
region(vs, 'dots', m('dots'));
text(p, 'only points with whole-number coordinates', 90, 220, m('dots') + .5, { size: 30, weight: 600 });
vs.show(['cv', 'dw', 'sum'], m('add'));
- vs.to({ v0: 2, v1: 1, w0: 1, w1: 3 }, m('add') + 2.6, 1.2); vs.to({ v0: 1, v1: 2, w0: 2, w1: 1 }, m('add') + 4.2, 1.2);
- verdict(p, vs, 'dots', 90, 400, m('add') + .8, { name: 'the tip' });
- vs.row([{ key: 'c' }, { t: 'v', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }], { x: 90, y: 320 });
- vs.hide(['dw'], m('scale') - .3);
- vs.to({ v0: 1, v1: 1, d: 0 }, m('scale'), 1.2);
- vs.to({ c: .5 }, m('half'), 1.4); vs.flash('c', m('half'));
+ const row = comboRow(vs, p, 250, 330, [{ col: 'cv', fixed: true }, '+', { col: 'dw', fixed: true }, '=', { col: 'sum', fixed: true }], m('add') + .3);
+ row.parts.slice(2).forEach(e => hide(e, m('two') - .3, .3)); // one vector stretched: "2v = [2 2]"
+ verdict(p, vs, 'dots', 90, 460, m('dot'));
+ readCols(vs, [['cv', m('add') + 1.6], ['dw', m('add') + 2.6], ['sum', m('add') + 3.8]]);
+ const whole = text(p, 'whole + whole = whole', 90, 530, m('whole') + 1, { size: 30, weight: 600 }); hide(whole, m('scale') - .3, .3);
+ vs.to({ v0: 2, v1: 1, w0: 1, w1: 3 }, m('whole') + 1.4, 1.2); vs.to({ v0: 1, v1: 2, w0: 2, w1: 1 }, m('whole') + 3.2, 1.2);
+ // stretching by a whole number: 2·(1, 1) = (2, 2), a dot
+ vs.hide(['dw'], m('two') - .3);
+ vs.to({ v0: 1, v1: 1, d: 0 }, m('two') - .3, .8); vs.to({ c: 2 }, m('two') + 2.2, 1.2);
+ vs.to({ c: 1 }, m('scale'), .8);
+ vs.to({ c: .5 }, m('half'), 1.4);
thick(vs, 'sum', m('half') + 1.6, 6);
- text(p, 'between the dots: not a vector space', 90, 520, m('fail'), { size: 32, fill: COL.bad, weight: 700 });
+ text(p, 'between the dots: not a vector space', 90, 560, m('fail'), { size: 32, fill: COL.bad, weight: 700 });
+ }],
+
+ ['more', 'Two more that fail', (m) => {
+ const p = panel(0);
+ title(p, 'Two more that fail');
+ // one vector, v, used twice in the second example (v + v): both of its arrows green
+ const vs = S.vs = plane2(p, V2, { show: [], c: 1, d: 0, colors: { w: GREEN, dw: GREEN } });
+ const vv = st => vs.combo(st, 'v', 'v');
+ vs.label('cv', cvName(vs)); vs.label('dw', []); vs.label('sum', vv);
+ // the first: the plane without its origin; 0·v = (0, 0) is not in it
+ const A_ = G(p, {}), B_ = G(p, { o: 0 });
+ comboRow(vs, A_, 250, 330, [{ col: 'cv', fixed: true }], m('hv') + .3, { name: s_ => Math.abs(s_.c) < 1e-9 ? ['0v'] : vv(s_), idle: [] });
+ const holeG = region(vs, 'holey', m('holey'));
+ text(A_, 'the plane with (0, 0) cut out', 90, 220, m('holey') + .5, { size: 30, weight: 600 });
+ vs.show('cv', m('hv'));
+ verdict(A_, vs, 'holey', 90, 460, m('hv') + .6);
+ vs.to({ c: 0 }, m('hz'), 1.6);
+ text(A_, 'rule 2 broken: not a vector space', 90, 560, m('hf'), { size: 32, fill: COL.bad, weight: 700 });
+ // the second: one arrow (1, 1) alone; v + v = (2, 2) is not in it
+ hide(A_, m('one') - .4, .4); hide(holeG, m('one') - .4, .4);
+ vs.to({ v0: 1, v1: 1, w0: 1, w1: 1, c: 1, d: 0 }, m('one') - .4, .6);
+ region(vs, 'one', m('one'));
+ show(B_, m('one'), .4);
+ text(B_, 'just one arrow: (1, 1)', 90, 220, m('one') + .5, { size: 30, weight: 600 });
+ const rowB = comboRow(vs, B_, 250, 330, [{ col: 'cv', fixed: true }, '+', { col: 'dw', fixed: true }, '=', { col: 'sum', fixed: true }], m('one') + .3, { name: vv, idle: ['v + v'] });
+ rowB.parts.slice(2).forEach(e => { put(e, { o: 0 }); show(e, m('oadd') + .3, .4); });
+ vs.show(['dw', 'sum'], m('oadd')); vs.to({ d: 1 }, m('oadd'), 1.4);
+ vs.flash('sum0', m('oadd') + 2); vs.flash('sum1', m('oadd') + 3.4);
+ verdict(B_, vs, 'one', 90, 460, m('oout'));
+ text(B_, 'rule 1 broken: not a vector space', 90, 560, m('of'), { size: 32, fill: COL.bad, weight: 700 });
}],
['q3', 'Your turn', () => {
const p = panel(0);
title(p, 'Your turn');
- const vs = S.vs = plane2(p, Q2, { show: ['sum'], c: 1, d: 0 });
- vs.label('sum', v_ => comboLabel(vs, v_.c, 0));
+ const vs = S.vs = plane2(p, Q2, { show: ['v', 'sum'], c: 1, d: 0 });
+ vs.label('sum', cvOnly(vs));
region(vs, 'quarter', .2);
vs.row([{ key: 'c' }, { col: 'v' }, '=', { col: 'sum', fixed: true }], { x: 90, y: 260 });
- verdict(p, vs, 'quarter', 90, 400, .4, { name: 'c·v' });
+ verdict(p, vs, 'quarter', 90, 400, .4);
}, { ask: done => quiz({ x: 40, y: 470, w: 740, cls: 'side' }, [{
id: 'c-break', prompt: ['Keep v in the quarter. Change c (or v) until c·v is outside it.'],
build: vsTask(S.vs, testOut('quarter'), (v, k) => `c·v = ${pair(k.sum[0], k.sum[1])} left the quarter, while v was inside: rule 2 fails.`,
v => !IN.quarter([v.v0, v.v1]) ? 'v itself must be in the quarter: both its numbers 0 or more.' : 'A positive c keeps the arrow in the quarter. Try a negative c.',
- () => S.vs.set({ c: -1 }), { only: ['c', 'v0', 'v1'], drag: [] }),
+ () => S.vs.set({ c: -1 }), { only: ['c', 'v0', 'v1'], drag: ['v'] }),
}], done) }],
['wrap', 'Summary', (m) => {
const p = panel(0);
[['A vector space: adding any two, or multiplying one by any number, stays inside.', 'w1'], ['So every combination stays inside, and the zero vector is always there.', 'w2'],
- ['R², R³ and Rⁿ (every list of n numbers) are vector spaces.', 'w3'], ['The quarter and the grid dots are not: a stretch throws a vector out.', 'w4']].forEach(([str, mark], i) => {
+ ['R², R³ and Rⁿ (every list of n numbers) are vector spaces.', 'w3'], ['The quarter, the dots, the plane without (0, 0) and one arrow alone are not.', 'w4']].forEach(([str, mark], i) => {
const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });
mk('circle', { cx: 120, cy: -12, r: 26, fill: COL.chalk }, g);
T(g, String(i + 1), { x: 120, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
@@ -406,18 +489,18 @@ const BEATS = [
['final4', 'Chapter practice', () => {
const p = panel(0);
title(p, 'Break the rules');
- const vs = S.vs = plane2(p, Q2, { show: ['sum'], c: 1, d: 0, steps: { c: .5 } });
- vs.label('sum', v_ => comboLabel(vs, v_.c, 0));
+ const vs = S.vs = plane2(p, Q2, { show: ['v', 'sum'], c: 1, d: 0, steps: { c: .5 } });
+ vs.label('sum', cvOnly(vs));
S.reg = { half: region(vs, 'half', null), dots: region(vs, 'dots', null) };
vs.row([{ key: 'c' }, { col: 'v' }, '=', { col: 'sum', fixed: true }], { x: 90, y: 260 });
- S.vd = { half: verdict(p, vs, 'half', 90, 400, null, { name: 'c·v' }), dots: verdict(p, vs, 'dots', 90, 400, null, { name: 'c·v' }) };
+ S.vd = { half: verdict(p, vs, 'half', 90, 400, null), dots: verdict(p, vs, 'dots', 90, 400, null) };
}, { ask: done => quiz({ x: 40, y: 470, w: 740, cls: 'side' }, HANDQ.map(q => ({
id: q.id, prompt: q.prompt,
build: (body, api) => {
Object.entries(S.reg).forEach(([k, g]) => put(g, { o: k === q.kind ? 1 : 0 }));
Object.entries(S.vd).forEach(([k, g]) => put(g, { o: k === q.kind ? 1 : 0 }));
S.vs.set(q.start);
- return vsTask(S.vs, testOut(q.kind), q.why, q.hint, () => S.vs.set(q.ans), { only: q.kind === 'dots' ? ['c'] : ['c', 'v0', 'v1'], drag: [] })(body, api);
+ return vsTask(S.vs, testOut(q.kind), q.why, q.hint, () => S.vs.set(q.ans), { only: q.kind === 'dots' ? ['c'] : ['c', 'v0', 'v1'], drag: q.kind === 'dots' ? [] : ['v'] })(body, api);
},
})), done, 'Chapter practice · set 4 of 4') }],
['play', 'Playground', (m) => {
@@ -426,7 +509,7 @@ const BEATS = [
const vs = S.vs = plane2(p, Q2, { show: ['v', 'w', 'cv', 'dw', 'sum'], c: 1, d: 1 });
region(vs, 'quarter', .2);
vs.row([{ key: 'c' }, { col: 'v' }, { key: 'd', signed: true }, { col: 'w' }, '=', { col: 'sum', fixed: true }], { x: 90, y: 260 });
- verdict(p, vs, 'quarter', 90, 400, .4, { name: 'c·v + d·w' });
+ verdict(p, vs, 'quarter', 90, 400, .4);
const hint = G(p, { o: 0 });
T(hint, 'try: a negative c · a w outside the quarter · c = d = 0', { x: 1160, y: 820, size: 24, fill: COL.dim, anchor: 'middle' });
show(hint, m('go'), .5);
diff --git a/site/linear-algebra/ch38/index.html b/site/linear-algebra/ch38/index.html
index 2fd5dbd..de7149a 100644
--- a/site/linear-algebra/ch38/index.html
+++ b/site/linear-algebra/ch38/index.html
@@ -35,7 +35,7 @@ const testBoard = (p, { set = 'line', line = [1, -2, 0], u = [2, 1], w = [-4, -2
eq: eq ? sb.eq({ x: 90, y: 200, size: 46, o }) : null,
u: sb.row([{ t: 'u', fill: GREEN }, '=', { col: 'u' }], { x: 90, y: 345, size: 40, o }),
w: sb.row([{ t: 'w', fill: VIOLET }, '=', { col: 'w' }], { x: 330, y: 345, size: 40, o }),
- combo: sb.row([{ key: 'c' }, { t: 'u', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { col: 'sum' }], { x: 90, y: 540, size: 40, o }),
+ combo: sb.row([{ key: 'c' }, { t: 'u', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { col: 'sum' }], { x: 90, y: 540, size: 40, o, tight: true }),
cu: sb.check('u', { x: 90, y: 428, size: 26, o }),
cw: sb.check('w', { x: 330, y: 428, size: 26, o }),
out: sb.readout({ x: 90, y: 650, size: 32, o }),
@@ -59,6 +59,23 @@ const hand = (sb, id) => {
sb.onChange(upd); upd(sb.v);
return g;
};
+// The walk tip to tail as hops over the line, as on a number line: u from 0, then w from u's tip (arrows on one line
+// lie on top of each other, so the hops show the order). pts are plane points; the first hop bulges up, the next down.
+const hops = (sb, pts, cols, t0, gap = 1.2) => {
+ const { PX, PY } = sb.P, g = G(sb.P.g, {});
+ g.style.pointerEvents = 'none';
+ for (let i = 0; i + 1 < pts.length; i++) {
+ const A = [PX(pts[i][0]), PY(pts[i][1])], B = [PX(pts[i + 1][0]), PY(pts[i + 1][1])], L = Math.hypot(B[0] - A[0], B[1] - A[1]);
+ let n = [-(B[1] - A[1]) / L, (B[0] - A[0]) / L];
+ if ((i % 2 === 0) === (n[1] > 0)) n = [-n[0], -n[1]]; // first hop above, the next below
+ const C = [(A[0] + B[0]) / 2 + n[0] * L * .45, (A[1] + B[1]) / 2 + n[1] * L * .45];
+ const arc = path(g, `M${A[0]} ${A[1]}Q${C[0]} ${C[1]} ${B[0]} ${B[1]}`, { stroke: cols[i], 'stroke-width': 3.5, 'stroke-dasharray': '1 1' }, { d: 0 });
+ const dx = B[0] - C[0], dy = B[1] - C[1], dl = Math.hypot(dx, dy), ux = dx / dl, uy = dy / dl;
+ const head = path(g, `M${B[0] - 16 * ux - 8 * uy} ${B[1] - 16 * uy + 8 * ux}L${B[0]} ${B[1]}L${B[0] - 16 * ux + 8 * uy} ${B[1] - 16 * uy - 8 * ux}`, { stroke: cols[i], 'stroke-width': 3.5 }, { o: 0 });
+ draw(arc, t0 + i * gap, .8); show(head, t0 + i * gap + .7, .2);
+ }
+ return g;
+};
// A dashed amber ring at a plane point: a target.
const ringAt = (sb, x, y, t0, into, { label = `(${num(x)}, ${num(y)})`, color = COL.task, dx = 22, dy = -16 } = {}) => {
const g = G(into, { x: sb.P.PX(x), y: sb.P.PY(y), o: 0 });
@@ -147,8 +164,9 @@ const BEATS = [
sb.to({ c: 2, d: 0 }, m('r2') + 5.2, 1.4); sb.hide(['dw', 'w'], m('r2') + 5, .4);
// a smaller set: the plane shrinks to one line through the origin
hide(r2t, m('q') - .2, .3);
+ // vs.to plans from the moves written before it, so moves are written in the order they play
+ sb.to({ c: 1, d: 1, u0: 2, u1: 1, w0: -4, w1: -2 }, m('q') - .5, .8);
sb.kind('line', m('q') + .4);
- sb.to({ c: 1, d: 1, u0: 2, u1: 1, w0: -4, w1: -2 }, m('q') + .2, .01);
sb.show(['w', 'dw'], m('q') + .6);
tw(sb.setG, { o: 0 }, m('q'), .4); tw(sb.setG, { o: 1 }, m('q') + .45, .6);
text(p, 'a part of the plane: one line', 90, 340, m('q') + .6, { size: 30, fill: SETC, weight: 600 });
@@ -156,7 +174,7 @@ const BEATS = [
T(nm, 'subspace:', { x: 90, y: 440, size: 40, weight: 700 });
T(nm, 'a set inside R² that obeys the rule by itself', { x: 90, y: 490, size: 30, weight: 600 });
show(nm, m('name'), .6);
- sb.to({ u0: 4, u1: 2 }, m('name') + 3, 2); sb.to({ w0: 2, w1: 1 }, m('name') + 5.5, 2); sb.to({ u0: -4, u1: -2 }, m('name') + 8, 2.4);
+ sb.to({ w0: 2, w1: 1 }, m('name') + 3, 2); sb.to({ u0: 4, u1: 2 }, m('name') + 5.5, 2); sb.to({ u0: 2, u1: 1 }, m('name') + 8, 2.4); // 2u and −1.5u stay on the board
const tt = G(p, { o: 0 });
T(tt, 'the test: pick u and w in the set', { x: 90, y: 580, size: 30, fill: COL.chalk, weight: 600 });
T(tt, 'is u + w in it? is every multiple c·u in it?', { x: 90, y: 628, size: 30, fill: COL.chalk, weight: 600 });
@@ -182,6 +200,8 @@ const BEATS = [
boxNums(p, [nb('u0')], m('add') + .9, m('add') + 4, GREEN); boxNums(p, [nb('w0')], m('add') + 1.5, m('add') + 4, VIOLET); boxNums(p, [nb('sum0')], m('add') + 2.5, m('add') + 4);
boxNums(p, [nb('u1')], m('add') + 4.1, m('add') + 7.6, GREEN); boxNums(p, [nb('w1')], m('add') + 4.7, m('add') + 7.6, VIOLET); boxNums(p, [nb('sum1')], m('add') + 5.7, m('add') + 7.6);
sb.show('dw', m('pic')); sb.show('sum', m('pic') + 2.6);
+ const hp = hops(sb, [[0, 0], [2, 1], [-2, -1]], [GREEN, VIOLET], m('pic') + .3);
+ hide(hp, m('three') - .3, .3);
show(B.out, m('test')); thickSet(sb, m('test') + 1.5);
tw(sb.ring, { s: 1.5 }, m('test') + 3.4, .25); tw(sb.ring, { s: 1 }, m('test') + 3.7, .4);
tw(sb.ring, { s: 1.5 }, m('on') + .2, .25); tw(sb.ring, { s: 1 }, m('on') + .5, .4);
@@ -196,14 +216,14 @@ const BEATS = [
const p = S.p, B = S.B, sb = S.sb;
sb.to({ c: 1, d: 1 }, .2, .8); sb.show(['w', 'dw'], .3); show(B.cw, .3);
pulseG(B.cu, m('each') + .6); pulseG(B.cw, m('each') + 3.2);
- sb.to({ u0: 4, u1: 2 }, m('each') + 4.6, 1.4); sb.to({ u0: 2, u1: 1 }, m('sum') + .2, 1.2);
+ sb.to({ u0: 6, u1: 3 }, m('each') + 4.6, 1.4); sb.to({ u0: 2, u1: 1 }, m('sum') + .2, 1.2);
sb.to({ c: 2 }, m('mult') + 1.5, 1.2); sb.to({ c: -1 }, m('mult') + 3, 1.2); sb.to({ c: 1 }, m('mult') + 4.5, 1);
const n1 = text(p, 'u + w gives 0 + 0 = 0', 90, 765, m('sum') + 4.6, { size: 30, weight: 600 });
const n2 = text(p, 'c·u gives c · 0 = 0', 430, 765, m('mult'), { size: 30, weight: 600 });
// a hand moves u and w along the line; every check stays 0
const hu = hand(sb, 'u'), hw = hand(sb, 'w');
show(hu, m('drag') - .2, .3);
- sb.to({ u0: 4, u1: 2 }, m('drag') + .2, 1.1); sb.to({ u0: -2, u1: -1 }, m('drag') + 1.5, 1.1);
+ sb.to({ u0: 6, u1: 3 }, m('drag') + .2, 1.1); sb.to({ u0: -2, u1: -1 }, m('drag') + 1.5, 1.1);
hide(hu, m('drag') + 2.7, .3); show(hw, m('drag') + 2.7, .3);
sb.to({ w0: 6, w1: 3 }, m('drag') + 3, 1.1); sb.to({ w0: 4, w1: 2 }, m('drag') + 4.3, 1);
hide(hw, m('drag') + 5.4, .3);
@@ -217,10 +237,13 @@ const BEATS = [
text(p, 'Test 2: the line 3x + y = 0', 60, 110, .2, { size: 40, weight: 600 });
const B = S.B = testBoard(p, { line: [1, -2, 0], u: [2, 1], w: [-4, -2], o: 1, show: ['u', 'w'] }), sb = S.sb = B.sb;
hide(B.combo.g, 0, 0); hide(B.out, 0, 0);
+ [B.cu, B.cw].forEach(e => { hide(e, m('turn') - .2, .2); show(e, m('turn') + 1.9, .4); });
sb.to({ a: 3, b: 1, u0: 1, u1: -3, w0: -2, w1: 6 }, m('turn'), 1.8);
['a', 'b'].forEach(k => sb.flash(k, m('turn')));
pulseG(B.cu, m('u') + .5); pulseG(B.cw, m('w') + .5);
show(B.combo.g, m('add'), .5); sb.show(['dw', 'sum'], m('add') + .4); show(B.out, m('add') + 2.6);
+ const hp = hops(sb, [[0, 0], [1, -3], [-1, 3]], [GREEN, VIOLET], m('add') + .5);
+ hide(hp, m('two') - .3, .3);
tw(sb.ring, { s: 1.5 }, m('on'), .25); tw(sb.ring, { s: 1 }, m('on') + .3, .4);
sb.hide(['dw', 'w'], m('two') - .3, .3); hide(B.cw, m('two') - .3, .3);
sb.to({ c: 2, d: 0 }, m('two'), 1.2); sb.flash('c', m('two'));
@@ -311,17 +334,17 @@ const BEATS = [
[B.u.g, B.w.g, B.cu, B.cw].forEach(e => put(e, { o: 0 }));
const t1 = text(p, 'the zero vector alone', 90, 210, m('z'), { size: 36, fill: SETC, weight: 600 });
put(sb.setG, { o: 0 }); show(sb.setG, m('z'), .5);
- showRow(B.u, m('z') + 1.2); showRow(B.w, m('z') + 1.2);
- say(p, ['0 + 0 = 0, c · 0 = 0'], 90, 450, m('zz'), { size: 34 });
+ [B.u.g, B.w.g].forEach(e => show(e, m('z') + 1.2, .5));
+ const zz = say(p, ['0 + 0 = 0, c · 0 = 0'], 90, 450, m('zz'), { size: 34 });
[[2, -1], [3, -2], [-1, 4], [2, 2]].forEach(([c, d], i) => { sb.to({ c, d }, (i ? m('stay') + (i - 1) * 1.3 : m('zz') + 1.5), 1); });
const n1 = text(p, 'a subspace: the smallest one', 90, 765, m('name'), { size: 30, fill: COL.good, weight: 700 });
// the whole plane
- [t1, n1].forEach(e => hide(e, m('all') - .3, .3));
+ [t1, n1, zz].forEach(e => hide(e, m('all') - .3, .3));
sb.kind('all', m('all'));
sb.to({ u0: 2, u1: 1, w0: -1, w1: 3, c: 1, d: 1 }, m('all') + .1, 1.2);
sb.show('dw', m('all') + .4);
text(p, 'the whole plane R²', 90, 210, m('all') + .2, { size: 36, fill: SETC, weight: 600 });
- [[2, -1], [-1, -1], [1, 2]].forEach(([c, d], i) => { sb.to({ c, d }, m('roam') + .4 + i * 1.4, 1.1); });
+ [[2, -1], [-1, -1], [1, 1]].forEach(([c, d], i) => { sb.to({ c, d }, m('roam') + .4 + i * 1.4, 1.1); });
sb.to({ u0: -3, u1: 2, w0: 1, w1: -2 }, m('name2') - .4, 1.2);
text(p, 'a subspace of itself: the biggest one', 90, 765, m('name2') + .4, { size: 30, fill: COL.good, weight: 700 });
}],
@@ -376,11 +399,11 @@ const BEATS = [
sb.kind('line', m('l'));
sb.to({ u0: 2, u1: 1 }, m('l') + .05, .01);
L('every line through the origin', 280, m('l'));
- sb.to({ a: 2, b: 1 }, m('l') + .4, 1.2); sb.to({ a: 1, b: -3 }, m('l') + 1.8, 1.2); sb.to({ a: 1, b: -2 }, m('l') + 3.2, 1);
+ sb.to({ a: 2, b: 1 }, m('l') + .2, .6); sb.to({ a: 1, b: -3 }, m('l') + .85, .6); sb.to({ a: 1, b: -2 }, m('l') + 1.5, .5); // done before the plane comes in
sb.kind('all', m('p'));
L('the whole plane R²', 340, m('p'));
// could there be more? one vector u gives its whole line
- sb.kind('line', m('one') - .1);
+ sb.kind('line', m('one') - .1); sb.to({ u0: 2, u1: 1 }, m('one') - .05, .01); // the turns moved u along: a long u again, before it shows
const q = text(p, 'anything else?', 90, 430, m('q'), { size: 32, fill: COL.dim, weight: 600 });
sb.show(['u', 'sum'], m('one') + .2); sb.multiples(m('one') + 1.5);
sb.to({ c: -2 }, m('one') + 2.4, 1.2); sb.to({ c: 2.5 }, m('one') + 3.7, 1.6); sb.to({ c: 1 }, m('one') + 5.4, .8);
@@ -397,6 +420,7 @@ const BEATS = [
T(so, 'nothing in between:', { x: 90, y: 730, size: 30, fill: COL.good, weight: 700 });
T(so, 'a point, a line through 0, or all of R²', { x: 90, y: 777, size: 30, fill: COL.good, weight: 700 });
show(so, m('so') + 1.4, .5);
+ sb.to({ c: 1, d: -1 }, m('so') + 2.8, .5);
sb.kind('zero', m('so') + 3.4); sb.kind('line', m('so') + 4.6); sb.to({ u0: 2, u1: 1, w0: 4, w1: 2 }, m('so') + 4.65, .01); sb.kind('all', m('so') + 6); sb.to({ w0: -1, w1: 2 }, m('so') + 6.05, .01);
}],
@@ -452,8 +476,8 @@ const BEATS = [
['final4', 'Chapter practice', () => {
const p = panel(0);
text(p, 'Make it', 60, 110, .2, { size: 40, weight: 600 });
- const sb = S.sb = subspace2(p, { line: [1, 1, 2], u: [0, 2], w: [3, -1], show: ['u', 'w', 'dw', 'sum'] });
- S.B = { sb, eq: sb.eq({ x: 90, y: 200, size: 46 }), out: sb.readout({ x: 90, y: 300, size: 32 }) };
+ const sb = S.sb = subspace2(p, { line: [1, 1, 2], u: [0, 2], w: [3, -1], show: ['u', 'w'] }); // the sum waits for p-back (it would sit on the target)
+ S.B = { sb, eq: sb.eq({ x: 90, y: 200, size: 46 }), out: sb.readout({ x: 90, y: 300, size: 32, o: 0 }) }; // the sum's test, for p-back
S.tg = G(p, {});
}, { ask: done => quiz({ ...CARD, y: 495 }, [{
id: 'p-make', prompt: ['Make the line a subspace that passes through ', $m('(3, 1)'), '. Change its numbers or drag it.'],
@@ -467,7 +491,8 @@ const BEATS = [
id: 'p-back', prompt: ['Now ', $m('u = [2, 1]'), ' and ', $m('w = [4, 2]'), '. Find ', $m('c ≠ 0'), ' and ', $m('d'), ' with ', $m('cu + dw'), ' = the zero vector.'],
build: (body, api) => {
S.sb.set({ a: 1, b: -2, k: 0, u0: 2, u1: 1, w0: 4, w1: 2, c: 1, d: 1 });
- if (!S.combo) S.combo = S.sb.row([{ key: 'c' }, { t: 'u', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { col: 'sum' }], { x: 90, y: 425, size: 38 });
+ ['dw', 'sum'].forEach(id => { put(S.sb.vs.A[id].g, { o: 1 }); put(S.sb.vs.A[id].lab, { o: 1 }); }); put(S.sb.ring, { o: 1 }); put(S.B.out, { o: 1 });
+ if (!S.combo) S.combo = S.sb.row([{ key: 'c' }, { t: 'u', fill: GREEN }, { key: 'd', signed: true }, { t: 'w', fill: VIOLET }, '=', { col: 'sum' }], { x: 90, y: 425, size: 38, tight: true });
return sbTask(S.sb, v => Math.abs(v.c) > 1e-9 && Math.hypot(...S.sb.vs.calc().sum) < 1e-9, 'w = 2u, so 2u − w = 0 (and any multiple: −4u + 2w, …).',
v => Math.abs(v.c) < 1e-9 ? 'c must not be 0.' : 'Not zero yet. w is twice u: how many u cancel one w?', () => S.sb.set({ c: 2, d: -1 }), { only: ['c', 'd'], drag: [] })(body, api);
},
@@ -477,9 +502,9 @@ const BEATS = [
text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });
const B = S.B = testBoard(p, { line: [1, -2, 0], u: [2, 1], w: [-4, -2], o: 1, show: ['u', 'w', 'dw', 'sum'] }), sb = S.sb = B.sb;
[B.cu, B.cw].forEach(e => put(e, { o: 0 }));
- put(B.combo.g, { y: -80 }); put(B.out, { y: -110 });
+ put(B.combo.g, { y: -80 }); put(B.out, { x: 330, y: -195 }); // the readout beside c u + d w: the card fits under them
text(p, 'try: slide it off the origin · make c negative · turn the line', 90, 256, m('go'), { size: 24, fill: COL.dim });
- }, { ask: playAsk(() => S.sb, { pos: { x: 40, y: 625, w: 720, cls: 'side' }, tip: 'Your test. Change any number, drag the line, or a tip along it. The ring is green while c u + d w stays on the line.' }) }],
+ }, { ask: playAsk(() => S.sb, { pos: { x: 40, y: 540, w: 720, cls: 'side' }, tip: 'Your test. Change any number, drag the line, or a tip along it. The ring is green while c u + d w stays on the line.' }) }],
['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
diff --git a/site/linear-algebra/ch39/index.html b/site/linear-algebra/ch39/index.html
index 0a13cad..8235c11 100644
--- a/site/linear-algebra/ch39/index.html
+++ b/site/linear-algebra/ch39/index.html
@@ -25,11 +25,11 @@ const CARD = { x: 40, y: 470, w: 720, cls: 'side' };
const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
const pulseG = (e, t0) => { tw(e, { o: .35 }, t0, .2); tw(e, { o: 1 }, t0 + .25, .3); tw(e, { o: .35 }, t0 + .6, .2); tw(e, { o: 1 }, t0 + .85, .3); };
-const bump = (sb, t0) => { tw(sb.ring, { s: 1.5 }, t0, .25); tw(sb.ring, { s: 1 }, t0 + .3, .4); };
-const sub3 = (p, o = {}) => subspace3(p, { space: { ...VIEW }, ...o });
+const bump = (sb, t0) => { const e = sb.ring.firstChild; tw(e, { s: 1.5 }, t0, .25); tw(e, { s: 1 }, t0 + .3, .4); }; // the ring's own dot: scaling the group would fling it toward the stage corner
+const sub3 = (p, o = {}) => subspace3(p, { space: { ...VIEW, size: 780 }, ...o }); // bigger than space3's 640: short arrows read
// The test on the left: the equation (or the line), u and w as columns with their checks, c u + d w and the verdict.
-const testBoard = (p, { set = 'plane', plane = [1, 1, 1, 0], line, u, w, c = 1, d = 1, show: sh = [], t0 = .1, o = 0, eq = true, range } = {}) => {
- const sb = sub3(p, { set, plane, line, u, w, c, d, show: sh, t0, range });
+const testBoard = (p, { set = 'plane', plane = [1, 1, 1, 0], line, u, w, c = 1, d = 1, show: sh = [], t0 = .1, o = 0, eq = true, range, view } = {}) => {
+ const sb = sub3(p, { set, plane, line, u, w, c, d, show: sh, t0, range, ...(view ? { space: { ...VIEW, size: 780, ...view } } : {}) });
return {
sb,
eq: eq ? sb.eq({ x: 90, y: 200, size: 44, o }) : null,
@@ -126,7 +126,7 @@ const BEATS = [
T(tt, 'pick u and w in the set', { x: 90, y: 372, size: 30, weight: 600 });
T(tt, 'every sum and every multiple stays in?', { x: 90, y: 420, size: 30, weight: 600 });
show(tt, m('test'), .6);
- sb.show(['u', 'w'], m('sp')); sb.show(['dw', 'sum'], m('sp') + 1.4);
+ sb.show('u', m('space') + 2.5); sb.show('w', m('test') + 2.5); sb.show(['dw', 'sum'], m('sp') + 1.4); // three numbers, an arrow; then the two the test picks
text(p, 'R³ is a subspace of itself', 90, 540, m('sp') + 4, { size: 30, fill: COL.good, weight: 700 });
}],
@@ -182,7 +182,7 @@ const BEATS = [
['q1', 'Quick check', () => {
const p = panel(0);
text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });
- const B = S.B = testBoard(p, { plane: [2, -1, 1, 0], u: [1, 2, 0], w: [0, 1, 1], o: 1, show: ['u', 'w'] }), sb = S.sb = B.sb;
+ const B = S.B = testBoard(p, { plane: [2, -1, 1, 0], u: [1, 2, 0], w: [0, 1, 1], o: 1, show: ['u', 'w'], view: { yaw: -30 } }), sb = S.sb = B.sb; // from yaw 30 this plane is seen edge on
[B.combo, B.out].forEach(e => put(e, { o: 0 }));
sb.V.sway(4, 18);
}, { ask: done => quiz(CARD, [{
@@ -242,7 +242,7 @@ const BEATS = [
['line', 'A line through the origin', (m) => {
const p = S.p = panel(0);
text(p, 'Test 4: a line through the origin', 60, 110, .2, { size: 40, weight: 600 });
- const B = S.B = testBoard(p, { set: 'line', line: { dir: [2, 1, -1], at: [0, 0, 0] }, u: [2, 1, -1], w: [-4, -2, 2], eq: false }), sb = S.sb = B.sb;
+ const B = S.B = testBoard(p, { set: 'line', line: { dir: [2, 1, -1], at: [0, 0, 0] }, u: [2, 1, -1], w: [-4, -2, 2], eq: false, view: { yaw: -15 } }), sb = S.sb = B.sb; // the line seen side on, not end on
sb.V.sway(5, 16);
const L = S.L = sb.lineRow({ x: 90, y: 215, size: 30, o: 0 });
put(L.at, { o: 0 }); put(L.g, { x: -98 });
@@ -259,11 +259,14 @@ const BEATS = [
['lineoff', 'A line that misses the origin', (m) => {
const p = S.p, B = S.B, sb = S.sb, L = S.L;
sb.V.sway(5, 16);
- [...p.querySelectorAll(':scope > text')].slice(-2).forEach(e => hide(e, .1, .3));
+ const tx = [...p.querySelectorAll(':scope > text')];
+ tx.slice(-2).forEach(e => hide(e, .1, .3));
+ hide(tx[0], m('shift') - .4, .3); text(p, 'Test 5: a line that misses the origin', 60, 110, m('shift') - .1, { size: 40, weight: 600 });
sb.to({ c: 1, d: 1 }, .1, .6); sb.show(['w', 'dw'], .2); show(B.cw, .2);
tw(L.g, { x: 0 }, m('shift'), .6); show(L.at, m('shift') + .4, .5);
sb.to({ p2: 2, u0: 2, u1: 1, u2: 1, w0: -2, w1: -1, w2: 3 }, m('shift'), 1.6); sb.flash('p2', m('shift') + 1);
pulseG(B.cu, m('u') + .3); pulseG(B.cw, m('w') + .3);
+ hide(B.out, m('shift') - .3, .3); show(B.out, m('test'), .4); // the verdict waits for the question
sb.flash('sum0', m('add') + .5); sb.flash('sum1', m('add') + .5); sb.flash('sum2', m('add') + .5);
const t1 = G(p, { o: 0 });
T(t1, 'first number 0 → t = 0 → the point would be (0, 0, 2)', { x: 90, y: 790, size: 26, weight: 600 });
@@ -277,7 +280,7 @@ const BEATS = [
['q3', 'Your turn', () => {
const p = panel(0);
text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });
- const sb = S.sb = sub3(p, { set: 'line', line: { dir: [2, 1, -1], at: [0, 0, 2] }, u: [2, 1, 1], w: [-2, -1, 3], show: ['u', 'w', 'dw', 'sum'] });
+ const sb = S.sb = sub3(p, { space: { ...VIEW, size: 780, yaw: -15 }, set: 'line', line: { dir: [2, 1, -1], at: [0, 0, 2] }, u: [2, 1, 1], w: [-2, -1, 3], show: ['u', 'w', 'dw', 'sum'] });
sb.lineRow({ x: 90, y: 250, size: 32 });
S.B = { sb, out: sb.readout({ x: 90, y: 400, size: 30 }) };
ring3(sb.V, [0, 0, 0], '(0, 0, 0)', COL.task);
@@ -292,12 +295,13 @@ const BEATS = [
text(p, 'The smallest and the biggest', 60, 110, .2, { size: 40, weight: 600 });
const sb = S.sb = sub3(p, { set: 'zero', u: [0, 0, 0], w: [0, 0, 0], show: ['sum'] });
sb.V.sway(5, 16);
- const c = sb.combo({ x: 90, y: 400, size: 32 }), out = sb.readout({ x: 90, y: 520, size: 30 });
+ const c = sb.combo({ x: 90, y: 400, size: 32, o: 0 }), out = sb.readout({ x: 90, y: 520, size: 30, o: 0 });
+ show(c, m('z') + 2.6, .5); show(out, m('z') + 2.6, .5); // with the first c and d, after the set is named
const t1 = text(p, 'the zero vector alone', 90, 210, m('z'), { size: 34, fill: SETC, weight: 600 });
- say(p, ['0 + 0 = 0, c · 0 = 0'], 90, 280, m('z') + 1.5, { size: 32 });
+ const zz = say(p, ['0 + 0 = 0, c · 0 = 0'], 90, 280, m('z') + 1.5, { size: 32 });
[[3, -2], [-1, 4]].forEach(([cc, d], i) => sb.to({ c: cc, d }, m('z') + 3 + i * 1.3, 1));
const n1 = text(p, 'a subspace', 90, 640, m('name'), { size: 30, fill: COL.good, weight: 700 });
- [t1, n1].forEach(e => hide(e, m('all') - .3, .3));
+ [t1, n1, zz].forEach(e => hide(e, m('all') - .3, .3));
sb.kind('all', m('all'));
sb.to({ u0: 2, u1: 1, u2: 0, w0: -1, w1: 1, w2: 2, c: 1, d: 1 }, m('all') + .1, 1.2);
sb.show(['u', 'w', 'dw'], m('all') + .4);
@@ -329,6 +333,8 @@ const BEATS = [
[[1, 1], [-1, 2], [1, -2], [1, 1]].forEach(([c, d], i) => sb.to({ c, d }, m('two') + 1 + i * 1.2, 1));
text(p, '+ w off that line → a plane through 0', 90, 572, m('two') + .5, { size: 28, weight: 600 });
sb.kind('all', m('three'));
+ const a3 = sb.V.arrow([0, 0, 0], [1, -1, 3], { color: S3_COLS[2] }); // off x − y + z = 0: it gives 5
+ put(a3.e, { o: 0 }); show(a3.e, m('three') + .2, .5);
text(p, '+ a third off the plane → all of space', 90, 624, m('three') + .3, { size: 28, weight: 600 });
text(p, 'point, line, plane, or everything', 90, 720, m('so'), { size: 32, fill: COL.good, weight: 700 });
}],
diff --git a/site/linear-algebra/ch40/audio/en/more.mp3 b/site/linear-algebra/ch40/audio/en/more.mp3
new file mode 100644
index 0000000..cbc94b7
Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/more.mp3 differ
diff --git a/site/linear-algebra/ch40/audio/en/plane.mp3 b/site/linear-algebra/ch40/audio/en/plane.mp3
index 9a8aaa2..eb1232c 100644
Binary files a/site/linear-algebra/ch40/audio/en/plane.mp3 and b/site/linear-algebra/ch40/audio/en/plane.mp3 differ
diff --git a/site/linear-algebra/ch40/audio/en/recap.mp3 b/site/linear-algebra/ch40/audio/en/recap.mp3
index 9b54075..65cdc2a 100644
Binary files a/site/linear-algebra/ch40/audio/en/recap.mp3 and b/site/linear-algebra/ch40/audio/en/recap.mp3 differ
diff --git a/site/linear-algebra/ch40/audio/en/sub.mp3 b/site/linear-algebra/ch40/audio/en/sub.mp3
index c30af3d..ff0ee8c 100644
Binary files a/site/linear-algebra/ch40/audio/en/sub.mp3 and b/site/linear-algebra/ch40/audio/en/sub.mp3 differ
diff --git a/site/linear-algebra/ch40/audio/en/timings.js b/site/linear-algebra/ch40/audio/en/timings.js
index 7a14733..9a49593 100644
--- a/site/linear-algebra/ch40/audio/en/timings.js
+++ b/site/linear-algebra/ch40/audio/en/timings.js
@@ -25,32 +25,36 @@ window.TIMINGS = {
]
},
"recap": {
- "dur": 20.496,
+ "dur": 21.936,
"marks": {
- "cols": 2.005,
- "sheet": 6.732,
- "reach": 12.904,
- "now": 16.797
+ "cols": 2.161,
+ "sheet": 7.383,
+ "reach": 11.302,
+ "now": 17.917
},
"cues": [
[
- 0.091,
+ 0.104,
"Remember chapter fourteen."
],
[
- 2.005,
- "We took columns and mixed them: x times column one plus y times column two."
+ 2.161,
+ "We took two columns and mixed them: x times column one plus y times column two."
],
[
- 6.732,
- "When column three fell into the flat sheet of the first two, every mix stayed in that sheet."
+ 7.383,
+ "Every mix landed in one flat sheet through the origin."
],
[
- 12.904,
+ 11.302,
"So A x equals b could be solved only when b was on the sheet."
],
[
- 16.797,
+ 15.326,
+ "Off the sheet, no mix reaches it."
+ ],
+ [
+ 17.917,
"That sheet is a subspace, and today it gets its name."
]
]
@@ -58,6 +62,7 @@ window.TIMINGS = {
"name": {
"dur": 36.864,
"marks": {
+ "A": 2.591,
"c1": 5.547,
"c2": 8.333,
"mix": 13.672,
@@ -114,14 +119,16 @@ window.TIMINGS = {
]
},
"sub": {
- "dur": 44.616,
+ "dur": 60.36,
"marks": {
- "two": 3.776,
- "add": 13.32,
- "mix": 15.312,
- "mult": 25.638,
- "zero": 34.948,
- "yes": 38.646
+ "two": 3.607,
+ "two2": 10.612,
+ "add": 16.51,
+ "mix": 20.482,
+ "mult": 34.18,
+ "mult2": 43.893,
+ "zero": 50.938,
+ "yes": 54.505
},
"cues": [
[
@@ -129,51 +136,68 @@ window.TIMINGS = {
"Is the column space a subspace?"
],
[
- 2.734,
+ 2.604,
"Let's test it."
],
[
- 3.776,
- "Take two vectors in it: four, five, five, which is one, one of the columns, and minus two, minus one, three, which is one, minus one."
+ 3.607,
+ "Take two vectors in it: four, five, five, which is one times column one plus one times column two, and two, one, minus three, which is minus one times column one plus one times column two."
],
[
- 13.32,
- "Their sum is two, four, eight."
+ 16.51,
+ "Add them, tip to tail: the sum is six, six, two."
],
[
- 15.312,
- "And that's two times column one plus zero times column two: the mixes add, one plus one, and one plus minus one."
+ 20.482,
+ "And the mixes add too: one plus minus one is zero, and one plus one is two."
],
[
- 24.167,
+ 26.953,
+ "Zero times column one plus two times column two is six, six, two."
+ ],
+ [
+ 32.669,
"A combination again."
],
[
- 25.638,
- "Multiply a combination by a number c, and you get c x times column one plus c y times column two: a combination again."
+ 34.18,
+ "Now multiply a combination by a number."
+ ],
+ [
+ 37.005,
+ "Minus one half times six, six, two is minus three, minus three, minus one."
],
[
- 34.948,
+ 43.893,
+ "Its mix gets multiplied by minus one half too: zero, and minus one."
+ ],
+ [
+ 49.479,
+ "A combination again."
+ ],
+ [
+ 50.938,
"And zero times both columns gives the zero vector."
],
[
- 38.646,
+ 54.505,
"So sums and multiples never leave."
],
[
- 41.667,
+ 57.422,
"The column space is always a subspace."
]
]
},
"plane": {
- "dur": 30.24,
+ "dur": 29.448,
"marks": {
- "two": 1.367,
- "fill": 6.628,
- "edge": 15.0,
- "back": 20.807,
- "not": 25.781
+ "two": 1.328,
+ "fill": 6.406,
+ "zero": 9.349,
+ "edge": 14.714,
+ "back": 20.299,
+ "not": 25.247
},
"cues": [
[
@@ -181,23 +205,27 @@ window.TIMINGS = {
"What shape is it?"
],
[
- 1.367,
+ 1.328,
"The two columns point in different directions: neither is a multiple of the other."
],
[
- 6.628,
- "So their combinations fill a whole flat plane, and it passes through the origin, since zero times both columns is zero."
+ 6.406,
+ "So their combinations fill a whole flat plane."
],
[
- 15.0,
+ 9.349,
+ "And it passes through the origin, since zero times both columns is zero."
+ ],
+ [
+ 14.714,
"Turn the picture to look along the plane: it shrinks to a line, and both columns lie in it."
],
[
- 20.807,
+ 20.299,
"For this A, C of A is a plane through the origin in R three."
],
[
- 25.781,
+ 25.247,
"It's not all of R three: most vectors in space are off this plane."
]
]
@@ -410,6 +438,99 @@ window.TIMINGS = {
]
]
},
+ "more": {
+ "dur": 66.96,
+ "marks": {
+ "b1": 3.398,
+ "x1": 6.263,
+ "y1": 12.474,
+ "t1": 20.846,
+ "mix1": 28.385,
+ "b2": 37.669,
+ "x2": 40.938,
+ "y2": 44.466,
+ "t2": 50.482,
+ "no2": 57.318
+ },
+ "cues": [
+ [
+ 0.104,
+ "Two more, step by step."
+ ],
+ [
+ 1.875,
+ "Watch both pictures."
+ ],
+ [
+ 3.398,
+ "b equals five, four, minus two."
+ ],
+ [
+ 6.263,
+ "Subtract the first equation from the second: x equals four minus five, which is minus one."
+ ],
+ [
+ 12.474,
+ "The first equation: minus one plus three y equals five."
+ ],
+ [
+ 17.669,
+ "So three y is six, and y is two."
+ ],
+ [
+ 20.846,
+ "Test the third: four times minus one, plus two, is minus two."
+ ],
+ [
+ 25.885,
+ "That's b three."
+ ],
+ [
+ 27.148,
+ "It matches!"
+ ],
+ [
+ 28.385,
+ "So b is minus one times column one plus two times column two."
+ ],
+ [
+ 33.385,
+ "And down below, the three lines meet at minus one, two."
+ ],
+ [
+ 37.669,
+ "Now b equals zero, three, three."
+ ],
+ [
+ 40.938,
+ "x equals three minus zero, which is three."
+ ],
+ [
+ 44.466,
+ "The first equation: three plus three y equals zero, so y is minus one."
+ ],
+ [
+ 50.482,
+ "Test the third: four times three, minus one, is eleven."
+ ],
+ [
+ 55.052,
+ "But b three is three."
+ ],
+ [
+ 57.318,
+ "Eleven is not three: no solution."
+ ],
+ [
+ 60.456,
+ "In space, b sits off the plane."
+ ],
+ [
+ 62.865,
+ "Below, the yellow line misses the point where the other two meet."
+ ]
+ ]
+ },
"q2": {
"dur": 5.976,
"marks": {},
diff --git a/site/linear-algebra/ch40/index.html b/site/linear-algebra/ch40/index.html
index 5e7de7e..d777792 100644
--- a/site/linear-algebra/ch40/index.html
+++ b/site/linear-algebra/ch40/index.html
@@ -10,20 +10,22 @@
<body>
<script src="../lib/engine.js"></script>
<script src="../lib/math.js"></script>
+<script src="../lib/mm.js"></script>
<script src="../lib/space3.js"></script>
<script src="../lib/play.js"></script>
<script src="audio/en/timings.js"></script>
<script>
'use strict';
-const CHAPTER = { number: 40, title: 'The Column Space', minutes: 11, language: 'en' };
+const CHAPTER = { number: 40, title: 'The Column Space', minutes: 12, language: 'en' };
/* ---------- the matrices of this chapter ---------- */
const LEC = [[1, 3], [2, 3], [4, 1]]; // the lecture's A: columns (1, 2, 4) and (3, 3, 1); C(A) is the plane −10x + 11y − 3z = 0
const CH14 = [[2, -1], [-1, 2], [0, -3]]; // chapter 14's columns 1 and 2: their sheet x + 2y + z = 0
const FLOOR = [[1, 0], [0, 1], [0, 0]], LINE = [[1, 2], [1, 2], [1, 2]];
const VIEW = { yaw: -24, pitch: 22 };
-const SPACE = { cx: 1190, cy: 430, size: 720, range: 8, ...VIEW };
-const ROWS2 = { cx: 600, cy: 680, u: 19, r: 6 };
+const SPACE = { cx: 1190, cy: 430, size: 720, range: 6, ...VIEW }; // every vector the lessons draw fits in ±6
+const ROWS2 = { cx: 420, cy: 650, u: 27, r: 6 }; // the row picture, under the equations
+const ROWS2S = { cx: 650, cy: 680, u: 22, r: 6 }; // beside a question card
const CARD = { x: 40, y: 560, w: 720, cls: 'side' };
const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };
const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };
@@ -42,6 +44,8 @@ const ring3 = (V, q, label, color = COL.task) => {
const c = d.e.firstChild; c.setAttribute('fill', 'none'); c.setAttribute('stroke', color); c.setAttribute('stroke-dasharray', '5 5'); c.setAttribute('stroke-width', 3.5);
return d;
};
+// a question where only b's numbers move: its key line names no tip drag
+const numbersOnly = task => (body, api) => ({ ...task(body, api), hint: [kbd('Tab'), ' pick the number ', kbd('↑'), kbd('↓'), ' or drag it sideways to change it; drag empty space to turn'] });
const hideB = cs => [cs.bArrow.e, cs.labels[2].e].forEach(e => put(e, { o: 0 }));
const showB = (cs, t0) => [cs.bArrow.e, cs.labels[2].e].forEach(e => show(e, t0, .4));
@@ -98,7 +102,7 @@ const BEATS = [
['recap', 'Chapter 14’s sheet', (m) => {
const p = S.p = panel(0);
text(p, 'Chapter 14: the flat sheet', 60, 110, .2, { size: 40, weight: 600 });
- const cs = S.cs = cspace(p, CH14, [1, 1, -3]), V = cs.V;
+ const cs = S.cs = cspace(p, CH14, [1, 1, -3], { space: { range: 4 } }), V = cs.V; // its mixes stay within ±4: a closer view
V.sway(5, 16);
const F = cs.form({ x: 90, y: 260, size: 32, o: 0 });
show(F.g, m('cols'), .5);
@@ -119,7 +123,13 @@ const BEATS = [
V.sway(5, 18);
cs.CA.fade(0, 0, 0); hideB(cs);
[...cs.cols, ...cs.labels.slice(0, 2)].forEach(c => put(c.e, { o: 0 }));
- const F = S.F = cs.form({ x: 90, y: 260, size: 32 });
+ // A itself: three rows, two columns, each column in its colour
+ const Am = G(p, { o: 0 });
+ T(Am, 'A =', { x: 90, y: 262, size: 32, font: MATH });
+ mmSmall(Am, LEC, 152, 252, { size: 30, fill: (i, j) => S3_COLS[j] });
+ show(Am, .3, .5);
+ text(p, '3 rows, 2 columns', 90, 350, m('A') + .2, { size: 24, fill: COL.dim });
+ const F = S.F = cs.form({ x: 320, y: 260, size: 32 });
Object.values(F.parts).forEach(g => put(g, { o: 0 }));
show(F.parts.c0, m('c1')); show(cs.cols[0].e, m('c1') + .3); show(cs.labels[0].e, m('c1') + .3);
show(F.parts.c1, m('c2')); show(cs.cols[1].e, m('c2') + .3); show(cs.labels[1].e, m('c2') + .3);
@@ -133,7 +143,7 @@ const BEATS = [
let k = 0;
for (let x = -2; x <= 2; x++) for (let y = -2; y <= 2; y++) {
const q = Ax(LEC, [x, y]);
- if ((x === 1 && Math.abs(y) === 1) || q.some(c => Math.abs(c) > 8)) continue;
+ if ((x === 1 && Math.abs(y) === 1) || q.some(c => Math.abs(c) > SPACE.range)) continue;
dotAt(V, q, COL.task, m('many') + .2 + (k++) * .12, 5);
}
cs.to({ x0: .5, x1: 1.5 }, m('many') + .6, 1.4); cs.to({ x0: -1.5, x1: .5 }, m('many') + 2.2, 1.4);
@@ -147,21 +157,32 @@ const BEATS = [
['sub', 'C(A) is a subspace', (m) => {
const p = S.p, cs = S.cs, V = cs.V;
+ V.sway(5, 18);
[...p.querySelectorAll(':scope > g')].slice(-1).forEach(e => hide(e, .1, .3));
const t = G(p, {});
- const L = (parts, y, t0, fill = COL.chalk, size = 30) => say(t, parts, 90, y, t0, { size, fill });
- L(['(4, 5, 5): x = 1, y = 1'], 450, m('two') + .5);
- cs.to({ x0: 1, x1: -1 }, m('two') + 3.4, 1.2); cs.flash('x1', m('two') + 3.6);
- L(['(−2, −1, 3): x = 1, y = −1'], 500, m('two') + 3.6);
- ring3(V, [4, 5, 5], '', COL.chalk); ring3(V, [-2, -1, 3], '', COL.chalk);
- L(['sum (2, 4, 8): x = 1 + 1, y = 1 + (−1)'], 560, m('add'));
- cs.to({ x0: 2, x1: 0 }, m('add') + .3, 1.4); cs.flash('x0', m('mix')); cs.flash('x1', m('mix'));
- cs.to({ x0: 1, x1: 1 }, m('mix') + 3.4, 1); cs.to({ x0: 1, x1: -1 }, m('mix') + 4.8, 1); cs.to({ x0: 2, x1: 0 }, m('mix') + 6.2, 1.2);
- L(['c·(x col 1 + y col 2) = (cx) col 1 + (cy) col 2'], 630, m('mult'), COL.chalk, 28);
- cs.to({ x0: -.5, x1: 0 }, m('mult') + 2, 1.2); cs.to({ x0: 1, x1: 0 }, m('mult') + 3.6, 1);
- L(['0·col 1 + 0·col 2 = (0, 0, 0)'], 690, m('zero'), COL.chalk, 28);
+ const L = (parts, y, t0, fill = COL.chalk, size = 28) => say(t, parts, 90, y, t0, { size, fill });
+ const O = [0, 0, 0], U = [4, 5, 5], W = [2, 1, -3], SUM = [6, 6, 2];
+ // the two vectors in chalk, so b is free to show each combination
+ const au = V.arrow(O, U, { color: COL.chalk, w: 4 }), aw = V.arrow(O, W, { color: COL.chalk, w: 4 }), aw2 = V.arrow(U, SUM, { color: COL.chalk, w: 4, dash: '9 7' });
+ [au, aw, aw2].forEach(a => put(a.e, { o: 0 }));
+ L(['(4, 5, 5) = 1·col 1 + 1·col 2'], 400, m('two') + .5);
+ show(au.e, m('two') + 1, .5);
+ cs.to({ x0: -1, x1: 1 }, m('two2') + .2, 1.2); cs.flash('x0', m('two2') + .4);
+ L(['(2, 1, −3) = −1·col 1 + 1·col 2'], 448, m('two2') + .3);
+ show(aw.e, m('two2') + 1.4, .5);
+ L(['sum: (4, 5, 5) + (2, 1, −3) = (6, 6, 2)'], 506, m('add'));
+ show(aw2.e, m('add') + .6, .6);
+ cs.to({ x0: 0, x1: 2 }, m('add') + 1.8, 1.4);
+ L(['mixes add: x = 1 + (−1) = 0, y = 1 + 1 = 2'], 554, m('mix') + .3);
+ cs.flash('x0', m('mix') + 1); cs.flash('x1', m('mix') + 3);
+ [au, aw, aw2].forEach(a => hide(a.e, m('mult'), .5));
+ L(['−½·(6, 6, 2) = (−3, −3, −1)'], 612, m('mult') + .5);
+ cs.to({ x0: 0, x1: -1 }, m('mult') + 3, 2);
+ L(['mix: −½·0 = 0, −½·2 = −1'], 660, m('mult2') + .3);
+ cs.flash('x0', m('mult2') + .8); cs.flash('x1', m('mult2') + 2.4);
+ L(['0·col 1 + 0·col 2 = (0, 0, 0)'], 718, m('zero'));
cs.to({ x0: 0, x1: 0 }, m('zero') + .3, 1.2);
- text(p, 'C(A) is always a subspace', 90, 770, m('yes') + 1, { size: 32, fill: COL.good, weight: 700 });
+ text(p, 'C(A) is always a subspace', 90, 790, m('yes') + 1, { size: 32, fill: COL.good, weight: 700 });
cs.to({ x0: 1, x1: 1 }, m('yes') + 1.5, 1.2);
}],
@@ -172,7 +193,9 @@ const BEATS = [
cs.form({ x: 90, y: 260, size: 32 });
text(p, 'col 2 is not a multiple of col 1:', 90, 430, m('two'), { size: 30, weight: 600 });
text(p, 'two directions → a plane through 0', 90, 480, m('fill'), { size: 30, weight: 600 });
- [[2, -1], [-1, 2], [1, 1]].forEach(([x, y], i) => cs.to({ x0: x, x1: y }, m('fill') + .8 + i * 1.3, 1.1));
+ [[2, -1], [-1, 2]].forEach(([x, y], i) => cs.to({ x0: x, x1: y }, m('fill') + .5 + i * 1.2, 1));
+ cs.to({ x0: 0, x1: 0 }, m('zero') + 1.6, 1.2); cs.flash('x0', m('zero') + 1.8); cs.flash('x1', m('zero') + 1.8);
+ cs.to({ x0: 1, x1: 1 }, m('zero') + 4, 1.1);
const n = S3_cross([1, 2, 4], [3, 3, 1]), ey = edgeYaw(n, 8, VIEW.yaw);
V.turn({ yaw: ey, pitch: 8 }, m('edge'), 2.4);
text(p, 'seen along it: a line', 90, 540, m('edge') + 2, { size: 28, fill: COL.dim, weight: 600 });
@@ -192,7 +215,7 @@ const BEATS = [
const F = cs.form({ x: 90, y: 260, size: 32 });
put(F.parts.b, { o: 0 }); hideB(cs); cs.legs.forEach(l => put(l.e, { o: 0 }));
}, { ask: done => quiz({ ...CARD, y: 420 }, [{
- id: 'c-ax', prompt: ['With ', $m('x = 1, y = −1'), ': compute ', $m('A x = 1·col 1 − 1·col 2'), '.'],
+ id: 'c-ax', prompt: ['With ', $m('x = 1, y = −1'), ', compute ', $m('A x = 1·col 1 − 1·col 2')],
build: blanks([{ parts: ['A x = (', { box: '-2' }, ', ', { box: '-1' }, ', ', { box: '3' }, ')'], why: '(1 − 3, 2 − 3, 4 − 1) = (−2, −1, 3): a vector in C(A).', hint: 'Top: 1·1 − 1·3. Middle: 1·2 − 1·3. Bottom: 1·4 − 1·1.',
fx: () => { const cs = S.cs; [cs.bArrow.e, cs.labels[2].e, ...cs.legs.map(l => l.e)].forEach((e, i) => fx(e, { o: 1 }, .1 + i * .2, .5)); } }]),
}], done) }],
@@ -225,12 +248,12 @@ const BEATS = [
const rd = cs.readout({ x: 90, y: 400, size: 32 });
put(cs.R2.P.g, { o: 0 }); show(cs.R2.P.g, m('rows') - .4, .5);
E.rows.forEach((r, i) => pulseG(r, m('rows') + 3 + i * 1.2));
- text(p, 'row picture: x, y', ROWS2.cx, ROWS2.cy + 152, m('rows') + .5, { size: 24, fill: COL.dim, anchor: 'middle' });
+ text(p, 'row picture: x, y', ROWS2.cx, ROWS2.cy + ROWS2.r * ROWS2.u + 38, m('rows') + .5, { size: 24, fill: COL.dim, anchor: 'middle' });
cs.to({ x0: 1, x1: 1 }, m('b1'), 1.4); cs.flash('b0', m('b1') + .2); cs.flash('b1', m('b1') + .2); cs.flash('b2', m('b1') + .2);
pulse(cs.R2.dot, m('meet') + 1);
cs.to({ b2: 6 }, m('off'), 1.4); cs.flash('b2', m('off'));
- text(p, 'off the plane: no common point', 90, 470, m('slide') + 1, { size: 28, fill: COL.bad, weight: 600 });
- cs.to({ b2: 5 }, m('on'), 1.4); cs.flash('b2', m('on'));
+ const offT = text(p, 'off the plane: no common point', 90, 448, m('slide') + 1, { size: 28, fill: COL.bad, weight: 600 });
+ cs.to({ b2: 5 }, m('on'), 1.4); cs.flash('b2', m('on')); hide(offT, m('on') + .2, .4);
}],
['decide', 'Solve two, test the third', (m) => {
@@ -241,34 +264,63 @@ const BEATS = [
const E = cs.eqs({ x: 110, y: 200, size: 28 });
const st = G(p, {});
say(st, ['(2) − (1): x = b₂ − b₁'], 90, 370, m('e12'), { size: 30 });
+ pulseG(E.rows[0], m('e12') + .5); pulseG(E.rows[1], m('e12') + .5);
say(st, ['(1): y = (b₁ − x) / 3'], 90, 418, m('ey'), { size: 30 });
+ pulseG(E.rows[0], m('ey') + .3);
say(st, ['test (3): 4x + y = b₃ ?'], 90, 466, m('t1') - .4, { size: 30 });
- const tb = G(p, {}), row = (cells, y, t0, ok) => {
- const g = G(tb, { o: 0 });
- cells.forEach((c, j) => M(g, [c], { x: [90, 290, 400, 510][j], y, size: 28, fill: j === 3 ? (ok ? COL.good : COL.bad) : j === 0 ? COL.task : COL.chalk, anchor: 'start' }));
- show(g, t0, .5); return g;
- };
- row(['(4, 5, 5)', 'x = 1', 'y = 1', '4 + 1 = 5 ✓'], 590, m('ex1') + .6, true);
+ // the table fills in as the voice works: b and x, then y, then the test
+ const tb = G(p, {}), row = (cells, y, times, ok) => cells.forEach((c, j) => {
+ const e = M(tb, [c], { x: [90, 290, 400, 530][j], y, size: 28, fill: j === 3 ? (ok ? COL.good : COL.bad) : j === 0 ? COL.task : COL.chalk, anchor: 'start', o: 0 });
+ show(e, times[j], .4);
+ });
+ row(['(4, 5, 5)', 'x = 1', 'y = 1', '4 + 1 = 5 ✓'], 590, [m('ex1') + .3, m('ex1') + 1.6, m('ex1') + 6, m('t1') + 1.5], true);
cs.to({ b0: -2, b1: -1, b2: 3 }, m('ex2'), 1.4);
- row(['(−2, −1, 3)', 'x = 1', 'y = −1', '4 − 1 = 3 ✓'], 640, m('ex2') + .8, true);
+ row(['(−2, −1, 3)', 'x = 1', 'y = −1', '4 − 1 = 3 ✓'], 640, [m('ex2') + .3, m('ex2') + 4.5, m('ex2') + 9.5, m('t2') + 1.5], true);
cs.to({ b0: 1, b1: 2, b2: 3 }, m('ex3'), 1.4);
- row(['(1, 2, 3)', 'x = 1', 'y = 0', '4 + 0 = 4 ≠ 3 ✗'], 690, m('ex3') + .8, false);
+ row(['(1, 2, 3)', 'x = 1', 'y = 0', '4 + 0 = 4 ≠ 3 ✗'], 690, [m('ex3') + .3, m('ex3') + 1.4, m('ex3') + 2.6, m('t3') + 1.8], false);
+ pulseG(E.rows[2], m('t1')); pulseG(E.rows[2], m('t2')); pulseG(E.rows[2], m('t3'));
const rd = cs.readout({ x: 90, y: 780, size: 30, o: 0 }); show(rd, m('no'), .4);
- // the 3D answer at each step: b on the plane, or a red ring off it
- pulseG(E.rows[2], m('t1'));
- pulseG(E.rows[2], m('t2')); pulseG(E.rows[2], m('t3'));
+ }],
+
+ ['more', 'Two more, step by step', (m) => {
+ const p = S.p = panel(0);
+ text(p, 'Two more, step by step', 60, 110, .2, { size: 40, weight: 600 });
+ const R2 = { cx: 430, cy: 694, u: 24, r: 6 };
+ const cs = S.cs = cspace(p, LEC, [4, 5, 5], { rows2: R2 }), V = cs.V;
+ V.sway(4, 18);
+ const E = cs.eqs({ x: 110, y: 200, size: 28 });
+ text(p, 'row picture: x, y', R2.cx, R2.cy + R2.r * R2.u + 34, .4, { size: 22, fill: COL.dim, anchor: 'middle' });
+ // each example: four lines of working, the next example replacing them
+ const work = (lines, t0, tEnd) => {
+ const g = G(p, {});
+ lines.forEach(([parts, t, fill = COL.chalk], i) => say(g, parts, 90, 345 + i * 44, t, { size: 28, fill }));
+ if (tEnd != null) hide(g, tEnd, .4);
+ };
+ cs.to({ b0: 5, b1: 4, b2: -2 }, m('b1'), 1.4); ['b0', 'b1', 'b2'].forEach(k => cs.flash(k, m('b1') + .2));
+ work([[['b = (5, 4, −2)'], m('b1'), COL.task], [['x = 4 − 5 = −1'], m('x1') + .8], [['−1 + 3y = 5, 3y = 6, y = 2'], m('y1') + 1],
+ [['test: 4·(−1) + 2 = −2 = b₃ ✓'], m('t1') + 1, COL.good]], 0, m('b2'));
+ pulseG(E.rows[0], m('x1')); pulseG(E.rows[1], m('x1')); pulseG(E.rows[0], m('y1')); pulseG(E.rows[2], m('t1'));
+ const r1 = text(p, 'b = −1·col 1 + 2·col 2: the lines meet at (−1, 2)', 90, 520, m('mix1'), { size: 26, fill: COL.task, weight: 600 });
+ pulse(cs.R2.dot, m('mix1') + 4);
+ hide(r1, m('b2'), .4);
+ cs.to({ b0: 0, b1: 3, b2: 3 }, m('b2'), 1.4); ['b0', 'b1', 'b2'].forEach(k => cs.flash(k, m('b2') + .2));
+ work([[['b = (0, 3, 3)'], m('b2'), COL.task], [['x = 3 − 0 = 3'], m('x2') + .6], [['3 + 3y = 0, y = −1'], m('y2') + 1],
+ [['test: 4·3 + (−1) = 11 ≠ 3 ✗'], m('t2') + 2, COL.bad]], 0, null);
+ pulseG(E.rows[0], m('x2')); pulseG(E.rows[1], m('x2')); pulseG(E.rows[0], m('y2')); pulseG(E.rows[2], m('t2'));
+ text(p, 'no solution: b is off the plane', 90, 520, m('no2') + .4, { size: 26, fill: COL.bad, weight: 600 });
+ pulseG(cs.R2.lines[2], m('no2') + 4);
}],
['q2', 'Your turn', () => {
const p = panel(0);
text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });
- const cs = S.cs = cspace(p, LEC, [1, 2, 3], { rows2: { ...ROWS2, cx: 660, cy: 690 } });
+ const cs = S.cs = cspace(p, LEC, [1, 2, 3], { rows2: ROWS2S });
cs.eqs({ x: 110, y: 210, size: 28 });
cs.readout({ x: 90, y: 380, size: 30 });
}, { ask: done => quiz({ ...CARD, y: 420, w: 470 }, [{
id: 'c-b3', prompt: ['Change only the bottom number of ', $m('b'), ' until ', $m('A x = b'), ' can be solved.'],
- build: csTask(S.cs, (v, cs) => cs.solve().x !== undefined, 'b = (1, 2, 4): x = 1, y = 0, and 4·1 + 0 = 4. b is in C(A), and the three lines meet at (1, 0).',
- v => `With b₃ = ${num(v.b2)} the third line misses the point where the first two meet. x = 1 and y = 0 from the first two: what is 4x + y?`, () => S.cs.set({ b2: 4 }), { only: ['b2'], drag: [] }),
+ build: numbersOnly(csTask(S.cs, (v, cs) => cs.solve().x !== undefined, 'b = (1, 2, 4): x = 1, y = 0, and 4·1 + 0 = 4. b is in C(A), and the three lines meet at (1, 0).',
+ v => `With b₃ = ${num(v.b2)} the third line misses the point where the first two meet. x = 1 and y = 0 from the first two: what is 4x + y?`, () => S.cs.set({ b2: 4 }), { only: ['b2'], drag: [] })),
}], done) }],
['shapes', 'Other matrices, other shapes', (m) => {
@@ -305,8 +357,8 @@ const BEATS = [
text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, [[1, 2], [2, 4], [3, 6]], [1, 2, 3]);
cs.V.sway(5, 16);
- cs.form({ x: 90, y: 260, size: 32 });
- put(cs.CAline.e, { o: 0 });
+ const F = cs.form({ x: 90, y: 260, size: 32 });
+ put(cs.CAline.e, { o: 0 }); hideB(cs); cs.legs.forEach(l => put(l.e, { o: 0 })); [F.parts.eq, F.parts.b].forEach(e => put(e, { o: 0 }));
}, { ask: done => quiz({ ...CARD, y: 420 }, [{
id: 'c-shape', prompt: ['What is the column space of this ', $m('A'), '?'],
build: choice(['the zero vector alone', 'a line through the origin', 'a plane through the origin', 'all of R³'], 1,
@@ -333,7 +385,7 @@ const BEATS = [
build: blanks(AXQ),
}], done, 'Chapter practice · set 1 of 4') }],
['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
- id: 'p-in', prompt: ['Same A. Is b in the column space? (x = b₂ − b₁, y = (b₁ − x)/3, then test 4x + y = b₃.)'],
+ id: 'p-in', prompt: ['Same A. Is b in C(A)? Solve two equations, test the third.'],
build: grid(INQ, YN, { multi: false, text: true }),
}], done, 'Chapter practice · set 2 of 4') }],
['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{
@@ -343,7 +395,7 @@ const BEATS = [
['final4', 'Chapter practice', () => {
const p = panel(0);
text(p, 'Move b', 60, 110, .2, { size: 40, weight: 600 });
- const cs = S.cs = cspace(p, LEC, [4, 5, 5], { rows2: { ...ROWS2, cx: 660, cy: 690 } });
+ const cs = S.cs = cspace(p, LEC, [4, 5, 5], { rows2: ROWS2S });
cs.form({ x: 90, y: 250, size: 30 });
cs.readout({ x: 90, y: 400, size: 30 });
}, { ask: done => quiz({ ...CARD, y: 440, w: 470 }, [{
@@ -355,16 +407,16 @@ const BEATS = [
},
}, {
id: 'p-off', prompt: ['Now change only the middle number of ', $m('b'), ' so that ', $m('A x = b'), ' has no solution.'],
- build: (body, api) => { S.cs.set({ b0: 4, b1: 5, b2: 5 }); return csTask(S.cs, (v, cs) => !!cs.solve().none, 'Any middle number but 5 lifts b off the plane: the three lines no longer meet.',
- 'b is still in C(A): the three lines still meet. Change the middle number.', () => S.cs.set({ b1: 6 }), { only: ['b1'], drag: [] })(body, api); },
+ build: (body, api) => { S.cs.set({ b0: 4, b1: 5, b2: 5 }); return numbersOnly(csTask(S.cs, (v, cs) => !!cs.solve().none, 'Any middle number but 5 lifts b off the plane: the three lines no longer meet.',
+ 'b is still in C(A): the three lines still meet. Change the middle number.', () => S.cs.set({ b1: 6 }), { only: ['b1'], drag: [] }))(body, api); },
}], done, 'Chapter practice · set 4 of 4') }],
['play', 'Playground', (m) => {
const p = panel(0);
text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });
- const cs = S.cs = cspace(p, LEC, [4, 5, 5], { rows2: { ...ROWS2, cx: 640, cy: 470, u: 15 } });
+ const cs = S.cs = cspace(p, LEC, [4, 5, 5], { rows2: { ...ROWS2, cx: 660, cy: 420, u: 14 } });
cs.form({ x: 90, y: 250, size: 30 });
cs.readout({ x: 90, y: 400, size: 30 });
- text(p, 'try: lift b off the plane · make col 2 = 2·col 1', 90, 520, m('go'), { size: 24, fill: COL.dim });
+ text(p, 'try: lift b off the plane · make col 2 = 2·col 1', 90, 568, m('go'), { size: 24, fill: COL.dim });
}, { ask: playAsk(() => S.cs, { pos: { x: 40, y: 610, w: 720, cls: 'side' }, tip: 'Your column space. Change any number, drag b or a column by its tip, turn the picture; the three lines are the row picture.' }) }],
['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],
].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));
diff --git a/site/linear-algebra/index.html b/site/linear-algebra/index.html
index 3191f51..71f486f 100644
--- a/site/linear-algebra/index.html
+++ b/site/linear-algebra/index.html
@@ -76,6 +76,7 @@ Contents.book({
['Elimination with Matrices', [['Elimination: Two Equations', 12], ['Pivots and Multipliers', 10], ['Elimination: Three Equations', 11], ['Back Substitution', 11], ['When Elimination Breaks Down', 11], ['Elimination Matrices', 11], ['Row Exchanges as Matrices', 10]]],
['Multiplication and Inverse Matrices', [['Matrix Times Matrix', 10], ['Four Ways to Multiply', 10], ['Rules for Matrix Arithmetic', 10], ['The Inverse: Undoing a Matrix', 12], ['Finding the Inverse: Gauss–Jordan', 11], ['Matrices with No Inverse', 11]]],
['Factorization into A = LU', [['Undoing Elimination', 11], ['A = LU', 11], ['Why L Is Clean and E Is Not', 11], ['A = LDU', 11], ['How Much Work Is Elimination?', 10], ['PA = LU', 11]]],
+ ['Transposes and Vector Spaces', [['The Transpose', 11], ['Symmetric Matrices', 11], ['What Is a Vector Space?', 13], ['Subspaces of the Plane', 11], ['Subspaces of Space', 11], ['The Column Space', 12]]],
],
hues: ['#f4a48c', '#86c9e8', '#f3c95c', '#e8a0c8', '#8fd6b0', '#bba8ee', '#f0b45a'], // one colour per unit, cycling
});
diff --git a/site/linear-algebra/lib/mm.js b/site/linear-algebra/lib/mm.js
index 4613721..647d783 100644
--- a/site/linear-algebra/lib/mm.js
+++ b/site/linear-algebra/lib/mm.js
@@ -545,7 +545,15 @@ function mmT(p, { A, at: [x0, y0] = [70, 300], size = 40, cw = 62, rh = 60, gap
const dd = G(M_.g, { o: diagOn ? 1 : 0 });
M_.g.insertBefore(dd, M_.g.firstChild);
const k = Math.min(M_.rows, M_.cols) - 1;
- path(dd, `M${M_.cx(0) - cw * .45} ${M_.ry(0) - size * .78}L${M_.cx(k) + cw * .45} ${M_.ry(k) + size * .3}`, { stroke: COL.chalk, 'stroke-width': 2.5, 'stroke-dasharray': '8 7', 'stroke-opacity': .7, fill: 'none' });
+ // corner to corner, broken round each number on it so the dashes never strike a digit through
+ const A0 = [M_.cx(0) - cw * .45, M_.ry(0) - size * .78], B0 = [M_.cx(k) + cw * .45, M_.ry(k) + size * .3];
+ const L0 = Math.hypot(B0[0] - A0[0], B0[1] - A0[1]), u = [(B0[0] - A0[0]) / L0, (B0[1] - A0[1]) / L0], r = size * .5;
+ const at = t => [A0[0] + u[0] * t, A0[1] + u[1] * t]; // the gaps sit where each number's middle falls on the line
+ const ts = [...Array(k + 1).keys()].map(i => (M_.cx(i) - A0[0]) * u[0] + (M_.ry(i) - size * .3 - A0[1]) * u[1]);
+ const ends = [A0, ...ts.flatMap(t => [at(t - r), at(t + r)]), B0];
+ let dPath = '';
+ for (let i = 0; i < ends.length; i += 2) dPath += `M${ends[i][0].toFixed(1)} ${ends[i][1].toFixed(1)}L${ends[i + 1][0].toFixed(1)} ${ends[i + 1][1].toFixed(1)}`;
+ path(dd, dPath, { stroke: COL.chalk, 'stroke-width': 2.5, 'stroke-dasharray': '8 7', 'stroke-opacity': .7, fill: 'none' });
return dd;
});
L = { a, t, dg, bottom: yS + 12, right: t.x + t.W, mid: a.x + a.W + gap / 2, midY: y0 + (Math.max(d.m, d.n) - 1) * rh / 2 - size * .3 };
@@ -641,6 +649,7 @@ function mmT(p, { A, at: [x0, y0] = [70, 300], size = 40, cw = 62, rh = 60, gap
const at_ = cands.find(c => !hits(c)) || cands[0];
placed.push(at_);
put(tp.lab, { x: at_[0], y: at_[1] });
+ tp.lab.style.opacity = Ln < 1 ? 0 : ''; // an arrow of length 0 has no name (zero columns would pile theirs on the origin)
tp.hit.setAttribute('cx', X2); tp.hit.setAttribute('cy', Y2);
});
}
diff --git a/site/linear-algebra/lib/space3.js b/site/linear-algebra/lib/space3.js
index 130c09e..c171a6d 100644
--- a/site/linear-algebra/lib/space3.js
+++ b/site/linear-algebra/lib/space3.js
@@ -113,7 +113,7 @@ function S3_pick(cands, boxes, segs = [], bounds = null) {
function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, pitch = 22, t0 = .1 } = {}) {
const g = G(p, { o: 0 }), svg = $('stage'), k = size / (3.4 * R), dist = S3_DIST * R;
- const cam = { yaw, pitch }, user = { yaw: 0, pitch: 0 }, drifts = [], items = [], sorted = [], hooks = [], avoids = [], planeItems = [];
+ const cam = { yaw, pitch }, user = { yaw: 0, pitch: 0 }, drifts = [], items = [], sorted = [], hooks = [], avoids = [], segAvoids = [], planeItems = [];
let plan = { yaw, pitch }, live = false, queued = false, sortKey = '', ca = 1, sa = 0, cb = 1, sb = 0;
const PITCH = [-15, 80]; // what the reader may reach; a beat may turn the camera up to 90 (straight down)
@@ -214,7 +214,7 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, p
// a dot just given a position is still hidden until its own redraw below: it counts as shown
const vis = pts.filter(it => it.pos && (it.hid || st(it.e).o >= .05) && seen(it.e.parentNode)), out = [];
const named = it => it.t.textContent.trim() && st(it.t).o >= .05;
- const segs = axes.filter(A => seen(A.g)).map(A => [A.at(-R), A.at(R + .7)]);
+ const segs = [...axes.filter(A => seen(A.g)).map(A => [A.at(-R), A.at(R + .7)]), ...segAvoids.flatMap(f => f(proj) || [])];
const boxes = [...lab.filter(l => l.o).map(l => [l.x - 13, l.y - 15, l.x + 13, l.y + 14]),
...avoidPts.map(([x, y]) => [x - 30, y - 12, x + 30, y + 10]),
...vis.map(it => { const q = proj(it.pos); return [q[0] - it.r - 2, q[1] - it.r - 2, q[0] + it.r + 2, q[1] + it.r + 2]; })];
@@ -399,6 +399,8 @@ function space3(p, { cx = 1150, cy = 450, size = 640, range: R = 4, yaw = -30, p
on(f) { hooks.push(f); dirty(); },
// f(proj) returns screen points of labels drawn over the view; axis numbers near them step aside (hide).
avoid(f) { avoids.push(f); dirty(); },
+ // f(proj) returns screen segments [[x0, y0], [x1, y1]] (arrows drawn over the view) that point labels keep off.
+ avoidSegs(f) { segAvoids.push(f); dirty(); },
// A pointer event in the view's own coordinates (the stage's, unless the panel moved).
local(e) { const q = svg.createSVGPoint(); q.x = e.clientX; q.y = e.clientY; const w = q.matrixTransform(g.getScreenCTM().inverse()); return [w.x, w.y]; },
// Turn the camera to { yaw, pitch } (degrees) over dur seconds on the beat clock, from where earlier turns left it.
@@ -833,7 +835,7 @@ const lin3Task = (sys, test, why, hint, reveal, keys = null) => (body, api) => {
// A value as math parts: a whole number, a fraction in lowest terms (denominators up to 12), else one decimal.
function S3_parts(n) {
if (Math.abs(n - Math.round(n)) < 1e-9) return [num(Math.round(n) || 0)];
- for (let q = 2; q <= 12; q++) { const k = Math.round(n * q); if (Math.abs(n * q - k) < 5e-6) return [k < 0 ? '−' : '', F(Math.abs(k), q)]; }
+ for (let q = 2; q <= 12; q++) { const k = Math.round(n * q); if (Math.abs(n * q - k) < 5e-6) return k % q ? [k < 0 ? '−' : '', F(Math.abs(k), q)] : [num(k / q || 0)]; } // a hair off a whole number reads whole, never 4/2
const r = Math.round(n * 10) / 10;
return [num(r) + (Number.isInteger(r) ? DECIMAL_SIGN + '0' : '')];
}
@@ -855,11 +857,18 @@ function S3_slot(g, key, x, y, ctx, { size = 40, fill = COL.chalk, w = size * 1.
set() {
let pp = pf ? pf(ctx.v) : S3_parts(abs ? Math.abs(ctx.v[key]) : ctx.v[key]);
if (coef && !s.held && pp.length === 1 && /^−?1$/.test(pp[0])) pp = [pp[0].slice(0, -1)];
- const k = JSON.stringify(pp);
+ const k = JSON.stringify(pp) + (s.pad ?? ''); // a row made tight redraws
if (k === shown) return;
shown = k; ink.replaceChildren();
const long = pp.some(q => typeof q === 'string' && q.includes(DECIMAL_SIGN));
- M(ink, pp, { x, y: long ? y - size * .06 : y, size: long ? size * .78 : size, fill: 'currentColor', anchor });
+ const draw_ = dx => M(ink, pp, { x: x - dx, y: long ? y - size * .06 : y, size: long ? size * .78 : size, fill: 'currentColor', anchor });
+ s.inkW = draw_(0)._w || 0;
+ if (s.pad != null) { // in a tight row (S3_tight): an end-anchored number gives back the room it does not fill (its box too)
+ s.own = Math.max(0, w - s.inkW - s.pad);
+ if (s.own) { ink.replaceChildren(); draw_(s.own); }
+ box?.setAttribute('x', bx - s.own);
+ }
+ s.after?.();
},
paint(on) {
if (!box) return;
@@ -903,6 +912,14 @@ function S3_slot(g, key, x, y, ctx, { size = 40, fill = COL.chalk, w = size * 1.
s.set();
return s;
}
+// One equation's parts left to right, each a group [{ g, s: an end-anchored slot in it, pad }]: a scalar's box keeps
+// room for a longer number; the number gives back what it does not fill and every part after it moves left, whenever
+// a number is redrawn, so "x + y + z = 0" reads "x + y + z = 0". pad: room kept before the number (after a sign).
+function S3_tight(pieces) {
+ const fit = () => { let sh = 0; pieces.forEach(pc => { if (st(pc.g).x !== -sh) put(pc.g, { x: -sh }); sh += pc.s?.own || 0; }); };
+ pieces.forEach(pc => { if (pc.s) { pc.s.pad = pc.pad || 0; pc.s.after = fit; pc.s.set(); } });
+ fit();
+}
// A column of three numbers in brackets, centred at x, its middle number on baseline y; keys [k0, k1, k2] (scrubbable)
// or pf: [v → parts, …] (computed). Returns { g, w }.
function S3_col(g, keys, x, y, ctx, { size = 38, fill = COL.chalk, w = size * 2, pf = null } = {}) {
@@ -1184,16 +1201,18 @@ function subspace3(p, { set = 'plane', plane: N0 = [1, 1, 1, 0], line: L0 = { di
eq({ x = 90, y = 200, size: sz = 44, o = 1 } = {}) {
const g = G(p, { o });
mk('rect', { x: x - 30, y: y - sz * .7, width: 8, height: sz * .8, rx: 4, fill: SET }, g);
- const sp = sz * 2.7;
+ const sp = sz * 2.7, pcs = [], pc = () => { const e = G(g, {}); pcs.push({ g: e }); return pcs[pcs.length - 1]; };
['x', 'y', 'z'].forEach((L, j) => {
const sx = x + j * sp, key = 'n' + j;
- if (j) S3_slot(g, null, sx - sz * .5, y, ctx, { size: sz, pf: s => [s[key] < -1e-9 ? '−' : '+'] });
- S3_slot(g, key, sx + sz * 1.0, y, ctx, { size: sz, anchor: 'end', w: sz * 1.25, coef: true, abs: j > 0 });
- const t = T(g, L, { x: sx + sz * 1.06, y, size: sz, fill: COL.chalk, font: MATH }); t.setAttribute('font-style', 'italic');
+ if (j) S3_slot(pc().g, null, sx - sz * .5, y, ctx, { size: sz, pf: s => [s[key] < -1e-9 ? '−' : '+'] });
+ const c = pc();
+ Object.assign(c, { s: S3_slot(c.g, key, sx + sz * 1.0, y, ctx, { size: sz, anchor: 'end', w: sz * 1.25, coef: true, abs: j > 0 }), w: sz * 1.25, pad: sz * (j ? .3 : .25) });
+ const t = T(pc().g, L, { x: sx + sz * 1.06, y, size: sz, fill: COL.chalk, font: MATH }); t.setAttribute('font-style', 'italic');
});
- const ex = x + 3 * sp - sz * .6;
- T(g, '=', { x: ex, y, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
- S3_slot(g, 'k', ex + sz * .75, y, ctx, { size: sz, anchor: 'start', w: sz * 1.4 });
+ const ex = x + 3 * sp - sz * .45, eg = pc().g;
+ T(eg, '=', { x: ex, y, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
+ S3_slot(eg, 'k', ex + sz * .7, y, ctx, { size: sz, anchor: 'start', w: sz * 1.4 });
+ S3_tight(pcs);
draw();
return g;
},
@@ -1211,23 +1230,25 @@ function subspace3(p, { set = 'plane', plane: N0 = [1, 1, 1, 0], line: L0 = { di
vec(n, { x = 90, y = 360, size: sz = 34, o = 1 } = {}) {
const g = G(p, { o }), w = sz * 2;
const t = T(g, n, { x, y: y + sz * .3, size: sz * 1.1, fill: COLR[n], font: MATH }); t.setAttribute('font-style', 'italic');
- T(g, '=', { x: x + sz * 1.15, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
- S3_col(g, [n + '0', n + '1', n + '2'], x + sz * 1.7 + w / 2, y, ctx, { size: sz, w, fill: COLR[n] });
+ T(g, '=', { x: x + sz * 1.3, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
+ S3_col(g, [n + '0', n + '1', n + '2'], x + sz * 1.9 + w / 2, y, ctx, { size: sz, w, fill: COLR[n] });
draw();
return g;
},
combo({ x = 90, y = 560, size: sz = 34, o = 1 } = {}) {
const g = G(p, { o }), w = sz * 2;
let cx = x;
- S3_slot(g, 'c', cx + sz * .9, y + sz * .3, ctx, { size: sz, anchor: 'end', w: sz * 1.2, coef: true });
- const t1 = T(g, 'u', { x: cx + sz * .95, y: y + sz * .3, size: sz * 1.1, fill: COLR.u, font: MATH }); t1.setAttribute('font-style', 'italic');
+ const g1 = G(g, {}), g2 = G(g, {}), g3 = G(g, {}), g4 = G(g, {}), g5 = G(g, {});
+ const sc = S3_slot(g1, 'c', cx + sz * .9, y + sz * .3, ctx, { size: sz, anchor: 'end', w: sz * 1.2, coef: true });
+ const t1 = T(g2, 'u', { x: cx + sz * .95, y: y + sz * .3, size: sz * 1.1, fill: COLR.u, font: MATH }); t1.setAttribute('font-style', 'italic');
cx += sz * 1.75;
- S3_slot(g, null, cx + sz * .3, y + sz * .3, ctx, { size: sz, pf: s => [s.d < -1e-9 ? '−' : '+'] });
- S3_slot(g, 'd', cx + sz * 1.75, y + sz * .3, ctx, { size: sz, anchor: 'end', w: sz * 1.2, coef: true, abs: true });
- const t2 = T(g, 'w', { x: cx + sz * 1.8, y: y + sz * .3, size: sz * 1.1, fill: COLR.w, font: MATH }); t2.setAttribute('font-style', 'italic');
+ S3_slot(g2, null, cx + sz * .3, y + sz * .3, ctx, { size: sz, pf: s => [s.d < -1e-9 ? '−' : '+'] });
+ const sd = S3_slot(g3, 'd', cx + sz * 1.75, y + sz * .3, ctx, { size: sz, anchor: 'end', w: sz * 1.2, coef: true, abs: true });
+ const t2 = T(g4, 'w', { x: cx + sz * 1.8, y: y + sz * .3, size: sz * 1.1, fill: COLR.w, font: MATH }); t2.setAttribute('font-style', 'italic');
cx += sz * 2.8;
- T(g, '=', { x: cx + sz * .3, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
- S3_col(g, null, cx + sz * .8 + w / 2, y, ctx, { size: sz, w, pf: I.map(j => s => S3_parts(calc(s).sum[j])) });
+ T(g5, '=', { x: cx + sz * .45, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
+ S3_col(g5, null, cx + sz * 1.0 + w / 2, y, ctx, { size: sz, w, pf: I.map(j => s => S3_parts(calc(s).sum[j])) });
+ S3_tight([{ g: g1, s: sc, w: sz * 1.2, pad: sz * .3 }, { g: g2 }, { g: g3, s: sd, w: sz * 1.2, pad: sz * .3 }, { g: g4 }, { g: g5 }]);
draw();
return g;
},
@@ -1356,6 +1377,15 @@ function colsp3(p, { A = [[1, 3], [2, 3], [4, 1]], b = [4, 5, 5], space: so = {}
return { k, g, rg };
});
V.on(proj => tips.forEach(({ k, g }) => { const q = proj(tipOf(k)); put(g, { x: Math.round(q[0] * 10) / 10, y: Math.round(q[1] * 10) / 10 }); }));
+ // the labels col 1, col 2, b keep off the arrows (and the mix's legs), not only off the axes
+ const vis_ = e => { for (let n = e; n && n !== V.g; n = n.parentNode) if (n._st && n._st.o < .05) return false; return true; };
+ V.avoidSegs(proj => {
+ const O = proj([0, 0, 0]), m1 = col(0).map(x => x * v.x0), out = [];
+ J.forEach(j => { if (vis_(cols[j].e)) out.push([O, proj(col(j))]); });
+ if (vis_(bArrow.e)) out.push([O, proj(bv())]);
+ if (vis_(legs[1].e) && inC(bv())) out.push([proj(m1), proj(bv())]);
+ return out;
+ });
/* ---------- the row picture: three lines in the x y plane ---------- */
let R2 = null;
@@ -1483,9 +1513,9 @@ function colsp3(p, { A = [[1, 3], [2, 3], [4, 1]], b = [4, 5, 5], space: so = {}
parts.x = G(g, {}); S3_slot(parts.x, 'x0', cx + sz * .95, y + sz * .3, ctx, { size: sz, anchor: 'end', w: sz * 1.2 });
parts.c0 = G(g, {}); S3_col(parts.c0, I.map(i => `a${i}0`), cx + sz * 1.2 + w / 2, y, ctx, { size: sz, w, fill: S3_COLS[0] });
cx += sz * 1.2 + w;
- parts.plus = G(g, {}); T(parts.plus, '+', { x: cx + sz * .45, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
- cx += sz * .9;
- parts.y = G(g, {}); S3_slot(parts.y, 'x1', cx + sz * .95, y + sz * .3, ctx, { size: sz, anchor: 'end', w: sz * 1.2 });
+ parts.plus = G(g, {}); S3_slot(parts.plus, null, cx + sz * .55, y + sz * .3, ctx, { size: sz, anchor: 'middle', pf: s => [s.x1 < -1e-9 ? '−' : '+'] });
+ cx += sz * .8;
+ parts.y = G(g, {}); S3_slot(parts.y, 'x1', cx + sz * .95, y + sz * .3, ctx, { size: sz, anchor: 'end', w: sz * 1.2, abs: true });
parts.c1 = G(g, {}); S3_col(parts.c1, I.map(i => `a${i}1`), cx + sz * 1.2 + w / 2, y, ctx, { size: sz, w, fill: S3_COLS[1] });
cx += sz * 1.2 + w;
parts.eq = G(g, {}); T(parts.eq, '=', { x: cx + sz * .5, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });
diff --git a/site/linear-algebra/lib/vecs.js b/site/linear-algebra/lib/vecs.js
index 0173671..c982632 100644
--- a/site/linear-algebra/lib/vecs.js
+++ b/site/linear-algebra/lib/vecs.js
@@ -12,9 +12,9 @@
// onto: (name, q, inBox) => [X, Y] where a dragged tip of a named vector lands (default inBox(q): the grid),
// fix: (v, changedKeys) => {} run after every change, to put the state back in order (a point kept on a line) })
// state vs.v = { v0, v1, w0, w1, c, d }; arrows vs.A[id] (id: each name, 'cv', 'dw', 'dw0', 'cv1', 'sum') with .g .path .lab
-// vs.row(items, { x, y, size, o }) the algebra, live (see row below); vs.to(next, t0, dur); vs.set(next); vs.onChange(f)
+// vs.row(items, { x, y, size, o, tight }) the algebra, live (see row below); vs.to(next, t0, dur); vs.set(next); vs.onChange(f)
// vs.show / hide / dim(ids, t0); vs.legs(ids, t0, on); vs.label(id, parts | v => parts, 'tip' | 'mid', [dx, dy]); vs.lattice(t0)
-// vs.solve(on); vs.solveFor(x, y) → { c, d }; vs.flash(key, t0); vs.num(key); vs.fmt(n), vs.parts(n), vs.paren(n), vs.nice(n)
+// vs.combo(state) → parts "2v − w" (label('sum', vs.combo)); vs.solve(on); vs.solveFor(x, y) → { c, d }; vs.flash(key, t0); vs.num(key); vs.fmt(n), vs.parts(n), vs.paren(n), vs.nice(n)
// vs.live(on, { drag: ids, move, only: keys }); questions: vsTask(vs, test, why, hint, reveal, opts), vcolBlanks(rows, { cols }), hcol(top, bottom, colour)
const VS_COL = [COL.irr, COL.real, COL.rat]; // first, second, third vector: green, violet, pink (the columns of A later)
@@ -37,7 +37,7 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna
// like 0.666667, still reads 2/3), else one decimal.
const parts = n => {
if (isInt(n)) return [num(Math.round(n) || 0)];
- for (let q = 2; q <= 12; q++) { const k = Math.round(n * q); if (Math.abs(n * q - k) < 5e-6) return [k < 0 ? '−' : '', F(Math.abs(k), q)]; }
+ for (let q = 2; q <= 12; q++) { const k = Math.round(n * q); if (Math.abs(n * q - k) < 5e-6) return k % q ? [k < 0 ? '−' : '', F(Math.abs(k), q)] : [num(k / q || 0)]; } // a hair off a whole number reads whole, never 4/2
const r = Math.round(n * 10) / 10; // a value in passing: always with its decimal sign (−0.97 is "−1.0", not a whole −1)
return [num(r) + (Number.isInteger(r) ? DECIMAL_SIGN + '0' : '')];
};
@@ -88,11 +88,18 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna
set() {
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);
+ const k = JSON.stringify(pp) + (s.pad ?? ''); // a row made tight redraws
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
- M(ink, pp, { x, y: long ? y - sz * .06 : y, size: long ? sz * .78 : sz, fill: 'currentColor', anchor });
+ const draw_ = dx => M(ink, pp, { x: x - dx, y: long ? y - sz * .06 : y, size: long ? sz * .78 : sz, fill: 'currentColor', anchor });
+ s.inkW = draw_(0)._w || 0;
+ if (s.pad != null) { // a tight row: an end-anchored number gives back the room it does not fill (its box too)
+ s.own = Math.max(0, w - s.inkW - s.pad);
+ if (s.own) { ink.replaceChildren(); draw_(s.own); }
+ box?.setAttribute('x', bx - s.own);
+ }
+ s.after?.();
},
};
if (box) {
@@ -138,8 +145,10 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna
// 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;
+ // tight: true closes the room a scalar's box keeps for longer numbers ("x − 2y = 0" reads "x − 2y = 0"); the parts
+ // after it move left as its number narrows or a 1 is hidden (an equation; columns of a system keep the default).
+ function row(items, { x = 90, y = 250, size: sz = size, o = 1, gap = sz * .28, tight = false } = {}) {
+ const g = G(p, {}), out = [], mid = y - sz * .32, rh = sz * 1.3, room = [];
let cx = x;
for (const it of items) {
const part = G(g, { o });
@@ -166,11 +175,18 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna
cx += sz * .45 + gap * .5;
}
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 });
+ const s = 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 });
+ if (tight) { s.pad = it.signed ? sz * .3 : 0; s.set(); room[out.length] = s; } // as much room after a sign as before it
cx += w + gap * .5 + (nx?.col || nx?.fn ? sz * .14 : 0); // clear of a bracket after it: "1[" must not touch
}
out.push(part);
}
+ if (tight) {
+ // each part moves left by the room its scalars closed before it (a scalar closes its own; a sign before it stays)
+ const fit = () => { let sh = 0; out.forEach((part, i) => { if (st(part).x !== -sh) put(part, { x: -sh }); sh += room[i]?.own || 0; }); };
+ room.forEach(s => { if (s) s.after = fit; });
+ fit();
+ }
return { g, parts: out, w: cx - x };
}
@@ -343,6 +359,17 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna
v, P: P2, stage: holder, A, names, calc, solveFor, parts, fmt, row, latticeG: latG, layer, colorOf, clip: clipDir, at: pt, // vs.lattice() shows it; vs.latticeG is the group
paren: n => n < 0 ? `(${fmt(n)})` : fmt(n), // a number inside a sum: 1 + (−4)
nice: n => !fmt(n).includes(DECIMAL_SIGN), // whole, or a simple fraction (not a value in passing)
+ // The combination's name as it is written: "2v − w", "½v", "−v + 3w", "0" (no 1s, no "+ −", no 0 terms);
+ // [] while c or d passes between nice values. vs.label('sum', vs.combo) names the sum live.
+ combo(st = v, a = n1, b = n2) {
+ const c = st.c, d = st.d, one = k => Math.abs(Math.abs(k) - 1) < 5e-6, z = k => Math.abs(k) < 5e-6; // as parts() reads a value a hair off
+ if (!vs.nice(c) || !vs.nice(d)) return [];
+ const term = (k, n) => one(k) ? [n] : [...parts(Math.abs(k)), n];
+ const out = [];
+ if (!z(c)) out.push(...(c < 0 ? ['−'] : []), ...term(c, a));
+ if (!z(d)) out.push(out.length ? (d < 0 ? ' − ' : ' + ') : (d < 0 ? '−' : ''), ...term(d, b));
+ return out.length ? out : ['0'];
+ },
// Move the numbers to new values over dur seconds, on the beat clock (deterministic, so seeking replays it).
to(next, at, dur = 1.2, ease = io) {
const from = { ...plan };
@@ -500,14 +527,7 @@ function subspace2(p, { set = 'line', line: L0 = [1, -2, 0], u = [2, 1], w = [-4
onto, fix, show: shown, plane: po, snap, labelSize, t0, hidePlane, size,
range: { a: [-6, 6], b: [-6, 6], k: [-12, 12], ...range } });
const P2 = vs.P, { PX, PY } = P2, svg = $('stage');
- const term = (k, n) => Math.abs(k - 1) < 1e-9 ? n : Math.abs(k + 1) < 1e-9 ? '−' + n : vs.fmt(k) + n;
- vs.label('sum', v => {
- if (!vs.nice(v.c) || !vs.nice(v.d)) return [];
- if (!v.c && !v.d) return ['0'];
- if (!v.d) return [term(v.c, 'u')];
- if (!v.c) return [term(v.d, 'w')];
- return [`${term(v.c, 'u')} ${v.d < 0 ? '−' : '+'} ${term(Math.abs(v.d), 'w')}`];
- });
+ vs.label('sum', vs.combo); // "u + w", "2u − w", "0"; nothing while c or d is between values
/* ---------- the set, under the arrows ---------- */
const sg = G(P2.g, {});
@@ -593,7 +613,7 @@ function subspace2(p, { set = 'line', line: L0 = [1, -2, 0], u = [2, 1], w = [-4
},
multiples(at, on = true, dur = .6) { tw(mult, { o: on ? 1 : 0 }, at, dur); },
eq({ x = 90, y = 200, size: sz = 46, o = 1 } = {}) {
- const r = vs.row([{ key: 'a' }, { t: 'x' }, { key: 'b', signed: true }, { t: 'y' }, '=', { key: 'k' }], { x, y, size: sz, o });
+ const r = vs.row([{ key: 'a' }, { t: 'x' }, { key: 'b', signed: true }, { t: 'y' }, '=', { key: 'k' }], { x, y, size: sz, o, tight: true });
mk('rect', { x: x - 30, y: y - sz * .7, width: 8, height: sz * .8, rx: 4, fill: SET }, r.g);
return r;
},