An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Column Space</title>
<link rel="stylesheet" href="../lib/engine.css">
<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->
</head>
<body>
<script src="../lib/engine.js"></script>
<script src="../lib/math.js"></script>
<script src="../lib/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: 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: 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; };
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 cspace = (p, A, b, o = {}) => colsp3(p, { A, b, space: { ...SPACE, ...(o.space || {}) }, rows2: o.rows2 ?? null, t0: o.t0 ?? .1 });
// The yaw that looks along a plane through the origin with normal n, at this pitch: the plane shows as a line.
const edgeYaw = (n, pitch, near) => {
const b = pitch * Math.PI / 180, f = a => { const r = a * Math.PI / 180; return n[0] * Math.sin(r) * Math.cos(b) + n[1] * Math.cos(r) * Math.cos(b) - n[2] * Math.sin(b); };
let best = near, low = Infinity;
for (let a = near - 90; a <= near + 90; a += .25) { const v = Math.abs(f(a)); if (v < low) { low = v; best = a; } }
return best;
};
const dotAt = (V, q, color, t0, r = 7) => { const d = V.point(q, { color, r }); put(d.e, { o: 0 }); show(d.e, t0, .3); return d; };
const ring3 = (V, q, label, color = COL.task) => {
const d = V.point(q, { color, r: 16, label, size: 26, halo: true });
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));
/* ---------- practice data ---------- */
const YN = [['y', 'Yes', null, 'Y'], ['n', 'No', null, 'N']];
const Ax = (A, x) => A.map(r => r[0] * x[0] + r[1] * x[1]);
const br = q => `(${q.map(num).join(', ')})`;
const AXQ = [[2, 0], [0, 1], [1, 1], [2, -1], [-1, 1]].map(x => {
const q = Ax(LEC, x);
return { parts: [`x = ${num(x[0])}, y = ${num(x[1])}: A x = (`, { box: String(q[0]) }, ', ', { box: String(q[1]) }, ', ', { box: String(q[2]) }, ')'],
why: `${num(x[0])}·(1, 2, 4) + ${x[1] < 0 ? `(${num(x[1])})` : num(x[1])}·(3, 3, 1) = ${br(q)}.`, hint: 'x times column one plus y times column two, one number at a time.' };
});
// b in C(A) for the lecture's A: x = b2 − b1, y = (b1 − x) / 3, then test 4x + y = b3
const inLec = b => { const x = b[1] - b[0], y = (b[0] - x) / 3; return Math.abs(4 * x + y - b[2]) < 1e-9; };
const INQ = [[4, 5, 5], [1, 2, 3], [3, 3, 1], [0, 0, 0], [5, 7, 9], [1, 1, 1], [-1, 1, 7], [2, 4, 6]].map(b => {
const x = b[1] - b[0], y = (b[0] - x) / 3, ok = inLec(b), yS = Number.isInteger(y) ? num(y) : `${num(b[0] - x)}/3`;
return { parts: ['b = ', $m(br(b))], ans: [ok ? 'y' : 'n'],
why: `x = ${num(b[1])} − ${b[0] < 0 ? `(${num(b[0])})` : num(b[0])} = ${num(x)}, y = ${yS}; then 4x + y = ${Number.isInteger(y) ? num(4 * x + y) : `${num(4 * x)} + ${yS}`}${ok ? `, which is b₃: in C(A).` : `, not ${num(b[2])}: not in C(A).`}` };
});
console.assert(INQ.map(q => q.ans[0]).join('') === 'ynyyynyn', 'INQ answers');
const MIXQ = [[[5, 7, 9], 2, 1], [[-2, -1, 3], 1, -1], [[2, 1, -3], -1, 1], [[6, 6, 2], 0, 2]].map(([b, x, y]) => {
console.assert(Ax(LEC, [x, y]).join() === b.join(), 'MIXQ', b);
return { parts: [`b = ${br(b)}: x = `, { box: String(x) }, ', y = ', { box: String(y) }], why: `${num(x)}·(1, 2, 4) + ${y < 0 ? `(${num(y)})` : num(y)}·(3, 3, 1) = ${br(b)}.`,
hint: 'Subtract the first equation from the second: x = b₂ − b₁. Then x + 3y = b₁ gives y.' };
});
MIXQ.push({ parts: ['floor columns (1, 0, 0), (0, 1, 0), b = (3, −2, 0): x = ', { box: '3' }, ', y = ', { box: '-2' }], why: '3·(1, 0, 0) − 2·(0, 1, 0) = (3, −2, 0).', hint: 'The top of b is x, the middle is y.' });
const REACHQ = [
{ parts: ['floor columns (1, 0, 0), (0, 1, 0): b = ', $m('(2, −3, 0)')], ans: ['y'], why: 'Bottom 0: it is on the floor, 2·col 1 − 3·col 2.' },
{ parts: ['floor columns: b = ', $m('(1, 1, 1)')], ans: ['n'], why: 'Every combination has bottom 0; this b has bottom 1.' },
{ parts: ['columns (1, 1, 1), (2, 2, 2): b = ', $m('(3, 3, 3)')], ans: ['y'], why: '3·(1, 1, 1): on the line.' },
{ parts: ['columns (1, 1, 1), (2, 2, 2): b = ', $m('(1, 2, 3)')], ans: ['n'], why: 'Every combination has three equal numbers.' },
{ parts: ['columns (1, 1, 1), (2, 2, 2): b = ', $m('(0, 0, 0)')], ans: ['y'], why: 'The zero vector is in every column space.' },
];
/* ---------- beats ---------- */
const BEATS = [
['intro', 'The column space', (m, D) => {
const g = G(scene, { o: 0, y: 24 });
T(g, 'Unit 5, Chapter 40', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });
T(g, 'The Column Space', { x: 800, y: 360, size: 88, weight: 600, anchor: 'middle' });
tw(g, { o: 1, y: 0 }, .2, 1.1, out);
const r = text(scene, 'every combination of the columns: where A x can land', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });
const lg = G(scene, { x: 800, y: 680, o: 0 });
path(lg, 'M-260 40L-60 -70L260 -40L60 70Z', { fill: COL.task, 'fill-opacity': .14, stroke: COL.task, 'stroke-width': 2, 'stroke-opacity': .6 });
const arr = (x0, y0, x1, y1, color, w = 5) => {
const L = Math.hypot(x1 - x0, y1 - y0), ux = (x1 - x0) / L, uy = (y1 - y0) / L;
return path(lg, `M${x0} ${y0}L${x1 - ux * 12} ${y1 - uy * 12}M${x1 - 20 * ux - 10 * uy} ${y1 - 20 * uy + 10 * ux}L${x1} ${y1}L${x1 - 20 * ux + 10 * uy} ${y1 - 20 * uy - 10 * ux}Z`, { stroke: color, fill: color, 'stroke-width': w, 'stroke-linejoin': 'round' }, { d: 0 });
};
const a1 = arr(0, 0, 120, -50, S3_COLS[0]), a2 = arr(0, 0, -40, 50, S3_COLS[1]), a3 = arr(0, 0, 80, 10, COL.task, 7);
show(lg, m('sub') + .8, .5); draw(a1, m('sub') + 1, .5); draw(a2, m('sub') + 1.4, .5); draw(a3, m('move') + .4, .7);
tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);
}],
['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], { 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);
cs.CA.fade(0, 0, 0); hideB(cs); cs.legs.forEach(l => put(l.e, { o: 0 }));
cs.CA.fade(1, m('sheet'), .8);
text(p, 'every mix stays in the sheet', 90, 430, m('sheet') + .6, { size: 30, weight: 600 });
showB(cs, m('reach')); cs.legs.forEach(l => show(l.e, m('reach'), .4));
cs.to({ x0: 2, x1: 1 }, m('reach') + 1, 1.2); cs.to({ x0: -1, x1: 1 }, m('reach') + 2.4, 1.2);
cs.to({ b2: 2 }, m('reach') + 3.8, 1.2);
const rd = cs.readout({ x: 90, y: 520, size: 32, o: 0 }); show(rd, m('reach') + .4, .4);
text(p, 'today: its name', 90, 620, m('now') + 1, { size: 32, weight: 700 });
}],
['name', 'All combinations of the columns', (m) => {
const p = S.p = panel(0);
text(p, 'The lecture’s A: two columns in R³', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, LEC, [0, 0, 0]), V = cs.V;
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 }));
// 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);
['x', 'plus', 'y', 'eq', 'b'].forEach(k => show(F.parts[k], m('mix'), .5));
showB(cs, m('m11'));
cs.to({ x0: 1, x1: 1 }, m('m11'), 1.2); cs.flash('x0', m('m11')); cs.flash('x1', m('m11'));
const d1 = dotAt(V, [4, 5, 5], COL.task, m('m11') + 1.3);
cs.to({ x0: 1, x1: -1 }, m('m1n'), 1.2); cs.flash('x1', m('m1n'));
const d2 = dotAt(V, [-2, -1, 3], COL.task, m('m1n') + 1.3);
// many mixes: the whole-number ones as dots, then fractions, then the plane fills in
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) > 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);
cs.CA.fade(1, m('many') + 3.4, 1);
const nm = G(p, { o: 0 });
T(nm, 'the column space of A:', { x: 90, y: 470, size: 32, weight: 600 });
T(nm, 'C(A) = every x·col 1 + y·col 2', { x: 90, y: 530, size: 34, fill: COL.task, weight: 600 });
show(nm, m('name') + 1, .6);
cs.to({ x0: 1, x1: 1 }, m('name') + 2, 1.2);
}],
['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 = 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, 790, m('yes') + 1, { size: 32, fill: COL.good, weight: 700 });
cs.to({ x0: 1, x1: 1 }, m('yes') + 1.5, 1.2);
}],
['plane', 'A plane through the origin', (m) => {
const p = S.p = panel(0);
text(p, 'What shape is C(A)?', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, LEC, [4, 5, 5]), V = cs.V;
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]].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 });
V.turn({ ...VIEW }, m('back'), 2.2);
text(p, 'C(A): a plane in R³', 90, 610, m('back') + .6, { size: 32, fill: COL.task, weight: 700 });
// most of space is off it: b leaves the plane
cs.to({ b2: 1 }, m('not') + .5, 1.4);
text(p, 'most vectors of R³ are off it', 90, 670, m('not') + .5, { size: 28, weight: 600 });
const rd = cs.readout({ x: 90, y: 740, size: 30, o: 0 }); show(rd, m('not') + 1.6, .4);
}],
['q1', 'Quick check', () => {
const p = panel(0);
text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, LEC, [-2, -1, 3]);
cs.V.sway(4, 18);
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')],
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) }],
['ax', 'A x = b', (m) => {
const p = S.p = panel(0);
text(p, 'Solving A x = b', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, LEC, [4, 5, 5]), V = cs.V;
V.sway(5, 16);
const E = cs.eqs({ x: 110, y: 210, size: 30, o: 0 });
show(E.g, m('eqs'), .5); E.rows.forEach((r, i) => pulseG(r, m('eqs') + 2 + i * 2.6));
const F = cs.form({ x: 90, y: 440, size: 30, o: 0 });
show(F.g, m('cols'), .5);
text(p, 'A x is always in C(A)', 90, 590, m('always'), { size: 30, weight: 600 });
[[2, -1], [-1, 1], [.5, .5], [1, 1]].forEach(([x, y], i) => cs.to({ x0: x, x1: y }, m('always') + .5 + i * 1.1, .9));
text(p, 'so A x = b needs b in C(A)', 90, 640, m('so'), { size: 30, weight: 600 });
const rd = cs.readout({ x: 90, y: 700, size: 30, o: 0 }); show(rd, m('and'), .4);
pulseG(rd, m('and') + 2);
const rl = G(p, { o: 0 });
T(rl, 'A x = b is solvable exactly when b is in C(A)', { x: 90, y: 790, size: 32, fill: COL.chalk, weight: 700 });
show(rl, m('rule'), .6);
}],
['rows', 'Both pictures', (m) => {
const p = S.p = panel(0);
text(p, 'Two pictures, one answer', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, LEC, [0, 0, 0], { rows2: ROWS2 }), V = cs.V;
V.sway(4, 18);
const E = cs.eqs({ x: 110, y: 210, size: 30 });
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 + 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'));
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) => {
const p = S.p = panel(0);
text(p, 'Solve two equations, test the third', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, LEC, [4, 5, 5]), V = cs.V;
V.sway(4, 18);
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 });
// 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') + .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') + .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);
}],
['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: 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: 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) => {
const p = S.p = panel(0);
text(p, 'Other matrices, other column spaces', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, LEC, [4, 5, 5]), V = cs.V;
V.sway(5, 16);
cs.form({ x: 90, y: 260, size: 32 });
cs.to({ a00: 1, a10: 0, a20: 0, a01: 0, a11: 1, a21: 0, x0: 3, x1: 2 }, m('floor'), 2);
const fl = text(p, 'C(A) = the floor: solvable when b₃ = 0', 90, 440, m('floor') + 2.2, { size: 28, fill: COL.task, weight: 600 });
tw(fl, { o: .35 }, m('line'), .4);
[[-2, 3], [2, -2]].forEach(([x, y], i) => cs.to({ x0: x, x1: y }, m('floor') + 5 + i * 1.4, 1.1));
cs.to({ a00: 1, a10: 1, a20: 1, a01: 2, a11: 2, a21: 2, x0: 1, x1: 1 }, m('line'), 2);
text(p, 'col 2 = 2·col 1: C(A) = a line', 90, 500, m('line') + 2.2, { size: 28, fill: COL.task, weight: 600 });
[[-2, 0], [1, 1]].forEach(([x, y], i) => cs.to({ x0: x, x1: y }, m('line') + 5.5 + i * 1.4, 1.1));
const al = G(p, { o: 0 });
T(al, 'three columns that point three ways', { x: 90, y: 580, size: 28, weight: 600 });
T(al, '(chapter 14): C(A) = R³, every b', { x: 90, y: 622, size: 28, fill: COL.task, weight: 600 });
show(al, m('all') + .5, .5);
}],
['q3', 'Quick check', () => {
const p = panel(0);
text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });
const cs = S.cs = cspace(p, FLOOR, [2, -3, 0]);
cs.V.sway(4, 18);
}, { ask: done => quiz({ x: 40, y: 190, w: 740, cls: 'side' }, [{
id: 'c-reach', prompt: ['Is ', $m('b'), ' in the column space? (The picture shows the floor columns.)'],
build: grid(REACHQ, YN, { multi: false, text: true }),
}], done) }],
['q4', 'Quick check', () => {
const p = panel(0);
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);
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,
'Column 2 = 2·column 1, so every combination is a multiple of (1, 2, 3): a line.',
['The columns are not zero, so their multiples go further than 0.', '', 'A plane needs two columns in different directions; here column 2 is 2·column 1.',
'Two columns can never fill all of space; and these two lie on one line.'], () => fx(S.cs.CAline.e, { o: 1 }, .1, .6)),
}], done) }],
['wrap', 'Summary', (m) => {
const p = panel(0);
[['The column space C(A): every combination of the columns of A.', 'w1'],
['It is always a subspace: sums and multiples of combinations are combinations.', 'w2'],
['A x = b is solvable exactly when b is in C(A).', 'w3'],
['C(A) can be a point, a line, a plane or all of space; for the lecture’s A, a plane.', 'w4']].forEach(([str, mark], i) => {
const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });
mk('circle', { cx: 150, cy: -12, r: 26, fill: COL.chalk }, g);
T(g, String(i + 1), { x: 150, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });
T(g, str, { x: 210, size: 33, weight: 600 });
tw(g, { o: 1, x: 0 }, m(mark), .6);
});
}],
['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{
id: 'p-ax', prompt: ['A has columns (1, 2, 4) and (3, 3, 1). Compute A x: each answer is a vector in C(A).'],
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 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, [{
id: 'p-mix', prompt: ['Find the mix x, y with x·col 1 + y·col 2 = b.'],
build: blanks(MIXQ),
}], done, 'Chapter practice · set 3 of 4') }],
['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: 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 }, [{
id: 'p-to', prompt: ['Move b onto the amber ring ', $m('(2, 1, −3)'), '. Then read the mix.'],
build: (body, api) => {
ring3(S.cs.V, [2, 1, -3], '(2, 1, −3)');
return csTask(S.cs, v => v.b0 === 2 && v.b1 === 1 && v.b2 === -3, 'b = (2, 1, −3) = −1·col 1 + 1·col 2: the mix is x = −1, y = 1.',
v => `b is at (${num(v.b0)}, ${num(v.b1)}, ${num(v.b2)}). Drag its tip one axis at a time, or change b's numbers.`, () => S.cs.set({ b0: 2, b1: 1, b2: -3 }), { only: ['b0', 'b1', 'b2'], drag: ['b'] })(body, api);
},
}, {
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 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: 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, 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 }));
boot();
</script>
</body>
</html>