An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
feat(linear-algebra): chapters 38-40 finish Unit 5; live subspace tests
yzrc4cd91dc9cc9
diff --git a/site/linear-algebra/ch38/audio/en/ex2.mp3 b/site/linear-algebra/ch38/audio/en/ex2.mp3new file mode 100644index 0000000..716d649Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/ex2.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/final1.mp3 b/site/linear-algebra/ch38/audio/en/final1.mp3new file mode 100644index 0000000..dce22d0Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/final1.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/final2.mp3 b/site/linear-algebra/ch38/audio/en/final2.mp3new file mode 100644index 0000000..8f9ca36Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/final2.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/final3.mp3 b/site/linear-algebra/ch38/audio/en/final3.mp3new file mode 100644index 0000000..6a77355Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/final3.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/final4.mp3 b/site/linear-algebra/ch38/audio/en/final4.mp3new file mode 100644index 0000000..5d6220aBinary files /dev/null and b/site/linear-algebra/ch38/audio/en/final4.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/finish.mp3 b/site/linear-algebra/ch38/audio/en/finish.mp3new file mode 100644index 0000000..a22f641Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/finish.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/intro.mp3 b/site/linear-algebra/ch38/audio/en/intro.mp3new file mode 100644index 0000000..ebcd8ecBinary files /dev/null and b/site/linear-algebra/ch38/audio/en/intro.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/line0.mp3 b/site/linear-algebra/ch38/audio/en/line0.mp3new file mode 100644index 0000000..4e2243aBinary files /dev/null and b/site/linear-algebra/ch38/audio/en/line0.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/list.mp3 b/site/linear-algebra/ch38/audio/en/list.mp3new file mode 100644index 0000000..90a1136Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/list.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/off.mp3 b/site/linear-algebra/ch38/audio/en/off.mp3new file mode 100644index 0000000..aa5884dBinary files /dev/null and b/site/linear-algebra/ch38/audio/en/off.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/play.mp3 b/site/linear-algebra/ch38/audio/en/play.mp3new file mode 100644index 0000000..8bf36b5Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/q1.mp3 b/site/linear-algebra/ch38/audio/en/q1.mp3new file mode 100644index 0000000..23a8f67Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/q1.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/q2.mp3 b/site/linear-algebra/ch38/audio/en/q2.mp3new file mode 100644index 0000000..7b3fa18Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/q2.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/q3.mp3 b/site/linear-algebra/ch38/audio/en/q3.mp3new file mode 100644index 0000000..07bb884Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/q3.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/q4.mp3 b/site/linear-algebra/ch38/audio/en/q4.mp3new file mode 100644index 0000000..742b9d8Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/q4.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/quad.mp3 b/site/linear-algebra/ch38/audio/en/quad.mp3new file mode 100644index 0000000..88f5d1bBinary files /dev/null and b/site/linear-algebra/ch38/audio/en/quad.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/recap.mp3 b/site/linear-algebra/ch38/audio/en/recap.mp3new file mode 100644index 0000000..21a4177Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/recap.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/slide.mp3 b/site/linear-algebra/ch38/audio/en/slide.mp3new file mode 100644index 0000000..feeb238Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/slide.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/small.mp3 b/site/linear-algebra/ch38/audio/en/small.mp3new file mode 100644index 0000000..989e05eBinary files /dev/null and b/site/linear-algebra/ch38/audio/en/small.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/timings.js b/site/linear-algebra/ch38/audio/en/timings.jsnew file mode 100644index 0000000..c332bb0--- /dev/null+++ b/site/linear-algebra/ch38/audio/en/timings.js@@ -0,0 +1,789 @@+window.TIMINGS = {+ "intro": {+ "dur": 12.144,+ "marks": {+ "sub": 3.281,+ "move": 8.164+ },+ "cues": [+ [+ 0.104,+ "Chapter thirty-eight."+ ],+ [+ 1.68,+ "Subspaces of the plane."+ ],+ [+ 3.281,+ "Some sets of arrows inside the plane are vector spaces of their own."+ ],+ [+ 8.164,+ "Add any two of them, stretch any one, and you never get out."+ ]+ ]+ },+ "recap": {+ "dur": 55.416,+ "marks": {+ "add": 3.763,+ "scale": 9.245,+ "r2": 15.312,+ "q": 24.701,+ "name": 29.844,+ "test": 40.794,+ "fail": 50.26+ },+ "cues": [+ [+ 0.117,+ "The last chapter gave the two rules of a vector space."+ ],+ [+ 3.763,+ "Rule one: add any two of its vectors, and the sum is still inside."+ ],+ [+ 9.245,+ "Rule two: multiply any one of them by any number, and the result is still inside."+ ],+ [+ 15.312,+ "The whole plane, R two, obeys both."+ ],+ [+ 17.904,+ "Add two arrows of the plane, and you get an arrow of the plane."+ ],+ [+ 21.654,+ "Stretch one, and it's still an arrow of the plane."+ ],+ [+ 24.701,+ "Today's question is about smaller sets: a part of the plane, like one line."+ ],+ [+ 29.844,+ "If a set inside R two obeys both rules all by itself, we call it a subspace."+ ],+ [+ 36.315,+ "A subspace is a vector space living inside a bigger one."+ ],+ [+ 40.794,+ "To test a set, pick two vectors in it, u and w."+ ],+ [+ 45.286,+ "Their sum must stay in the set, and every multiple must stay in the set."+ ],+ [+ 50.26,+ "If even one sum or one multiple gets out, the set is not a subspace."+ ]+ ]+ },+ "line0": {+ "dur": 73.536,+ "marks": {+ "eq": 5.742,+ "u": 13.099,+ "w": 19.844,+ "add": 30.508,+ "pic": 38.841,+ "test": 45.078,+ "on": 51.185,+ "three": 55.039,+ "neg": 61.888,+ "zero": 66.549+ },+ "cues": [+ [+ 0.104,+ "Let's test our first set: the line x minus two y equals zero."+ ],+ [+ 5.742,+ "From chapter one, you know an equation like this is a line."+ ],+ [+ 8.984,+ "Its right side is zero, so it passes through the origin."+ ],+ [+ 13.099,+ "Here's a vector on it: u equals two, one."+ ],+ [+ 16.341,+ "Check: two minus two times one is zero."+ ],+ [+ 19.844,+ "And another: w equals minus four, minus two."+ ],+ [+ 24.284,+ "Minus four, minus two times minus two, is minus four plus four."+ ],+ [+ 29.375,+ "Zero again."+ ],+ [+ 30.508,+ "Now add them."+ ],+ [+ 31.549,+ "Tops: two plus minus four is minus two."+ ],+ [+ 34.987,+ "Bottoms: one plus minus two is minus one."+ ],+ [+ 38.841,+ "On the picture, w starts from the tip of u, and the sum ends at minus two, minus one."+ ],+ [+ 45.078,+ "Is it on the line?"+ ],+ [+ 46.276,+ "Minus two, minus two times minus one, is minus two plus two."+ ],+ [+ 51.185,+ "Zero."+ ],+ [+ 52.057,+ "On the line, and the ring turns green."+ ],+ [+ 55.039,+ "Now multiples."+ ],+ [+ 56.38,+ "Three u is six, three."+ ],+ [+ 58.568,+ "Six minus six is zero: on the line."+ ],+ [+ 61.888,+ "Minus one times u is minus two, minus one: on the line."+ ],+ [+ 66.549,+ "And zero times u is the zero vector."+ ],+ [+ 69.674,+ "Zero minus zero is zero."+ ],+ [+ 72.37,+ "On the line too."+ ]+ ]+ },+ "why0": {+ "dur": 39.48,+ "marks": {+ "each": 1.914,+ "sum": 9.557,+ "mult": 18.789,+ "drag": 24.792,+ "name": 31.693+ },+ "cues": [+ [+ 0.104,+ "Why does every test pass?"+ ],+ [+ 1.914,+ "Put u into the left side, x minus two y: it gives zero."+ ],+ [+ 6.81,+ "Put in w: it gives zero too."+ ],+ [+ 9.557,+ "When you add two vectors, the tops add and the bottoms add, so what they give adds too."+ ],+ [+ 15.247,+ "The sum gives zero plus zero, which is zero."+ ],+ [+ 18.789,+ "Multiply u by any number c, and it gives c times zero, which is still zero."+ ],+ [+ 24.792,+ "Watch: u and w can be anywhere on the line, and the sum always gives zero plus zero."+ ],+ [+ 31.693,+ "No sum and no multiple can ever leave."+ ],+ [+ 34.531,+ "The line x minus two y equals zero is a subspace of R two."+ ]+ ]+ },+ "ex2": {+ "dur": 45.024,+ "marks": {+ "turn": 4.818,+ "u": 9.675,+ "w": 14.596,+ "add": 20.078,+ "on": 26.315,+ "two": 27.318,+ "same": 32.279+ },+ "cues": [+ [+ 0.104,+ "One more line through the origin: three x plus y equals zero."+ ],+ [+ 4.818,+ "The line turns to its new place, and u and w move along with it."+ ],+ [+ 9.675,+ "u is now one, minus three."+ ],+ [+ 12.24,+ "Three minus three is zero."+ ],+ [+ 14.596,+ "w is minus two, six."+ ],+ [+ 17.318,+ "Minus six plus six is zero."+ ],+ [+ 20.078,+ "Their sum is minus one, three."+ ],+ [+ 22.63,+ "Three times minus one, plus three: zero."+ ],+ [+ 26.315,+ "On the line."+ ],+ [+ 27.318,+ "Two u is two, minus six."+ ],+ [+ 29.818,+ "Six minus six: zero."+ ],+ [+ 32.279,+ "Same reason as before."+ ],+ [+ 33.945,+ "Each vector gives zero, so a sum gives zero plus zero, and a multiple gives some number times zero."+ ],+ [+ 41.497,+ "Every line through the origin is a subspace."+ ]+ ]+ },+ "q1": {+ "dur": 4.08,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.12,+ "Add the two vectors, and test the sum."+ ]+ ]+ },+ "off": {+ "dur": 49.512,+ "marks": {+ "u": 6.667,+ "w": 11.393,+ "add": 15.833,+ "test": 17.786,+ "off": 20.456,+ "why": 24.857,+ "mult": 32.018,+ "zero": 36.836,+ "no0": 42.617,+ "name": 45.365+ },+ "cues": [+ [+ 0.091,+ "Now a line that misses the origin: x plus y equals four, our very first line from chapter one."+ ],+ [+ 6.667,+ "u equals one, three is on it: one plus three is four."+ ],+ [+ 11.393,+ "w equals three, one: three plus one, four."+ ],+ [+ 15.833,+ "Add them: four, four."+ ],+ [+ 17.786,+ "Put it in: four plus four is eight."+ ],+ [+ 20.456,+ "Not four."+ ],+ [+ 21.51,+ "The sum has left the line, and the ring turns red."+ ],+ [+ 24.857,+ "It's no accident."+ ],+ [+ 26.159,+ "Each vector gives four, so the sum gives four plus four, which is eight."+ ],+ [+ 31.003,+ "Never four."+ ],+ [+ 32.018,+ "Multiples fail too."+ ],+ [+ 33.594,+ "Two u is two, six, which gives eight."+ ],+ [+ 36.836,+ "And zero times u is the zero vector, which gives zero, not four."+ ],+ [+ 42.617,+ "The zero vector isn't even on this line."+ ],+ [+ 45.365,+ "So this line is not a subspace."+ ],+ [+ 47.63,+ "One failure is enough."+ ]+ ]+ },+ "slide": {+ "dur": 34.752,+ "marks": {+ "zero": 1.693,+ "miss": 10.638,+ "watch": 14.818,+ "k2": 17.578,+ "k0": 21.68,+ "kn": 26.458,+ "rule": 30.469+ },+ "cues": [+ [+ 0.104,+ "That gives us a quick test."+ ],+ [+ 1.693,+ "Every subspace contains the zero vector, because zero times any of its vectors is the zero vector, and that must stay inside."+ ],+ [+ 10.638,+ "So a line that misses the origin can never be a subspace."+ ],+ [+ 14.818,+ "Watch the test while the line slides."+ ],+ [+ 17.578,+ "Right side two: the sum gives four, not two."+ ],+ [+ 20.859,+ "Off."+ ],+ [+ 21.68,+ "Right side zero: the line goes through the origin, and the sum stays on."+ ],+ [+ 26.458,+ "Minus two: the sum gives minus four."+ ],+ [+ 29.518,+ "Off again."+ ],+ [+ 30.469,+ "A line is a subspace exactly when it passes through the origin."+ ]+ ]+ },+ "q2": {+ "dur": 3.912,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn."+ ],+ [+ 0.99,+ "Slide the line until it's a subspace."+ ]+ ]+ },+ "small": {+ "dur": 32.136,+ "marks": {+ "z": 4.349,+ "zz": 8.841,+ "stay": 14.258,+ "name": 18.971,+ "all": 22.161,+ "roam": 24.518,+ "name2": 29.544+ },+ "cues": [+ [+ 0.104,+ "Two more subspaces: the smallest one and the biggest."+ ],+ [+ 4.349,+ "First, a set with just one vector in it: the zero vector."+ ],+ [+ 8.841,+ "Zero plus zero is zero."+ ],+ [+ 11.458,+ "Any number times zero is zero."+ ],+ [+ 14.258,+ "Whatever c and d you pick, the combination stays at the origin."+ ],+ [+ 18.971,+ "So the zero vector alone is a subspace."+ ],+ [+ 22.161,+ "Now the biggest: the whole plane."+ ],+ [+ 24.518,+ "Any sum and any multiple of arrows in the plane is an arrow in the plane."+ ],+ [+ 29.544,+ "R two is a subspace of itself."+ ]+ ]+ },+ "quad": {+ "dur": 46.992,+ "marks": {+ "zero": 8.073,+ "u": 9.935,+ "add": 14.701,+ "mult": 22.786,+ "out": 24.167,+ "name": 27.604,+ "lesson": 32.227,+ "line": 40.807+ },+ "cues": [+ [+ 0.091,+ "Is holding the zero vector enough?"+ ],+ [+ 2.5,+ "Think back to the quarter plane from the last chapter, where both numbers are zero or more."+ ],+ [+ 8.073,+ "It holds the zero vector."+ ],+ [+ 9.935,+ "Here's u equals two, one, and w equals one, three."+ ],+ [+ 14.701,+ "Their sum, three, four, is inside, and sums of numbers that are zero or more never turn negative."+ ],+ [+ 22.786,+ "But minus one times u is minus two, minus one: outside."+ ],+ [+ 27.604,+ "So the quarter is not a subspace, although it holds the zero vector."+ ],+ [+ 32.227,+ "That's the lesson: the zero test can only throw a set out."+ ],+ [+ 35.925,+ "To let a set in, every sum and every multiple has to pass."+ ],+ [+ 40.807,+ "A line through the origin does: minus u lies on the same line, pointing the other way."+ ]+ ]+ },+ "q3": {+ "dur": 13.56,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn."+ ],+ [+ 1.094,+ "The line x plus y equals four is not a subspace, but some combinations still land on it."+ ],+ [+ 6.927,+ "Find c and d, neither one zero, that bring c u plus d w back onto the line."+ ]+ ]+ },+ "list": {+ "dur": 38.448,+ "marks": {+ "z": 2.513,+ "l": 5.156,+ "p": 7.279,+ "q": 8.607,+ "one": 10.013,+ "two": 18.776,+ "fill": 25.573,+ "so": 30.156+ },+ "cues": [+ [+ 0.104,+ "So what are all the subspaces of the plane?"+ ],+ [+ 2.513,+ "We've found the zero vector alone, every line through the origin, and the whole plane."+ ],+ [+ 8.607,+ "Could there be another kind?"+ ],+ [+ 10.013,+ "Suppose a subspace holds a vector u that is not zero."+ ],+ [+ 14.128,+ "Then it holds every multiple of u: the whole line through u."+ ],+ [+ 18.776,+ "If it also holds a vector w off that line, it holds every combination, c u plus d w."+ ],+ [+ 25.573,+ "And in chapter six, we saw those combinations fill the whole plane."+ ],+ [+ 30.156,+ "So there's nothing in between."+ ],+ [+ 32.083,+ "A subspace of the plane is the zero vector, a line through the origin, or all of R two."+ ]+ ]+ },+ "q4": {+ "dur": 3.072,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Quick check."+ ],+ [+ 1.094,+ "Which set is a subspace?"+ ]+ ]+ },+ "wrap": {+ "dur": 29.328,+ "marks": {+ "w1": 1.016,+ "w2": 7.539,+ "w3": 15.182,+ "w4": 20.846,+ "end": 27.24+ },+ "cues": [+ [+ 0.104,+ "To sum up."+ ],+ [+ 1.016,+ "A subspace is a set inside a space where every sum and every multiple stays inside."+ ],+ [+ 7.539,+ "A line through the origin is a subspace: each vector gives zero, so sums and multiples give zero too."+ ],+ [+ 15.182,+ "A line off the origin is not: it misses the zero vector, and its sums leave."+ ],+ [+ 20.846,+ "The subspaces of the plane are the zero vector, the lines through the origin, and the whole plane."+ ],+ [+ 27.24,+ "Now try the chapter practice."+ ]+ ]+ },+ "final1": {+ "dur": 3.264,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Chapter practice."+ ],+ [+ 1.55,+ "Is the set a subspace?"+ ]+ ]+ },+ "final2": {+ "dur": 3.216,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Next, add the vectors and test the sum."+ ]+ ]+ },+ "final3": {+ "dur": 3.336,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Now use the rule: what does each vector give?"+ ]+ ]+ },+ "final4": {+ "dur": 2.664,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Last set."+ ],+ [+ 1.224,+ "Make it with your hands."+ ]+ ]+ },+ "play": {+ "dur": 10.944,+ "marks": {+ "go": 4.102+ },+ "cues": [+ [+ 0.104,+ "Playground."+ ],+ [+ 1.068,+ "Nothing here is marked right or wrong."+ ],+ [+ 4.102,+ "Slide the line, turn it, move u and w, change c and d, and watch the ring."+ ]+ ]+ },+ "finish": {+ "dur": 9.336,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Well done."+ ],+ [+ 1.107,+ "That's the end of chapter thirty-eight, subspaces of the plane."+ ],+ [+ 5.0,+ "Next: subspaces of space, in three dimensions."+ ]+ ]+ }+};diff --git a/site/linear-algebra/ch38/audio/en/why0.mp3 b/site/linear-algebra/ch38/audio/en/why0.mp3new file mode 100644index 0000000..c69e2fdBinary files /dev/null and b/site/linear-algebra/ch38/audio/en/why0.mp3 differdiff --git a/site/linear-algebra/ch38/audio/en/wrap.mp3 b/site/linear-algebra/ch38/audio/en/wrap.mp3new file mode 100644index 0000000..1a62865Binary files /dev/null and b/site/linear-algebra/ch38/audio/en/wrap.mp3 differdiff --git a/site/linear-algebra/ch38/index.html b/site/linear-algebra/ch38/index.htmlnew file mode 100644index 0000000..2fd5dbd--- /dev/null+++ b/site/linear-algebra/ch38/index.html@@ -0,0 +1,489 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>Subspaces of the Plane</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/vecs.js"></script>+<script src="../lib/play.js"></script>+<script src="audio/en/timings.js"></script>+<script>+'use strict';+const CHAPTER = { number: 38, title: 'Subspaces of the Plane', minutes: 11, language: 'en', next: '../ch39/' };++/* ---------- chapter drawing helpers ---------- */+const [GREEN, VIOLET] = VS_COL; // u green, w violet (as v and w in chapters 4-6); the set S blue (an equation's line)+const SETC = COL.whole;+const CARD = { x: 40, y: 450, 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 showRow = (r, t0, dur = .5) => r.parts.forEach(e => show(e, t0, dur));+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 thickSet = (sb, t0) => { const e = sb.setG.querySelector('path:nth-of-type(2)'); tw(e, { 'a_stroke-width': 11 }, t0, .3); tw(e, { 'a_stroke-width': 6 }, t0 + .8, .5); };+// The test in the picture: one subspace2 with the equation on top, u and w as columns, the combination row and the verdict.+// rows: u = [ ], w = [ ] at y 345; c u + d w = [ ] at y 540; checks under u and w at y 425; readout at y 650+const testBoard = (p, { set = 'line', line = [1, -2, 0], u = [2, 1], w = [-4, -2], c = 1, d = 1, show: sh = [], t0 = .1, eq = true, o = 0, range } = {}) => {+ const sb = subspace2(p, { set, line, u, w, c, d, show: sh, t0, range });+ const R = {+ sb,+ 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 }),+ 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 }),+ };+ return R;+};+// A rounded box drawn around some numbers (the tops being added), then gone.+const boxNums = (p, els, t0, until, color = COL.chalk) => {+ const bs = els.map(e => e.getBBox()), x = Math.min(...bs.map(b => b.x)) - 8, y = Math.min(...bs.map(b => b.y)) - 6;+ const w = Math.max(...bs.map(b => b.x + b.width)) + 8 - x, hh = Math.max(...bs.map(b => b.y + b.height)) + 6 - y;+ const r = path(p, `M${x} ${y}H${x + w}V${y + hh}H${x}Z`, { stroke: color, 'stroke-width': 2.5, fill: 'none', 'stroke-linejoin': 'round' }, { d: 0 });+ draw(r, t0, .6); hide(r, until, .3);+ return r;+};+// A pointer riding on an arrow's tip while the beat moves it ("u can be anywhere on the line").+const hand = (sb, id) => {+ const { PX, PY } = sb.P, g = G(sb.P.g, { o: 0 });+ g.style.pointerEvents = 'none';+ path(g, 'M0 0L0 30L8 23L14 36L20 33L14 21L24 21Z', { fill: COL.chalk, stroke: COL.board, 'stroke-width': 2.5, 'stroke-linejoin': 'round' });+ const upd = v => { const q = id === 'u' || id === 'w' ? [v[id + '0'], v[id + '1']] : sb.vs.calc()[id]; put(g, { x: PX(q[0]) + 6, y: PY(q[1]) + 6 }); };+ sb.onChange(upd); upd(sb.v);+ 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 });+ mk('circle', { r: 17, fill: 'none', stroke: color, 'stroke-width': 4, 'stroke-dasharray': '5 5' }, g);+ if (label) M(g, [label], { x: dx, y: dy, size: 26, fill: color, anchor: dx < 0 ? 'end' : 'start' });+ show(g, t0, .4);+ return g;+};+// A small plane with one set drawn on it, for the choice question.+const thumb = (p, cx, cy, n, draw_) => {+ const P2 = plane(p, { cx, cy, u: 20, x0: -4, x1: 4, y0: -4, y1: 4, t0: .3, step: 2 });+ const g = G(P2.g, {}), { PX, PY } = P2;+ draw_(g, PX, PY);+ T(p, String(n), { x: cx - 4 * 20 - 26, y: cy - 4 * 20 + 6, size: 30, fill: COL.chalk, weight: 700, anchor: 'middle' });+ return P2;+};++/* ---------- practice data ---------- */+const YN = [['y', 'Yes', null, 'Y'], ['n', 'No', null, 'N']];+const SETQ = [+ { parts: ['the line ', $m('y = 3x')], ans: ['y'], why: 'It is 3x − y = 0: right side 0, through the origin. Sums give 0 + 0, multiples c·0.' },+ { parts: ['the line ', $m('y = 3x + 1')], ans: ['n'], why: '(0, 0) gives 0 = 1? No: the zero vector is not on it.' },+ { parts: ['the x-axis, ', $m('y = 0')], ans: ['y'], why: 'A line through the origin: [a, 0] + [b, 0] = [a + b, 0], and c·[a, 0] = [ca, 0].' },+ { parts: ['the line ', $m('x = 2')], ans: ['n'], why: '[2, 0] + [2, 1] = [4, 1]: x is 4, not 2. It misses the origin.' },+ { parts: ['the zero vector alone'], ans: ['y'], why: '0 + 0 = 0 and c·0 = 0: the smallest subspace.' },+ { parts: ['the single point ', $m('(1, 1)')], ans: ['n'], why: '2·[1, 1] = [2, 2] is not [1, 1]; and the zero vector is missing.' },+ { parts: ['the whole plane ', $m('R²')], ans: ['y'], why: 'Every sum and multiple of vectors in the plane is in the plane.' },+ { parts: ['the upper half, ', $m('y ≥ 0')], ans: ['n'], why: '[0, 1] is in it, but −1·[0, 1] = [0, −1] is not.' },+];+// Lines with two vectors on them: add, then put the sum into the left side.+const SUMQ = [+ ['2x + y = 0', [1, -2], [-3, 6], (x, y) => 2 * x + y],+ ['x − 3y = 0', [3, 1], [-6, -2], (x, y) => x - 3 * y],+ ['x + y = 4', [1, 3], [2, 2], (x, y) => x + y],+ ['x − y = 1', [3, 2], [0, -1], (x, y) => x - y],+].map(([eq, u, w, f]) => {+ const s = [u[0] + w[0], u[1] + w[1]], val = f(...s);+ console.assert(f(...u) === f(...w), 'SUMQ: u and w on one line', eq);+ const br = q => `[${q.map(num).join(', ')}]`;+ return { eq, gives: f(...u), parts: [`${eq}: u = ${br(u)}, w = ${br(w)}. u + w = [`, { box: String(s[0]) }, ', ', { box: String(s[1]) }, '], left side ', { box: String(val) }],+ why: `u + w = ${br(s)}, which gives ${num(val)}. ${val === f(...u) ? 'The same as u and w: on the line.' : `The line needs ${num(f(...u))}: off the line.`}`,+ hint: 'Add tops, add bottoms. Then put the two numbers into the left side of the equation.' };+});+const RULEQ = [+ { parts: ['every vector on x + 2y = 3 gives 3. u + w gives ', { box: '6' }], why: '3 + 3 = 6: the sum is off the line.', hint: 'u gives 3 and w gives 3. What do they give together?' },+ { parts: ['… and 4u gives ', { box: '12' }], why: '4 · 3 = 12.', hint: 'Four times u gives four times what u gives.' },+ { parts: ['… and 0u, the zero vector, gives ', { box: '0' }], why: '0 + 2·0 = 0, not 3: the zero vector is not on this line.', hint: 'Put x = 0 and y = 0 into x + 2y.' },+ { parts: ['x + 5y = k is a subspace exactly when k = ', { box: '0' }], why: 'Only then does it pass through the origin.', hint: 'A subspace must hold the zero vector: put (0, 0) into x + 5y.' },+ { parts: ['u = [2, 1] is in a subspace, so −3u = [', { box: '-6' }, ', ', { box: '-3' }, '] is too'], why: 'Every multiple stays inside: −3·2 = −6, −3·1 = −3.', hint: 'Multiply both numbers of u by −3.' },+ { parts: ['u = [1, 2], w = [0, 1] are in it, so 2u − w = [', { box: '2' }, ', ', { box: '3' }, '] is too'], why: '[2, 4] − [0, 1] = [2, 3]: a combination stays inside.', hint: 'First 2u = [2, 4], then subtract w.' },+];++/* ---------- beats: [id, title, run(m, D), { ask }?] ---------- */+const BEATS = [+ ['intro', 'Subspaces of the plane', (m, D) => {+ const g = G(scene, { o: 0, y: 24 });+ T(g, 'Unit 5, Chapter 38', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });+ T(g, 'Subspaces of the Plane', { x: 800, y: 360, size: 88, weight: 600, anchor: 'middle' });+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);+ const r = text(scene, 'a space inside a space: add and stretch, and you never get out', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });+ // a line through the origin; two arrows on it and their sum, which stays on it+ const lg = G(scene, { x: 800, y: 700, o: 0 }), U = 46, at = (x, y) => [x * U, -y * U];+ path(lg, `M${at(-6, -3)}L${at(6, 3)}`, { stroke: SETC, 'stroke-width': 6, 'stroke-linecap': 'round' });+ const arr = (a, b, color, w = 5) => {+ const [x0, y0] = at(...a), [x1, y1] = at(...b), 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 });+ };+ mk('circle', { r: 6, fill: COL.chalk }, lg);+ const a1 = arr([0, 0], [2, 1], GREEN), a2 = arr([2, 1], [5, 2.5], VIOLET), a3 = arr([0, 0], [5, 2.5], COL.chalk, 6);+ show(lg, m('sub') + .8, .5); draw(a1, m('sub') + 1, .6); draw(a2, m('move'), .7); draw(a3, m('move') + .9, .7);+ const ok = text(lg, '✓ still on the line', 5 * U + 24, -2.5 * U + 10, m('move') + 1.8, { size: 28, fill: COL.good, weight: 700 });+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);+ }],++ ['recap', 'The rule, and a smaller set', (m) => {+ const p = S.p = panel(0);+ text(p, 'A space inside a space', 60, 110, .2, { size: 40, weight: 600 });+ const sb = subspace2(p, { set: 'all', u: [2, 1], w: [-1, 3], show: [], t0: .3 });+ const r1 = text(p, 'rule 1: add any two vectors: the sum stays inside', 90, 210, m('add'), { size: 30, weight: 600 });+ const r2 = text(p, 'rule 2: multiply one by any number: it stays inside', 90, 262, m('scale'), { size: 30, weight: 600 });+ sb.show(['u', 'w'], m('add') + .3); sb.show(['dw', 'sum'], m('add') + 1.3);+ // R²: everything; a sum of two of its arrows, then a stretch+ const r2t = text(p, 'R²: every vector of the plane', 90, 340, m('r2'), { size: 30, fill: SETC, weight: 600 });+ sb.to({ c: 2, d: 0 }, m('scale') + 1, 1.2); sb.to({ c: 1, d: 1 }, m('r2') + .5, 1);+ sb.to({ u0: -1, u1: 2, w0: 3, w1: -1 }, m('r2') + 2.6, 1.6);+ 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);+ 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 });+ const nm = G(p, { o: 0 });+ 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);+ 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 });+ show(tt, m('test'), .6);+ pulseG(sb.vs.A.u.g, m('test') + 1.6); pulseG(sb.vs.A.w.g, m('test') + 1.9);+ sb.hide(['dw', 'w'], m('test') + 4.6, .3); sb.to({ c: 2, d: 0 }, m('test') + 5, 1.2); sb.to({ c: -1.5 }, m('test') + 6.4, 1.4); sb.to({ c: 1, d: 1 }, m('fail') - .3, .8); sb.show(['dw', 'w'], m('fail'), .3);+ text(p, 'one sum or one multiple outside: not a subspace', 90, 710, m('fail'), { size: 30, fill: COL.bad, weight: 600 });+ }],++ ['line0', 'A line through the origin', (m) => {+ const p = S.p = panel(0);+ text(p, 'Test 1: the line x − 2y = 0', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { line: [1, -2, 0], u: [2, 1], w: [-4, -2] }), sb = S.sb = B.sb;+ put(sb.setG, { o: 0 });+ showRow(B.eq, .3); show(sb.setG, m('eq'), .8); thickSet(sb, m('eq') + 3.2);+ text(p, 'right side 0: through the origin', 90, 256, m('eq') + 3.4, { size: 26, fill: COL.dim });+ showRow(B.u, m('u')); sb.show('u', m('u') + .2); show(B.cu, m('u') + 2.2);+ showRow(B.w, m('w')); sb.show('w', m('w') + .2); show(B.cw, m('w') + 3);+ showRow(B.combo, m('add'));+ sb.flash('u0', m('add') + 1); sb.flash('w0', m('add') + 1.6); sb.flash('sum0', m('add') + 2.6);+ sb.flash('u1', m('add') + 4.2); sb.flash('w1', m('add') + 4.8); sb.flash('sum1', m('add') + 5.8);+ const nb = k => sb.num(k)[0];+ 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);+ 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);+ // multiples: 3u, −u, 0u (d = 0: w steps aside)+ sb.hide(['dw', 'w'], m('three') - .3, .3); hide(B.cw, m('three') - .3, .3);+ sb.to({ c: 3, d: 0 }, m('three'), 1.3); sb.flash('c', m('three'));+ sb.to({ c: -1 }, m('neg'), 1.3); sb.flash('c', m('neg'));+ sb.to({ c: 0 }, m('zero'), 1.1); sb.flash('c', m('zero'));+ }],++ ['why0', 'Why it always works', (m) => {+ 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({ 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);+ 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);+ hide(n1, m('name') - .2, .3); hide(n2, m('name') - .2, .3);+ const nm = text(p, 'x − 2y = 0 is a subspace of R²', 90, 765, m('name') + 2.4, { size: 32, fill: COL.good, weight: 700 });+ thickSet(sb, m('name') + 2.4);+ }],++ ['ex2', 'Another line through the origin', (m) => {+ const p = S.p = panel(0);+ 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);+ 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);+ 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'));+ text(p, 'each gives 0: sums give 0 + 0, multiples c · 0', 90, 765, m('same') + 1, { size: 30, weight: 600 });+ sb.to({ c: -1 }, m('same') + 2.5, 1.4); sb.to({ c: 1.5 }, m('same') + 4.2, 1.4); sb.to({ c: 2 }, m('same') + 6, 1);+ text(p, 'every line through the origin is a subspace', 90, 815, m('same') + 7.4, { size: 30, fill: COL.good, weight: 700 });+ }],++ ['q1', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { line: [2, 1, 0], u: [2, -4], w: [-1, 2], o: 1, show: ['u', 'w'] }), sb = S.sb = B.sb;+ [B.combo.g, B.out].forEach(e => put(e, { o: 0 }));+ }, { ask: done => quiz(CARD, [{+ id: 'c-sum', prompt: ['On the line ', $m('2x + y = 0'), ': add ', $m('u'), ' and ', $m('w'), ', then put the sum into ', $m('2x + y'), '.'],+ build: blanks([+ { parts: ['u + w = [', { box: '1' }, ', ', { box: '-2' }, ']'], why: '2 + (−1) = 1 and −4 + 2 = −2.', hint: 'Add the tops: 2 + (−1). Add the bottoms: −4 + 2.',+ fx: () => { const sb = S.sb; fx(sb.vs.A.dw.g, { o: 1 }, .1, .5); fx(sb.vs.A.dw.lab, { o: 1 }, .1, .5); fx(sb.vs.A.sum.g, { o: 1 }, .6, .5); fx(sb.vs.A.sum.lab, { o: 1 }, .6, .5); fx(sb.ring, { o: 1 }, .6, .5); } },+ { parts: ['2·1 + (−2) = ', { box: '0' }], why: 'Zero, as the line needs: the sum is on the line.', hint: '2 times 1 is 2. Then 2 + (−2).',+ fx: () => fx(S.B.out, { o: 1 }, .1, .5) },+ ]),+ }], done) }],++ ['off', 'A line that misses the origin', (m) => {+ const p = S.p = panel(0);+ text(p, 'Test 3: the line x + y = 4', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { line: [1, 1, 4], u: [1, 3], w: [3, 1] }), sb = S.sb = B.sb;+ showRow(B.eq, .3); text(p, 'right side 4: misses the origin', 90, 256, .8, { size: 26, fill: COL.dim });+ showRow(B.u, m('u')); sb.show('u', m('u') + .2); show(B.cu, m('u') + 1.6);+ showRow(B.w, m('w')); sb.show('w', m('w') + .2); show(B.cw, m('w') + 1.4);+ showRow(B.combo, m('add')); sb.show(['dw', 'sum'], m('add') + .5);+ show(B.out, m('test'));+ tw(sb.ring, { s: 1.6 }, m('off') + .2, .25); tw(sb.ring, { s: 1 }, m('off') + .5, .4);+ const why = text(p, 'u gives 4, w gives 4: u + w gives 4 + 4 = 8', 90, 765, m('why') + 1, { size: 30, weight: 600 });+ hide(why, m('mult') - .3, .3);+ sb.hide(['dw', 'w'], m('mult') - .3, .3); hide(B.cw, m('mult') - .3, .3);+ sb.to({ c: 2, d: 0 }, m('mult'), 1.3); sb.flash('c', m('mult'));+ sb.to({ c: 0 }, m('zero'), 1.1); sb.flash('c', m('zero'));+ const o = G(sb.P.g, { x: sb.P.PX(0), y: sb.P.PY(0), o: 0 });+ mk('circle', { r: 26, fill: 'none', stroke: COL.bad, 'stroke-width': 4, 'stroke-dasharray': '6 5' }, o);+ show(o, m('no0'), .4); pulse(o, m('no0') + .5);+ text(p, '(0, 0) gives 0, not 4', 90, 765, m('no0') + .3, { size: 30, fill: COL.chalk, weight: 600 });+ text(p, 'x + y = 4 is not a subspace', 90, 815, m('name') + .3, { size: 32, fill: COL.bad, weight: 700 });+ }],++ ['slide', 'Slide the line', (m) => {+ const p = S.p = panel(0);+ text(p, 'A quick test: the origin', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { line: [1, 1, 4], u: [-1, 5], w: [3, 1], o: 1, show: ['u', 'w', 'dw', 'sum'] }), sb = S.sb = B.sb;+ [B.cu, B.cw].forEach(e => put(e, { o: 0 }));+ const z = G(p, { o: 0 });+ T(z, '0 · u = the zero vector,', { x: 90, y: 765, size: 30, weight: 600 });+ T(z, 'so every subspace holds (0, 0)', { x: 90, y: 812, size: 30, weight: 600 });+ show(z, m('zero') + .5, .5);+ sb.hide(['dw', 'w'], m('zero') + 2.5, .3); sb.to({ c: 0, d: 0 }, m('zero') + 2.8, 1.8); sb.flash('c', m('zero') + 2.8);+ sb.to({ c: 1, d: 1 }, m('miss') + 1.6, 1.2); sb.show(['dw', 'w'], m('miss') + 2.2, .4);+ const o = G(sb.P.g, { x: sb.P.PX(0), y: sb.P.PY(0), o: 0 });+ mk('circle', { r: 26, fill: 'none', stroke: COL.chalk, 'stroke-width': 4, 'stroke-dasharray': '6 5' }, o);+ show(o, m('zero') + 1, .4); pulse(o, m('miss') + .8);+ hide(z, m('watch') - .2, .3);+ sb.to({ k: 2 }, m('k2') - .3, 1.3); sb.flash('k', m('k2'));+ sb.to({ k: 0 }, m('k0') - .2, 1.3); sb.flash('k', m('k0'));+ sb.to({ k: -2 }, m('kn') - .2, 1.3); sb.flash('k', m('kn'));+ const rl = G(p, { o: 0 });+ T(rl, 'a line is a subspace exactly when', { x: 90, y: 765, size: 30, weight: 600 });+ T(rl, 'it passes through the origin (right side 0)', { x: 90, y: 812, size: 30, weight: 600 });+ show(rl, m('rule'), .5);+ sb.to({ k: 0 }, m('rule') + .4, 1.4);+ }],++ ['q2', 'Your turn', () => {+ const p = panel(0);+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });+ const sb = S.sb = subspace2(p, { line: [2, -1, 6], u: [1, -4], w: [4, 2], show: ['u', 'w', 'dw', 'sum'], range: { k: [-8, 8] } });+ sb.eq({ x: 90, y: 200, size: 46 });+ S.B = { sb, out: sb.readout({ x: 90, y: 300, size: 32 }) };+ }, { ask: done => quiz(CARD, [{+ id: 'c-slide', prompt: ['Slide the line until it is a subspace: drag the line, or change its right side.'],+ build: sbTask(S.sb, v => v.k === 0, 'Right side 0: the line 2x − y = 0 passes through the origin, and every sum stays on it.',+ v => v.k > 0 ? `Right side ${num(v.k)}: the line misses (0, 0). Slide it toward the origin.` : `Right side ${num(v.k)}: still off the origin. Slide it back up.`,+ () => S.sb.set({ k: 0 }), { only: ['k'], drag: [] }),+ }], done) }],++ ['small', 'The smallest and the biggest', (m) => {+ const p = S.p = panel(0);+ text(p, 'The smallest and the biggest', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { set: 'zero', u: [0, 0], w: [0, 0], eq: false, show: ['u', 'w', 'sum'], o: 1 }), sb = S.sb = B.sb;+ [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 });+ [[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));+ 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); });+ 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 });+ }],++ ['quad', 'Zero is not enough', (m) => {+ const p = S.p = panel(0);+ text(p, 'Is the zero vector enough?', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { set: 'quad', u: [2, 1], w: [1, 3], eq: false }), sb = S.sb = B.sb;+ [B.cu, B.cw].forEach(e => put(e, { o: 0 }));+ put(sb.setG, { o: 0 }); show(sb.setG, 1.6, .6);+ say(p, ['x ≥ 0 and y ≥ 0'], 90, 210, 2, { size: 40, fill: SETC });+ text(p, 'the quarter plane, from chapter 37', 90, 256, 2.4, { size: 26, fill: COL.dim });+ const o = G(sb.P.g, { x: sb.P.PX(0), y: sb.P.PY(0), o: 0 });+ mk('circle', { r: 22, fill: 'none', stroke: COL.good, 'stroke-width': 4 }, o);+ show(o, m('zero'), .4); pulse(o, m('zero') + .4); hide(o, m('u') - .2, .3);+ showRow(B.u, m('u')); sb.show('u', m('u') + .2);+ showRow(B.w, m('u') + 1.6); sb.show('w', m('u') + 1.8);+ showRow(B.combo, m('add')); sb.show(['dw', 'sum'], m('add') + .3); show(B.out, m('add') + 1);+ sb.hide(['dw', 'w'], m('mult') - .3, .3);+ sb.to({ c: -1, d: 0 }, m('mult') + .4, 1.4); sb.flash('c', m('mult') + .4);+ tw(sb.ring, { s: 1.6 }, m('out') + .4, .25); tw(sb.ring, { s: 1 }, m('out') + .7, .4);+ text(p, 'the quarter is not a subspace', 90, 765, m('name'), { size: 32, fill: COL.bad, weight: 700 });+ const ls = G(p, { o: 0 });+ T(ls, 'holding (0, 0) is not enough:', { x: 1160, y: 820, size: 28, weight: 600, anchor: 'middle' });+ T(ls, 'every sum and every multiple must pass', { x: 1160, y: 862, size: 28, weight: 600, anchor: 'middle' });+ show(ls, m('lesson') + 1, .5);+ sb.to({ c: 2 }, m('lesson') + 1.5, 1.6); sb.to({ c: .5 }, m('lesson') + 3.4, 1.2); sb.to({ c: -1 }, m('lesson') + 5, 1.4);+ sb.multiples(m('line'), true, .8);+ text(p, 'a line through 0 keeps −u: same line, other way', 90, 815, m('line') + .4, { size: 28, weight: 600 });+ }],++ ['q3', 'Your turn', () => {+ const p = panel(0);+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { line: [1, 1, 4], u: [1, 3], w: [3, 1], 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: -125 });+ }, { ask: done => quiz({ x: 40, y: 600, w: 720, cls: 'side' }, [{+ id: 'c-back', prompt: ['Find ', $m('c'), ' and ', $m('d'), ', neither of them 0, so that ', $m('cu + dw'), ' lands back on the line.'],+ build: sbTask(S.sb, (v, sb) => sb.ok() && v.c !== 0 && v.d !== 0,+ v => `c + d = ${num(v.c + v.d)}: u and w each give 4, so c u + d w gives 4c + 4d = 4·1 = 4. It works only when c + d = 1; a subspace would need it for every c and d.`,+ v => v.c === 0 || v.d === 0 ? 'Neither c nor d may be 0.' : `c u + d w gives 4·${v.c + v.d < 0 ? `(${num(v.c + v.d)})` : num(v.c + v.d)} = ${num(4 * (v.c + v.d))}, not 4. What must c + d be?`,+ () => S.sb.set({ c: 2, d: -1 }), { only: ['c', 'd'], drag: [] }),+ }], done) }],++ ['list', 'Every subspace of the plane', (m) => {+ const p = S.p = panel(0);+ text(p, 'Every subspace of the plane', 60, 110, .2, { size: 40, weight: 600 });+ const sb = S.sb = subspace2(p, { set: 'zero', u: [0, 0], w: [0, 0], c: 1, d: 0, show: [], t0: .3 });+ const L = (str, y, t) => { const g = G(p, { o: 0 }); mk('circle', { cx: 104, cy: y - 10, r: 8, fill: SETC }, g); T(g, str, { x: 130, y, size: 32, weight: 600 }); show(g, t, .5); return g; };+ L('the zero vector alone', 220, m('z'));+ 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.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);+ 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);+ const o1 = text(p, 'one vector u ≠ 0 → its whole line', 90, 520, m('one') + 1, { size: 30, weight: 600 });+ // a second vector off the line: every combination, the whole plane (chapter 6's grid)+ sb.kind('all', m('two'));+ sb.to({ w0: -1, w1: 2, d: 1 }, m('two') + .1, 1.1); sb.show(['w', 'dw'], m('two') + .3);+ sb.to({ c: 2, d: 1 }, m('two') + 2.2, 1.2); sb.to({ c: -1, d: 2 }, m('two') + 3.8, 1.2); sb.to({ c: 1, d: 1 }, m('two') + 5.4, 1);+ const o2 = text(p, 'and w off that line → every c u + d w', 90, 575, m('two') + .8, { size: 30, weight: 600 });+ prog(() => sb.vs.lattice(m('fill')), m('fill'), 0);+ [[2, 1], [-1, 2], [1, -2], [-2, -1]].forEach(([c, d], i) => sb.to({ c, d }, m('fill') + 1 + i * 1.1, .9));+ text(p, '→ the whole plane', 90, 630, m('fill') + .3, { size: 30, weight: 600 });+ const so = G(p, { o: 0 });+ 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.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);+ }],++ ['q4', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const line = (g, PX, PY, a, b, k) => { // a x + b y = k across the small board, blue+ const pts = [];+ for (const X of [-4, 4]) { const Y = (k - a * X) / b; if (Y >= -4 && Y <= 4) pts.push([X, Y]); }+ for (const Y of [-4, 4]) { const X = (k - b * Y) / a; if (X > -4 && X < 4) pts.push([X, Y]); }+ path(g, `M${PX(pts[0][0])} ${PY(pts[0][1])}L${PX(pts[1][0])} ${PY(pts[1][1])}`, { stroke: SETC, 'stroke-width': 5, 'stroke-linecap': 'round' });+ };+ thumb(p, 1000, 290, 1, (g, PX, PY) => line(g, PX, PY, 2, -1, -1));+ thumb(p, 1340, 290, 2, (g, PX, PY) => line(g, PX, PY, 2, -1, 0));+ thumb(p, 1000, 660, 3, (g, PX, PY) => { path(g, `M${PX(0)} ${PY(4)}V${PY(0)}H${PX(4)}V${PY(4)}Z`, { fill: SETC, 'fill-opacity': .18, stroke: 'none' }); path(g, `M${PX(0)} ${PY(4)}V${PY(0)}H${PX(4)}`, { stroke: SETC, 'stroke-width': 5, fill: 'none' }); });+ thumb(p, 1340, 660, 4, (g, PX, PY) => mk('circle', { cx: PX(1), cy: PY(1), r: 9, fill: SETC }, g));+ }, { ask: done => quiz({ x: 40, y: 200, w: 720, cls: 'side' }, [{+ id: 'c-which', prompt: ['Which set is a subspace of ', $m('R²'), '?'],+ build: choice([['1: the line ', $m('y = 2x + 1')], ['2: the line ', $m('y = 2x')], ['3: the quarter ', $m('x ≥ 0, y ≥ 0')], ['4: the single point ', $m('(1, 1)')]], 1,+ 'y = 2x is 2x − y = 0: right side 0, through the origin. Every sum and every multiple stays on it.',+ ['(0, 0) gives 0 = 0 + 1? No. It misses the origin, and the sum of two of its vectors leaves it.', '',+ 'Sums stay in, but −1 times [1, 1] is [−1, −1]: outside.', '2·[1, 1] = [2, 2] is not in it; nor is the zero vector.']),+ }], done) }],++ ['wrap', 'Summary', (m) => {+ const p = panel(0);+ [['A subspace: a set inside a space where every sum and every multiple stays inside.', 'w1'],+ ['A line through the origin is a subspace: sums give 0 + 0, multiples c · 0.', 'w2'],+ ['A line off the origin is not: no zero vector, and its sums leave.', 'w3'],+ ['Subspaces of R²: the zero vector, the lines through 0, the whole 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: 34, weight: 600 });+ tw(g, { o: 1, x: 0 }, m(mark), .6);+ });+ }],+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{+ id: 'p-sets', prompt: ['Is the set a subspace of ', $m('R²'), '?'],+ build: grid(SETQ, YN, { multi: false, text: true }),+ }], done, 'Chapter practice · set 1 of 4') }],+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-sums', prompt: ['u and w are on the line. Add them, then put the sum into the left side.'],+ build: blanks(SUMQ),+ }, {+ id: 'p-lines', prompt: ['So which of these lines are subspaces?'],+ build: grid(SUMQ.map(q => ({ parts: [$m(q.eq)], ans: [q.gives === 0 ? 'y' : 'n'], why: q.gives === 0 ? 'Right side 0: through the origin.' : `Right side ${num(q.gives)}: it misses the origin, and the sum gave twice ${num(q.gives)}.` })), YN, { multi: false, text: true }),+ }], done, 'Chapter practice · set 2 of 4') }],+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-rule', prompt: ['Use the rule. Each vector on a line gives the right side; a sum gives the sum, a multiple the multiple.'],+ build: blanks(RULEQ),+ }], done, 'Chapter practice · set 3 of 4') }],+ ['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 }) };+ 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.'],+ build: (body, api) => {+ ringAt(S.sb, 3, 1, 0, qlayer());+ return sbTask(S.sb, v => v.k === 0 && 3 * v.a + v.b === 0 && (v.a || v.b), 'x − 3y = 0 (or any multiple of it): right side 0, and (3, 1) gives 3 − 3 = 0.',+ v => v.k !== 0 ? 'A subspace passes through the origin: make the right side 0 first.' : `(3, 1) gives ${num(3 * v.a + v.b)}, not 0. Three times the x number plus the y number must be 0.`,+ () => S.sb.set({ a: 1, b: -3, k: 0 }), { drag: [] })(body, api);+ },+ }, {+ 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 });+ 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);+ },+ }], 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 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 });+ 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.' }) }],+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));++boot();+</script>+</body>+</html>diff --git a/site/linear-algebra/ch39/audio/en/ex2.mp3 b/site/linear-algebra/ch39/audio/en/ex2.mp3new file mode 100644index 0000000..a5f4d5dBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/ex2.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/final1.mp3 b/site/linear-algebra/ch39/audio/en/final1.mp3new file mode 100644index 0000000..c456947Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/final1.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/final2.mp3 b/site/linear-algebra/ch39/audio/en/final2.mp3new file mode 100644index 0000000..039a43aBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/final2.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/final3.mp3 b/site/linear-algebra/ch39/audio/en/final3.mp3new file mode 100644index 0000000..ab4c0abBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/final3.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/final4.mp3 b/site/linear-algebra/ch39/audio/en/final4.mp3new file mode 100644index 0000000..886fd4cBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/final4.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/finish.mp3 b/site/linear-algebra/ch39/audio/en/finish.mp3new file mode 100644index 0000000..76af39cBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/finish.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/intro.mp3 b/site/linear-algebra/ch39/audio/en/intro.mp3new file mode 100644index 0000000..bc5c53fBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/intro.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/line.mp3 b/site/linear-algebra/ch39/audio/en/line.mp3new file mode 100644index 0000000..66c20afBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/line.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/lineoff.mp3 b/site/linear-algebra/ch39/audio/en/lineoff.mp3new file mode 100644index 0000000..b36ff74Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/lineoff.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/list.mp3 b/site/linear-algebra/ch39/audio/en/list.mp3new file mode 100644index 0000000..bed95c7Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/list.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/off.mp3 b/site/linear-algebra/ch39/audio/en/off.mp3new file mode 100644index 0000000..f2217aaBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/off.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/plane0.mp3 b/site/linear-algebra/ch39/audio/en/plane0.mp3new file mode 100644index 0000000..c715331Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/plane0.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/play.mp3 b/site/linear-algebra/ch39/audio/en/play.mp3new file mode 100644index 0000000..5b3b868Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/q1.mp3 b/site/linear-algebra/ch39/audio/en/q1.mp3new file mode 100644index 0000000..39aad09Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/q1.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/q2.mp3 b/site/linear-algebra/ch39/audio/en/q2.mp3new file mode 100644index 0000000..b7334bfBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/q2.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/q3.mp3 b/site/linear-algebra/ch39/audio/en/q3.mp3new file mode 100644index 0000000..8ba3879Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/q3.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/q4.mp3 b/site/linear-algebra/ch39/audio/en/q4.mp3new file mode 100644index 0000000..907d3efBinary files /dev/null and b/site/linear-algebra/ch39/audio/en/q4.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/recap.mp3 b/site/linear-algebra/ch39/audio/en/recap.mp3new file mode 100644index 0000000..8a04254Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/recap.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/slide.mp3 b/site/linear-algebra/ch39/audio/en/slide.mp3new file mode 100644index 0000000..86455b1Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/slide.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/small.mp3 b/site/linear-algebra/ch39/audio/en/small.mp3new file mode 100644index 0000000..ac45d23Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/small.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/timings.js b/site/linear-algebra/ch39/audio/en/timings.jsnew file mode 100644index 0000000..f1ecbf7--- /dev/null+++ b/site/linear-algebra/ch39/audio/en/timings.js@@ -0,0 +1,758 @@+window.TIMINGS = {+ "intro": {+ "dur": 12.192,+ "marks": {+ "sub": 3.425,+ "move": 6.276+ },+ "cues": [+ [+ 0.104,+ "Chapter thirty-nine."+ ],+ [+ 1.536,+ "Subspaces of space."+ ],+ [+ 3.425,+ "Now the same test in three dimensions."+ ],+ [+ 6.276,+ "Space has room for one more kind of subspace: a flat plane through the origin."+ ]+ ]+ },+ "recap": {+ "dur": 32.424,+ "marks": {+ "z": 3.919,+ "l": 5.612,+ "p": 7.826,+ "space": 9.089,+ "test": 15.69,+ "sp": 23.32+ },+ "cues": [+ [+ 0.091,+ "In the plane, we found three kinds of subspace."+ ],+ [+ 3.919,+ "The zero vector alone."+ ],+ [+ 5.612,+ "Any line through the origin."+ ],+ [+ 7.826,+ "And the whole plane."+ ],+ [+ 9.089,+ "Now we move up to space, R three: vectors with three numbers, x, y and z."+ ],+ [+ 15.69,+ "The test is the same."+ ],+ [+ 17.578,+ "Pick two vectors in the set."+ ],+ [+ 19.609,+ "Every sum and every multiple must stay inside."+ ],+ [+ 23.32,+ "Here is all of R three."+ ],+ [+ 24.831,+ "Add two arrows of space, and the sum is an arrow of space."+ ],+ [+ 29.518,+ "So R three is a subspace of itself."+ ]+ ]+ },+ "plane0": {+ "dur": 62.376,+ "marks": {+ "eq": 4.714,+ "u": 13.737,+ "w": 21.589,+ "add": 30.169,+ "pic": 32.904,+ "test": 39.089,+ "on": 42.383,+ "two": 45.547,+ "neg": 51.992,+ "zero": 56.706+ },+ "cues": [+ [+ 0.104,+ "Our first set: the plane x plus y plus z equals zero."+ ],+ [+ 4.714,+ "In chapter eleven, you met x plus y plus z equals three."+ ],+ [+ 9.323,+ "Slide it to right side zero, and it passes through the origin."+ ],+ [+ 13.737,+ "Here's u equals one, zero, minus one."+ ],+ [+ 17.214,+ "One plus zero minus one is zero: it's in the plane."+ ],+ [+ 21.589,+ "And w equals zero, two, minus two."+ ],+ [+ 25.365,+ "Zero plus two minus two: zero."+ ],+ [+ 28.906,+ "In the plane too."+ ],+ [+ 30.169,+ "Add them: one, two, minus three."+ ],+ [+ 32.904,+ "In the picture, w starts from the tip of u, and the sum lands at one, two, minus three."+ ],+ [+ 39.089,+ "Put it in: one plus two minus three."+ ],+ [+ 42.383,+ "Zero."+ ],+ [+ 43.255,+ "In the plane, and the ring is green."+ ],+ [+ 45.547,+ "Multiples: two u is two, zero, minus two."+ ],+ [+ 49.753,+ "Two minus two: zero."+ ],+ [+ 51.992,+ "Minus u is minus one, zero, one: zero again."+ ],+ [+ 56.706,+ "And zero times u is the zero vector, which gives zero."+ ],+ [+ 61.146,+ "Still in the plane."+ ]+ ]+ },+ "why0": {+ "dur": 26.88,+ "marks": {+ "each": 2.435,+ "sum": 8.008,+ "mult": 13.346,+ "drag": 17.604,+ "name": 21.836+ },+ "cues": [+ [+ 0.104,+ "The reason is the one from the plane."+ ],+ [+ 2.435,+ "Every vector in this plane gives zero when you put it into x plus y plus z."+ ],+ [+ 8.008,+ "Adding two vectors adds what they give: zero plus zero, which is zero."+ ],+ [+ 13.346,+ "Multiplying by c gives c times zero, still zero."+ ],+ [+ 17.604,+ "Watch u and w slide around the plane."+ ],+ [+ 20.391,+ "The sum never leaves it."+ ],+ [+ 21.836,+ "So the plane x plus y plus z equals zero is a subspace of R three."+ ]+ ]+ },+ "ex2": {+ "dur": 54.24,+ "marks": {+ "turn": 5.964,+ "u": 9.154,+ "w": 15.404,+ "back": 22.904,+ "add": 31.927,+ "neg": 38.958,+ "same": 45.547+ },+ "cues": [+ [+ 0.104,+ "Another plane through the origin: x plus two y plus z equals zero."+ ],+ [+ 5.964,+ "The plane tilts, and u and w move with it."+ ],+ [+ 9.154,+ "u is now two, minus one, zero."+ ],+ [+ 12.083,+ "Two minus two plus zero is zero."+ ],+ [+ 15.404,+ "w is minus one, two, minus three."+ ],+ [+ 18.685,+ "Minus one plus four minus three: zero."+ ],+ [+ 22.904,+ "You've seen these two before: they were the first two columns of the lecture's matrix, in chapter fourteen, and this plane was their flat sheet."+ ],+ [+ 31.927,+ "Their sum is one, one, minus three."+ ],+ [+ 34.922,+ "One plus two minus three is zero: in the plane."+ ],+ [+ 38.958,+ "Minus w is one, minus two, three."+ ],+ [+ 42.435,+ "One minus four plus three: zero."+ ],+ [+ 45.547,+ "Any plane through the origin is a subspace, for the same reason: each vector gives zero, so sums and multiples give zero."+ ]+ ]+ },+ "q1": {+ "dur": 4.08,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.12,+ "Add the two vectors, and test the sum."+ ]+ ]+ },+ "off": {+ "dur": 40.704,+ "marks": {+ "u": 5.755,+ "w": 12.109,+ "add": 16.497,+ "test": 18.359,+ "off": 21.211,+ "why": 23.828,+ "mult": 29.01,+ "zero": 33.19,+ "name": 38.607+ },+ "cues": [+ [+ 0.091,+ "Now a plane that misses the origin: x plus y plus z equals three."+ ],+ [+ 5.755,+ "u equals two, one, zero is in it: two plus one plus zero is three."+ ],+ [+ 12.109,+ "w equals two, zero, one: also three."+ ],+ [+ 16.497,+ "Their sum is four, one, one."+ ],+ [+ 18.359,+ "Four plus one plus one is six."+ ],+ [+ 21.211,+ "Not three."+ ],+ [+ 22.266,+ "The sum has left the plane."+ ],+ [+ 23.828,+ "Each vector gives three, so the sum gives three plus three, six."+ ],+ [+ 29.01,+ "Two u is four, two, zero, which gives six too."+ ],+ [+ 33.19,+ "And zero times u, the zero vector, gives zero, not three."+ ],+ [+ 38.607,+ "This plane is not a subspace."+ ]+ ]+ },+ "slide": {+ "dur": 24.72,+ "marks": {+ "zero": 2.617,+ "watch": 5.417,+ "k1": 6.836,+ "k0": 10.729,+ "kn": 15.768,+ "rule": 19.844+ },+ "cues": [+ [+ 0.104,+ "So the quick test works in space too."+ ],+ [+ 2.617,+ "A subspace must hold the zero vector."+ ],+ [+ 5.417,+ "Watch the plane slide."+ ],+ [+ 6.836,+ "Right side one: the sum gives two, not one."+ ],+ [+ 9.909,+ "Off."+ ],+ [+ 10.729,+ "Right side zero: the plane passes through the origin, and the sum stays in."+ ],+ [+ 15.768,+ "Minus one: the sum gives minus two."+ ],+ [+ 18.893,+ "Off again."+ ],+ [+ 19.844,+ "A plane is a subspace exactly when it passes through the origin."+ ]+ ]+ },+ "q2": {+ "dur": 3.72,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Your turn."+ ],+ [+ 0.964,+ "Slide the plane until it's a subspace."+ ]+ ]+ },+ "line": {+ "dur": 40.152,+ "marks": {+ "line": 2.878,+ "u": 10.625,+ "w": 14.102,+ "add": 18.906,+ "two": 26.029,+ "why": 29.753,+ "name": 36.12+ },+ "cues": [+ [+ 0.104,+ "Planes aren't the only flat things in space."+ ],+ [+ 2.878,+ "Take every multiple of one vector, t times two, one, minus one."+ ],+ [+ 8.464,+ "That's a line through the origin."+ ],+ [+ 10.625,+ "u is one multiple of it, the vector itself."+ ],+ [+ 14.102,+ "w is minus two times it: minus four, minus two, two."+ ],+ [+ 18.906,+ "Their sum is minus two, minus one, one: minus one times the vector."+ ],+ [+ 24.87,+ "Still on the line."+ ],+ [+ 26.029,+ "And two u is two times the vector: still on the line."+ ],+ [+ 29.753,+ "A multiple plus a multiple is a multiple, and a multiple of a multiple is a multiple."+ ],+ [+ 36.12,+ "So every line through the origin is a subspace of R three."+ ]+ ]+ },+ "lineoff": {+ "dur": 37.848,+ "marks": {+ "shift": 6.576,+ "u": 12.07,+ "w": 13.646,+ "add": 17.188,+ "test": 20.352,+ "off": 30.182,+ "zero": 31.198,+ "name": 34.258+ },+ "cues": [+ [+ 0.091,+ "Now move the same line up, so it starts from zero, zero, two instead of the origin."+ ],+ [+ 6.576,+ "Every point is zero, zero, two plus t times the vector."+ ],+ [+ 12.07,+ "u is two, one, one."+ ],+ [+ 13.646,+ "w is minus two, minus one, three."+ ],+ [+ 17.188,+ "Their sum is zero, zero, four."+ ],+ [+ 20.352,+ "Is that on the line?"+ ],+ [+ 21.576,+ "Its first number is zero, so t must be zero, and then the point would be zero, zero, two, not zero, zero, four."+ ],+ [+ 30.182,+ "Off the line."+ ],+ [+ 31.198,+ "And the line never passes through the zero vector."+ ],+ [+ 34.258,+ "A line that misses the origin is not a subspace."+ ]+ ]+ },+ "q3": {+ "dur": 5.016,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn."+ ],+ [+ 1.042,+ "Change the starting point until the line is a subspace."+ ]+ ]+ },+ "small": {+ "dur": 18.192,+ "marks": {+ "z": 2.5,+ "name": 10.117,+ "all": 11.38,+ "name2": 16.38+ },+ "cues": [+ [+ 0.117,+ "The smallest and the biggest again."+ ],+ [+ 2.5,+ "The zero vector alone: zero plus zero is zero, and any number times zero is zero."+ ],+ [+ 10.117,+ "A subspace."+ ],+ [+ 11.38,+ "And all of R three, which holds every sum and every multiple."+ ],+ [+ 16.38,+ "A subspace of itself."+ ]+ ]+ },+ "list": {+ "dur": 37.224,+ "marks": {+ "z": 3.49,+ "l": 5.169,+ "p": 7.422,+ "r3": 9.635,+ "why": 10.99,+ "one": 12.214,+ "two": 16.341,+ "three": 26.706,+ "so": 34.661+ },+ "cues": [+ [+ 0.104,+ "So here is every subspace of space."+ ],+ [+ 3.49,+ "The zero vector alone."+ ],+ [+ 5.169,+ "Any line through the origin."+ ],+ [+ 7.422,+ "Any plane through the origin."+ ],+ [+ 9.635,+ "And all of R three."+ ],+ [+ 10.99,+ "Why nothing else?"+ ],+ [+ 12.214,+ "A subspace with a vector u that is not zero holds its whole line."+ ],+ [+ 16.341,+ "Add a vector w off that line, and it holds every c u plus d w: a whole plane through the origin, like the flat sheet in chapter fourteen."+ ],+ [+ 26.706,+ "Add a third vector off that plane, and the combinations fill all of space, as three columns did in chapter fourteen."+ ],+ [+ 34.661,+ "Point, line, plane, or everything."+ ]+ ]+ },+ "q4": {+ "dur": 3.048,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.107,+ "Which set is not a subspace?"+ ]+ ]+ },+ "wrap": {+ "dur": 27.792,+ "marks": {+ "w1": 1.003,+ "w2": 6.862,+ "w3": 14.245,+ "w4": 18.047,+ "end": 25.586+ },+ "cues": [+ [+ 0.104,+ "To sum up."+ ],+ [+ 1.003,+ "The test in space is the same: every sum and every multiple must stay inside."+ ],+ [+ 6.862,+ "A plane through the origin is a subspace: each vector gives zero, so sums and multiples do too."+ ],+ [+ 14.245,+ "A plane or a line that misses the origin is not."+ ],+ [+ 18.047,+ "The subspaces of R three are the zero vector, the lines and planes through the origin, and R three itself."+ ],+ [+ 25.586,+ "Now try the chapter practice."+ ]+ ]+ },+ "final1": {+ "dur": 4.056,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Chapter practice."+ ],+ [+ 1.562,+ "Is the set a subspace of R three?"+ ]+ ]+ },+ "final2": {+ "dur": 3.216,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Next, add the vectors and test the sum."+ ]+ ]+ },+ "final3": {+ "dur": 2.808,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Now some sums and multiples to work out."+ ]+ ]+ },+ "final4": {+ "dur": 2.664,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Last set."+ ],+ [+ 1.224,+ "Make it with your hands."+ ]+ ]+ },+ "play": {+ "dur": 12.192,+ "marks": {+ "go": 4.076+ },+ "cues": [+ [+ 0.104,+ "Playground."+ ],+ [+ 1.081,+ "Nothing here is marked right or wrong."+ ],+ [+ 4.076,+ "Slide the plane, tilt it, move u and w, change c and d, turn the picture, and watch the ring."+ ]+ ]+ },+ "finish": {+ "dur": 10.68,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Well done."+ ],+ [+ 1.12,+ "That's the end of chapter thirty-nine, subspaces of space."+ ],+ [+ 5.221,+ "Next: the column space, the subspace made by the columns of a matrix."+ ]+ ]+ }+};diff --git a/site/linear-algebra/ch39/audio/en/why0.mp3 b/site/linear-algebra/ch39/audio/en/why0.mp3new file mode 100644index 0000000..8b64a99Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/why0.mp3 differdiff --git a/site/linear-algebra/ch39/audio/en/wrap.mp3 b/site/linear-algebra/ch39/audio/en/wrap.mp3new file mode 100644index 0000000..075c875Binary files /dev/null and b/site/linear-algebra/ch39/audio/en/wrap.mp3 differdiff --git a/site/linear-algebra/ch39/index.html b/site/linear-algebra/ch39/index.htmlnew file mode 100644index 0000000..0a13cad--- /dev/null+++ b/site/linear-algebra/ch39/index.html@@ -0,0 +1,421 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>Subspaces of 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/space3.js"></script>+<script src="../lib/play.js"></script>+<script src="audio/en/timings.js"></script>+<script>+'use strict';+const CHAPTER = { number: 39, title: 'Subspaces of Space', minutes: 11, language: 'en', next: '../ch40/' };++/* ---------- chapter drawing helpers ---------- */+const [GREEN, VIOLET] = S3_COLS; // u green, w violet; the set S blue (an equation's plane, or a line)+const SETC = COL.whole;+const VIEW = { yaw: 30, pitch: 24 }; // chapter 11's view: the origin's corner faces us+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 });+// 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 });+ return {+ sb,+ eq: eq ? sb.eq({ x: 90, y: 200, size: 44, o }) : null,+ u: sb.vec('u', { x: 90, y: 345, size: 32, o }),+ w: sb.vec('w', { x: 340, y: 345, size: 32, o }),+ cu: sb.check('u', { x: 90, y: 452, size: 24, o }),+ cw: sb.check('w', { x: 340, y: 452, size: 24, o }),+ combo: sb.combo({ x: 90, y: 560, size: 32, o }),+ out: sb.readout({ x: 90, y: 680, size: 30, o }),+ };+};+// A dashed ring at a point in space: a target (amber) or a mark.+const ring3 = (V, q, label, color = COL.task, into) => {+ const d = V.point(q, { color, r: 16, label, size: 26, into: into ?? V.content, 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 small flat plane with one set drawn on it (the plane's subspaces, recalled).+const thumb = (p, cx, cy, label, draw_, t0) => {+ const g = G(p, { o: 0 });+ const P2 = plane(g, { cx, cy, u: 16, x0: -4, x1: 4, y0: -4, y1: 4, t0: 0, labels: false });+ draw_(G(P2.g, {}), P2.PX, P2.PY);+ T(g, label, { x: cx, y: cy + 4 * 16 + 52, size: 24, fill: COL.chalk, weight: 600, anchor: 'middle' });+ show(g, t0, .5);+ return g;+};++/* ---------- practice data ---------- */+const YN = [['y', 'Yes', null, 'Y'], ['n', 'No', null, 'N']];+const SETQ = [+ { parts: ['the plane ', $m('x + y + z = 0')], ans: ['y'], why: 'Right side 0: through the origin. Sums give 0 + 0, multiples c·0.' },+ { parts: ['the plane ', $m('x + y + z = 1')], ans: ['n'], why: '(0, 0, 0) gives 0, not 1: no zero vector.' },+ { parts: ['the z-axis'], ans: ['y'], why: 'Every multiple of (0, 0, 1): a line through the origin.' },+ { parts: ['the floor, ', $m('z = 0')], ans: ['y'], why: 'The plane 0x + 0y + z = 0, through the origin.' },+ { parts: ['the plane ', $m('z = 2')], ans: ['n'], why: '(0, 0, 2) + (0, 0, 2) = (0, 0, 4): z is 4, not 2.' },+ { parts: ['every multiple ', $m('t·(1, 2, 3)')], ans: ['y'], why: 'A line through the origin: multiples add to multiples.' },+ { parts: ['the line ', $m('(1, 0, 0) + t·(0, 1, 0)')], ans: ['n'], why: 'Every point has x = 1, so (0, 0, 0) is not on it.' },+ { parts: ['the single point ', $m('(1, 1, 1)')], ans: ['n'], why: '2·(1, 1, 1) = (2, 2, 2) is not in it.' },+];+const SUMQ = [+ ['x + y + z = 0', [1, 2, -3], [2, -1, -1], q => q[0] + q[1] + q[2]],+ ['2x − y + z = 0', [1, 2, 0], [1, 3, 1], q => 2 * q[0] - q[1] + q[2]],+ ['x + y + z = 3', [1, 1, 1], [3, 0, 0], q => q[0] + q[1] + q[2]],+ ['x − z = 2', [2, 5, 0], [3, -1, 1], q => q[0] - q[2]],+].map(([eq, u, w, f]) => {+ const s = u.map((x, j) => x + w[j]), val = f(s), br = q => `(${q.map(num).join(', ')})`;+ console.assert(f(u) === f(w), 'SUMQ: u and w in one plane', eq);+ return { eq, gives: f(u), parts: [`${eq}: u = ${br(u)}, w = ${br(w)}. u + w = (`, { box: String(s[0]) }, ', ', { box: String(s[1]) }, ', ', { box: String(s[2]) }, '), left side ', { box: String(val) }],+ why: `u + w = ${br(s)}, which gives ${num(val)}. ${val === f(u) ? 'In the plane.' : `The plane needs ${num(f(u))}: off it.`}`,+ hint: 'Add the three pairs of numbers. Then put the sum into the left side of the equation.' };+});+const RULEQ = [+ { parts: ['u = (1, −2, 3) is in a subspace, so −2u = (', { box: '-2' }, ', ', { box: '4' }, ', ', { box: '-6' }, ') is too'], why: '−2 times each number.', hint: 'Multiply each number of u by −2.' },+ { parts: ['u = (1, 0, 2), w = (0, 1, 1): so u + 2w = (', { box: '1' }, ', ', { box: '2' }, ', ', { box: '4' }, ') is too'], why: '2w = (0, 2, 2); then (1, 0, 2) + (0, 2, 2) = (1, 2, 4).', hint: 'First 2w, then add u.' },+ { parts: ['x + 2y − z = k is a subspace exactly when k = ', { box: '0' }], why: 'Only then does (0, 0, 0) lie on it.', hint: 'Put (0, 0, 0) into x + 2y − z.' },+ { parts: ['every vector on 3x + y + z = 5 gives 5: u + w gives ', { box: '10' }, ', 2u gives ', { box: '10' }], why: '5 + 5 = 10 and 2 · 5 = 10: both leave the plane.', hint: 'A sum gives the sum of what each gives; 2u gives twice what u gives.' },+ { parts: ['on the line t·(1, 2, 2), the point (3, 6, 6) has t = ', { box: '3' }], why: '3·(1, 2, 2) = (3, 6, 6).', hint: 'What times 1 is 3?' },+];++/* ---------- beats ---------- */+const BEATS = [+ ['intro', 'Subspaces of space', (m, D) => {+ const g = G(scene, { o: 0, y: 24 });+ T(g, 'Unit 5, Chapter 39', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });+ T(g, 'Subspaces of 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, 'in three dimensions: lines and planes through the origin', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });+ // a tilted sheet through the origin with two arrows in it and their sum, still in it+ const lg = G(scene, { x: 800, y: 680, o: 0 });+ path(lg, 'M-260 40L-60 -70L260 -40L60 70Z', { fill: SETC, 'fill-opacity': .18, stroke: SETC, 'stroke-width': 3 });+ const arr = (x0, y0, x1, y1, color) => {+ 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': 5, 'stroke-linejoin': 'round' }, { d: 0 });+ };+ const a1 = arr(0, 0, 110, -40, GREEN), a2 = arr(110, -40, 170, 30, VIOLET), a3 = arr(0, 0, 170, 30, COL.chalk);+ show(lg, m('sub') + .8, .5); draw(a1, m('sub') + 1.2, .6); draw(a2, m('move') + .3, .6); draw(a3, m('move') + 1.1, .6);+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);+ }],++ ['recap', 'From the plane to space', (m) => {+ const p = S.p = panel(0);+ text(p, 'From the plane to space', 60, 110, .2, { size: 40, weight: 600 });+ const th = G(p, {});+ thumb(th, 980, 330, 'the zero vector', (g, PX, PY) => mk('circle', { cx: PX(0), cy: PY(0), r: 8, fill: SETC }, g), m('z'));+ thumb(th, 1190, 330, 'a line through 0', (g, PX, PY) => path(g, `M${PX(-4)} ${PY(-2)}L${PX(4)} ${PY(2)}`, { stroke: SETC, 'stroke-width': 5 }), m('l'));+ thumb(th, 1400, 330, 'the whole plane', (g, PX, PY) => mk('rect', { x: PX(-4), y: PY(4), width: PX(4) - PX(-4), height: PY(-4) - PY(4), fill: SETC, 'fill-opacity': .2 }, g), m('p'));+ text(p, 'subspaces of R²', 1190, 200, m('z'), { size: 30, fill: COL.dim, anchor: 'middle', weight: 600 });+ hide(th, m('space') - .3, .4); hide(p.lastChild, m('space') - .3, .4);+ const sb = S.sb = sub3(p, { set: 'all', u: [2, 1, 0], w: [-1, 1, 2], show: [], t0: m('space') + .2 });+ sb.V.sway(5, 16, m('space'));+ text(p, 'R³: vectors with three numbers', 90, 210, m('space') + .4, { size: 32, fill: SETC, weight: 600 });+ const tt = G(p, { o: 0 });+ T(tt, 'the test, as before:', { x: 90, y: 320, size: 30, fill: COL.dim, weight: 600 });+ 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);+ text(p, 'R³ is a subspace of itself', 90, 540, m('sp') + 4, { size: 30, fill: COL.good, weight: 700 });+ }],++ ['plane0', 'A plane through the origin', (m) => {+ const p = S.p = panel(0);+ text(p, 'Test 1: the plane x + y + z = 0', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { u: [1, 0, -1], w: [0, 2, -2] }), sb = S.sb = B.sb;+ sb.V.sway(5, 16);+ sb.plane.fade(0, 0, 0); show(B.eq, .3); sb.show('set', m('eq'), .8);+ text(p, 'right side 0: through the origin', 90, 256, m('eq') + 4, { size: 26, fill: COL.dim });+ show(B.u, m('u')); sb.show('u', m('u') + .2); show(B.cu, m('u') + 2.4);+ show(B.w, m('w')); sb.show('w', m('w') + .2); show(B.cw, m('w') + 2.6);+ show(B.combo, m('add'));+ ['0', '1', '2'].forEach((j, i) => { sb.flash('u' + j, m('add') + .6 + i * .8); sb.flash('w' + j, m('add') + .6 + i * .8); });+ sb.show('dw', m('pic')); sb.show('sum', m('pic') + 2.4);+ show(B.out, m('test')); bump(sb, m('on') + .2);+ sb.hide(['dw', 'w'], m('two') - .3, .3); hide(B.cw, m('two') - .3, .3);+ sb.to({ c: 2, d: 0 }, m('two'), 1.3); sb.flash('c', m('two'));+ sb.to({ c: -1 }, m('neg'), 1.3); sb.flash('c', m('neg'));+ sb.to({ c: 0 }, m('zero'), 1.1); sb.flash('c', m('zero'));+ }],++ ['why0', 'Why it always works', (m) => {+ 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') + .8); pulseG(B.cw, m('each') + 1.6);+ const n1 = text(p, 'u + w gives 0 + 0 = 0', 90, 790, m('sum') + 1, { size: 30, weight: 600 });+ const n2 = text(p, 'c·u gives c · 0 = 0', 430, 790, m('mult'), { size: 30, weight: 600 });+ sb.to({ u0: 2, u1: -1 }, m('drag') + .2, 1.2); sb.to({ w0: -1, w1: 2 }, m('drag') + 1.6, 1.2); sb.to({ u0: 1, u1: 1 }, m('drag') + 3, 1.2);+ sb.V.turn({ yaw: VIEW.yaw + 25 }, m('drag'), 3); sb.V.turn({ yaw: VIEW.yaw }, m('drag') + 3.2, 2);+ hide(n1, m('name') - .2, .3); hide(n2, m('name') - .2, .3);+ text(p, 'x + y + z = 0 is a subspace of R³', 90, 790, m('name') + 1, { size: 32, fill: COL.good, weight: 700 });+ }],++ ['ex2', 'Another plane through the origin', (m) => {+ const p = S.p = panel(0);+ text(p, 'Test 2: the plane x + 2y + z = 0', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { u: [1, 0, -1], w: [0, 2, -2], o: 1, show: ['u', 'w'] }), sb = S.sb = B.sb;+ sb.V.sway(5, 16);+ hide(B.combo, 0, 0); hide(B.out, 0, 0);+ sb.to({ n1: 2, u0: 2, u1: -1, u2: 0, w0: -1, w1: 2, w2: -3 }, m('turn'), 1.8); sb.flash('n1', m('turn'));+ pulseG(B.cu, m('u') + .5); pulseG(B.cw, m('w') + .5);+ const bk = G(p, { o: 0 });+ T(bk, 'chapter 14: columns 1 and 2 of the lecture’s matrix,', { x: 90, y: 790, size: 26, fill: COL.dim, weight: 600 });+ T(bk, 'and this plane was their flat sheet', { x: 90, y: 828, size: 26, fill: COL.dim, weight: 600 });+ show(bk, m('back'), .5); hide(bk, m('same') - .3, .3);+ show(B.combo, m('add'), .5); sb.show(['dw', 'sum'], m('add') + .3); show(B.out, m('add') + 1.6); bump(sb, m('add') + 3);+ sb.hide(['dw', 'u'], m('neg') - .3, .3); hide(B.cu, m('neg') - .3, .3);+ sb.to({ c: 0, d: -1 }, m('neg'), 1.3); sb.flash('d', m('neg'));+ text(p, 'every plane through the origin is a subspace', 90, 790, m('same') + 3, { size: 30, fill: COL.good, weight: 700 });+ }],++ ['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;+ [B.combo, B.out].forEach(e => put(e, { o: 0 }));+ sb.V.sway(4, 18);+ }, { ask: done => quiz(CARD, [{+ id: 'c-sum', prompt: ['In the plane ', $m('2x − y + z = 0'), ': add ', $m('u'), ' and ', $m('w'), ', then put the sum into ', $m('2x − y + z'), '.'],+ build: blanks([+ { parts: ['u + w = (', { box: '1' }, ', ', { box: '3' }, ', ', { box: '1' }, ')'], why: '1 + 0, 2 + 1, 0 + 1.', hint: 'Add the tops, the middles, the bottoms.',+ fx: () => { const sb = S.sb; [sb.A.dw.g, sb.A.sum.g, sb.ring].forEach((e, i) => fx(e, { o: 1 }, .1 + i * .3, .5)); } },+ { parts: ['2·1 − 3 + 1 = ', { box: '0' }], why: 'Zero: the sum is in the plane.', hint: '2 − 3 is −1. Then add 1.', fx: () => fx(S.B.out, { o: 1 }, .1, .5) },+ ]),+ }], done) }],++ ['off', 'A plane that misses the origin', (m) => {+ const p = S.p = panel(0);+ text(p, 'Test 3: the plane x + y + z = 3', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { plane: [1, 1, 1, 3], u: [2, 1, 0], w: [2, 0, 1] }), sb = S.sb = B.sb;+ sb.V.sway(5, 16);+ show(B.eq, .3); text(p, 'right side 3: misses the origin', 90, 256, .8, { size: 26, fill: COL.dim });+ show(B.u, m('u')); sb.show('u', m('u') + .2); show(B.cu, m('u') + 1.8);+ show(B.w, m('w')); sb.show('w', m('w') + .2); show(B.cw, m('w') + 1);+ show(B.combo, m('add')); sb.show(['dw', 'sum'], m('add') + .4);+ show(B.out, m('test')); bump(sb, m('off') + .2);+ const why = text(p, 'u gives 3, w gives 3: u + w gives 3 + 3 = 6', 90, 790, m('why') + .5, { size: 30, weight: 600 });+ hide(why, m('mult') - .3, .3);+ sb.hide(['dw', 'w'], m('mult') - .3, .3); hide(B.cw, m('mult') - .3, .3);+ sb.to({ c: 2, d: 0 }, m('mult'), 1.3); sb.flash('c', m('mult'));+ sb.to({ c: 0 }, m('zero'), 1.1); sb.flash('c', m('zero'));+ const o = ring3(sb.V, [0, 0, 0], '', COL.bad); put(o.e, { o: 0 }); show(o.e, m('zero') + 1.2, .4);+ text(p, '(0, 0, 0) gives 0, not 3', 90, 790, m('zero') + 1, { size: 30, weight: 600 });+ text(p, 'x + y + z = 3 is not a subspace', 90, 838, m('name'), { size: 32, fill: COL.bad, weight: 700 });+ }],++ ['slide', 'Slide the plane', (m) => {+ const p = S.p = panel(0);+ text(p, 'The quick test: the origin', 60, 110, .2, { size: 40, weight: 600 });+ const B = S.B = testBoard(p, { plane: [1, 1, 1, 3], u: [2, 1, 0], w: [2, 0, 1], o: 1, show: ['u', 'w', 'dw', 'sum'] }), sb = S.sb = B.sb;+ sb.V.sway(5, 16);+ text(p, 'a subspace holds (0, 0, 0)', 90, 790, m('zero'), { size: 30, weight: 600 });+ sb.to({ k: 1 }, m('k1') - .3, 1.3); sb.flash('k', m('k1'));+ sb.to({ k: 0 }, m('k0') - .2, 1.3); sb.flash('k', m('k0'));+ sb.to({ k: -1 }, m('kn') - .2, 1.3); sb.flash('k', m('kn'));+ text(p, 'a plane is a subspace exactly when it passes through 0', 90, 838, m('rule'), { size: 28, fill: COL.good, weight: 700 });+ sb.to({ k: 0 }, m('rule') + .4, 1.4);+ }],++ ['q2', 'Your turn', () => {+ const p = panel(0);+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });+ const sb = S.sb = sub3(p, { plane: [1, 2, -1, 4], u: [2, 2, 2], w: [0, 1, -2], show: ['u', 'w', 'dw', 'sum'], range: { k: [-8, 8] } });+ sb.eq({ x: 90, y: 200, size: 44 });+ S.B = { sb, out: sb.readout({ x: 90, y: 300, size: 30 }) };+ }, { ask: done => quiz({ ...CARD, y: 410 }, [{+ id: 'c-slide', prompt: ['Slide the plane until it is a subspace: drag it by its edge, or change its right side.'],+ build: sub3Task(S.sb, v => v.k === 0, 'Right side 0: x + 2y − z = 0 passes through the origin, and every sum stays in it.',+ v => `Right side ${num(v.k)}: the plane misses (0, 0, 0). What does (0, 0, 0) give?`, () => S.sb.set({ k: 0 }), { only: ['k'], drag: [] }),+ }], done) }],++ ['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;+ 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 });+ show(L.g, m('line'), .5); sb.setG && put(sb.setG, { o: 0 }); show(sb.setG, m('line') + .3, .6);+ show(B.u, m('u')); sb.show('u', m('u') + .2); show(B.cu, m('u') + .8);+ show(B.w, m('w')); sb.show('w', m('w') + .2); show(B.cw, m('w') + 1.6);+ show(B.combo, m('add')); sb.show(['dw', 'sum'], m('add') + .4); show(B.out, m('add') + 1.6); bump(sb, m('add') + 3);+ sb.hide(['dw', 'w'], m('two') - .3, .3); hide(B.cw, m('two') - .3, .3);+ sb.to({ c: 2, d: 0 }, m('two'), 1.3); sb.flash('c', m('two'));+ text(p, 'a multiple + a multiple = a multiple', 90, 790, m('why'), { size: 30, weight: 600 });+ text(p, 'every line through the origin is a subspace', 90, 838, m('name'), { size: 30, fill: COL.good, weight: 700 });+ }],++ ['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));+ 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);+ 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 });+ show(t1, m('test') + 2, .5); bump(sb, m('off'));+ hide(t1, m('zero') - .3, .3);+ const o = ring3(sb.V, [0, 0, 0], '', COL.bad); put(o.e, { o: 0 }); show(o.e, m('zero'), .4);+ text(p, 'it never passes through (0, 0, 0)', 90, 790, m('zero') + .3, { size: 28, weight: 600 });+ text(p, 'a line that misses the origin is not a subspace', 90, 838, m('name'), { size: 30, fill: COL.bad, weight: 700 });+ }],++ ['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'] });+ 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);+ }, { ask: done => quiz({ ...CARD, y: 500 }, [{+ id: 'c-line', prompt: ['Change the starting point (the first column) until the line is a subspace.'],+ build: sub3Task(S.sb, (v, sb) => sb.inSet([0, 0, 0]), 'Now (0, 0, 0) is on the line, so it is a line through the origin: a subspace. (Starting at (0, 0, 0) works, and so does any multiple of (2, 1, −1).)',+ 'The line still misses (0, 0, 0). Try the starting point (0, 0, 0).', () => S.sb.set({ p0: 0, p1: 0, p2: 0 }), { only: ['p0', 'p1', 'p2'], drag: [] }),+ }], done) }],++ ['small', 'The smallest and the biggest', (m) => {+ const p = S.p = panel(0);+ 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 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 });+ [[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));+ 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);+ text(p, 'all of R³', 90, 210, m('all') + .2, { size: 34, fill: SETC, weight: 600 });+ [[2, -1], [-1, 1]].forEach(([cc, d], i) => sb.to({ c: cc, d }, m('all') + 1.6 + i * 1.3, 1));+ text(p, 'a subspace of itself', 90, 640, m('name2'), { size: 30, fill: COL.good, weight: 700 });+ }],++ ['list', 'Every subspace of space', (m) => {+ const p = S.p = panel(0);+ text(p, 'Every subspace of space', 60, 110, .2, { size: 40, weight: 600 });+ const sb = S.sb = sub3(p, { set: 'zero', u: [0, 0, 0], w: [0, 0, 0], c: 1, d: 0, show: [], t0: .3 });+ sb.V.sway(6, 18);+ const L = (str, y, t) => { const g = G(p, { o: 0 }); mk('circle', { cx: 104, cy: y - 10, r: 8, fill: SETC }, g); T(g, str, { x: 130, y, size: 30, weight: 600 }); show(g, t, .5); return g; };+ L('the zero vector alone', 210, m('z'));+ sb.kind('line', m('l')); sb.to({ e0: 2, e1: 1, e2: -1, u0: 2, u1: 1, u2: -1 }, m('l') + .05, .01);+ L('any line through the origin', 262, m('l'));+ sb.kind('plane', m('p')); sb.to({ n0: 1, n1: -1, n2: 1, k: 0, u0: 2, u1: 1, u2: -1, w0: 0, w1: 1, w2: 1 }, m('p') + .05, .01);+ L('any plane through the origin', 314, m('p'));+ sb.kind('all', m('r3'));+ L('all of R³', 366, m('r3'));+ text(p, 'why nothing else?', 90, 450, m('why'), { size: 30, fill: COL.dim, weight: 600 });+ // one vector: its line; a second off it: a plane; a third off that: everything+ sb.kind('line', m('one') - .1); sb.show(['u', 'sum'], m('one') + .2); sb.multiples(m('one') + 1);+ sb.to({ c: -1.5 }, m('one') + 1.6, 1.2); sb.to({ c: 1.5 }, m('one') + 2.9, 1.4);+ text(p, 'one vector u ≠ 0 → its whole line', 90, 520, m('one') + .5, { size: 28, weight: 600 });+ sb.kind('plane', m('two')); sb.multiples(m('two'), false);+ sb.show(['w', 'dw'], m('two') + .3);+ [[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'));+ 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 });+ }],++ ['q4', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const sb = S.sb = sub3(p, { plane: [0, 0, 1, 1], u: [2, 0, 1], w: [0, 2, 1], show: [] });+ sb.V.sway(6, 16);+ }, { ask: done => quiz({ x: 40, y: 200, w: 720, cls: 'side' }, [{+ id: 'c-not', prompt: ['Which set is ', h('b', '', ['not']), ' a subspace of ', $m('R³'), '? (The picture shows one of them.)'],+ build: choice([['the plane ', $m('x + y + z = 0')], ['the z-axis'], ['the plane ', $m('z = 1')], ['all of ', $m('R³')]], 2,+ 'z = 1 misses the origin: (0, 0, 0) gives 0, not 1. And (0, 0, 1) + (0, 0, 1) = (0, 0, 2) leaves it.',+ ['Right side 0: it passes through the origin, and it is a subspace.', 'The z-axis is every multiple of (0, 0, 1): a line through the origin, a subspace.', '',+ 'All of space holds every sum and multiple: a subspace of itself.']),+ }], done) }],++ ['wrap', 'Summary', (m) => {+ const p = panel(0);+ [['The test in space is the same: every sum and every multiple stays inside.', 'w1'],+ ['A plane through the origin is a subspace: sums give 0 + 0, multiples c · 0.', 'w2'],+ ['A plane or a line that misses the origin is not.', 'w3'],+ ['Subspaces of R³: the zero vector, lines and planes through 0, R³ itself.', '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: 34, weight: 600 });+ tw(g, { o: 1, x: 0 }, m(mark), .6);+ });+ }],+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{+ id: 'p-sets', prompt: ['Is the set a subspace of ', $m('R³'), '?'],+ build: grid(SETQ, YN, { multi: false, text: true }),+ }], done, 'Chapter practice · set 1 of 4') }],+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-sums', prompt: ['u and w are in the plane. Add them, then put the sum into the left side.'],+ build: blanks(SUMQ),+ }, {+ id: 'p-planes', prompt: ['So which of these planes are subspaces?'],+ build: grid(SUMQ.map(q => ({ parts: [$m(q.eq)], ans: [q.gives === 0 ? 'y' : 'n'], why: q.gives === 0 ? 'Right side 0: through the origin.' : `Right side ${num(q.gives)}: it misses the origin; the sum gave twice ${num(q.gives)}.` })), YN, { multi: false, text: true }),+ }], done, 'Chapter practice · set 2 of 4') }],+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-rule', prompt: ['Sums and multiples stay inside a subspace. Work them out.'],+ build: blanks(RULEQ),+ }], done, 'Chapter practice · set 3 of 4') }],+ ['final4', 'Chapter practice', () => {+ const p = panel(0);+ text(p, 'Make it', 60, 110, .2, { size: 40, weight: 600 });+ const sb = S.sb = sub3(p, { plane: [1, 1, 1, 2], u: [1, 1, 0], w: [0, 1, 1], show: [] });+ sb.V.sway(4, 18);+ S.B = { sb, eq: sb.eq({ x: 90, y: 200, size: 44 }) };+ }, { ask: done => quiz({ ...CARD, y: 495 }, [{+ id: 'p-plane', prompt: ['Make the plane a subspace that holds both amber points, ', $m('(1, 0, 1)'), ' and ', $m('(0, 1, 1)'), '.'],+ build: (body, api) => {+ const L = qlayer(), V = S.sb.V, rg = G(V.content, {});+ ring3(V, [1, 0, 1], '(1, 0, 1)', COL.task, rg); ring3(V, [0, 1, 1], '(0, 1, 1)', COL.task, rg);+ S.rg = rg;+ return sub3Task(S.sb, v => v.k === 0 && v.n0 + v.n2 === 0 && v.n1 + v.n2 === 0 && (v.n0 || v.n1 || v.n2),+ 'x + y − z = 0 (or a multiple): right side 0, and both points give 1 − 1 = 0.',+ v => v.k !== 0 ? 'A subspace passes through the origin: make the right side 0.' : `(1, 0, 1) gives ${num(v.n0 + v.n2)} and (0, 1, 1) gives ${num(v.n1 + v.n2)}; both must give 0. Try −1 in front of z.`,+ () => S.sb.set({ n0: 1, n1: 1, n2: -1, k: 0 }), { drag: [] })(body, api);+ },+ }, {+ id: 'p-reach', prompt: ['In the plane ', $m('x + y + z = 0'), ', find ', $m('c'), ' and ', $m('d'), ' so that ', $m('cu + dw'), ' lands on the amber ring.'],+ build: (body, api) => {+ if (S.rg) S.rg.remove();+ S.sb.set({ n0: 1, n1: 1, n2: 1, k: 0, u0: 1, u1: -1, u2: 0, w0: 1, w1: 0, w2: -1, c: 1, d: 1 });+ ['u', 'w', 'dw', 'sum'].forEach(id => put(S.sb.A[id].g, { o: 1 })); put(S.sb.ring, { o: 1 });+ ring3(S.sb.V, [1, 2, -3], '(1, 2, −3)', COL.task);+ if (!S.combo) S.combo = S.sb.combo({ x: 90, y: 400, size: 30 });+ return sub3Task(S.sb, v => { const s = S.sb.calc().sum; return s[0] === 1 && s[1] === 2 && s[2] === -3; }, 'c = −2, d = 3: −2·(1, −1, 0) + 3·(1, 0, −1) = (1, 2, −3).',+ () => { const s = S.sb.calc().sum; return `c u + d w = (${s.map(S3_fmt).join(', ')}). The middle number is −c and the bottom is −d: read c and d off the ring.`; },+ () => S.sb.set({ c: -2, d: 3 }), { only: ['c', 'd'], 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 B = S.B = testBoard(p, { u: [1, 0, -1], w: [0, 2, -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, { y: -110 }); put(B.out, { y: -150 });+ text(p, 'try: slide it off the origin · tilt it · make c negative', 90, 256, m('go'), { size: 24, fill: COL.dim });+ }, { ask: playAsk(() => S.sb, { pos: { x: 40, y: 590, w: 720, cls: 'side' }, tip: 'Your test in space: change anything, drag the plane or a tip, turn the picture. Green ring: c u + d w stays in.' }) }],+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));++boot();+</script>+</body>+</html>diff --git a/site/linear-algebra/ch40/audio/en/ax.mp3 b/site/linear-algebra/ch40/audio/en/ax.mp3new file mode 100644index 0000000..609ffd1Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/ax.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/decide.mp3 b/site/linear-algebra/ch40/audio/en/decide.mp3new file mode 100644index 0000000..5c80ab7Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/decide.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/final1.mp3 b/site/linear-algebra/ch40/audio/en/final1.mp3new file mode 100644index 0000000..04be330Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/final1.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/final2.mp3 b/site/linear-algebra/ch40/audio/en/final2.mp3new file mode 100644index 0000000..552b37dBinary files /dev/null and b/site/linear-algebra/ch40/audio/en/final2.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/final3.mp3 b/site/linear-algebra/ch40/audio/en/final3.mp3new file mode 100644index 0000000..3ba1e48Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/final3.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/final4.mp3 b/site/linear-algebra/ch40/audio/en/final4.mp3new file mode 100644index 0000000..dac5446Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/final4.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/finish.mp3 b/site/linear-algebra/ch40/audio/en/finish.mp3new file mode 100644index 0000000..e163ec0Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/finish.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/intro.mp3 b/site/linear-algebra/ch40/audio/en/intro.mp3new file mode 100644index 0000000..a34f2cfBinary files /dev/null and b/site/linear-algebra/ch40/audio/en/intro.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/name.mp3 b/site/linear-algebra/ch40/audio/en/name.mp3new file mode 100644index 0000000..bb774f3Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/name.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/plane.mp3 b/site/linear-algebra/ch40/audio/en/plane.mp3new file mode 100644index 0000000..9a8aaa2Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/plane.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/play.mp3 b/site/linear-algebra/ch40/audio/en/play.mp3new file mode 100644index 0000000..62488cbBinary files /dev/null and b/site/linear-algebra/ch40/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/q1.mp3 b/site/linear-algebra/ch40/audio/en/q1.mp3new file mode 100644index 0000000..e478c94Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/q1.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/q2.mp3 b/site/linear-algebra/ch40/audio/en/q2.mp3new file mode 100644index 0000000..9c5af44Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/q2.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/q3.mp3 b/site/linear-algebra/ch40/audio/en/q3.mp3new file mode 100644index 0000000..a45d193Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/q3.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/q4.mp3 b/site/linear-algebra/ch40/audio/en/q4.mp3new file mode 100644index 0000000..f1a5c56Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/q4.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/recap.mp3 b/site/linear-algebra/ch40/audio/en/recap.mp3new file mode 100644index 0000000..9b54075Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/recap.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/rows.mp3 b/site/linear-algebra/ch40/audio/en/rows.mp3new file mode 100644index 0000000..42e9825Binary files /dev/null and b/site/linear-algebra/ch40/audio/en/rows.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/shapes.mp3 b/site/linear-algebra/ch40/audio/en/shapes.mp3new file mode 100644index 0000000..2cd76cfBinary files /dev/null and b/site/linear-algebra/ch40/audio/en/shapes.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/sub.mp3 b/site/linear-algebra/ch40/audio/en/sub.mp3new file mode 100644index 0000000..c30af3dBinary files /dev/null and b/site/linear-algebra/ch40/audio/en/sub.mp3 differdiff --git a/site/linear-algebra/ch40/audio/en/timings.js b/site/linear-algebra/ch40/audio/en/timings.jsnew file mode 100644index 0000000..7a14733--- /dev/null+++ b/site/linear-algebra/ch40/audio/en/timings.js@@ -0,0 +1,631 @@+window.TIMINGS = {+ "intro": {+ "dur": 12.888,+ "marks": {+ "sub": 2.852,+ "move": 8.125+ },+ "cues": [+ [+ 0.104,+ "Chapter forty."+ ],+ [+ 1.367,+ "The column space."+ ],+ [+ 2.852,+ "Every matrix carries a subspace with it: all the combinations of its columns."+ ],+ [+ 8.125,+ "And that subspace tells you exactly which right sides b you can solve for."+ ]+ ]+ },+ "recap": {+ "dur": 20.496,+ "marks": {+ "cols": 2.005,+ "sheet": 6.732,+ "reach": 12.904,+ "now": 16.797+ },+ "cues": [+ [+ 0.091,+ "Remember chapter fourteen."+ ],+ [+ 2.005,+ "We took 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."+ ],+ [+ 12.904,+ "So A x equals b could be solved only when b was on the sheet."+ ],+ [+ 16.797,+ "That sheet is a subspace, and today it gets its name."+ ]+ ]+ },+ "name": {+ "dur": 36.864,+ "marks": {+ "c1": 5.547,+ "c2": 8.333,+ "mix": 13.672,+ "m11": 19.049,+ "m1n": 21.628,+ "many": 25.339,+ "name": 31.328+ },+ "cues": [+ [+ 0.117,+ "Here is the matrix from the lecture."+ ],+ [+ 2.591,+ "A has three rows and two columns."+ ],+ [+ 5.547,+ "Column one is one, two, four."+ ],+ [+ 8.333,+ "Column two is three, three, one."+ ],+ [+ 11.25,+ "Each column is a vector in R three."+ ],+ [+ 13.672,+ "Now take every combination, x times column one plus y times column two."+ ],+ [+ 19.049,+ "One and one gives four, five, five."+ ],+ [+ 21.628,+ "One and minus one gives minus two, minus one, three."+ ],+ [+ 25.339,+ "Whole numbers, fractions, negatives: let x and y be anything."+ ],+ [+ 31.328,+ "All these combinations together are called the column space of A."+ ],+ [+ 35.365,+ "We write it C of A."+ ]+ ]+ },+ "sub": {+ "dur": 44.616,+ "marks": {+ "two": 3.776,+ "add": 13.32,+ "mix": 15.312,+ "mult": 25.638,+ "zero": 34.948,+ "yes": 38.646+ },+ "cues": [+ [+ 0.091,+ "Is the column space a subspace?"+ ],+ [+ 2.734,+ "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."+ ],+ [+ 13.32,+ "Their sum is two, four, eight."+ ],+ [+ 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."+ ],+ [+ 24.167,+ "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.948,+ "And zero times both columns gives the zero vector."+ ],+ [+ 38.646,+ "So sums and multiples never leave."+ ],+ [+ 41.667,+ "The column space is always a subspace."+ ]+ ]+ },+ "plane": {+ "dur": 30.24,+ "marks": {+ "two": 1.367,+ "fill": 6.628,+ "edge": 15.0,+ "back": 20.807,+ "not": 25.781+ },+ "cues": [+ [+ 0.104,+ "What shape is it?"+ ],+ [+ 1.367,+ "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."+ ],+ [+ 15.0,+ "Turn the picture to look along the plane: it shrinks to a line, and both columns lie in it."+ ],+ [+ 20.807,+ "For this A, C of A is a plane through the origin in R three."+ ],+ [+ 25.781,+ "It's not all of R three: most vectors in space are off this plane."+ ]+ ]+ },+ "q1": {+ "dur": 5.088,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.133,+ "Compute A times x, a vector in the column space."+ ]+ ]+ },+ "ax": {+ "dur": 40.968,+ "marks": {+ "eqs": 1.25,+ "cols": 13.867,+ "always": 19.167,+ "so": 21.888,+ "and": 27.266,+ "rule": 35.612+ },+ "cues": [+ [+ 0.091,+ "Now the big point."+ ],+ [+ 1.25,+ "A x equals b is three equations with two unknowns."+ ],+ [+ 5.925,+ "x plus three y equals b one."+ ],+ [+ 8.62,+ "Two x plus three y equals b two."+ ],+ [+ 11.523,+ "Four x plus y equals b three."+ ],+ [+ 13.867,+ "Read down the columns: A x is x times column one plus y times column two."+ ],+ [+ 19.167,+ "So A x is always in the column space."+ ],+ [+ 21.888,+ "That means A x equals b can be solved only when b is in C of A."+ ],+ [+ 27.266,+ "And when b is in C of A, it is some combination of the columns, and that combination's x and y solve the equations."+ ],+ [+ 35.612,+ "A x equals b is solvable exactly when b is in the column space of A."+ ]+ ]+ },+ "rows": {+ "dur": 37.776,+ "marks": {+ "rows": 2.266,+ "b1": 11.81,+ "meet": 16.81,+ "off": 25.286,+ "slide": 28.867,+ "on": 34.622+ },+ "cues": [+ [+ 0.104,+ "Let's see it in both pictures at once."+ ],+ [+ 2.266,+ "With two unknowns, each equation is a line in the x y plane: blue for the first, coral for the second, yellow for the third."+ ],+ [+ 11.81,+ "Take b equals four, five, five."+ ],+ [+ 14.414,+ "In space, b sits on the plane."+ ],+ [+ 16.81,+ "And down here, the three lines meet at one point, one, one."+ ],+ [+ 21.419,+ "That point is the mix: x equals one, y equals one."+ ],+ [+ 25.286,+ "Now lift b off the plane: four, five, six."+ ],+ [+ 28.867,+ "Only the third line slides."+ ],+ [+ 30.99,+ "The three lines no longer share a point."+ ],+ [+ 33.411,+ "No solution."+ ],+ [+ 34.622,+ "Put b back on the plane, and the lines meet again."+ ]+ ]+ },+ "decide": {+ "dur": 61.152,+ "marks": {+ "e12": 5.234,+ "ey": 11.146,+ "ex1": 13.659,+ "t1": 23.099,+ "ex2": 29.831,+ "t2": 42.161,+ "ex3": 47.227,+ "t3": 53.177,+ "no": 57.656+ },+ "cues": [+ [+ 0.104,+ "How can you tell without a picture?"+ ],+ [+ 1.914,+ "Solve two equations, then test the third."+ ],+ [+ 5.234,+ "Subtract the first equation from the second: x equals b two minus b one."+ ],+ [+ 11.146,+ "Then the first equation gives y."+ ],+ [+ 13.659,+ "For b equals four, five, five: x equals five minus four, one."+ ],+ [+ 19.102,+ "Then one plus three y equals four, so y is one."+ ],+ [+ 23.099,+ "Test the third: four times one plus one is five."+ ],+ [+ 26.784,+ "Yes, it matches b three."+ ],+ [+ 28.763,+ "Solvable."+ ],+ [+ 29.831,+ "For b equals minus two, minus one, three: x equals minus one minus minus two, which is one."+ ],+ [+ 37.695,+ "One plus three y equals minus two, so y is minus one."+ ],+ [+ 42.161,+ "Third: four minus one is three."+ ],+ [+ 44.987,+ "It matches."+ ],+ [+ 46.172,+ "Solvable."+ ],+ [+ 47.227,+ "For b equals one, two, three: x is one, y is zero."+ ],+ [+ 53.177,+ "Third: four times one plus zero is four, not three."+ ],+ [+ 57.656,+ "No solution: b is not in the column space."+ ]+ ]+ },+ "q2": {+ "dur": 5.976,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn."+ ],+ [+ 1.068,+ "Change only the bottom number of b until A x equals b can be solved."+ ]+ ]+ },+ "shapes": {+ "dur": 47.352,+ "marks": {+ "floor": 3.255,+ "line": 20.365,+ "all": 36.38+ },+ "cues": [+ [+ 0.104,+ "Different matrices have different column spaces."+ ],+ [+ 3.255,+ "Take columns one, zero, zero and zero, one, zero."+ ],+ [+ 8.177,+ "Their combinations are every vector with bottom number zero: the floor."+ ],+ [+ 12.812,+ "C of A is the floor, so A x equals b is solvable exactly when b three is zero."+ ],+ [+ 20.365,+ "Now take columns one, one, one and two, two, two."+ ],+ [+ 24.258,+ "Column two is twice column one, so every combination is a multiple of one, one, one."+ ],+ [+ 31.992,+ "C of A is just a line."+ ],+ [+ 33.646,+ "Only b's on that line can be solved."+ ],+ [+ 36.38,+ "And in chapter fourteen, three columns that point in three truly different directions filled all of space: C of A was R three, and every b could be solved."+ ]+ ]+ },+ "q3": {+ "dur": 3.936,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.159,+ "For each matrix, which b can be reached?"+ ]+ ]+ },+ "q4": {+ "dur": 3.36,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.094,+ "What shape is this column space?"+ ]+ ]+ },+ "wrap": {+ "dur": 25.944,+ "marks": {+ "w1": 1.016,+ "w2": 5.443,+ "w3": 11.172,+ "w4": 16.146,+ "end": 24.01+ },+ "cues": [+ [+ 0.104,+ "To sum up."+ ],+ [+ 1.016,+ "The column space C of A is every combination of the columns of A."+ ],+ [+ 5.443,+ "It's always a subspace: sums and multiples of combinations are combinations."+ ],+ [+ 11.172,+ "A x equals b can be solved exactly when b is in the column space."+ ],+ [+ 16.146,+ "It can be a point, a line, a plane, or all of space."+ ],+ [+ 19.805,+ "For the lecture's A, it's a plane through the origin in R three."+ ],+ [+ 24.01,+ "Now try the chapter practice."+ ]+ ]+ },+ "final1": {+ "dur": 4.056,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Chapter practice."+ ],+ [+ 1.497,+ "Compute vectors in the column space."+ ]+ ]+ },+ "final2": {+ "dur": 2.76,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Next."+ ],+ [+ 0.99,+ "Is b in the column space?"+ ]+ ]+ },+ "final3": {+ "dur": 2.208,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Now find the mix that reaches b."+ ]+ ]+ },+ "final4": {+ "dur": 2.784,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Last set."+ ],+ [+ 1.211,+ "Move b with your hands."+ ]+ ]+ },+ "play": {+ "dur": 10.992,+ "marks": {+ "go": 4.01+ },+ "cues": [+ [+ 0.104,+ "Playground."+ ],+ [+ 1.12,+ "Nothing here is marked right or wrong."+ ],+ [+ 4.01,+ "Move b, change the mix, change the columns, turn the picture, and watch the three lines below."+ ]+ ]+ },+ "finish": {+ "dur": 11.4,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Well done."+ ],+ [+ 1.12,+ "That's the end of chapter forty, the column space, and the end of unit five."+ ],+ [+ 6.628,+ "Next: unit six, and a second subspace, the nullspace."+ ]+ ]+ }+};diff --git a/site/linear-algebra/ch40/audio/en/wrap.mp3 b/site/linear-algebra/ch40/audio/en/wrap.mp3new file mode 100644index 0000000..5845aefBinary files /dev/null and b/site/linear-algebra/ch40/audio/en/wrap.mp3 differdiff --git a/site/linear-algebra/ch40/index.html b/site/linear-algebra/ch40/index.htmlnew file mode 100644index 0000000..5e7de7e--- /dev/null+++ b/site/linear-algebra/ch40/index.html@@ -0,0 +1,375 @@+<!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/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' };++/* ---------- 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 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;+};+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]), V = cs.V;+ 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 }));+ const F = S.F = cs.form({ x: 90, 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) > 8)) 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;+ [...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);+ 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 });+ 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], [1, 1]].forEach(([x, y], i) => cs.to({ x0: x, x1: y }, m('fill') + .8 + i * 1.3, 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 + 152, 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'));+ }],++ ['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 });+ say(st, ['(1): y = (b₁ − x) / 3'], 90, 418, m('ey'), { size: 30 });+ 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);+ 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);+ 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);+ 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'));+ }],++ ['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 } });+ 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: [] }),+ }], 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);+ cs.form({ x: 90, y: 260, size: 32 });+ put(cs.CAline.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 the column space? (x = b₂ − b₁, y = (b₁ − x)/3, then test 4x + y = b₃.)'],+ 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: { ...ROWS2, cx: 660, cy: 690 } });+ 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 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 } });+ 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 });+ }, { 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>diff --git a/site/linear-algebra/lib/space3.js b/site/linear-algebra/lib/space3.jsindex 1b5b9e0..130c09e 100644--- a/site/linear-algebra/lib/space3.js+++ b/site/linear-algebra/lib/space3.js@@ -828,3 +828,716 @@ const lin3Task = (sys, test, why, hint, reveal, keys = null) => (body, api) => {hint: [kbd('Tab'), 'pick a number', kbd('↑'), kbd('↓'), 'change it; drag the picture to turn it'],};};++/* ---------- numbers and columns you can scrub, for the components below ---------- */+// 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)]; }+ const r = Math.round(n * 10) / 10;+ return [num(r) + (Number.isInteger(r) ? DECIMAL_SIGN + '0' : '')];+}+const S3_fmt = n => S3_parts(n).map(x => typeof x === 'string' ? x : x.f.join('/')).join('');+const S3_pp = n => n < -1e-9 ? ['(', ...S3_parts(n), ')'] : S3_parts(n); // a number inside a sum: 1 + (−4)+// One number on screen that the reader can scrub (drag sideways, or focus it and press ↑/↓), as in vecs and lin3.+// ctx: { v, edit(to), live() → bool, can(key) → bool, step(key), clamp(key, n), slots: [] }.+// coef: a number in front of a letter; a 1 there is not written (−1 is "−") unless the reader can scrub it.+// pf: v → parts, for a computed number (no box).+// abs: the number's size only (a later term, whose sign is drawn before it).+function S3_slot(g, key, x, y, ctx, { size = 40, fill = COL.chalk, w = size * 1.6, anchor = 'middle', coef = false, pf = null, abs = false } = {}) {+ const scrub = !pf, svg = $('stage');+ const bx = anchor === 'middle' ? x - w / 2 : anchor === 'end' ? x - w : x;+ const box = scrub ? mk('rect', { x: bx, y: y - size * .95, width: w, height: size * 1.3, rx: 10, fill: 'transparent' }, g) : null;+ const ink = G(g, {}); ink.style.pointerEvents = 'none'; ink.setAttribute('color', fill);+ let shown = '';+ const s = {+ key, box, ink, fill, coef, held: false,+ 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);+ 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 });+ },+ paint(on) {+ if (!box) return;+ const ok = on && ctx.can(key);+ box.style.cursor = ok ? 'ew-resize' : '';+ box.style.touchAction = ok ? 'none' : '';+ box.setAttribute('stroke', ok ? COL.faint : 'none');+ box.setAttribute('stroke-dasharray', '4 6');+ if (ok) box.setAttribute('tabindex', 0); else box.removeAttribute('tabindex');+ if (coef && s.held !== ok) { s.held = ok; s.set(); }+ },+ };+ if (box) {+ box.setAttribute('aria-label', key);+ let drag = null;+ const snapTo = n => Math.round(n / ctx.step(key)) * ctx.step(key);+ box.addEventListener('pointerdown', e => {+ if (!ctx.live() || !ctx.can(key)) return;+ e.preventDefault();+ drag = { x: e.clientX, from: snapTo(ctx.v[key]) };+ box.setPointerCapture(e.pointerId);+ });+ box.addEventListener('pointermove', e => {+ if (!drag) return;+ const k = svg.getScreenCTM().a;+ ctx.edit({ [key]: ctx.clamp(key, drag.from + Math.round((e.clientX - drag.x) / k / 22) * ctx.step(key)) });+ });+ const end = () => { drag = null; };+ box.addEventListener('pointerup', end);+ box.addEventListener('lostpointercapture', end);+ box.addEventListener('keydown', e => {+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); box.blur(); P.keys?.(e); return; } // Enter checks, as in an answer box+ if (!ctx.live() || !ctx.can(key)) return;+ const dd = { ArrowUp: 1, ArrowRight: 1, ArrowDown: -1, ArrowLeft: -1 }[e.key];+ if (!dd) return;+ e.preventDefault(); e.stopPropagation(); // the player's ←/→ must not leave the beat+ ctx.edit({ [key]: ctx.clamp(key, snapTo(ctx.v[key]) + dd * ctx.step(key)) });+ });+ }+ ctx.slots.push(s);+ s.set();+ return s;+}+// 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 } = {}) {+ const rh = size * 1.18, top = y - rh - size * .95, bot = y + rh + size * .38, x0 = x - w / 2, x1 = x + w / 2;+ path(g, `M${x0 + 12} ${top}H${x0}V${bot}H${x0 + 12}M${x1 - 12} ${top}H${x1}V${bot}H${x1 - 12}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });+ [0, 1, 2].forEach(i => S3_slot(g, keys?.[i], x, y + (i - 1) * rh, ctx, { size, fill, w: w - 14, pf: pf?.[i] }));+ return { g, w };+}++/* ---------- the subspace test in space ---------- */+// A set S in space drawn in blue (row 1's colour: S is an equation's plane, or a line), two vectors u and w kept inside+// S, the numbers c and d, and the combination c·u + d·w from the origin with a ring at its tip: green while it stays in+// S, red once it leaves. One state (sb.v), so the numbers and the picture move together: scrub any number, drag a tip+// (it slides in S), drag the plane by its edge (it slides along its normal, k follows), orbit by dragging empty space.+// set: 'plane' n0·x + n1·y + n2·z = k 'line' every p + t·e (through the origin when p = 0)+// 'zero' the zero vector alone 'all' every vector of space+// const sb = subspace3(p, { set, plane: [n0, n1, n2, k], line: { dir: e, at: p }, u, w, c, d, space: { cx, cy, size, range, yaw, pitch } })+// state sb.v = { n0 n1 n2 k e0 e1 e2 p0 p1 p2 u0 u1 u2 w0 w1 w2 c d }+// sb.eq({ x, y, size }) the plane's equation, scrubbable, with a blue bar+// sb.lineRow({ x, y, size }) the line: [p] + t·[e] (or t·[e] when p is 0 and nothing moves it), scrubbable+// sb.vec('u' | 'w', { x, y, size }) u = [ ] as a column; sb.combo({ x, y, size }) c u + d w = [ ]+// sb.check(id, { x, y, size }) one vector ('u', 'w', 'sum') put into S's rule, live, with ✓ or ✗+// sb.readout({ x, y, size }) the test of c u + d w with the verdict in words+// sb.kind(name, t0); sb.ok(); sb.inSet(q); sb.calc() → { cu, dw, sum }; sb.multiples(t0, on)+// sb.to / set / onChange / flash / num / show / hide (ids: 'u', 'w', 'cv', 'dw', 'sum', 'set')+// sb.live(on, { only: keys, drag: ['u', 'w'], slide: true }); sub3Task(sb, test, why, hint, reveal, opts)+function subspace3(p, { set = 'plane', plane: N0 = [1, 1, 1, 0], line: L0 = { dir: [1, 2, 2], at: [0, 0, 0] }, u = [1, 0, -1], w = [0, 1, -1], c = 1, d = 1,+ space: so = {}, show: shown = ['u', 'w', 'dw', 'sum'], t0 = .1, snap = 1, range = {} } = {}) {+ const V = space3(p, { t0, ...so }), R = V.R, SET = COL.whole, I = [0, 1, 2], listeners = [], slots = [];+ // the kind of set is part of the state (v.kind, an index into KINDS): a move planned for later uses the set it will be then+ const KINDS = ['plane', 'line', 'zero', 'all'], kindOf = s => KINDS[Math.round(s.kind)] ?? 'plane';+ let live = false, only = null, dragOn = ['u', 'w'], slideOn = true;+ const v = { c, d, k: N0[3], kind: KINDS.indexOf(set) }, K = () => kindOf(v);+ I.forEach(j => { v['n' + j] = N0[j]; v['e' + j] = L0.dir[j]; v['p' + j] = (L0.at ?? [0, 0, 0])[j]; v['u' + j] = u[j]; v['w' + j] = w[j]; });+ const vec = (n, s = v) => I.map(j => s[n + j]);+ const nrm = (s = v) => vec('n', s), nOK = s => Math.hypot(...nrm(s)) > 1e-9, eOK = s => Math.hypot(...vec('e', s)) > 1e-9;+ const calc = (s = v) => { const cu = vec('u', s).map(x => s.c * x), dw = vec('w', s).map(x => s.d * x); return { cu, dw, sum: cu.map((x, j) => x + dw[j]) }; };+ const inSet = (q, s = v) => {+ const kind = kindOf(s);+ if (kind === 'all') return true;+ if (kind === 'zero') return Math.hypot(...q) < 1e-6;+ if (kind === 'plane') return nOK(s) && Math.abs(S3_dot(nrm(s), q) - s.k) < 1e-6 * (1 + Math.abs(s.k));+ const r = q.map((x, j) => x - s['p' + j]), e = vec('e', s);+ return eOK(s) ? Math.hypot(...S3_cross(r, e)) < 1e-6 * (1 + Math.hypot(...r)) : Math.hypot(...r) < 1e-6;+ };+ // The coordinate of a point that is solved for on the plane: not one just changed, the largest |n_j| among the rest.+ const dep = (s, n, changed) => {+ const free = I.filter(j => !changed.includes(n + j) && Math.abs(s['n' + j]) > 1e-9);+ const pool = free.length ? free : I.filter(j => Math.abs(s['n' + j]) > 1e-9);+ return pool.reduce((a, j) => Math.abs(s['n' + j]) > Math.abs(s['n' + a]) ? j : a, pool[0]);+ };+ const fix = (s, changed = []) => {+ const kind = kindOf(s);+ for (const n of ['u', 'w']) {+ if (kind === 'zero') I.forEach(j => { s[n + j] = 0; });+ else if (kind === 'plane' && nOK(s)) {+ const j = dep(s, n, changed);+ s[n + j] = (s.k - I.filter(i => i !== j).reduce((t, i) => t + s['n' + i] * s[n + i], 0)) / s['n' + j] || 0;+ } else if (kind === 'line' && eOK(s)) {+ const e = vec('e', s), pt = vec('p', s), q = vec(n, s), ch = I.find(j => changed.includes(n + j) && Math.abs(e[j]) > 1e-9 && !I.some(i => i !== j && changed.includes(n + i)));+ const t = ch !== undefined ? (q[ch] - pt[ch]) / e[ch] : S3_dot(q.map((x, j) => x - pt[j]), e) / S3_dot(e, e);+ I.forEach(j => { s[n + j] = pt[j] + t * e[j] || 0; });+ }+ }+ };+ fix(v);+ let plan = { ...v };+ const RANGE = key => range[key] ?? (key === 'c' || key === 'd' ? [-5, 5] : key === 'k' ? [-12, 12] : /^[ne]/.test(key) ? [-6, 6] : [-R, R]);+ const ctx = {+ v, slots, live: () => live,+ can: key => key in v && (!only || only.includes(key)),+ step: key => key === 'c' || key === 'd' ? 1 : snap,+ clamp: (key, n) => Math.max(RANGE(key)[0], Math.min(RANGE(key)[1], n)),+ edit: to => edit(to),+ };++ /* ---------- the picture ---------- */+ const setG = G(V.content, {}), planeIt = V.plane(0, 0, 0, 0, { color: SET, fo: .2, into: V.polys });+ const lineIt = V.seg(null, null, { color: SET, w: 6, into: setG });+ lineIt.e.setAttribute('stroke-linecap', 'round');+ const zeroIt = V.point(null, { color: SET, r: 12, into: setG });+ const faces = []; // 'all': the cube's faces, faintly+ for (const j of I) for (const sgn of [-1, 1]) {+ const a = (j + 1) % 3, b = (j + 2) % 3, q = (x, y) => { const r = [0, 0, 0]; r[j] = sgn * R; r[a] = x; r[b] = y; return r; };+ faces.push(V.poly([q(-R, -R), q(R, -R), q(R, R), q(-R, R)], { color: SET, fo: .05, w: 0 }));+ }+ const multL = V.seg(null, null, { color: COL.chalk, w: 2.5, dash: '8 9', into: setG });+ const multG = G(setG, { o: 0 }); multG.append(multL.e);+ const COLR = { u: S3_COLS[0], w: S3_COLS[1], cv: S3_COLS[0], dw: S3_COLS[1], sum: COL.chalk };+ const arrG = G(V.content, {}), A = {};+ for (const id of ['cv', 'dw', 'u', 'w', 'sum']) {+ const g = G(arrG, { o: shown.includes(id) ? 1 : 0 });+ const a = V.arrow(null, null, { color: COLR[id], w: id === 'sum' ? 6 : 5, into: g, ...(id === 'cv' || id === 'dw' ? { dash: '10 8' } : {}) });+ const lab = V.point(null, { color: COLR[id], r: .1, label: '', size: 28, into: g, halo: true });+ A[id] = { g, a, lab };+ }+ const ringP = V.point(null, { color: COL.good, r: 17, into: arrG });+ const ringC = ringP.e.firstChild;+ Object.entries({ fill: 'none', 'stroke-width': 4 }).forEach(([k, x]) => ringC.setAttribute(k, x));+ const ring = G(arrG, { o: shown.includes('sum') ? 1 : 0 }); ring.append(ringP.e);+ const term = (k, n) => Math.abs(k - 1) < 1e-9 ? n : Math.abs(k + 1) < 1e-9 ? '−' + n : S3_fmt(k) + n;+ const nice = n => !S3_fmt(n).includes(DECIMAL_SIGN);+ const sumLabel = s => {+ if (!nice(s.c) || !nice(s.d)) return '';+ if (!s.c && !s.d) return '0';+ if (!s.d) return term(s.c, 'u');+ if (!s.c) return term(s.d, 'w');+ return `${term(s.c, 'u')} ${s.d < 0 ? '−' : '+'} ${term(Math.abs(s.d), 'w')}`;+ };++ // tip handles for u and w+ const tips = ['u', 'w'].map(n => {+ const g = G(V.content, {});+ mk('circle', { r: 22, fill: 'transparent' }, g);+ const rg = mk('circle', { r: 13, fill: 'none', stroke: COLR[n], 'stroke-width': 3, 'stroke-dasharray': '4 4' }, g);+ rg.style.opacity = 0; g.style.pointerEvents = 'none';+ g.setAttribute('aria-label', 'tip of ' + n);+ return { n, g, rg };+ });+ const planeHit = path(V.content, '', { stroke: 'transparent', 'stroke-width': 26, fill: 'none' });+ planeHit.style.pointerEvents = 'none';+ planeHit.setAttribute('aria-label', 'the plane');+ V.on(proj => {+ const d = planeIt.e.getAttribute('d');+ if (planeHit.getAttribute('d') !== d) planeHit.setAttribute('d', d);+ tips.forEach(t => { const q = proj(vec(t.n)); put(t.g, { x: Math.round(q[0] * 10) / 10, y: Math.round(q[1] * 10) / 10 }); });+ });++ function draw() {+ slots.forEach(s => s.set());+ planeIt.visible = K() === 'plane';+ planeIt.set(...nrm(), v.k);+ let la = null, lb = null;+ if (K() === 'line' && eOK(v)) { const e = vec('e'), L = Math.hypot(...e), pt = vec('p'), f = 6 * R / L; [la, lb] = S3_clipSeg(pt.map((x, j) => x - f * e[j]), pt.map((x, j) => x + f * e[j]), R) || [null, null]; }+ lineIt.set(la, lb);+ zeroIt.set(K() === 'zero' ? [0, 0, 0] : null);+ faces.forEach(f => { f.on = K() === 'all'; f.e.style.display = K() === 'all' ? '' : 'none'; });+ const uu = vec('u');+ const f = Math.hypot(...uu) > 1e-9 ? 6 * R / Math.hypot(...uu) : 0;+ multL.set(...(f && S3_clipSeg(uu.map(x => -f * x), uu.map(x => f * x), R) || [null, null]));+ const k = calc(), O = [0, 0, 0], ends = { u: [O, uu], w: [O, vec('w')], cv: [O, k.cu], dw: [k.cu, k.sum], sum: [O, k.sum] };+ for (const id in A) {+ const [a, b] = ends[id], L = Math.hypot(...b.map((x, j) => x - a[j]));+ A[id].a.set(L > 1e-6 ? a : null, L > 1e-6 ? b : null);+ A[id].lab.set(id === 'sum' || L > .3 ? b : null);+ A[id].lab.label(id === 'sum' ? sumLabel(v) : id === 'cv' ? (nice(v.c) && Math.abs(v.c - 1) > 1e-9 ? term(v.c, 'u') : '') : id === 'dw' ? (nice(v.d) && Math.abs(v.d - 1) > 1e-9 ? term(v.d, 'w') : '') : id);+ }+ ringP.set(k.sum);+ ringC.setAttribute('stroke', inSet(k.sum) ? COL.good : COL.bad);+ listeners.forEach(f => f(v, k));+ V.redraw();+ }+ function edit(to) {+ const changed = Object.keys(to).filter(key => v[key] !== to[key]);+ if (!changed.length) return;+ changed.forEach(key => { v[key] = to[key]; });+ fix(v, changed);+ draw();+ }++ /* ---------- dragging in space ---------- */+ // The point on the plane n·q = kk under the pointer: the screen point at depth t is affine in t, so one division finds it.+ const onPlane = (sx, sy, n, kk) => {+ const P0 = V.unproj(sx, sy, 0), P1 = V.unproj(sx, sy, 1).map((x, j) => x - P0[j]), den = S3_dot(n, P1);+ if (Math.abs(den) < 1e-9) return null;+ const t = (kk - S3_dot(n, P0)) / den;+ return P0.map((x, j) => x + t * P1[j]);+ };+ const snapTo = x => Math.round(x / snap) * snap;+ // Where a dragged tip lands in S, from the pointer's place on screen.+ const landing = (n, [sx, sy]) => {+ if (K() === 'zero') return null;+ if (K() === 'line') {+ if (!eOK(v)) return null;+ const pt = vec('p'), e = vec('e'), A0 = V.proj(pt), B0 = V.proj(pt.map((x, j) => x + e[j])), dx = B0[0] - A0[0], dy = B0[1] - A0[1], L2 = dx * dx + dy * dy;+ if (L2 < 1) return null;+ const t = snapTo(((sx - A0[0]) * dx + (sy - A0[1]) * dy) / L2), q = pt.map((x, j) => x + t * e[j]);+ return q.every(x => Math.abs(x) <= R + 1e-9) ? q : null;+ }+ const nn = K() === 'plane' ? nrm() : [0, 0, 1], kk = K() === 'plane' ? v.k : v[n + '2'];+ if (K() === 'plane' && !nOK(v)) return null;+ const q = onPlane(sx, sy, nn, kk);+ if (!q) return null;+ const j = I.reduce((a, i) => Math.abs(nn[i]) > Math.abs(nn[a]) ? i : a, 0);+ I.forEach(i => { if (i !== j) q[i] = Math.max(-R, Math.min(R, snapTo(q[i]))); });+ q[j] = (kk - I.filter(i => i !== j).reduce((t, i) => t + nn[i] * q[i], 0)) / nn[j];+ return Math.abs(q[j]) <= R + 1e-9 ? q : null;+ };+ const tipOK = n => live && dragOn.includes(n) && K() !== 'zero' && I.every(j => ctx.can(n + j));+ tips.forEach(({ n, g }) => {+ let on = false;+ g.addEventListener('pointerdown', e => { if (!tipOK(n)) return; e.preventDefault(); e.stopPropagation(); on = true; g.setPointerCapture(e.pointerId); });+ g.addEventListener('pointermove', e => { if (!on) return; const q = landing(n, V.local(e)); if (q) edit(Object.fromEntries(I.map(j => [n + j, q[j]]))); });+ const up = () => { on = false; };+ g.addEventListener('pointerup', up);+ g.addEventListener('lostpointercapture', up);+ // keys: ←/→ and ↑/↓ step the two free coordinates on a plane (or t along a line); in 'all' ←/→ x, ↑/↓ z, Shift+↑/↓ y+ g.addEventListener('keydown', e => {+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); g.blur(); P.keys?.(e); return; }+ if (!tipOK(n)) return;+ const lr = { ArrowLeft: -1, ArrowRight: 1 }[e.key], ud = { ArrowDown: -1, ArrowUp: 1 }[e.key];+ if (!lr && !ud) return;+ e.preventDefault(); e.stopPropagation();+ const q = vec(n);+ if (K() === 'line') { const pt = vec('p'), ee = vec('e'), t = snapTo(S3_dot(q.map((x, j) => x - pt[j]), ee) / S3_dot(ee, ee)) + (lr || ud) * snap; const r = pt.map((x, j) => x + t * ee[j]); if (r.every(x => Math.abs(x) <= R + 1e-9)) edit(Object.fromEntries(I.map(j => [n + j, r[j]]))); return; }+ const free = K() === 'plane' ? I.filter(j => j !== dep(v, n, [])) : [0, e.shiftKey ? 1 : 2];+ const j = lr ? free[0] : free[1];+ edit({ [n + j]: ctx.clamp(n + j, snapTo(q[j]) + (lr || ud) * snap) });+ });+ });+ // The plane slides along its normal: moving it by t·n raises k by t·|n|²; t from the pointer's motion along the normal+ // as drawn on screen (as lin3's planes).+ const slideOK = () => live && slideOn && K() === 'plane' && ctx.can('k');+ let sl = null;+ planeHit.addEventListener('pointerdown', e => {+ if (!slideOK()) return;+ e.preventDefault(); e.stopPropagation();+ const n = nrm(), c0 = planeIt.pts ? I.map(j => planeIt.pts.reduce((s, q) => s + q[j], 0) / planeIt.pts.length) : [0, 0, 0];+ const P0 = V.proj(c0), P1 = V.proj(c0.map((x, j) => x + n[j]));+ sl = { at: V.local(e), k0: v.k, n2: S3_dot(n, n), ns: [P1[0] - P0[0], P1[1] - P0[1]] };+ planeHit.setPointerCapture(e.pointerId);+ });+ planeHit.addEventListener('pointermove', e => {+ if (!sl) return;+ const [x, y] = V.local(e), t = ((x - sl.at[0]) * sl.ns[0] + (y - sl.at[1]) * sl.ns[1]) / Math.max(sl.ns[0] ** 2 + sl.ns[1] ** 2, 400);+ edit({ k: ctx.clamp('k', Math.round(sl.k0 + t * sl.n2)) });+ });+ const slEnd = () => { sl = null; };+ planeHit.addEventListener('pointerup', slEnd);+ planeHit.addEventListener('lostpointercapture', slEnd);+ planeHit.addEventListener('pointerenter', () => { if (slideOK()) planeIt.width(6); });+ planeHit.addEventListener('pointerleave', () => planeIt.width(3));++ /* ---------- the algebra on the left ---------- */+ const testParts = (q, short = false) => {+ if (K() === 'plane') {+ const out = [];+ I.forEach(j => {+ const a = v['n' + j];+ if (Math.abs(a) < 1e-9) return;+ const neg = a < 0, m = Math.abs(a), t = Math.abs(m - 1) < 1e-9 ? S3_pp(q[j]) : [...S3_parts(m), '·', ...S3_pp(q[j])];+ out.push(...(out.length ? [neg ? ' − ' : ' + '] : neg ? ['−'] : []), ...t);+ });+ return [...out, ' = ', ...S3_parts(S3_dot(nrm(), q))];+ }+ const col = q.map(S3_fmt).join(', ');+ if (K() === 'line') {+ const pt = vec('p'), e = vec('e'), r = q.map((x, j) => x - pt[j]), t = eOK(v) ? S3_dot(r, e) / S3_dot(e, e) : 0, off = Math.hypot(...pt) > 1e-9;+ if (short) return inSet(q) ? ['t = ', ...S3_parts(t)] : ['not on the line']; // one vector's check: which multiple it is+ return inSet(q) ? [off ? `(${col}) = (${pt.map(S3_fmt).join(', ')}) + ` : `(${col}) = `, ...S3_parts(t), `·(${e.map(S3_fmt).join(', ')})`] : [`(${col})`];+ }+ return [`(${col})`];+ };+ const verdict = (q, ok) => K() === 'plane' ? (ok ? `${S3_fmt(v.k)}, as the plane needs: in the plane ✓` : `not ${S3_fmt(v.k)}: off the plane ✗`)+ : K() === 'line' ? (ok ? 'on the line ✓' : 'not on the line ✗')+ : K() === 'zero' ? (ok ? 'the zero vector: still inside ✓' : 'not the zero vector: outside ✗')+ : 'a vector of space: inside ✓';+ const live_ = (g, f) => { let key = ''; const upd = () => { const k = f(null); const s = JSON.stringify(k[0]); if (s === key) return; key = s; g.replaceChildren(); k[1](); }; listeners.push(upd); upd(); return g; };+ const sb = {+ V, space: V, v, calc: () => calc(), inSet: q => inSet(q), ok: () => inSet(calc().sum), kindNow: K, A, ring, setG, plane: planeIt, line: lineIt, mult: multG, faces,+ to(next, at, dur = 1.2, ease = io) {+ const from = { ...plan };+ plan = { ...plan, ...next };+ fix(plan, Object.keys(next));+ const goal = { ...plan };+ prog(q => edit(Object.fromEntries(Object.keys(goal).map(k => [k, from[k] + (goal[k] - from[k]) * q]))), at, dur, ease);+ },+ set: to => edit(to),+ onChange(f) { listeners.push(f); f(v, calc()); },+ num: key => slots.filter(s => s.key === key).map(s => s.ink),+ flash(key, at) { slots.filter(s => s.key === key).forEach(s => { tw(s.ink, { c_color: COL.task }, at, .25); tw(s.ink, { c_color: s.fill }, at + 1.2, .6); }); },+ show(ids, at, dur = .5) { [].concat(ids).forEach(id => { show(id === 'set' ? setG : A[id].g, at, dur); if (id === 'sum') show(ring, at, dur); if (id === 'set') planeIt.fade(1, at, dur); }); },+ hide(ids, at, dur = .5) { [].concat(ids).forEach(id => { hide(id === 'set' ? setG : A[id].g, at, dur); if (id === 'sum') hide(ring, at, dur); if (id === 'set') planeIt.fade(0, at, dur); }); },+ kind(name, at) {+ const n = KINDS.indexOf(name);+ if (at === undefined) { plan.kind = n; edit({ kind: n }); } else sb.to({ kind: n }, at, 0);+ },+ multiples(at, on = true, dur = .6) { tw(multG, { o: on ? 1 : 0 }, at, dur); },+ 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;+ ['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');+ });+ 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 });+ draw();+ return g;+ },+ lineRow({ x = 90, y = 210, size: sz = 34, o = 1, at = true } = {}) {+ const g = G(p, { o }), w = sz * 2, gp = G(g, {});+ mk('rect', { x: x - 30, y: y - sz * .7, width: 8, height: sz * .8, rx: 4, fill: SET }, g);+ let cx = x;+ if (at) { S3_col(gp, ['p0', 'p1', 'p2'], cx + w / 2, y, ctx, { size: sz, w }); T(gp, '+', { x: cx + w + sz * .5, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' }); cx += w + sz; }+ const t = T(g, 't', { x: cx + sz * .2, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH }); t.setAttribute('font-style', 'italic');+ T(g, '·', { x: cx + sz * .7, y: y + sz * .3, size: sz, fill: COL.chalk, font: MATH });+ S3_col(g, ['e0', 'e1', 'e2'], cx + sz * 1.2 + w / 2, y, ctx, { size: sz, w, fill: SET });+ draw();+ return { g, at: gp };+ },+ 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] });+ 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');+ 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');+ 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])) });+ draw();+ return g;+ },+ check(id, { x = 90, y = 470, size: sz = 26, o = 1 } = {}) {+ const g = G(p, { o });+ return live_(g, () => {+ const q = id === 'sum' ? calc().sum : vec(id), ok = inSet(q), tp = testParts(q, id !== 'sum');+ return [[tp, ok, K()], () => { const e = M(g, tp, { x, y, size: sz, fill: COL.chalk, anchor: 'start' }); T(g, ok ? ' ✓' : ' ✗', { x: x + e._w, y, size: sz, fill: ok ? COL.good : COL.bad, weight: 700 }); }];+ });+ },+ readout({ x = 90, y = 680, size: sz = 32, o = 1 } = {}) {+ const g = G(p, { o });+ return live_(g, () => {+ const q = calc().sum, ok = inSet(q), tp = testParts(q), w = verdict(q, ok);+ return [[tp, w], () => { M(g, tp, { x, y, size: sz, fill: COL.chalk, anchor: 'start' }); T(g, w, { x, y: y + sz * 1.35, size: sz * .82, fill: ok ? COL.good : COL.bad, weight: 600 }); }];+ });+ },+ live(on, { only: keys = null, drag = ['u', 'w'], slide = true } = {}) {+ live = on; only = keys; dragOn = drag; slideOn = slide;+ V.live(on);+ slots.forEach(s => s.paint(on));+ tips.forEach(({ n, g, rg }) => {+ const ok = tipOK(n) && st(A[n].g).o > .3;+ g.style.pointerEvents = ok ? '' : 'none'; g.style.cursor = ok ? 'grab' : ''; rg.style.opacity = ok ? 1 : 0;+ if (ok) g.setAttribute('tabindex', 0); else g.removeAttribute('tabindex');+ });+ planeHit.style.pointerEvents = slideOK() ? '' : 'none';+ planeHit.style.cursor = slideOK() ? 'move' : '';+ },+ redraw: draw,+ };+ draw();+ return sb;+}++// A question that is a task on the 3D subspace test: the reader changes it until test(v, sb) holds, then checks.+const sub3Task = (sb, test, why, hint, reveal, opts) => (body, api) => {+ sb.live(true, opts);+ const say = f => typeof f === 'function' ? f(sb.v, sb) : f;+ return {+ check: () => { const ok = !!test(sb.v, sb); api.grade(ok, say(ok ? why : hint)); },+ reveal: () => { reveal?.(); return say(why); },+ lock: () => sb.live(false),+ hint: [kbd('Tab'), ' pick a number ', kbd('↑'), kbd('↓'), ' change it; drag a tip, the plane by its edge, or empty space to turn'],+ };+};++/* ---------- the column space of a 3 × 2 matrix ---------- */+// Two columns in space, everything they can make, C(A), and a target b. One state, cs.v = { a00 a01 a10 a11 a20 a21+// b0 b1 b2 x0 x1 } (x0, x1: the mix x, y). A changed mix (or A) moves b to A x, so b rides in C(A); a changed b solves+// for the mix again when b is in C(A) and leaves it when b is off (then no mix reaches b).+// Picture: column 1 green, column 2 violet, C(A) amber (where b can be: a plane, a line or the origin alone), b amber;+// the mix drawn tip to tail (x·col 1, then y·col 2, dashed) when it reaches b; when b is off C(A), a red ring on b and+// a dashed drop from b to C(A). b's tip and the columns' tips drag one axis at a time, as lin3's.+// const cs = colsp3(p, { A, b, space: { cx, cy, size, range, yaw, pitch }, rows2: { cx, cy, u, r } })+// cs.form({ x, y, size }) x·[col 1] + y·[col 2] = [b], every number scrubbable+// cs.eqs({ x, y, size }) the three equations a·x + b·y = bᵢ, with their row colours+// cs.readout({ x, y, size }) "x = 1, y = 1" (amber), "many mixes …" or "no mix: b is not in C(A)"+// rows2: the row picture: each equation a line in the x y plane (blue, coral, yellow), the mix a dot where all three meet+// cs.solve() → { x, y } | { many: true, x, y (one of them) } | { none: true }; cs.inC(q); cs.span() → 'plane' | 'line' | 'zero'+// cs.to / set / onChange / flash / num / live(on, { only: keys, drag: ['b', 0, 1] }); cs.cols, cs.bArrow, cs.CA, cs.R2+// csTask(cs, test, why, hint, reveal, opts): a hands-on question.+function colsp3(p, { A = [[1, 3], [2, 3], [4, 1]], b = [4, 5, 5], space: so = {}, rows2 = null, t0 = .1 } = {}) {+ const V = space3(p, { t0, ...so }), R = V.R, I = [0, 1, 2], J = [0, 1], listeners = [], slots = [], svg = $('stage');+ let live = false, only = null, dragOn = ['b', 0, 1];+ const v = { x0: 0, x1: 0 };+ I.forEach(i => { J.forEach(j => { v[`a${i}${j}`] = A[i][j]; }); v['b' + i] = b[i]; });+ const col = (j, s = v) => I.map(i => s[`a${i}${j}`]), bv = (s = v) => I.map(i => s['b' + i]);+ const Ax = (s = v) => I.map(i => s[`a${i}0`] * s.x0 + s[`a${i}1`] * s.x1);+ const nrm = (s = v) => S3_cross(col(0, s), col(1, s));+ const spanOf = s => Math.hypot(...nrm(s)) > 1e-9 ? 'plane' : Math.hypot(...col(0, s)) + Math.hypot(...col(1, s)) > 1e-9 ? 'line' : 'zero';+ const inC = (q, s = v) => {+ const k = spanOf(s), L = Math.hypot(...q);+ if (k === 'plane') return Math.abs(S3_dot(nrm(s), q)) < 1e-6 * (1 + Math.hypot(...nrm(s)) * L);+ if (k === 'line') { const e = Math.hypot(...col(0, s)) > 1e-9 ? col(0, s) : col(1, s); return Math.hypot(...S3_cross(q, e)) < 1e-6 * (1 + L * Math.hypot(...e)); }+ return L < 1e-6;+ };+ const solveOf = s => {+ const q = bv(s);+ if (!inC(q, s)) return { none: true };+ if (spanOf(s) !== 'plane') { // many mixes; one of them along the first column that is not zero+ const j = Math.hypot(...col(0, s)) > 1e-9 ? 0 : 1, c = col(j, s), t = Math.hypot(...c) > 1e-9 ? S3_dot(c, q) / S3_dot(c, c) : 0;+ return { many: true, x: j ? 0 : t, y: j ? t : 0, one: false };+ }+ const c0 = col(0, s), c1 = col(1, s), g00 = S3_dot(c0, c0), g01 = S3_dot(c0, c1), g11 = S3_dot(c1, c1), r0 = S3_dot(c0, q), r1 = S3_dot(c1, q), det = g00 * g11 - g01 * g01;+ const fix = n => Math.abs(n - Math.round(n)) < 1e-9 ? Math.round(n) : n;+ return { x: fix((r0 * g11 - g01 * r1) / det), y: fix((g00 * r1 - g01 * r0) / det) };+ };+ const derive = (s, changed) => {+ if (changed.some(k => k[0] === 'x' || k[0] === 'a')) I.forEach(i => { s['b' + i] = s[`a${i}0`] * s.x0 + s[`a${i}1`] * s.x1; });+ else if (changed.some(k => k[0] === 'b')) { const r = solveOf(s); if (r.x !== undefined) { s.x0 = r.x; s.x1 = r.y; } }+ };+ { const r = solveOf(v); if (r.x !== undefined) { v.x0 = r.x; v.x1 = r.y; } }+ const unique = r => r.x !== undefined && !r.many;+ let plan = { ...v };+ const RANGE = key => key[0] === 'b' ? [-R, R] : key[0] === 'x' ? [-6, 6] : [-9, 9];+ const ctx = {+ v, slots, live: () => live,+ can: key => key in v && (!only || only.includes(key)),+ step: () => 1,+ clamp: (key, n) => Math.max(RANGE(key)[0], Math.min(RANGE(key)[1], n)),+ edit: to => edit(to),+ };++ /* ---------- space ---------- */+ const CAg = G(V.content, {});+ const CA = V.plane(0, 0, 0, 0, { color: S3_B, fo: .08, w: 2, into: V.polys });+ const CAline = V.seg(null, null, { color: S3_B, w: 6, into: CAg });+ CAline.e.setAttribute('stroke-opacity', .55);+ const legs = J.map(j => V.arrow(null, null, { color: S3_COLS[j], w: 4, dash: '10 8' }));+ const drop = V.seg(null, null, { color: COL.bad, w: 3, dash: '5 6' });+ const bArrow = V.arrow(null, null, { color: S3_B, w: 9 });+ const cols = J.map(j => V.arrow(null, null, { color: S3_COLS[j] }));+ const badRing = V.point(null, { color: COL.bad, r: 17 });+ Object.entries({ fill: 'none', stroke: COL.bad, 'stroke-width': 4 }).forEach(([k, x]) => badRing.e.firstChild.setAttribute(k, x));+ const labs = ['col 1', 'col 2', 'b'].map((L, n) => V.point(null, { color: [...S3_COLS.slice(0, 2), S3_B][n], r: .1, label: L, size: 26, halo: true }));+ const guide = V.seg(null, null, { color: COL.chalk, w: 2, dash: '3 7' });+ const tipKeys = ['b', 0, 1], tipColor = [S3_B, ...S3_COLS.slice(0, 2)];+ const tipOf = k => k === 'b' ? bv() : col(k);+ const tips = tipKeys.map((k, n) => {+ const g = G(V.content, {});+ mk('circle', { r: 22, fill: 'transparent' }, g);+ const rg = mk('circle', { r: 13, fill: 'none', stroke: tipColor[n], 'stroke-width': 3, 'stroke-dasharray': '4 4' }, g);+ rg.style.opacity = 0; g.style.pointerEvents = 'none';+ g.setAttribute('aria-label', k === 'b' ? 'tip of b' : `tip of column ${k + 1}`);+ 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 row picture: three lines in the x y plane ---------- */+ let R2 = null;+ if (rows2) {+ const { cx, cy, u = 22, r = 6 } = rows2;+ const P2 = plane(p, { cx, cy, u, x0: -r, x1: r, y0: -r, y1: r, t0, step: 2 });+ const ls = I.map(i => path(P2.g, '', { stroke: S3_ROW[i], 'stroke-width': 4, 'stroke-linecap': 'round', fill: 'none' }));+ const dot = mk('circle', { r: 9, fill: COL.chalk, stroke: COL.board, 'stroke-width': 3 }, P2.g);+ R2 = { P: P2, lines: ls, dot, draw() {+ I.forEach(i => {+ const a = v[`a${i}0`], c = v[`a${i}1`], k = v['b' + i], pts = [];+ if (Math.abs(c) > 1e-9) for (const X of [-r, r]) { const Y = (k - a * X) / c; if (Y >= -r - 1e-9 && Y <= r + 1e-9) pts.push([X, Y]); }+ if (Math.abs(a) > 1e-9) for (const Y of [-r, r]) { const X = (k - c * Y) / a; if (X > -r + 1e-9 && X < r - 1e-9) pts.push([X, Y]); }+ const d = pts.length >= 2 ? `M${P2.PX(pts[0][0]).toFixed(1)} ${P2.PY(pts[0][1]).toFixed(1)}L${P2.PX(pts[1][0]).toFixed(1)} ${P2.PY(pts[1][1]).toFixed(1)}` : '';+ if (ls[i].getAttribute('d') !== d) ls[i].setAttribute('d', d);+ });+ const s = solveOf(v), on = unique(s) && Math.abs(s.x) <= r && Math.abs(s.y) <= r;+ dot.style.opacity = on ? 1 : 0;+ if (on) { dot.setAttribute('cx', P2.PX(s.x).toFixed(1)); dot.setAttribute('cy', P2.PY(s.y).toFixed(1)); }+ } };+ }++ function draw() {+ slots.forEach(s => s.set());+ const span = spanOf(v), n = nrm(), O = [0, 0, 0], q = bv(), on = inC(q);+ CA.visible = span === 'plane';+ CA.set(...n, 0);+ let la = null, lb = null;+ if (span === 'line') { const e = Math.hypot(...col(0)) > 1e-9 ? col(0) : col(1), f = 6 * R / Math.hypot(...e); [la, lb] = S3_clipSeg(e.map(x => -f * x), e.map(x => f * x), R) || [null, null]; }+ CAline.set(la, lb);+ J.forEach(j => cols[j].set(O, col(j)));+ bArrow.set(O, q);+ // the mix tip to tail, when it reaches b+ const m1 = col(0).map(x => x * v.x0), show_ = on && solveOf(v).x !== undefined; // with many mixes, the one along a column+ legs[0].set(show_ && Math.abs(v.x0) > 1e-9 ? O : null, m1);+ legs[1].set(show_ && Math.abs(v.x1) > 1e-9 ? m1 : null, q);+ // off C(A): a red ring on b and a dashed drop to the nearest point of C(A)+ let foot = null;+ if (!on) {+ if (span === 'plane') { const t = S3_dot(n, q) / S3_dot(n, n); foot = q.map((x, j) => x - t * n[j]); }+ else if (span === 'line') { const e = Math.hypot(...col(0)) > 1e-9 ? col(0) : col(1), t = S3_dot(q, e) / S3_dot(e, e); foot = e.map(x => t * x); }+ else foot = O;+ }+ drop.set(foot ? q : null, foot);+ badRing.set(on ? null : q);+ [col(0), col(1), q].forEach((t, i) => labs[i].set(Math.hypot(...t) > .2 ? t : null));+ R2?.draw();+ listeners.forEach(f => f(v, solveOf(v)));+ V.redraw();+ }+ function edit(to) {+ const changed = Object.keys(to).filter(key => v[key] !== to[key]);+ if (!changed.length) return;+ changed.forEach(key => { v[key] = to[key]; });+ derive(v, changed);+ draw();+ }++ /* ---------- tips: one axis per drag (as lin3) ---------- */+ const lattice = n => Math.max(-R, Math.min(R, Math.round(n))) || 0;+ const keysOf = k => k === 'b' ? I.map(i => 'b' + i) : I.map(i => `a${i}${k}`);+ const putTip = (k, q) => edit(Object.fromEntries(keysOf(k).map((key, i) => [key, q[i]])));+ const tipOK = k => live && dragOn.includes(k) && keysOf(k).every(ctx.can);+ tips.forEach(({ k, g }) => {+ let s = null;+ g.addEventListener('pointerdown', e => { if (!tipOK(k)) return; e.preventDefault(); e.stopPropagation(); s = { at: V.local(e), start: tipOf(k).map(lattice), axis: null }; g.setPointerCapture(e.pointerId); });+ g.addEventListener('pointermove', e => {+ if (!s) return;+ const [x, y] = V.local(e), dx = x - s.at[0], dy = y - s.at[1];+ if (s.axis === null) {+ const L = Math.hypot(dx, dy);+ if (L < 10) return;+ const O = V.proj(s.start);+ let best = -1;+ I.forEach(j => {+ const ee = [...s.start]; ee[j] += 1;+ const P1 = V.proj(ee), ux = P1[0] - O[0], uy = P1[1] - O[1], Lu = Math.hypot(ux, uy);+ if (Lu < 6) return;+ const c = Math.abs(dx * ux + dy * uy) / Lu / L;+ if (c > best) { best = c; s.axis = j; s.u = [ux / Lu, uy / Lu]; s.L = Lu; }+ });+ if (s.axis === null) return;+ const a = [...s.start], bb = [...s.start]; a[s.axis] = -R; bb[s.axis] = R;+ guide.e.setAttribute('stroke', S3_ROW[s.axis]);+ guide.set(a, bb);+ }+ const q = [...s.start];+ q[s.axis] = lattice(s.start[s.axis] + (dx * s.u[0] + dy * s.u[1]) / s.L);+ putTip(k, q);+ });+ const up = () => { s = null; guide.set(null, null); };+ g.addEventListener('pointerup', up);+ g.addEventListener('lostpointercapture', up);+ g.addEventListener('keydown', e => {+ if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); g.blur(); P.keys?.(e); return; }+ if (!tipOK(k)) return;+ const upk = e.key === 'ArrowUp' || e.key === 'PageUp' ? 1 : e.key === 'ArrowDown' || e.key === 'PageDown' ? -1 : 0;+ const j = e.key === 'ArrowLeft' || e.key === 'ArrowRight' ? 0 : upk && (e.shiftKey || e.key.startsWith('Page')) ? 1 : upk ? 2 : -1;+ if (j < 0) return;+ e.preventDefault(); e.stopPropagation();+ const q = tipOf(k).map(lattice);+ q[j] = lattice(q[j] + (j === 0 ? (e.key === 'ArrowRight' ? 1 : -1) : upk));+ putTip(k, q);+ });+ });++ const live_ = (g, f) => { let key = ''; const upd = () => { const [k, paint] = f(); const s = JSON.stringify(k); if (s === key) return; key = s; g.replaceChildren(); paint(); }; listeners.push(upd); upd(); return g; };+ const cs = {+ V, space: V, v, cols, bArrow, legs, drop, badRing, CA, CAline, labels: labs, R2,+ solve: () => solveOf(v), inC: q => inC(q), span: () => spanOf(v), Ax: () => Ax(),+ to(next, at, dur = 1.2, ease = io) {+ const from = { ...plan };+ plan = { ...plan, ...next };+ derive(plan, Object.keys(next));+ const goal = { ...plan }, keys = Object.keys(goal);+ prog(q => edit(Object.fromEntries(keys.map(k => [k, from[k] + (goal[k] - from[k]) * q]))), at, dur, ease);+ },+ set: to => edit(to),+ onChange(f) { listeners.push(f); f(v, solveOf(v)); },+ num: key => slots.filter(s => s.key === key).map(s => s.ink),+ flash(key, at) { slots.filter(s => s.key === key).forEach(s => { tw(s.ink, { c_color: COL.task }, at, .25); tw(s.ink, { c_color: s.fill }, at + 1.2, .6); }); },+ form({ x = 90, y = 230, size: sz = 32, o = 1 } = {}) {+ const g = G(p, { o }), w = sz * 2.1, parts = {};+ let cx = x;+ 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.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' });+ cx += sz;+ parts.b = G(g, {}); S3_col(parts.b, I.map(i => 'b' + i), cx + w / 2, y, ctx, { size: sz, w, fill: S3_B });+ draw();+ return { g, parts, w: cx + w - x };+ },+ eqs({ x = 90, y = 400, size: sz = 30, gap = sz * 1.45, o = 1 } = {}) {+ const g = G(p, { o }), rowsG = [];+ I.forEach(i => {+ const r = G(g, {}), yy = y + i * gap;+ rowsG.push(r);+ mk('rect', { x: x - 26, y: yy - sz * .7, width: 7, height: sz * .8, rx: 3, fill: S3_ROW[i] }, r);+ S3_slot(r, `a${i}0`, x + sz * .9, yy, ctx, { size: sz, anchor: 'end', w: sz * 1.1, coef: true });+ T(r, 'x', { x: x + sz * .95, y: yy, size: sz, fill: COL.chalk, font: MATH }).setAttribute('font-style', 'italic');+ S3_slot(r, null, x + sz * 2.15, yy, ctx, { size: sz, pf: s => [s[`a${i}1`] < -1e-9 ? '−' : '+'] });+ S3_slot(r, `a${i}1`, x + sz * 3.35, yy, ctx, { size: sz, anchor: 'end', w: sz * 1.1, coef: true, abs: true });+ T(r, 'y', { x: x + sz * 3.4, y: yy, size: sz, fill: COL.chalk, font: MATH }).setAttribute('font-style', 'italic');+ T(r, '=', { x: x + sz * 4.55, y: yy, size: sz, fill: COL.chalk, font: MATH, anchor: 'middle' });+ S3_slot(r, 'b' + i, x + sz * 5.1, yy, ctx, { size: sz, anchor: 'start', w: sz * 1.5, fill: S3_B });+ });+ draw();+ return { g, rows: rowsG };+ },+ readout({ x = 90, y = 600, size: sz = 34, o = 1 } = {}) {+ const g = G(p, { o });+ return live_(g, () => {+ const s = solveOf(v);+ if (unique(s)) return [['m', s.x, s.y], () => M(g, ['x = ', ...S3_parts(s.x), ', y = ', ...S3_parts(s.y)], { x, y, size: sz, fill: S3_B, anchor: 'start' })];+ if (s.many) return [['many'], () => T(g, 'b is in C(A): many mixes reach it', { x, y: y - 4, size: sz * .8, fill: S3_B, weight: 600 })];+ return [['none'], () => T(g, 'no mix: b is not in C(A)', { x, y: y - 4, size: sz * .8, fill: COL.bad, weight: 600 })];+ });+ },+ live(on, { only: keys = null, drag = ['b', 0, 1] } = {}) {+ live = on; only = keys; dragOn = drag;+ V.live(on);+ slots.forEach(s => s.paint(on));+ tips.forEach(({ k, g, rg }) => { const ok = tipOK(k); g.style.pointerEvents = ok ? '' : 'none'; g.style.cursor = ok ? 'grab' : ''; rg.style.opacity = ok ? 1 : 0; if (ok) g.setAttribute('tabindex', 0); else g.removeAttribute('tabindex'); });+ },+ redraw: draw,+ };+ draw();+ return cs;+}+const csTask = (cs, test, why, hint, reveal, opts) => (body, api) => {+ cs.live(true, opts);+ const say = f => typeof f === 'function' ? f(cs.v, cs) : f;+ return {+ check: () => { const ok = !!test(cs.v, cs); api.grade(ok, say(ok ? why : hint)); },+ reveal: () => { reveal?.(); return say(why); },+ lock: () => cs.live(false),+ hint: [kbd('Tab'), ' pick a number ', kbd('↑'), kbd('↓'), ' change it; drag b’s tip along an axis, or empty space to turn'],+ };+};diff --git a/site/linear-algebra/lib/vecs.js b/site/linear-algebra/lib/vecs.jsindex 276bde4..0173671 100644--- a/site/linear-algebra/lib/vecs.js+++ b/site/linear-algebra/lib/vecs.js@@ -7,25 +7,29 @@// Loads after engine.js and math.js (it uses plane() and mathW()); linsys.js is not needed.//// const vs = vecs(p, { vecs: { v: [2, −1], w: [−1, 2] }, c: 1, d: 2, show: ['cv', 'dw', 'sum'], plane: { cx, cy, u, step },-// snap: 1 | .5, steps: { c: .5 }, range: { c: [−5, 5] }, labelSize, hidePlane })+// snap: 1 | .5, steps: { c: .5 }, range: { c: [−5, 5] }, labelSize, hidePlane,+// extra: { k: 0 } more numbers in the state (scrubbable in rows, moved by to()), colors: { sum: COL.chalk },+// 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.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.live(on, { drag: ids, move }); questions: vsTask(vs, test, why, hint, reveal, opts), vcolBlanks(rows, { cols }), hcol(top, bottom, colour)+// 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)-function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snap = 1, steps = {}, range = {}, show: shown, size = 46, labelSize = 32, t0 = .1, hidePlane = false } = {}) {+function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snap = 1, steps = {}, range = {}, show: shown, size = 46, labelSize = 32, t0 = .1, hidePlane = false,+ extra = {}, colors = {}, onto = null, fix = null } = {}) {const names = Object.keys(list), [n1, n2 = n1] = names;- const v = { c, d };+ const v = { c, d, ...extra };names.forEach(n => { v[n + '0'] = list[n][0]; v[n + '1'] = list[n][1]; });const holder = G(p, { o: hidePlane ? 0 : 1 });const P2 = plane(holder, { cx: 1160, cy: 450, u: 52, x0: -6, x1: 6, y0: -6, y1: 6, t0, ...po });const { PX, PY } = P2, svg = $('stage');const listeners = [], slots = [];- let live = false, solving = false, plan = { ...v }, dragSet = null, moveVec = false;+ let live = false, solving = false, plan = { ...v }, dragSet = null, moveVec = false, only = null;const colorOf = Object.fromEntries(names.map((n, i) => [n, VS_COL[i % 3]]));- Object.assign(colorOf, { cv: colorOf[n1], dw: colorOf[n2], dw0: colorOf[n2], cv1: colorOf[n1], sum: COL.task });+ Object.assign(colorOf, { cv: colorOf[n1], dw: colorOf[n2], dw0: colorOf[n2], cv1: colorOf[n1], sum: COL.task }, colors);/* ---------- numbers ---------- */const isInt = n => Math.abs(n - Math.round(n)) < 1e-9;@@ -68,7 +72,7 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snas[i] = Math.max(i ? P2.y0 : P2.x0, Math.min(i ? P2.y1 : P2.x1, n));edit(solveFor(s[0], s[1]));};- const canScrub = key => key in v || (solving && /^sum/.test(key));+ const canScrub = key => (!only || only.includes(key)) && (key in v || (solving && /^sum/.test(key)));/* ---------- numbers you can scrub ---------- */// A slot shows one value; its ink is redrawn when the value's text changes and keeps its colour in `color`,@@ -172,6 +176,7 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna/* ---------- arrows in the plane ---------- */const layer = G(P2.g, {}), latG = G(layer, { o: 0 }), legG = G(layer, {}), arrG = G(layer, {}), labG = G(layer, {}), hanG = G(layer, {});+ [latG, legG, arrG, labG].forEach(e => { e.style.pointerEvents = 'none'; }); // only the tip handles take the pointer (a hidden leg would cover what is under it)const arrowD = (xa, ya, xb, yb) => {const a = [PX(xa), PY(ya)], b = [PX(xb), PY(yb)], L = Math.hypot(b[0] - a[0], b[1] - a[1]);if (L < 1) return '';@@ -300,9 +305,9 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snalisteners.forEach(f => f(v, calc()));}function edit(to) {- let changed = false;- for (const k in to) if (v[k] !== to[k]) { v[k] = to[k]; changed = true; }- if (changed) draw();+ const changed = Object.keys(to).filter(k => v[k] !== to[k]);+ changed.forEach(k => { v[k] = to[k]; });+ if (changed.length) { fix?.(v, changed); draw(); } // fix: the owner's rule that puts the state back in order (a point kept on a line)}/* ---------- dragging in the plane ---------- */@@ -322,7 +327,7 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, sna},sum: q => { if (solving) { const [X, Y] = inBox(q); edit(solveFor(X, Y)); } },};- names.forEach(n => { onDrag[n] = q => { const [X, Y] = inBox(q); edit({ [n + '0']: X, [n + '1']: Y }); }; });+ names.forEach(n => { onDrag[n] = q => { const [X, Y] = onto ? onto(n, q, inBox) : inBox(q); edit({ [n + '0']: X, [n + '1']: Y }); }; });for (const id of ['sum', ...names, 'cv', 'dw']) {const h = A[id].h;let on = false;@@ -335,13 +340,14 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snadraw();const vs = {- v, P: P2, stage: holder, A, names, calc, solveFor, parts, fmt, row, latticeG: latG, // vs.lattice() shows it; vs.latticeG is the group+ 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 groupparen: 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)// 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 };plan = { ...plan, ...next };+ fix?.(plan, Object.keys(next)); // the goal in order too (a point on a line that slides goes with it)const goal = { ...plan };prog(q => edit(Object.fromEntries(Object.keys(goal).map(k => [k, from[k] + (goal[k] - from[k]) * q]))), at, dur, ease);},@@ -358,8 +364,8 @@ function vecs(p, { vecs: list = { v: [3, 2] }, c = 1, d = 1, plane: po = {}, snasolve(on = true) { solving = on; },// Hands on: scrub numbers and drag tips. drag lists the arrows whose tips move (default: every arrow showing);// move: true makes the tips of 'cv' and 'dw' carry v and w instead of changing c and d.- live(on, { drag, move = false } = {}) {- live = on; dragSet = drag ?? null; moveVec = move;+ live(on, { drag, move = false, only: keys = null } = {}) {+ live = on; dragSet = drag ?? null; moveVec = move; only = keys;for (const s of slots) {const ok = on && s.box && canScrub(s.key) && st(s.box.parentNode).o > .3;if (!s.box) continue;@@ -426,3 +432,221 @@ const vcolBlanks = (rowsIn, { cols } = {}) => (body, api) => {document.head.append(Object.assign(document.createElement('style'), { textContent:'.blanks.vgrid{display:grid;grid-template-columns:1fr 1fr;column-gap:2.5em}' +'.vcol.vin{padding:.15em .5em;gap:.18em;font-size:30px}.vcol.vin input{margin:0}.bline .veq{font-family:var(--math-font,serif);font-size:30px;margin:0 .3em}' }));++/* ---------- the subspace test in the plane ---------- */+// A set S drawn in blue (row 1's colour: S is an equation's line), two vectors u and w kept inside S, the numbers c and d,+// and the combination c·u + d·w from the origin with a ring at its tip: green while it stays in S, red once it leaves.+// It is vecs underneath (sb.vs), so it is one state (sb.v: u0 u1 w0 w1 c d a b k): scrub a number and the picture moves,+// drag a tip (it slides along S) or the line itself (it slides, k follows) and the numbers move.+// set: 'line' the line a·x + b·y = k 'zero' the zero vector alone+// 'all' every vector of the plane 'quad' the quarter where x ≥ 0 and y ≥ 0+// const sb = subspace2(p, { set, line: [a, b, k], u: [2, 1], w: [−4, −2], c, d, plane, show, snap, t0, hidePlane })+// sb.eq({ x, y, size }) the equation a x + b y = k, scrubbable, with a blue bar; returns the row (its .parts)+// sb.readout({ x, y, size }) the test, live: c·u + d·w put into S's rule (6 − 2·3 = 0), then the verdict in words+// sb.check(id, { x, y, size }) one vector ('u', 'w', 'cv', 'sum') put into the rule, live, with ✓ or ✗+// sb.kind(name, t0) another set (u and w move into it); sb.kindNow()+// sb.multiples(t0, on) the dashed line of every multiple of u (where c·u can go)+// sb.ok() is c·u + d·w in S; sb.inSet([x, y]); sb.setG, sb.ring (groups to show or hide); sb.row (vs.row)+// sb.to / set / onChange / flash / num as in vecs; sb.live(on, { only: keys, drag: ids, slide })+// sbTask(sb, test, why, hint, reveal, opts): a hands-on question; test(v, sb) decides.+function subspace2(p, { set = 'line', line: L0 = [1, -2, 0], u = [2, 1], w = [-4, -2], c = 1, d = 1, plane: po = {}, show: shown = ['u', 'w', 'dw', 'sum'],+ snap = 1, labelSize = 30, t0 = .1, hidePlane = false, size = 46, range = {} } = {}) {+ // The kind of set is part of the state (v.kind, an index into KINDS), so a move planned for later uses the set it will+ // be then: sb.kind('all', t) is a step of the state on the beat clock like any other.+ const KINDS = ['line', 'zero', 'all', 'quad'], kindOf = v => KINDS[Math.round(v.kind)] ?? 'line';+ let vs = null, live = false, onlyKeys = null, slideOn = true;+ const SET = COL.whole, x0 = po.x0 ?? -6, x1 = po.x1 ?? 6, y0 = po.y0 ?? -6, y1 = po.y1 ?? 6;+ const lineOK = v => Math.abs(v.a) + Math.abs(v.b) > 1e-9;+ const inSet = ([x, y], v = vs.v, kind = kindOf(v)) => kind === 'all' ? true : kind === 'zero' ? Math.hypot(x, y) < 1e-6+ : kind === 'quad' ? x > -1e-9 && y > -1e-9 : lineOK(v) && Math.abs(v.a * x + v.b * y - v.k) < 1e-6 * (1 + Math.abs(v.k));+ // Which coordinate of a point stays when it is put back on the line: the one just changed, else the one along which+ // the line is flatter (a point on a steep line keeps its height), so the other changes least.+ const keepX = (v, n, changed) => {+ if (changed.includes(n + '1') && !changed.includes(n + '0') && Math.abs(v.a) > 1e-9) return false;+ if (changed.includes(n + '0') && !changed.includes(n + '1') && Math.abs(v.b) > 1e-9) return true;+ return Math.abs(v.b) >= Math.abs(v.a);+ };+ const fix = (v, changed = []) => {+ const kind = kindOf(v);+ for (const n of ['u', 'w']) {+ if (kind === 'zero') { v[n + '0'] = 0; v[n + '1'] = 0; }+ else if (kind === 'quad') { v[n + '0'] = Math.max(0, v[n + '0']); v[n + '1'] = Math.max(0, v[n + '1']); }+ else if (kind === 'line' && lineOK(v)) {+ if (keepX(v, n, changed)) v[n + '1'] = (v.k - v.a * v[n + '0']) / v.b || 0;+ else v[n + '0'] = (v.k - v.b * v[n + '1']) / v.a || 0;+ }+ }+ };+ // A dragged tip lands on S: the foot of the pointer on the line, its free coordinate on the grid (and kept so the+ // other one stays on the board).+ const onto = (n, q, inBox) => {+ const v = vs.v, r = t => Math.round(t / snap) * snap, kind = kindOf(v);+ if (kind === 'zero') return [0, 0];+ if (kind === 'all') return inBox(q);+ if (kind === 'quad') { const [X, Y] = inBox(q); return [Math.max(0, X), Math.max(0, Y)]; }+ if (!lineOK(v)) return inBox(q);+ const L = v.a * v.a + v.b * v.b, e = (v.a * q[0] + v.b * q[1] - v.k) / L, f = [q[0] - e * v.a, q[1] - e * v.b];+ const byX = Math.abs(v.b) >= Math.abs(v.a), [P, Q] = byX ? [v.a, v.b] : [v.b, v.a], [lo, hi] = byX ? [y0, y1] : [x0, x1], [flo, fhi] = byX ? [x0, x1] : [y0, y1];+ // the free coordinate t keeps the other, (k − P t) / Q, inside [lo, hi]+ let tlo = flo, thi = fhi;+ if (Math.abs(P) > 1e-9) { const A = (v.k - Q * hi) / P, B = (v.k - Q * lo) / P; tlo = Math.max(tlo, Math.min(A, B)); thi = Math.min(thi, Math.max(A, B)); }+ const t = Math.max(Math.ceil(tlo / snap - 1e-9) * snap, Math.min(Math.floor(thi / snap + 1e-9) * snap, r(byX ? f[0] : f[1])));+ const o = (v.k - P * t) / Q || 0;+ return byX ? [t, o] : [o, t];+ };+ const st0 = { u0: u[0], u1: u[1], w0: w[0], w1: w[1], a: L0[0], b: L0[1], k: L0[2], kind: KINDS.indexOf(set) };+ fix(st0);+ vs = vecs(p, { vecs: { u: [st0.u0, st0.u1], w: [st0.w0, st0.w1] }, c, d, extra: { a: st0.a, b: st0.b, k: st0.k, kind: st0.kind }, colors: { sum: COL.chalk },+ 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')}`];+ });++ /* ---------- the set, under the arrows ---------- */+ const sg = G(P2.g, {});+ P2.g.insertBefore(sg, vs.layer);+ const shade = path(sg, '', { fill: SET, 'fill-opacity': .13, stroke: 'none' });+ const edge = path(sg, '', { stroke: SET, 'stroke-width': 6, 'stroke-linecap': 'round', fill: 'none' });+ const zdot = mk('circle', { cx: PX(0), cy: PY(0), r: 11, fill: SET }, sg);+ const mult = G(P2.g, { o: 0 });+ P2.g.insertBefore(mult, vs.layer);+ const multP = path(mult, '', { stroke: COL.chalk, 'stroke-width': 2.5, 'stroke-dasharray': '8 9', 'stroke-opacity': .7, fill: 'none' });+ const hit = path(sg, '', { stroke: 'transparent', 'stroke-width': 30, fill: 'none' });+ hit.setAttribute('aria-label', 'the line');+ // the ring at the tip of c·u + d·w: green in S, red out of it; over the arrows+ const ring = G(P2.g, { o: shown.includes('sum') ? 1 : 0 });+ ring.style.pointerEvents = 'none';+ const ringC = mk('circle', { r: 17, fill: 'none', 'stroke-width': 4 }, ring);+ let setKey = '';+ const drawSet = v => {+ const L = lineOK(v) ? v.a * v.a + v.b * v.b : 1, foot = [v.k * v.a / L, v.k * v.b / L], kind = kindOf(v);+ const key = [kind, v.a, v.b, v.k].join();+ if (key !== setKey) {+ setKey = key;+ const box = `M${PX(x0)} ${PY(y1)}H${PX(x1)}V${PY(y0)}H${PX(x0)}Z`;+ const ld = kind === 'line' && lineOK(v) ? vs.clip(foot, [-v.b, v.a]) : '';+ shade.setAttribute('d', kind === 'all' ? box : kind === 'quad' ? `M${PX(0)} ${PY(y1)}H${PX(x1)}V${PY(0)}H${PX(0)}Z` : '');+ edge.setAttribute('d', kind === 'line' ? ld : kind === 'quad' ? `M${PX(0)} ${PY(y1)}V${PY(0)}H${PX(x1)}` : '');+ hit.setAttribute('d', ld);+ zdot.style.opacity = kind === 'zero' ? 1 : 0;+ }+ const s = vs.calc().sum, ok = inSet(s, v);+ put(ring, { x: PX(s[0]), y: PY(s[1]) });+ ringC.setAttribute('stroke', ok ? COL.good : COL.bad);+ multP.setAttribute('d', Math.hypot(v.u0, v.u1) > 1e-9 ? vs.clip([0, 0], [v.u0, v.u1]) : '');+ };+ vs.onChange(drawSet); drawSet(vs.v);++ /* ---------- sliding the line by hand ---------- */+ const canSlide = () => live && slideOn && kindOf(vs.v) === 'line' && (!onlyKeys || onlyKeys.includes('k'));+ let sliding = false;+ hit.addEventListener('pointerdown', e => {+ if (!canSlide()) return;+ e.preventDefault(); e.stopPropagation();+ sliding = true; hit.setPointerCapture(e.pointerId);+ });+ hit.addEventListener('pointermove', e => {+ if (!sliding) return;+ const q = vs.at(e), v = vs.v, [lo, hi] = range.k ?? [-12, 12];+ vs.set({ k: Math.max(lo, Math.min(hi, Math.round(v.a * q[0] + v.b * q[1]))) });+ });+ const stop = () => { sliding = false; };+ hit.addEventListener('pointerup', stop);+ hit.addEventListener('lostpointercapture', stop);+ hit.addEventListener('pointerenter', () => { if (canSlide()) edge.setAttribute('stroke-width', 9); });+ hit.addEventListener('pointerleave', () => edge.setAttribute('stroke-width', 6));++ /* ---------- the test in words ---------- */+ const pp = n => n < -1e-9 ? ['(', ...vs.parts(n), ')'] : vs.parts(n);+ const coefT = (a, s) => Math.abs(a - 1) < 1e-9 ? pp(s) : Math.abs(a + 1) < 1e-9 ? ['−', ...pp(s)] : [...vs.parts(a), '·', ...pp(s)];+ const testParts = (v, s) => {+ if (kindOf(v) === 'line') return [...coefT(v.a, s[0]), v.b < -1e-9 ? ' − ' : ' + ', ...coefT(Math.abs(v.b), s[1]), ' = ', ...vs.parts(v.a * s[0] + v.b * s[1])];+ return ['(', ...vs.parts(s[0]), ', ', ...vs.parts(s[1]), ')'];+ };+ const verdict = (v, s, ok, kind = kindOf(v)) => kind === 'line' ? (ok ? `${vs.fmt(v.k)}, as the line needs: on the line ✓` : `not ${vs.fmt(v.k)}: off the line ✗`)+ : kind === 'zero' ? (ok ? 'the zero vector: still inside ✓' : 'not the zero vector: outside ✗')+ : kind === 'quad' ? (ok ? 'no negative number: inside ✓' : 'a negative number: outside ✗')+ : 'a vector of the plane: inside ✓';++ const sb = {+ vs, v: vs.v, P: P2, setG: sg, ring, mult, row: vs.row, inSet: q => inSet(q),+ ok: () => inSet(vs.calc().sum),+ kindNow: () => kindOf(vs.v),+ to: (next, at, dur, ease) => vs.to(next, at, dur, ease),+ set: to => vs.set(to),+ onChange: f => vs.onChange(f),+ flash: (key, at) => vs.flash(key, at),+ num: key => vs.num(key),+ show: (ids, at, dur) => { vs.show(ids, at, dur); if ([].concat(ids).includes('sum')) show(ring, at, dur); },+ hide: (ids, at, dur) => { vs.hide(ids, at, dur); if ([].concat(ids).includes('sum')) hide(ring, at, dur); },+ // another set from t0 (at once without t0): u and w are put into it+ kind(name, at) {+ const n = KINDS.indexOf(name);+ if (at === undefined) vs.set({ kind: n }); else vs.to({ kind: n }, at, 0);+ },+ 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 });+ mk('rect', { x: x - 30, y: y - sz * .7, width: 8, height: sz * .8, rx: 4, fill: SET }, r.g);+ return r;+ },+ // One vector put into S's rule, live: 'u', 'w', 'cv' or 'sum' → "2 − 2·1 = 0 ✓" (✓ green, ✗ red).+ check(id, { x = 90, y = 430, size: sz = 28, o = 1, anchor = 'start' } = {}) {+ const g = G(p, { o });+ let key = '';+ const upd = v => {+ const q = id === 'sum' ? vs.calc().sum : id === 'cv' ? vs.calc().cv : [v[id + '0'], v[id + '1']], ok = inSet(q, v), tp = [...testParts(v, q), ok ? ' ✓' : ' ✗'];+ const k = JSON.stringify(tp);+ if (k === key) return;+ key = k; g.replaceChildren();+ const e = M(g, tp.slice(0, -1), { x, y, size: sz, fill: COL.chalk, anchor });+ T(g, tp[tp.length - 1], { x: anchor === 'start' ? x + e._w : x + e._w / 2, y, size: sz, fill: ok ? COL.good : COL.bad, weight: 700, anchor: anchor === 'start' ? 'start' : 'start' });+ };+ vs.onChange(upd); upd(vs.v);+ return g;+ },+ readout({ x = 90, y = 600, size: sz = 34, o = 1 } = {}) {+ const g = G(p, { o }), a = G(g, {}), b = G(g, {});+ let key = '';+ const upd = v => {+ const s = vs.calc().sum, ok = inSet(s, v), tp = testParts(v, s), w = verdict(v, s, ok), k = JSON.stringify([tp, w]);+ if (k === key) return;+ key = k; a.replaceChildren(); b.replaceChildren();+ M(a, tp, { x, y, size: sz, fill: COL.chalk, anchor: 'start' });+ T(b, w, { x, y: y + sz * 1.35, size: sz * .82, fill: ok ? COL.good : COL.bad, weight: 600 });+ };+ vs.onChange(upd); upd(vs.v);+ return g;+ },+ live(on, { only = null, drag, slide = true } = {}) {+ live = on; onlyKeys = only; slideOn = slide;+ const ids = drag ?? ['u', 'w', 'cv', 'dw'].filter(id => st(vs.A[id].g).o > .3);+ vs.live(on, { drag: ids, only });+ hit.style.cursor = canSlide() ? 'move' : '';+ hit.style.pointerEvents = canSlide() ? '' : 'none';+ hit.style.touchAction = canSlide() ? 'none' : '';+ },+ redraw: () => vs.redraw(),+ };+ hit.style.pointerEvents = 'none';+ return sb;+}++// A question that is a task on the subspace test: the reader changes it until test(v, sb) holds, then checks.+const sbTask = (sb, test, why, hint, reveal, opts) => (body, api) => {+ sb.live(true, opts);+ const say = f => typeof f === 'function' ? f(sb.v, sb) : f;+ return {+ check: () => { const ok = !!test(sb.v, sb); api.grade(ok, say(ok ? why : hint)); },+ reveal: () => { reveal?.(); return say(why); },+ lock: () => sb.live(false),+ hint: [kbd('Tab'), ' pick a number ', kbd('↑'), kbd('↓'), ' change it; drag the line to slide it, a tip to move it along'],+ };+};